documentation.d.ts 2.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts current color in rgb space to HSV values
  464. * @returns a new color3 representing the HSV values
  465. */
  466. toHSV(): Color3;
  467. /**
  468. * Converts current color in rgb space to HSV values
  469. * @param result defines the Color3 where to store the HSV values
  470. */
  471. toHSVToRef(result: Color3): void;
  472. /**
  473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  474. * @param convertedColor defines the Color3 object where to store the linear space version
  475. * @returns the unmodified Color3
  476. */
  477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  478. /**
  479. * Computes a new Color3 converted from the current one to gamma space
  480. * @returns a new Color3 object
  481. */
  482. toGammaSpace(): Color3;
  483. /**
  484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  485. * @param convertedColor defines the Color3 object where to store the gamma space version
  486. * @returns the unmodified Color3
  487. */
  488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  489. private static _BlackReadOnly;
  490. /**
  491. * Convert Hue, saturation and value to a Color3 (RGB)
  492. * @param hue defines the hue
  493. * @param saturation defines the saturation
  494. * @param value defines the value
  495. * @param result defines the Color3 where to store the RGB values
  496. */
  497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  498. /**
  499. * Creates a new Color3 from the string containing valid hexadecimal values
  500. * @param hex defines a string containing valid hexadecimal values
  501. * @returns a new Color3 object
  502. */
  503. static FromHexString(hex: string): Color3;
  504. /**
  505. * Creates a new Color3 from the starting index of the given array
  506. * @param array defines the source array
  507. * @param offset defines an offset in the source array
  508. * @returns a new Color3 object
  509. */
  510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  511. /**
  512. * Creates a new Color3 from integer values (< 256)
  513. * @param r defines the red component to read from (value between 0 and 255)
  514. * @param g defines the green component to read from (value between 0 and 255)
  515. * @param b defines the blue component to read from (value between 0 and 255)
  516. * @returns a new Color3 object
  517. */
  518. static FromInts(r: number, g: number, b: number): Color3;
  519. /**
  520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  521. * @param start defines the start Color3 value
  522. * @param end defines the end Color3 value
  523. * @param amount defines the gradient value between start and end
  524. * @returns a new Color3 object
  525. */
  526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  527. /**
  528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  529. * @param left defines the start value
  530. * @param right defines the end value
  531. * @param amount defines the gradient factor
  532. * @param result defines the Color3 object where to store the result
  533. */
  534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  535. /**
  536. * Returns a Color3 value containing a red color
  537. * @returns a new Color3 object
  538. */
  539. static Red(): Color3;
  540. /**
  541. * Returns a Color3 value containing a green color
  542. * @returns a new Color3 object
  543. */
  544. static Green(): Color3;
  545. /**
  546. * Returns a Color3 value containing a blue color
  547. * @returns a new Color3 object
  548. */
  549. static Blue(): Color3;
  550. /**
  551. * Returns a Color3 value containing a black color
  552. * @returns a new Color3 object
  553. */
  554. static Black(): Color3;
  555. /**
  556. * Gets a Color3 value containing a black color that must not be updated
  557. */
  558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  559. /**
  560. * Returns a Color3 value containing a white color
  561. * @returns a new Color3 object
  562. */
  563. static White(): Color3;
  564. /**
  565. * Returns a Color3 value containing a purple color
  566. * @returns a new Color3 object
  567. */
  568. static Purple(): Color3;
  569. /**
  570. * Returns a Color3 value containing a magenta color
  571. * @returns a new Color3 object
  572. */
  573. static Magenta(): Color3;
  574. /**
  575. * Returns a Color3 value containing a yellow color
  576. * @returns a new Color3 object
  577. */
  578. static Yellow(): Color3;
  579. /**
  580. * Returns a Color3 value containing a gray color
  581. * @returns a new Color3 object
  582. */
  583. static Gray(): Color3;
  584. /**
  585. * Returns a Color3 value containing a teal color
  586. * @returns a new Color3 object
  587. */
  588. static Teal(): Color3;
  589. /**
  590. * Returns a Color3 value containing a random color
  591. * @returns a new Color3 object
  592. */
  593. static Random(): Color3;
  594. }
  595. /**
  596. * Class used to hold a RBGA color
  597. */
  598. export class Color4 {
  599. /**
  600. * Defines the red component (between 0 and 1, default is 0)
  601. */
  602. r: number;
  603. /**
  604. * Defines the green component (between 0 and 1, default is 0)
  605. */
  606. g: number;
  607. /**
  608. * Defines the blue component (between 0 and 1, default is 0)
  609. */
  610. b: number;
  611. /**
  612. * Defines the alpha component (between 0 and 1, default is 1)
  613. */
  614. a: number;
  615. /**
  616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  617. * @param r defines the red component (between 0 and 1, default is 0)
  618. * @param g defines the green component (between 0 and 1, default is 0)
  619. * @param b defines the blue component (between 0 and 1, default is 0)
  620. * @param a defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. constructor(
  623. /**
  624. * Defines the red component (between 0 and 1, default is 0)
  625. */
  626. r?: number,
  627. /**
  628. * Defines the green component (between 0 and 1, default is 0)
  629. */
  630. g?: number,
  631. /**
  632. * Defines the blue component (between 0 and 1, default is 0)
  633. */
  634. b?: number,
  635. /**
  636. * Defines the alpha component (between 0 and 1, default is 1)
  637. */
  638. a?: number);
  639. /**
  640. * Adds in place the given Color4 values to the current Color4 object
  641. * @param right defines the second operand
  642. * @returns the current updated Color4 object
  643. */
  644. addInPlace(right: DeepImmutable<Color4>): Color4;
  645. /**
  646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  647. * @returns the new array
  648. */
  649. asArray(): number[];
  650. /**
  651. * Stores from the starting index in the given array the Color4 successive values
  652. * @param array defines the array where to store the r,g,b components
  653. * @param index defines an optional index in the target array to define where to start storing values
  654. * @returns the current Color4 object
  655. */
  656. toArray(array: number[], index?: number): Color4;
  657. /**
  658. * Determines equality between Color4 objects
  659. * @param otherColor defines the second operand
  660. * @returns true if the rgba values are equal to the given ones
  661. */
  662. equals(otherColor: DeepImmutable<Color4>): boolean;
  663. /**
  664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  665. * @param right defines the second operand
  666. * @returns a new Color4 object
  667. */
  668. add(right: DeepImmutable<Color4>): Color4;
  669. /**
  670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  671. * @param right defines the second operand
  672. * @returns a new Color4 object
  673. */
  674. subtract(right: DeepImmutable<Color4>): Color4;
  675. /**
  676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  677. * @param right defines the second operand
  678. * @param result defines the Color4 object where to store the result
  679. * @returns the current Color4 object
  680. */
  681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  682. /**
  683. * Creates a new Color4 with the current Color4 values multiplied by scale
  684. * @param scale defines the scaling factor to apply
  685. * @returns a new Color4 object
  686. */
  687. scale(scale: number): Color4;
  688. /**
  689. * Multiplies the current Color4 values by scale and stores the result in "result"
  690. * @param scale defines the scaling factor to apply
  691. * @param result defines the Color4 object where to store the result
  692. * @returns the current unmodified Color4
  693. */
  694. scaleToRef(scale: number, result: Color4): Color4;
  695. /**
  696. * Scale the current Color4 values by a factor and add the result to a given Color4
  697. * @param scale defines the scale factor
  698. * @param result defines the Color4 object where to store the result
  699. * @returns the unmodified current Color4
  700. */
  701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  702. /**
  703. * Clamps the rgb values by the min and max values and stores the result into "result"
  704. * @param min defines minimum clamping value (default is 0)
  705. * @param max defines maximum clamping value (default is 1)
  706. * @param result defines color to store the result into.
  707. * @returns the cuurent Color4
  708. */
  709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  710. /**
  711. * Multipy an Color4 value by another and return a new Color4 object
  712. * @param color defines the Color4 value to multiply by
  713. * @returns a new Color4 object
  714. */
  715. multiply(color: Color4): Color4;
  716. /**
  717. * Multipy a Color4 value by another and push the result in a reference value
  718. * @param color defines the Color4 value to multiply by
  719. * @param result defines the Color4 to fill the result in
  720. * @returns the result Color4
  721. */
  722. multiplyToRef(color: Color4, result: Color4): Color4;
  723. /**
  724. * Creates a string with the Color4 current values
  725. * @returns the string representation of the Color4 object
  726. */
  727. toString(): string;
  728. /**
  729. * Returns the string "Color4"
  730. * @returns "Color4"
  731. */
  732. getClassName(): string;
  733. /**
  734. * Compute the Color4 hash code
  735. * @returns an unique number that can be used to hash Color4 objects
  736. */
  737. getHashCode(): number;
  738. /**
  739. * Creates a new Color4 copied from the current one
  740. * @returns a new Color4 object
  741. */
  742. clone(): Color4;
  743. /**
  744. * Copies the given Color4 values into the current one
  745. * @param source defines the source Color4 object
  746. * @returns the current updated Color4 object
  747. */
  748. copyFrom(source: Color4): Color4;
  749. /**
  750. * Copies the given float values into the current one
  751. * @param r defines the red component to read from
  752. * @param g defines the green component to read from
  753. * @param b defines the blue component to read from
  754. * @param a defines the alpha component to read from
  755. * @returns the current updated Color4 object
  756. */
  757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  758. /**
  759. * Copies the given float values into the current one
  760. * @param r defines the red component to read from
  761. * @param g defines the green component to read from
  762. * @param b defines the blue component to read from
  763. * @param a defines the alpha component to read from
  764. * @returns the current updated Color4 object
  765. */
  766. set(r: number, g: number, b: number, a: number): Color4;
  767. /**
  768. * Compute the Color4 hexadecimal code as a string
  769. * @returns a string containing the hexadecimal representation of the Color4 object
  770. */
  771. toHexString(): string;
  772. /**
  773. * Computes a new Color4 converted from the current one to linear space
  774. * @returns a new Color4 object
  775. */
  776. toLinearSpace(): Color4;
  777. /**
  778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  779. * @param convertedColor defines the Color4 object where to store the linear space version
  780. * @returns the unmodified Color4
  781. */
  782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  783. /**
  784. * Computes a new Color4 converted from the current one to gamma space
  785. * @returns a new Color4 object
  786. */
  787. toGammaSpace(): Color4;
  788. /**
  789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  790. * @param convertedColor defines the Color4 object where to store the gamma space version
  791. * @returns the unmodified Color4
  792. */
  793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  794. /**
  795. * Creates a new Color4 from the string containing valid hexadecimal values
  796. * @param hex defines a string containing valid hexadecimal values
  797. * @returns a new Color4 object
  798. */
  799. static FromHexString(hex: string): Color4;
  800. /**
  801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  802. * @param left defines the start value
  803. * @param right defines the end value
  804. * @param amount defines the gradient factor
  805. * @returns a new Color4 object
  806. */
  807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  808. /**
  809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  810. * @param left defines the start value
  811. * @param right defines the end value
  812. * @param amount defines the gradient factor
  813. * @param result defines the Color4 object where to store data
  814. */
  815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  816. /**
  817. * Creates a new Color4 from a Color3 and an alpha value
  818. * @param color3 defines the source Color3 to read from
  819. * @param alpha defines the alpha component (1.0 by default)
  820. * @returns a new Color4 object
  821. */
  822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  823. /**
  824. * Creates a new Color4 from the starting index element of the given array
  825. * @param array defines the source array to read from
  826. * @param offset defines the offset in the source array
  827. * @returns a new Color4 object
  828. */
  829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  830. /**
  831. * Creates a new Color3 from integer values (< 256)
  832. * @param r defines the red component to read from (value between 0 and 255)
  833. * @param g defines the green component to read from (value between 0 and 255)
  834. * @param b defines the blue component to read from (value between 0 and 255)
  835. * @param a defines the alpha component to read from (value between 0 and 255)
  836. * @returns a new Color3 object
  837. */
  838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  839. /**
  840. * Check the content of a given array and convert it to an array containing RGBA data
  841. * If the original array was already containing count * 4 values then it is returned directly
  842. * @param colors defines the array to check
  843. * @param count defines the number of RGBA data to expect
  844. * @returns an array containing count * 4 values (RGBA)
  845. */
  846. static CheckColors4(colors: number[], count: number): number[];
  847. }
  848. /**
  849. * Class representing a vector containing 2 coordinates
  850. */
  851. export class Vector2 {
  852. /** defines the first coordinate */
  853. x: number;
  854. /** defines the second coordinate */
  855. y: number;
  856. /**
  857. * Creates a new Vector2 from the given x and y coordinates
  858. * @param x defines the first coordinate
  859. * @param y defines the second coordinate
  860. */
  861. constructor(
  862. /** defines the first coordinate */
  863. x?: number,
  864. /** defines the second coordinate */
  865. y?: number);
  866. /**
  867. * Gets a string with the Vector2 coordinates
  868. * @returns a string with the Vector2 coordinates
  869. */
  870. toString(): string;
  871. /**
  872. * Gets class name
  873. * @returns the string "Vector2"
  874. */
  875. getClassName(): string;
  876. /**
  877. * Gets current vector hash code
  878. * @returns the Vector2 hash code as a number
  879. */
  880. getHashCode(): number;
  881. /**
  882. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  883. * @param array defines the source array
  884. * @param index defines the offset in source array
  885. * @returns the current Vector2
  886. */
  887. toArray(array: FloatArray, index?: number): Vector2;
  888. /**
  889. * Copy the current vector to an array
  890. * @returns a new array with 2 elements: the Vector2 coordinates.
  891. */
  892. asArray(): number[];
  893. /**
  894. * Sets the Vector2 coordinates with the given Vector2 coordinates
  895. * @param source defines the source Vector2
  896. * @returns the current updated Vector2
  897. */
  898. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  899. /**
  900. * Sets the Vector2 coordinates with the given floats
  901. * @param x defines the first coordinate
  902. * @param y defines the second coordinate
  903. * @returns the current updated Vector2
  904. */
  905. copyFromFloats(x: number, y: number): Vector2;
  906. /**
  907. * Sets the Vector2 coordinates with the given floats
  908. * @param x defines the first coordinate
  909. * @param y defines the second coordinate
  910. * @returns the current updated Vector2
  911. */
  912. set(x: number, y: number): Vector2;
  913. /**
  914. * Add another vector with the current one
  915. * @param otherVector defines the other vector
  916. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  917. */
  918. add(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  921. * @param otherVector defines the other vector
  922. * @param result defines the target vector
  923. * @returns the unmodified current Vector2
  924. */
  925. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  926. /**
  927. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  928. * @param otherVector defines the other vector
  929. * @returns the current updated Vector2
  930. */
  931. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  932. /**
  933. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  934. * @param otherVector defines the other vector
  935. * @returns a new Vector2
  936. */
  937. addVector3(otherVector: Vector3): Vector2;
  938. /**
  939. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  940. * @param otherVector defines the other vector
  941. * @returns a new Vector2
  942. */
  943. subtract(otherVector: Vector2): Vector2;
  944. /**
  945. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  946. * @param otherVector defines the other vector
  947. * @param result defines the target vector
  948. * @returns the unmodified current Vector2
  949. */
  950. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  951. /**
  952. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns the current updated Vector2
  955. */
  956. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Multiplies in place the current Vector2 coordinates by the given ones
  959. * @param otherVector defines the other vector
  960. * @returns the current updated Vector2
  961. */
  962. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  963. /**
  964. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  965. * @param otherVector defines the other vector
  966. * @returns a new Vector2
  967. */
  968. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  969. /**
  970. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  971. * @param otherVector defines the other vector
  972. * @param result defines the target vector
  973. * @returns the unmodified current Vector2
  974. */
  975. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  976. /**
  977. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  978. * @param x defines the first coordinate
  979. * @param y defines the second coordinate
  980. * @returns a new Vector2
  981. */
  982. multiplyByFloats(x: number, y: number): Vector2;
  983. /**
  984. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  985. * @param otherVector defines the other vector
  986. * @returns a new Vector2
  987. */
  988. divide(otherVector: Vector2): Vector2;
  989. /**
  990. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  991. * @param otherVector defines the other vector
  992. * @param result defines the target vector
  993. * @returns the unmodified current Vector2
  994. */
  995. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  996. /**
  997. * Divides the current Vector2 coordinates by the given ones
  998. * @param otherVector defines the other vector
  999. * @returns the current updated Vector2
  1000. */
  1001. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1002. /**
  1003. * Gets a new Vector2 with current Vector2 negated coordinates
  1004. * @returns a new Vector2
  1005. */
  1006. negate(): Vector2;
  1007. /**
  1008. * Multiply the Vector2 coordinates by scale
  1009. * @param scale defines the scaling factor
  1010. * @returns the current updated Vector2
  1011. */
  1012. scaleInPlace(scale: number): Vector2;
  1013. /**
  1014. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1015. * @param scale defines the scaling factor
  1016. * @returns a new Vector2
  1017. */
  1018. scale(scale: number): Vector2;
  1019. /**
  1020. * Scale the current Vector2 values by a factor to a given Vector2
  1021. * @param scale defines the scale factor
  1022. * @param result defines the Vector2 object where to store the result
  1023. * @returns the unmodified current Vector2
  1024. */
  1025. scaleToRef(scale: number, result: Vector2): Vector2;
  1026. /**
  1027. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1028. * @param scale defines the scale factor
  1029. * @param result defines the Vector2 object where to store the result
  1030. * @returns the unmodified current Vector2
  1031. */
  1032. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1033. /**
  1034. * Gets a boolean if two vectors are equals
  1035. * @param otherVector defines the other vector
  1036. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1037. */
  1038. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1039. /**
  1040. * Gets a boolean if two vectors are equals (using an epsilon value)
  1041. * @param otherVector defines the other vector
  1042. * @param epsilon defines the minimal distance to consider equality
  1043. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1044. */
  1045. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. floor(): Vector2;
  1051. /**
  1052. * Gets a new Vector2 from current Vector2 floored values
  1053. * @returns a new Vector2
  1054. */
  1055. fract(): Vector2;
  1056. /**
  1057. * Gets the length of the vector
  1058. * @returns the vector length (float)
  1059. */
  1060. length(): number;
  1061. /**
  1062. * Gets the vector squared length
  1063. * @returns the vector squared length (float)
  1064. */
  1065. lengthSquared(): number;
  1066. /**
  1067. * Normalize the vector
  1068. * @returns the current updated Vector2
  1069. */
  1070. normalize(): Vector2;
  1071. /**
  1072. * Gets a new Vector2 copied from the Vector2
  1073. * @returns a new Vector2
  1074. */
  1075. clone(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(0, 0)
  1078. * @returns a new Vector2
  1079. */
  1080. static Zero(): Vector2;
  1081. /**
  1082. * Gets a new Vector2(1, 1)
  1083. * @returns a new Vector2
  1084. */
  1085. static One(): Vector2;
  1086. /**
  1087. * Gets a new Vector2 set from the given index element of the given array
  1088. * @param array defines the data source
  1089. * @param offset defines the offset in the data source
  1090. * @returns a new Vector2
  1091. */
  1092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1093. /**
  1094. * Sets "result" from the given index element of the given array
  1095. * @param array defines the data source
  1096. * @param offset defines the offset in the data source
  1097. * @param result defines the target vector
  1098. */
  1099. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1100. /**
  1101. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1102. * @param value1 defines 1st point of control
  1103. * @param value2 defines 2nd point of control
  1104. * @param value3 defines 3rd point of control
  1105. * @param value4 defines 4th point of control
  1106. * @param amount defines the interpolation factor
  1107. * @returns a new Vector2
  1108. */
  1109. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1110. /**
  1111. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1112. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1113. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1114. * @param value defines the value to clamp
  1115. * @param min defines the lower limit
  1116. * @param max defines the upper limit
  1117. * @returns a new Vector2
  1118. */
  1119. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1120. /**
  1121. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1122. * @param value1 defines the 1st control point
  1123. * @param tangent1 defines the outgoing tangent
  1124. * @param value2 defines the 2nd control point
  1125. * @param tangent2 defines the incoming tangent
  1126. * @param amount defines the interpolation factor
  1127. * @returns a new Vector2
  1128. */
  1129. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1130. /**
  1131. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1132. * @param start defines the start vector
  1133. * @param end defines the end vector
  1134. * @param amount defines the interpolation factor
  1135. * @returns a new Vector2
  1136. */
  1137. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1138. /**
  1139. * Gets the dot product of the vector "left" and the vector "right"
  1140. * @param left defines first vector
  1141. * @param right defines second vector
  1142. * @returns the dot product (float)
  1143. */
  1144. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1145. /**
  1146. * Returns a new Vector2 equal to the normalized given vector
  1147. * @param vector defines the vector to normalize
  1148. * @returns a new Vector2
  1149. */
  1150. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1151. /**
  1152. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1153. * @param left defines 1st vector
  1154. * @param right defines 2nd vector
  1155. * @returns a new Vector2
  1156. */
  1157. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1158. /**
  1159. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1160. * @param left defines 1st vector
  1161. * @param right defines 2nd vector
  1162. * @returns a new Vector2
  1163. */
  1164. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1165. /**
  1166. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1167. * @param vector defines the vector to transform
  1168. * @param transformation defines the matrix to apply
  1169. * @returns a new Vector2
  1170. */
  1171. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1172. /**
  1173. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1174. * @param vector defines the vector to transform
  1175. * @param transformation defines the matrix to apply
  1176. * @param result defines the target vector
  1177. */
  1178. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1179. /**
  1180. * Determines if a given vector is included in a triangle
  1181. * @param p defines the vector to test
  1182. * @param p0 defines 1st triangle point
  1183. * @param p1 defines 2nd triangle point
  1184. * @param p2 defines 3rd triangle point
  1185. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1186. */
  1187. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1188. /**
  1189. * Gets the distance between the vectors "value1" and "value2"
  1190. * @param value1 defines first vector
  1191. * @param value2 defines second vector
  1192. * @returns the distance between vectors
  1193. */
  1194. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1195. /**
  1196. * Returns the squared distance between the vectors "value1" and "value2"
  1197. * @param value1 defines first vector
  1198. * @param value2 defines second vector
  1199. * @returns the squared distance between vectors
  1200. */
  1201. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1202. /**
  1203. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1204. * @param value1 defines first vector
  1205. * @param value2 defines second vector
  1206. * @returns a new Vector2
  1207. */
  1208. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1209. /**
  1210. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1211. * @param p defines the middle point
  1212. * @param segA defines one point of the segment
  1213. * @param segB defines the other point of the segment
  1214. * @returns the shortest distance
  1215. */
  1216. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1217. }
  1218. /**
  1219. * Classed used to store (x,y,z) vector representation
  1220. * A Vector3 is the main object used in 3D geometry
  1221. * It can represent etiher the coordinates of a point the space, either a direction
  1222. * Reminder: js uses a left handed forward facing system
  1223. */
  1224. export class Vector3 {
  1225. /**
  1226. * Defines the first coordinates (on X axis)
  1227. */
  1228. x: number;
  1229. /**
  1230. * Defines the second coordinates (on Y axis)
  1231. */
  1232. y: number;
  1233. /**
  1234. * Defines the third coordinates (on Z axis)
  1235. */
  1236. z: number;
  1237. private static _UpReadOnly;
  1238. private static _ZeroReadOnly;
  1239. /**
  1240. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1241. * @param x defines the first coordinates (on X axis)
  1242. * @param y defines the second coordinates (on Y axis)
  1243. * @param z defines the third coordinates (on Z axis)
  1244. */
  1245. constructor(
  1246. /**
  1247. * Defines the first coordinates (on X axis)
  1248. */
  1249. x?: number,
  1250. /**
  1251. * Defines the second coordinates (on Y axis)
  1252. */
  1253. y?: number,
  1254. /**
  1255. * Defines the third coordinates (on Z axis)
  1256. */
  1257. z?: number);
  1258. /**
  1259. * Creates a string representation of the Vector3
  1260. * @returns a string with the Vector3 coordinates.
  1261. */
  1262. toString(): string;
  1263. /**
  1264. * Gets the class name
  1265. * @returns the string "Vector3"
  1266. */
  1267. getClassName(): string;
  1268. /**
  1269. * Creates the Vector3 hash code
  1270. * @returns a number which tends to be unique between Vector3 instances
  1271. */
  1272. getHashCode(): number;
  1273. /**
  1274. * Creates an array containing three elements : the coordinates of the Vector3
  1275. * @returns a new array of numbers
  1276. */
  1277. asArray(): number[];
  1278. /**
  1279. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1280. * @param array defines the destination array
  1281. * @param index defines the offset in the destination array
  1282. * @returns the current Vector3
  1283. */
  1284. toArray(array: FloatArray, index?: number): Vector3;
  1285. /**
  1286. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1287. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1288. */
  1289. toQuaternion(): Quaternion;
  1290. /**
  1291. * Adds the given vector to the current Vector3
  1292. * @param otherVector defines the second operand
  1293. * @returns the current updated Vector3
  1294. */
  1295. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1296. /**
  1297. * Adds the given coordinates to the current Vector3
  1298. * @param x defines the x coordinate of the operand
  1299. * @param y defines the y coordinate of the operand
  1300. * @param z defines the z coordinate of the operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1304. /**
  1305. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Subtract the given vector from the current Vector3
  1319. * @param otherVector defines the second operand
  1320. * @returns the current updated Vector3
  1321. */
  1322. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1323. /**
  1324. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1325. * @param otherVector defines the second operand
  1326. * @returns the resulting Vector3
  1327. */
  1328. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1329. /**
  1330. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1331. * @param otherVector defines the second operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1336. /**
  1337. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1338. * @param x defines the x coordinate of the operand
  1339. * @param y defines the y coordinate of the operand
  1340. * @param z defines the z coordinate of the operand
  1341. * @returns the resulting Vector3
  1342. */
  1343. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1344. /**
  1345. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1346. * @param x defines the x coordinate of the operand
  1347. * @param y defines the y coordinate of the operand
  1348. * @param z defines the z coordinate of the operand
  1349. * @param result defines the Vector3 object where to store the result
  1350. * @returns the current Vector3
  1351. */
  1352. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1353. /**
  1354. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1355. * @returns a new Vector3
  1356. */
  1357. negate(): Vector3;
  1358. /**
  1359. * Multiplies the Vector3 coordinates by the float "scale"
  1360. * @param scale defines the multiplier factor
  1361. * @returns the current updated Vector3
  1362. */
  1363. scaleInPlace(scale: number): Vector3;
  1364. /**
  1365. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1366. * @param scale defines the multiplier factor
  1367. * @returns a new Vector3
  1368. */
  1369. scale(scale: number): Vector3;
  1370. /**
  1371. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1372. * @param scale defines the multiplier factor
  1373. * @param result defines the Vector3 object where to store the result
  1374. * @returns the current Vector3
  1375. */
  1376. scaleToRef(scale: number, result: Vector3): Vector3;
  1377. /**
  1378. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1379. * @param scale defines the scale factor
  1380. * @param result defines the Vector3 object where to store the result
  1381. * @returns the unmodified current Vector3
  1382. */
  1383. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1384. /**
  1385. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1386. * @param otherVector defines the second operand
  1387. * @returns true if both vectors are equals
  1388. */
  1389. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1390. /**
  1391. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1392. * @param otherVector defines the second operand
  1393. * @param epsilon defines the minimal distance to define values as equals
  1394. * @returns true if both vectors are distant less than epsilon
  1395. */
  1396. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1397. /**
  1398. * Returns true if the current Vector3 coordinates equals the given floats
  1399. * @param x defines the x coordinate of the operand
  1400. * @param y defines the y coordinate of the operand
  1401. * @param z defines the z coordinate of the operand
  1402. * @returns true if both vectors are equals
  1403. */
  1404. equalsToFloats(x: number, y: number, z: number): boolean;
  1405. /**
  1406. * Multiplies the current Vector3 coordinates by the given ones
  1407. * @param otherVector defines the second operand
  1408. * @returns the current updated Vector3
  1409. */
  1410. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1411. /**
  1412. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1413. * @param otherVector defines the second operand
  1414. * @returns the new Vector3
  1415. */
  1416. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1417. /**
  1418. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1419. * @param otherVector defines the second operand
  1420. * @param result defines the Vector3 object where to store the result
  1421. * @returns the current Vector3
  1422. */
  1423. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1424. /**
  1425. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1426. * @param x defines the x coordinate of the operand
  1427. * @param y defines the y coordinate of the operand
  1428. * @param z defines the z coordinate of the operand
  1429. * @returns the new Vector3
  1430. */
  1431. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1432. /**
  1433. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1434. * @param otherVector defines the second operand
  1435. * @returns the new Vector3
  1436. */
  1437. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1440. * @param otherVector defines the second operand
  1441. * @param result defines the Vector3 object where to store the result
  1442. * @returns the current Vector3
  1443. */
  1444. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1445. /**
  1446. * Divides the current Vector3 coordinates by the given ones.
  1447. * @param otherVector defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. divideInPlace(otherVector: Vector3): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1453. * @param other defines the second operand
  1454. * @returns the current updated Vector3
  1455. */
  1456. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1457. /**
  1458. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1459. * @param other defines the second operand
  1460. * @returns the current updated Vector3
  1461. */
  1462. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1463. /**
  1464. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1465. * @param x defines the x coordinate of the operand
  1466. * @param y defines the y coordinate of the operand
  1467. * @param z defines the z coordinate of the operand
  1468. * @returns the current updated Vector3
  1469. */
  1470. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1471. /**
  1472. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1473. * @param x defines the x coordinate of the operand
  1474. * @param y defines the y coordinate of the operand
  1475. * @param z defines the z coordinate of the operand
  1476. * @returns the current updated Vector3
  1477. */
  1478. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1479. /**
  1480. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1481. * Check if is non uniform within a certain amount of decimal places to account for this
  1482. * @param epsilon the amount the values can differ
  1483. * @returns if the the vector is non uniform to a certain number of decimal places
  1484. */
  1485. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1486. /**
  1487. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1488. */
  1489. readonly isNonUniform: boolean;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. floor(): Vector3;
  1495. /**
  1496. * Gets a new Vector3 from current Vector3 floored values
  1497. * @returns a new Vector3
  1498. */
  1499. fract(): Vector3;
  1500. /**
  1501. * Gets the length of the Vector3
  1502. * @returns the length of the Vector3
  1503. */
  1504. length(): number;
  1505. /**
  1506. * Gets the squared length of the Vector3
  1507. * @returns squared length of the Vector3
  1508. */
  1509. lengthSquared(): number;
  1510. /**
  1511. * Normalize the current Vector3.
  1512. * Please note that this is an in place operation.
  1513. * @returns the current updated Vector3
  1514. */
  1515. normalize(): Vector3;
  1516. /**
  1517. * Reorders the x y z properties of the vector in place
  1518. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1519. * @returns the current updated vector
  1520. */
  1521. reorderInPlace(order: string): this;
  1522. /**
  1523. * Rotates the vector around 0,0,0 by a quaternion
  1524. * @param quaternion the rotation quaternion
  1525. * @param result vector to store the result
  1526. * @returns the resulting vector
  1527. */
  1528. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1529. /**
  1530. * Rotates a vector around a given point
  1531. * @param quaternion the rotation quaternion
  1532. * @param point the point to rotate around
  1533. * @param result vector to store the result
  1534. * @returns the resulting vector
  1535. */
  1536. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1537. /**
  1538. * Normalize the current Vector3 with the given input length.
  1539. * Please note that this is an in place operation.
  1540. * @param len the length of the vector
  1541. * @returns the current updated Vector3
  1542. */
  1543. normalizeFromLength(len: number): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to a new vector
  1546. * @returns the new Vector3
  1547. */
  1548. normalizeToNew(): Vector3;
  1549. /**
  1550. * Normalize the current Vector3 to the reference
  1551. * @param reference define the Vector3 to update
  1552. * @returns the updated Vector3
  1553. */
  1554. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1555. /**
  1556. * Creates a new Vector3 copied from the current Vector3
  1557. * @returns the new Vector3
  1558. */
  1559. clone(): Vector3;
  1560. /**
  1561. * Copies the given vector coordinates to the current Vector3 ones
  1562. * @param source defines the source Vector3
  1563. * @returns the current updated Vector3
  1564. */
  1565. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1566. /**
  1567. * Copies the given floats to the current Vector3 coordinates
  1568. * @param x defines the x coordinate of the operand
  1569. * @param y defines the y coordinate of the operand
  1570. * @param z defines the z coordinate of the operand
  1571. * @returns the current updated Vector3
  1572. */
  1573. copyFromFloats(x: number, y: number, z: number): Vector3;
  1574. /**
  1575. * Copies the given floats to the current Vector3 coordinates
  1576. * @param x defines the x coordinate of the operand
  1577. * @param y defines the y coordinate of the operand
  1578. * @param z defines the z coordinate of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. set(x: number, y: number, z: number): Vector3;
  1582. /**
  1583. * Copies the given float to the current Vector3 coordinates
  1584. * @param v defines the x, y and z coordinates of the operand
  1585. * @returns the current updated Vector3
  1586. */
  1587. setAll(v: number): Vector3;
  1588. /**
  1589. * Get the clip factor between two vectors
  1590. * @param vector0 defines the first operand
  1591. * @param vector1 defines the second operand
  1592. * @param axis defines the axis to use
  1593. * @param size defines the size along the axis
  1594. * @returns the clip factor
  1595. */
  1596. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1597. /**
  1598. * Get angle between two vectors
  1599. * @param vector0 angle between vector0 and vector1
  1600. * @param vector1 angle between vector0 and vector1
  1601. * @param normal direction of the normal
  1602. * @return the angle between vector0 and vector1
  1603. */
  1604. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1605. /**
  1606. * Returns a new Vector3 set from the index "offset" of the given array
  1607. * @param array defines the source array
  1608. * @param offset defines the offset in the source array
  1609. * @returns the new Vector3
  1610. */
  1611. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1612. /**
  1613. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1614. * This function is deprecated. Use FromArray instead
  1615. * @param array defines the source array
  1616. * @param offset defines the offset in the source array
  1617. * @returns the new Vector3
  1618. */
  1619. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1620. /**
  1621. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1622. * @param array defines the source array
  1623. * @param offset defines the offset in the source array
  1624. * @param result defines the Vector3 where to store the result
  1625. */
  1626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1627. /**
  1628. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1629. * This function is deprecated. Use FromArrayToRef instead.
  1630. * @param array defines the source array
  1631. * @param offset defines the offset in the source array
  1632. * @param result defines the Vector3 where to store the result
  1633. */
  1634. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1635. /**
  1636. * Sets the given vector "result" with the given floats.
  1637. * @param x defines the x coordinate of the source
  1638. * @param y defines the y coordinate of the source
  1639. * @param z defines the z coordinate of the source
  1640. * @param result defines the Vector3 where to store the result
  1641. */
  1642. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1645. * @returns a new empty Vector3
  1646. */
  1647. static Zero(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1650. * @returns a new unit Vector3
  1651. */
  1652. static One(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1655. * @returns a new up Vector3
  1656. */
  1657. static Up(): Vector3;
  1658. /**
  1659. * Gets a up Vector3 that must not be updated
  1660. */
  1661. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1662. /**
  1663. * Gets a zero Vector3 that must not be updated
  1664. */
  1665. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1668. * @returns a new down Vector3
  1669. */
  1670. static Down(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Forward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1678. * @returns a new forward Vector3
  1679. */
  1680. static Backward(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1683. * @returns a new right Vector3
  1684. */
  1685. static Right(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1688. * @returns a new left Vector3
  1689. */
  1690. static Left(): Vector3;
  1691. /**
  1692. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1693. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1694. * @param vector defines the Vector3 to transform
  1695. * @param transformation defines the transformation matrix
  1696. * @returns the transformed Vector3
  1697. */
  1698. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1699. /**
  1700. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1701. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1702. * @param vector defines the Vector3 to transform
  1703. * @param transformation defines the transformation matrix
  1704. * @param result defines the Vector3 where to store the result
  1705. */
  1706. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1707. /**
  1708. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1709. * This method computes tranformed coordinates only, not transformed direction vectors
  1710. * @param x define the x coordinate of the source vector
  1711. * @param y define the y coordinate of the source vector
  1712. * @param z define the z coordinate of the source vector
  1713. * @param transformation defines the transformation matrix
  1714. * @param result defines the Vector3 where to store the result
  1715. */
  1716. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1717. /**
  1718. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1720. * @param vector defines the Vector3 to transform
  1721. * @param transformation defines the transformation matrix
  1722. * @returns the new Vector3
  1723. */
  1724. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1725. /**
  1726. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1728. * @param vector defines the Vector3 to transform
  1729. * @param transformation defines the transformation matrix
  1730. * @param result defines the Vector3 where to store the result
  1731. */
  1732. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1733. /**
  1734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1736. * @param x define the x coordinate of the source vector
  1737. * @param y define the y coordinate of the source vector
  1738. * @param z define the z coordinate of the source vector
  1739. * @param transformation defines the transformation matrix
  1740. * @param result defines the Vector3 where to store the result
  1741. */
  1742. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1743. /**
  1744. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1745. * @param value1 defines the first control point
  1746. * @param value2 defines the second control point
  1747. * @param value3 defines the third control point
  1748. * @param value4 defines the fourth control point
  1749. * @param amount defines the amount on the spline to use
  1750. * @returns the new Vector3
  1751. */
  1752. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1753. /**
  1754. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1755. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1756. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1757. * @param value defines the current value
  1758. * @param min defines the lower range value
  1759. * @param max defines the upper range value
  1760. * @returns the new Vector3
  1761. */
  1762. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1763. /**
  1764. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1765. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1766. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1767. * @param value defines the current value
  1768. * @param min defines the lower range value
  1769. * @param max defines the upper range value
  1770. * @param result defines the Vector3 where to store the result
  1771. */
  1772. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1773. /**
  1774. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1775. * @param value1 defines the first control point
  1776. * @param tangent1 defines the first tangent vector
  1777. * @param value2 defines the second control point
  1778. * @param tangent2 defines the second tangent vector
  1779. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1780. * @returns the new Vector3
  1781. */
  1782. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1783. /**
  1784. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1785. * @param start defines the start value
  1786. * @param end defines the end value
  1787. * @param amount max defines amount between both (between 0 and 1)
  1788. * @returns the new Vector3
  1789. */
  1790. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1793. * @param start defines the start value
  1794. * @param end defines the end value
  1795. * @param amount max defines amount between both (between 0 and 1)
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1799. /**
  1800. * Returns the dot product (float) between the vectors "left" and "right"
  1801. * @param left defines the left operand
  1802. * @param right defines the right operand
  1803. * @returns the dot product
  1804. */
  1805. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1806. /**
  1807. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1808. * The cross product is then orthogonal to both "left" and "right"
  1809. * @param left defines the left operand
  1810. * @param right defines the right operand
  1811. * @returns the cross product
  1812. */
  1813. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1814. /**
  1815. * Sets the given vector "result" with the cross product of "left" and "right"
  1816. * The cross product is then orthogonal to both "left" and "right"
  1817. * @param left defines the left operand
  1818. * @param right defines the right operand
  1819. * @param result defines the Vector3 where to store the result
  1820. */
  1821. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1822. /**
  1823. * Returns a new Vector3 as the normalization of the given vector
  1824. * @param vector defines the Vector3 to normalize
  1825. * @returns the new Vector3
  1826. */
  1827. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1828. /**
  1829. * Sets the given vector "result" with the normalization of the given first vector
  1830. * @param vector defines the Vector3 to normalize
  1831. * @param result defines the Vector3 where to store the result
  1832. */
  1833. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1834. /**
  1835. * Project a Vector3 onto screen space
  1836. * @param vector defines the Vector3 to project
  1837. * @param world defines the world matrix to use
  1838. * @param transform defines the transform (view x projection) matrix to use
  1839. * @param viewport defines the screen viewport to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1843. /** @hidden */
  1844. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param transform defines the transform (view x projection) matrix to use
  1852. * @returns the new Vector3
  1853. */
  1854. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param source defines the screen space Vector3 to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @returns the new Vector3
  1864. */
  1865. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1866. /**
  1867. * Unproject from screen space to object space
  1868. * @param source defines the screen space Vector3 to use
  1869. * @param viewportWidth defines the current width of the viewport
  1870. * @param viewportHeight defines the current height of the viewport
  1871. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1872. * @param view defines the view matrix to use
  1873. * @param projection defines the projection matrix to use
  1874. * @param result defines the Vector3 where to store the result
  1875. */
  1876. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1877. /**
  1878. * Unproject from screen space to object space
  1879. * @param sourceX defines the screen space x coordinate to use
  1880. * @param sourceY defines the screen space y coordinate to use
  1881. * @param sourceZ defines the screen space z coordinate to use
  1882. * @param viewportWidth defines the current width of the viewport
  1883. * @param viewportHeight defines the current height of the viewport
  1884. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1885. * @param view defines the view matrix to use
  1886. * @param projection defines the projection matrix to use
  1887. * @param result defines the Vector3 where to store the result
  1888. */
  1889. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1890. /**
  1891. * Gets the minimal coordinate values between two Vector3
  1892. * @param left defines the first operand
  1893. * @param right defines the second operand
  1894. * @returns the new Vector3
  1895. */
  1896. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1897. /**
  1898. * Gets the maximal coordinate values between two Vector3
  1899. * @param left defines the first operand
  1900. * @param right defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Returns the distance between the vectors "value1" and "value2"
  1906. * @param value1 defines the first operand
  1907. * @param value2 defines the second operand
  1908. * @returns the distance
  1909. */
  1910. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1911. /**
  1912. * Returns the squared distance between the vectors "value1" and "value2"
  1913. * @param value1 defines the first operand
  1914. * @param value2 defines the second operand
  1915. * @returns the squared distance
  1916. */
  1917. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1918. /**
  1919. * Returns a new Vector3 located at the center between "value1" and "value2"
  1920. * @param value1 defines the first operand
  1921. * @param value2 defines the second operand
  1922. * @returns the new Vector3
  1923. */
  1924. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1925. /**
  1926. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1927. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1928. * to something in order to rotate it from its local system to the given target system
  1929. * Note: axis1, axis2 and axis3 are normalized during this operation
  1930. * @param axis1 defines the first axis
  1931. * @param axis2 defines the second axis
  1932. * @param axis3 defines the third axis
  1933. * @returns a new Vector3
  1934. */
  1935. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1936. /**
  1937. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1938. * @param axis1 defines the first axis
  1939. * @param axis2 defines the second axis
  1940. * @param axis3 defines the third axis
  1941. * @param ref defines the Vector3 where to store the result
  1942. */
  1943. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1944. }
  1945. /**
  1946. * Vector4 class created for EulerAngle class conversion to Quaternion
  1947. */
  1948. export class Vector4 {
  1949. /** x value of the vector */
  1950. x: number;
  1951. /** y value of the vector */
  1952. y: number;
  1953. /** z value of the vector */
  1954. z: number;
  1955. /** w value of the vector */
  1956. w: number;
  1957. /**
  1958. * Creates a Vector4 object from the given floats.
  1959. * @param x x value of the vector
  1960. * @param y y value of the vector
  1961. * @param z z value of the vector
  1962. * @param w w value of the vector
  1963. */
  1964. constructor(
  1965. /** x value of the vector */
  1966. x: number,
  1967. /** y value of the vector */
  1968. y: number,
  1969. /** z value of the vector */
  1970. z: number,
  1971. /** w value of the vector */
  1972. w: number);
  1973. /**
  1974. * Returns the string with the Vector4 coordinates.
  1975. * @returns a string containing all the vector values
  1976. */
  1977. toString(): string;
  1978. /**
  1979. * Returns the string "Vector4".
  1980. * @returns "Vector4"
  1981. */
  1982. getClassName(): string;
  1983. /**
  1984. * Returns the Vector4 hash code.
  1985. * @returns a unique hash code
  1986. */
  1987. getHashCode(): number;
  1988. /**
  1989. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1990. * @returns the resulting array
  1991. */
  1992. asArray(): number[];
  1993. /**
  1994. * Populates the given array from the given index with the Vector4 coordinates.
  1995. * @param array array to populate
  1996. * @param index index of the array to start at (default: 0)
  1997. * @returns the Vector4.
  1998. */
  1999. toArray(array: FloatArray, index?: number): Vector4;
  2000. /**
  2001. * Adds the given vector to the current Vector4.
  2002. * @param otherVector the vector to add
  2003. * @returns the updated Vector4.
  2004. */
  2005. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2006. /**
  2007. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2008. * @param otherVector the vector to add
  2009. * @returns the resulting vector
  2010. */
  2011. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2012. /**
  2013. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2014. * @param otherVector the vector to add
  2015. * @param result the vector to store the result
  2016. * @returns the current Vector4.
  2017. */
  2018. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2019. /**
  2020. * Subtract in place the given vector from the current Vector4.
  2021. * @param otherVector the vector to subtract
  2022. * @returns the updated Vector4.
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2025. /**
  2026. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2027. * @param otherVector the vector to add
  2028. * @returns the new vector with the result
  2029. */
  2030. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2031. /**
  2032. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2033. * @param otherVector the vector to subtract
  2034. * @param result the vector to store the result
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2040. */
  2041. /**
  2042. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2043. * @param x value to subtract
  2044. * @param y value to subtract
  2045. * @param z value to subtract
  2046. * @param w value to subtract
  2047. * @returns new vector containing the result
  2048. */
  2049. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2050. /**
  2051. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2052. * @param x value to subtract
  2053. * @param y value to subtract
  2054. * @param z value to subtract
  2055. * @param w value to subtract
  2056. * @param result the vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2060. /**
  2061. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2062. * @returns a new vector with the negated values
  2063. */
  2064. negate(): Vector4;
  2065. /**
  2066. * Multiplies the current Vector4 coordinates by scale (float).
  2067. * @param scale the number to scale with
  2068. * @returns the updated Vector4.
  2069. */
  2070. scaleInPlace(scale: number): Vector4;
  2071. /**
  2072. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2073. * @param scale the number to scale with
  2074. * @returns a new vector with the result
  2075. */
  2076. scale(scale: number): Vector4;
  2077. /**
  2078. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2079. * @param scale the number to scale with
  2080. * @param result a vector to store the result in
  2081. * @returns the current Vector4.
  2082. */
  2083. scaleToRef(scale: number, result: Vector4): Vector4;
  2084. /**
  2085. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2086. * @param scale defines the scale factor
  2087. * @param result defines the Vector4 object where to store the result
  2088. * @returns the unmodified current Vector4
  2089. */
  2090. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2091. /**
  2092. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2093. * @param otherVector the vector to compare against
  2094. * @returns true if they are equal
  2095. */
  2096. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2097. /**
  2098. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2099. * @param otherVector vector to compare against
  2100. * @param epsilon (Default: very small number)
  2101. * @returns true if they are equal
  2102. */
  2103. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2104. /**
  2105. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2106. * @param x x value to compare against
  2107. * @param y y value to compare against
  2108. * @param z z value to compare against
  2109. * @param w w value to compare against
  2110. * @returns true if equal
  2111. */
  2112. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2113. /**
  2114. * Multiplies in place the current Vector4 by the given one.
  2115. * @param otherVector vector to multiple with
  2116. * @returns the updated Vector4.
  2117. */
  2118. multiplyInPlace(otherVector: Vector4): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2121. * @param otherVector vector to multiple with
  2122. * @returns resulting new vector
  2123. */
  2124. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2127. * @param otherVector vector to multiple with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2134. * @param x x value multiply with
  2135. * @param y y value multiply with
  2136. * @param z z value multiply with
  2137. * @param w w value multiply with
  2138. * @returns resulting new vector
  2139. */
  2140. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2141. /**
  2142. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2143. * @param otherVector vector to devide with
  2144. * @returns resulting new vector
  2145. */
  2146. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2147. /**
  2148. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2149. * @param otherVector vector to devide with
  2150. * @param result vector to store the result
  2151. * @returns the current Vector4.
  2152. */
  2153. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2154. /**
  2155. * Divides the current Vector3 coordinates by the given ones.
  2156. * @param otherVector vector to devide with
  2157. * @returns the updated Vector3.
  2158. */
  2159. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2160. /**
  2161. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2162. * @param other defines the second operand
  2163. * @returns the current updated Vector4
  2164. */
  2165. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2166. /**
  2167. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2168. * @param other defines the second operand
  2169. * @returns the current updated Vector4
  2170. */
  2171. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2172. /**
  2173. * Gets a new Vector4 from current Vector4 floored values
  2174. * @returns a new Vector4
  2175. */
  2176. floor(): Vector4;
  2177. /**
  2178. * Gets a new Vector4 from current Vector3 floored values
  2179. * @returns a new Vector4
  2180. */
  2181. fract(): Vector4;
  2182. /**
  2183. * Returns the Vector4 length (float).
  2184. * @returns the length
  2185. */
  2186. length(): number;
  2187. /**
  2188. * Returns the Vector4 squared length (float).
  2189. * @returns the length squared
  2190. */
  2191. lengthSquared(): number;
  2192. /**
  2193. * Normalizes in place the Vector4.
  2194. * @returns the updated Vector4.
  2195. */
  2196. normalize(): Vector4;
  2197. /**
  2198. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2199. * @returns this converted to a new vector3
  2200. */
  2201. toVector3(): Vector3;
  2202. /**
  2203. * Returns a new Vector4 copied from the current one.
  2204. * @returns the new cloned vector
  2205. */
  2206. clone(): Vector4;
  2207. /**
  2208. * Updates the current Vector4 with the given one coordinates.
  2209. * @param source the source vector to copy from
  2210. * @returns the updated Vector4.
  2211. */
  2212. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2213. /**
  2214. * Updates the current Vector4 coordinates with the given floats.
  2215. * @param x float to copy from
  2216. * @param y float to copy from
  2217. * @param z float to copy from
  2218. * @param w float to copy from
  2219. * @returns the updated Vector4.
  2220. */
  2221. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2222. /**
  2223. * Updates the current Vector4 coordinates with the given floats.
  2224. * @param x float to set from
  2225. * @param y float to set from
  2226. * @param z float to set from
  2227. * @param w float to set from
  2228. * @returns the updated Vector4.
  2229. */
  2230. set(x: number, y: number, z: number, w: number): Vector4;
  2231. /**
  2232. * Copies the given float to the current Vector3 coordinates
  2233. * @param v defines the x, y, z and w coordinates of the operand
  2234. * @returns the current updated Vector3
  2235. */
  2236. setAll(v: number): Vector4;
  2237. /**
  2238. * Returns a new Vector4 set from the starting index of the given array.
  2239. * @param array the array to pull values from
  2240. * @param offset the offset into the array to start at
  2241. * @returns the new vector
  2242. */
  2243. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2244. /**
  2245. * Updates the given vector "result" from the starting index of the given array.
  2246. * @param array the array to pull values from
  2247. * @param offset the offset into the array to start at
  2248. * @param result the vector to store the result in
  2249. */
  2250. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2251. /**
  2252. * Updates the given vector "result" from the starting index of the given Float32Array.
  2253. * @param array the array to pull values from
  2254. * @param offset the offset into the array to start at
  2255. * @param result the vector to store the result in
  2256. */
  2257. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2258. /**
  2259. * Updates the given vector "result" coordinates from the given floats.
  2260. * @param x float to set from
  2261. * @param y float to set from
  2262. * @param z float to set from
  2263. * @param w float to set from
  2264. * @param result the vector to the floats in
  2265. */
  2266. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2267. /**
  2268. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2269. * @returns the new vector
  2270. */
  2271. static Zero(): Vector4;
  2272. /**
  2273. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2274. * @returns the new vector
  2275. */
  2276. static One(): Vector4;
  2277. /**
  2278. * Returns a new normalized Vector4 from the given one.
  2279. * @param vector the vector to normalize
  2280. * @returns the vector
  2281. */
  2282. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2283. /**
  2284. * Updates the given vector "result" from the normalization of the given one.
  2285. * @param vector the vector to normalize
  2286. * @param result the vector to store the result in
  2287. */
  2288. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2289. /**
  2290. * Returns a vector with the minimum values from the left and right vectors
  2291. * @param left left vector to minimize
  2292. * @param right right vector to minimize
  2293. * @returns a new vector with the minimum of the left and right vector values
  2294. */
  2295. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2296. /**
  2297. * Returns a vector with the maximum values from the left and right vectors
  2298. * @param left left vector to maximize
  2299. * @param right right vector to maximize
  2300. * @returns a new vector with the maximum of the left and right vector values
  2301. */
  2302. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns the distance (float) between the vectors "value1" and "value2".
  2305. * @param value1 value to calulate the distance between
  2306. * @param value2 value to calulate the distance between
  2307. * @return the distance between the two vectors
  2308. */
  2309. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2310. /**
  2311. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2312. * @param value1 value to calulate the distance between
  2313. * @param value2 value to calulate the distance between
  2314. * @return the distance between the two vectors squared
  2315. */
  2316. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2317. /**
  2318. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2319. * @param value1 value to calulate the center between
  2320. * @param value2 value to calulate the center between
  2321. * @return the center between the two vectors
  2322. */
  2323. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2324. /**
  2325. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2326. * This methods computes transformed normalized direction vectors only.
  2327. * @param vector the vector to transform
  2328. * @param transformation the transformation matrix to apply
  2329. * @returns the new vector
  2330. */
  2331. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2332. /**
  2333. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2334. * This methods computes transformed normalized direction vectors only.
  2335. * @param vector the vector to transform
  2336. * @param transformation the transformation matrix to apply
  2337. * @param result the vector to store the result in
  2338. */
  2339. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2340. /**
  2341. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2342. * This methods computes transformed normalized direction vectors only.
  2343. * @param x value to transform
  2344. * @param y value to transform
  2345. * @param z value to transform
  2346. * @param w value to transform
  2347. * @param transformation the transformation matrix to apply
  2348. * @param result the vector to store the results in
  2349. */
  2350. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2351. /**
  2352. * Creates a new Vector4 from a Vector3
  2353. * @param source defines the source data
  2354. * @param w defines the 4th component (default is 0)
  2355. * @returns a new Vector4
  2356. */
  2357. static FromVector3(source: Vector3, w?: number): Vector4;
  2358. }
  2359. /**
  2360. * Interface for the size containing width and height
  2361. */
  2362. export interface ISize {
  2363. /**
  2364. * Width
  2365. */
  2366. width: number;
  2367. /**
  2368. * Heighht
  2369. */
  2370. height: number;
  2371. }
  2372. /**
  2373. * Size containing widht and height
  2374. */
  2375. export class Size implements ISize {
  2376. /**
  2377. * Width
  2378. */
  2379. width: number;
  2380. /**
  2381. * Height
  2382. */
  2383. height: number;
  2384. /**
  2385. * Creates a Size object from the given width and height (floats).
  2386. * @param width width of the new size
  2387. * @param height height of the new size
  2388. */
  2389. constructor(width: number, height: number);
  2390. /**
  2391. * Returns a string with the Size width and height
  2392. * @returns a string with the Size width and height
  2393. */
  2394. toString(): string;
  2395. /**
  2396. * "Size"
  2397. * @returns the string "Size"
  2398. */
  2399. getClassName(): string;
  2400. /**
  2401. * Returns the Size hash code.
  2402. * @returns a hash code for a unique width and height
  2403. */
  2404. getHashCode(): number;
  2405. /**
  2406. * Updates the current size from the given one.
  2407. * @param src the given size
  2408. */
  2409. copyFrom(src: Size): void;
  2410. /**
  2411. * Updates in place the current Size from the given floats.
  2412. * @param width width of the new size
  2413. * @param height height of the new size
  2414. * @returns the updated Size.
  2415. */
  2416. copyFromFloats(width: number, height: number): Size;
  2417. /**
  2418. * Updates in place the current Size from the given floats.
  2419. * @param width width to set
  2420. * @param height height to set
  2421. * @returns the updated Size.
  2422. */
  2423. set(width: number, height: number): Size;
  2424. /**
  2425. * Multiplies the width and height by numbers
  2426. * @param w factor to multiple the width by
  2427. * @param h factor to multiple the height by
  2428. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2429. */
  2430. multiplyByFloats(w: number, h: number): Size;
  2431. /**
  2432. * Clones the size
  2433. * @returns a new Size copied from the given one.
  2434. */
  2435. clone(): Size;
  2436. /**
  2437. * True if the current Size and the given one width and height are strictly equal.
  2438. * @param other the other size to compare against
  2439. * @returns True if the current Size and the given one width and height are strictly equal.
  2440. */
  2441. equals(other: Size): boolean;
  2442. /**
  2443. * The surface of the Size : width * height (float).
  2444. */
  2445. readonly surface: number;
  2446. /**
  2447. * Create a new size of zero
  2448. * @returns a new Size set to (0.0, 0.0)
  2449. */
  2450. static Zero(): Size;
  2451. /**
  2452. * Sums the width and height of two sizes
  2453. * @param otherSize size to add to this size
  2454. * @returns a new Size set as the addition result of the current Size and the given one.
  2455. */
  2456. add(otherSize: Size): Size;
  2457. /**
  2458. * Subtracts the width and height of two
  2459. * @param otherSize size to subtract to this size
  2460. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2461. */
  2462. subtract(otherSize: Size): Size;
  2463. /**
  2464. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2465. * @param start starting size to lerp between
  2466. * @param end end size to lerp between
  2467. * @param amount amount to lerp between the start and end values
  2468. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2469. */
  2470. static Lerp(start: Size, end: Size, amount: number): Size;
  2471. }
  2472. /**
  2473. * Class used to store quaternion data
  2474. * @see https://en.wikipedia.org/wiki/Quaternion
  2475. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2476. */
  2477. export class Quaternion {
  2478. /** defines the first component (0 by default) */
  2479. x: number;
  2480. /** defines the second component (0 by default) */
  2481. y: number;
  2482. /** defines the third component (0 by default) */
  2483. z: number;
  2484. /** defines the fourth component (1.0 by default) */
  2485. w: number;
  2486. /**
  2487. * Creates a new Quaternion from the given floats
  2488. * @param x defines the first component (0 by default)
  2489. * @param y defines the second component (0 by default)
  2490. * @param z defines the third component (0 by default)
  2491. * @param w defines the fourth component (1.0 by default)
  2492. */
  2493. constructor(
  2494. /** defines the first component (0 by default) */
  2495. x?: number,
  2496. /** defines the second component (0 by default) */
  2497. y?: number,
  2498. /** defines the third component (0 by default) */
  2499. z?: number,
  2500. /** defines the fourth component (1.0 by default) */
  2501. w?: number);
  2502. /**
  2503. * Gets a string representation for the current quaternion
  2504. * @returns a string with the Quaternion coordinates
  2505. */
  2506. toString(): string;
  2507. /**
  2508. * Gets the class name of the quaternion
  2509. * @returns the string "Quaternion"
  2510. */
  2511. getClassName(): string;
  2512. /**
  2513. * Gets a hash code for this quaternion
  2514. * @returns the quaternion hash code
  2515. */
  2516. getHashCode(): number;
  2517. /**
  2518. * Copy the quaternion to an array
  2519. * @returns a new array populated with 4 elements from the quaternion coordinates
  2520. */
  2521. asArray(): number[];
  2522. /**
  2523. * Check if two quaternions are equals
  2524. * @param otherQuaternion defines the second operand
  2525. * @return true if the current quaternion and the given one coordinates are strictly equals
  2526. */
  2527. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2528. /**
  2529. * Clone the current quaternion
  2530. * @returns a new quaternion copied from the current one
  2531. */
  2532. clone(): Quaternion;
  2533. /**
  2534. * Copy a quaternion to the current one
  2535. * @param other defines the other quaternion
  2536. * @returns the updated current quaternion
  2537. */
  2538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Updates the current quaternion with the given float coordinates
  2541. * @param x defines the x coordinate
  2542. * @param y defines the y coordinate
  2543. * @param z defines the z coordinate
  2544. * @param w defines the w coordinate
  2545. * @returns the updated current quaternion
  2546. */
  2547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2548. /**
  2549. * Updates the current quaternion from the given float coordinates
  2550. * @param x defines the x coordinate
  2551. * @param y defines the y coordinate
  2552. * @param z defines the z coordinate
  2553. * @param w defines the w coordinate
  2554. * @returns the updated current quaternion
  2555. */
  2556. set(x: number, y: number, z: number, w: number): Quaternion;
  2557. /**
  2558. * Adds two quaternions
  2559. * @param other defines the second operand
  2560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2561. */
  2562. add(other: DeepImmutable<Quaternion>): Quaternion;
  2563. /**
  2564. * Add a quaternion to the current one
  2565. * @param other defines the quaternion to add
  2566. * @returns the current quaternion
  2567. */
  2568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2569. /**
  2570. * Subtract two quaternions
  2571. * @param other defines the second operand
  2572. * @returns a new quaternion as the subtraction result of the given one from the current one
  2573. */
  2574. subtract(other: Quaternion): Quaternion;
  2575. /**
  2576. * Multiplies the current quaternion by a scale factor
  2577. * @param value defines the scale factor
  2578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2579. */
  2580. scale(value: number): Quaternion;
  2581. /**
  2582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2583. * @param scale defines the scale factor
  2584. * @param result defines the Quaternion object where to store the result
  2585. * @returns the unmodified current quaternion
  2586. */
  2587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2588. /**
  2589. * Multiplies in place the current quaternion by a scale factor
  2590. * @param value defines the scale factor
  2591. * @returns the current modified quaternion
  2592. */
  2593. scaleInPlace(value: number): Quaternion;
  2594. /**
  2595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2596. * @param scale defines the scale factor
  2597. * @param result defines the Quaternion object where to store the result
  2598. * @returns the unmodified current quaternion
  2599. */
  2600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2601. /**
  2602. * Multiplies two quaternions
  2603. * @param q1 defines the second operand
  2604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2605. */
  2606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2607. /**
  2608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2609. * @param q1 defines the second operand
  2610. * @param result defines the target quaternion
  2611. * @returns the current quaternion
  2612. */
  2613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2614. /**
  2615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2616. * @param q1 defines the second operand
  2617. * @returns the currentupdated quaternion
  2618. */
  2619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2620. /**
  2621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2622. * @param ref defines the target quaternion
  2623. * @returns the current quaternion
  2624. */
  2625. conjugateToRef(ref: Quaternion): Quaternion;
  2626. /**
  2627. * Conjugates in place (1-q) the current quaternion
  2628. * @returns the current updated quaternion
  2629. */
  2630. conjugateInPlace(): Quaternion;
  2631. /**
  2632. * Conjugates in place (1-q) the current quaternion
  2633. * @returns a new quaternion
  2634. */
  2635. conjugate(): Quaternion;
  2636. /**
  2637. * Gets length of current quaternion
  2638. * @returns the quaternion length (float)
  2639. */
  2640. length(): number;
  2641. /**
  2642. * Normalize in place the current quaternion
  2643. * @returns the current updated quaternion
  2644. */
  2645. normalize(): Quaternion;
  2646. /**
  2647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2648. * @param order is a reserved parameter and is ignore for now
  2649. * @returns a new Vector3 containing the Euler angles
  2650. */
  2651. toEulerAngles(order?: string): Vector3;
  2652. /**
  2653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2654. * @param result defines the vector which will be filled with the Euler angles
  2655. * @param order is a reserved parameter and is ignore for now
  2656. * @returns the current unchanged quaternion
  2657. */
  2658. toEulerAnglesToRef(result: Vector3): Quaternion;
  2659. /**
  2660. * Updates the given rotation matrix with the current quaternion values
  2661. * @param result defines the target matrix
  2662. * @returns the current unchanged quaternion
  2663. */
  2664. toRotationMatrix(result: Matrix): Quaternion;
  2665. /**
  2666. * Updates the current quaternion from the given rotation matrix values
  2667. * @param matrix defines the source matrix
  2668. * @returns the current updated quaternion
  2669. */
  2670. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2671. /**
  2672. * Creates a new quaternion from a rotation matrix
  2673. * @param matrix defines the source matrix
  2674. * @returns a new quaternion created from the given rotation matrix values
  2675. */
  2676. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2677. /**
  2678. * Updates the given quaternion with the given rotation matrix values
  2679. * @param matrix defines the source matrix
  2680. * @param result defines the target quaternion
  2681. */
  2682. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2683. /**
  2684. * Returns the dot product (float) between the quaternions "left" and "right"
  2685. * @param left defines the left operand
  2686. * @param right defines the right operand
  2687. * @returns the dot product
  2688. */
  2689. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2690. /**
  2691. * Checks if the two quaternions are close to each other
  2692. * @param quat0 defines the first quaternion to check
  2693. * @param quat1 defines the second quaternion to check
  2694. * @returns true if the two quaternions are close to each other
  2695. */
  2696. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2697. /**
  2698. * Creates an empty quaternion
  2699. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2700. */
  2701. static Zero(): Quaternion;
  2702. /**
  2703. * Inverse a given quaternion
  2704. * @param q defines the source quaternion
  2705. * @returns a new quaternion as the inverted current quaternion
  2706. */
  2707. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2708. /**
  2709. * Inverse a given quaternion
  2710. * @param q defines the source quaternion
  2711. * @param result the quaternion the result will be stored in
  2712. * @returns the result quaternion
  2713. */
  2714. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2715. /**
  2716. * Creates an identity quaternion
  2717. * @returns the identity quaternion
  2718. */
  2719. static Identity(): Quaternion;
  2720. /**
  2721. * Gets a boolean indicating if the given quaternion is identity
  2722. * @param quaternion defines the quaternion to check
  2723. * @returns true if the quaternion is identity
  2724. */
  2725. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2726. /**
  2727. * Creates a quaternion from a rotation around an axis
  2728. * @param axis defines the axis to use
  2729. * @param angle defines the angle to use
  2730. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2731. */
  2732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2733. /**
  2734. * Creates a rotation around an axis and stores it into the given quaternion
  2735. * @param axis defines the axis to use
  2736. * @param angle defines the angle to use
  2737. * @param result defines the target quaternion
  2738. * @returns the target quaternion
  2739. */
  2740. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Creates a new quaternion from data stored into an array
  2743. * @param array defines the data source
  2744. * @param offset defines the offset in the source array where the data starts
  2745. * @returns a new quaternion
  2746. */
  2747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2748. /**
  2749. * Create a quaternion from Euler rotation angles
  2750. * @param x Pitch
  2751. * @param y Yaw
  2752. * @param z Roll
  2753. * @returns the new Quaternion
  2754. */
  2755. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2756. /**
  2757. * Updates a quaternion from Euler rotation angles
  2758. * @param x Pitch
  2759. * @param y Yaw
  2760. * @param z Roll
  2761. * @param result the quaternion to store the result
  2762. * @returns the updated quaternion
  2763. */
  2764. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2765. /**
  2766. * Create a quaternion from Euler rotation vector
  2767. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2768. * @returns the new Quaternion
  2769. */
  2770. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2771. /**
  2772. * Updates a quaternion from Euler rotation vector
  2773. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2774. * @param result the quaternion to store the result
  2775. * @returns the updated quaternion
  2776. */
  2777. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2780. * @param yaw defines the rotation around Y axis
  2781. * @param pitch defines the rotation around X axis
  2782. * @param roll defines the rotation around Z axis
  2783. * @returns the new quaternion
  2784. */
  2785. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2786. /**
  2787. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2788. * @param yaw defines the rotation around Y axis
  2789. * @param pitch defines the rotation around X axis
  2790. * @param roll defines the rotation around Z axis
  2791. * @param result defines the target quaternion
  2792. */
  2793. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2794. /**
  2795. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2796. * @param alpha defines the rotation around first axis
  2797. * @param beta defines the rotation around second axis
  2798. * @param gamma defines the rotation around third axis
  2799. * @returns the new quaternion
  2800. */
  2801. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2802. /**
  2803. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2804. * @param alpha defines the rotation around first axis
  2805. * @param beta defines the rotation around second axis
  2806. * @param gamma defines the rotation around third axis
  2807. * @param result defines the target quaternion
  2808. */
  2809. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2810. /**
  2811. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2812. * @param axis1 defines the first axis
  2813. * @param axis2 defines the second axis
  2814. * @param axis3 defines the third axis
  2815. * @returns the new quaternion
  2816. */
  2817. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2818. /**
  2819. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2820. * @param axis1 defines the first axis
  2821. * @param axis2 defines the second axis
  2822. * @param axis3 defines the third axis
  2823. * @param ref defines the target quaternion
  2824. */
  2825. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2826. /**
  2827. * Interpolates between two quaternions
  2828. * @param left defines first quaternion
  2829. * @param right defines second quaternion
  2830. * @param amount defines the gradient to use
  2831. * @returns the new interpolated quaternion
  2832. */
  2833. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2834. /**
  2835. * Interpolates between two quaternions and stores it into a target quaternion
  2836. * @param left defines first quaternion
  2837. * @param right defines second quaternion
  2838. * @param amount defines the gradient to use
  2839. * @param result defines the target quaternion
  2840. */
  2841. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2842. /**
  2843. * Interpolate between two quaternions using Hermite interpolation
  2844. * @param value1 defines first quaternion
  2845. * @param tangent1 defines the incoming tangent
  2846. * @param value2 defines second quaternion
  2847. * @param tangent2 defines the outgoing tangent
  2848. * @param amount defines the target quaternion
  2849. * @returns the new interpolated quaternion
  2850. */
  2851. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2852. }
  2853. /**
  2854. * Class used to store matrix data (4x4)
  2855. */
  2856. export class Matrix {
  2857. private static _updateFlagSeed;
  2858. private static _identityReadOnly;
  2859. private _isIdentity;
  2860. private _isIdentityDirty;
  2861. private _isIdentity3x2;
  2862. private _isIdentity3x2Dirty;
  2863. /**
  2864. * Gets the update flag of the matrix which is an unique number for the matrix.
  2865. * It will be incremented every time the matrix data change.
  2866. * You can use it to speed the comparison between two versions of the same matrix.
  2867. */
  2868. updateFlag: number;
  2869. private readonly _m;
  2870. /**
  2871. * Gets the internal data of the matrix
  2872. */
  2873. readonly m: DeepImmutable<Float32Array>;
  2874. /** @hidden */
  2875. _markAsUpdated(): void;
  2876. /** @hidden */
  2877. private _updateIdentityStatus;
  2878. /**
  2879. * Creates an empty matrix (filled with zeros)
  2880. */
  2881. constructor();
  2882. /**
  2883. * Check if the current matrix is identity
  2884. * @returns true is the matrix is the identity matrix
  2885. */
  2886. isIdentity(): boolean;
  2887. /**
  2888. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2889. * @returns true is the matrix is the identity matrix
  2890. */
  2891. isIdentityAs3x2(): boolean;
  2892. /**
  2893. * Gets the determinant of the matrix
  2894. * @returns the matrix determinant
  2895. */
  2896. determinant(): number;
  2897. /**
  2898. * Returns the matrix as a Float32Array
  2899. * @returns the matrix underlying array
  2900. */
  2901. toArray(): DeepImmutable<Float32Array>;
  2902. /**
  2903. * Returns the matrix as a Float32Array
  2904. * @returns the matrix underlying array.
  2905. */
  2906. asArray(): DeepImmutable<Float32Array>;
  2907. /**
  2908. * Inverts the current matrix in place
  2909. * @returns the current inverted matrix
  2910. */
  2911. invert(): Matrix;
  2912. /**
  2913. * Sets all the matrix elements to zero
  2914. * @returns the current matrix
  2915. */
  2916. reset(): Matrix;
  2917. /**
  2918. * Adds the current matrix with a second one
  2919. * @param other defines the matrix to add
  2920. * @returns a new matrix as the addition of the current matrix and the given one
  2921. */
  2922. add(other: DeepImmutable<Matrix>): Matrix;
  2923. /**
  2924. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2925. * @param other defines the matrix to add
  2926. * @param result defines the target matrix
  2927. * @returns the current matrix
  2928. */
  2929. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2930. /**
  2931. * Adds in place the given matrix to the current matrix
  2932. * @param other defines the second operand
  2933. * @returns the current updated matrix
  2934. */
  2935. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2936. /**
  2937. * Sets the given matrix to the current inverted Matrix
  2938. * @param other defines the target matrix
  2939. * @returns the unmodified current matrix
  2940. */
  2941. invertToRef(other: Matrix): Matrix;
  2942. /**
  2943. * add a value at the specified position in the current Matrix
  2944. * @param index the index of the value within the matrix. between 0 and 15.
  2945. * @param value the value to be added
  2946. * @returns the current updated matrix
  2947. */
  2948. addAtIndex(index: number, value: number): Matrix;
  2949. /**
  2950. * mutiply the specified position in the current Matrix by a value
  2951. * @param index the index of the value within the matrix. between 0 and 15.
  2952. * @param value the value to be added
  2953. * @returns the current updated matrix
  2954. */
  2955. multiplyAtIndex(index: number, value: number): Matrix;
  2956. /**
  2957. * Inserts the translation vector (using 3 floats) in the current matrix
  2958. * @param x defines the 1st component of the translation
  2959. * @param y defines the 2nd component of the translation
  2960. * @param z defines the 3rd component of the translation
  2961. * @returns the current updated matrix
  2962. */
  2963. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2964. /**
  2965. * Adds the translation vector (using 3 floats) in the current matrix
  2966. * @param x defines the 1st component of the translation
  2967. * @param y defines the 2nd component of the translation
  2968. * @param z defines the 3rd component of the translation
  2969. * @returns the current updated matrix
  2970. */
  2971. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2972. /**
  2973. * Inserts the translation vector in the current matrix
  2974. * @param vector3 defines the translation to insert
  2975. * @returns the current updated matrix
  2976. */
  2977. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2978. /**
  2979. * Gets the translation value of the current matrix
  2980. * @returns a new Vector3 as the extracted translation from the matrix
  2981. */
  2982. getTranslation(): Vector3;
  2983. /**
  2984. * Fill a Vector3 with the extracted translation from the matrix
  2985. * @param result defines the Vector3 where to store the translation
  2986. * @returns the current matrix
  2987. */
  2988. getTranslationToRef(result: Vector3): Matrix;
  2989. /**
  2990. * Remove rotation and scaling part from the matrix
  2991. * @returns the updated matrix
  2992. */
  2993. removeRotationAndScaling(): Matrix;
  2994. /**
  2995. * Multiply two matrices
  2996. * @param other defines the second operand
  2997. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2998. */
  2999. multiply(other: DeepImmutable<Matrix>): Matrix;
  3000. /**
  3001. * Copy the current matrix from the given one
  3002. * @param other defines the source matrix
  3003. * @returns the current updated matrix
  3004. */
  3005. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3006. /**
  3007. * Populates the given array from the starting index with the current matrix values
  3008. * @param array defines the target array
  3009. * @param offset defines the offset in the target array where to start storing values
  3010. * @returns the current matrix
  3011. */
  3012. copyToArray(array: Float32Array, offset?: number): Matrix;
  3013. /**
  3014. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3015. * @param other defines the second operand
  3016. * @param result defines the matrix where to store the multiplication
  3017. * @returns the current matrix
  3018. */
  3019. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3020. /**
  3021. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3022. * @param other defines the second operand
  3023. * @param result defines the array where to store the multiplication
  3024. * @param offset defines the offset in the target array where to start storing values
  3025. * @returns the current matrix
  3026. */
  3027. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3028. /**
  3029. * Check equality between this matrix and a second one
  3030. * @param value defines the second matrix to compare
  3031. * @returns true is the current matrix and the given one values are strictly equal
  3032. */
  3033. equals(value: DeepImmutable<Matrix>): boolean;
  3034. /**
  3035. * Clone the current matrix
  3036. * @returns a new matrix from the current matrix
  3037. */
  3038. clone(): Matrix;
  3039. /**
  3040. * Returns the name of the current matrix class
  3041. * @returns the string "Matrix"
  3042. */
  3043. getClassName(): string;
  3044. /**
  3045. * Gets the hash code of the current matrix
  3046. * @returns the hash code
  3047. */
  3048. getHashCode(): number;
  3049. /**
  3050. * Decomposes the current Matrix into a translation, rotation and scaling components
  3051. * @param scale defines the scale vector3 given as a reference to update
  3052. * @param rotation defines the rotation quaternion given as a reference to update
  3053. * @param translation defines the translation vector3 given as a reference to update
  3054. * @returns true if operation was successful
  3055. */
  3056. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3057. /**
  3058. * Gets specific row of the matrix
  3059. * @param index defines the number of the row to get
  3060. * @returns the index-th row of the current matrix as a new Vector4
  3061. */
  3062. getRow(index: number): Nullable<Vector4>;
  3063. /**
  3064. * Sets the index-th row of the current matrix to the vector4 values
  3065. * @param index defines the number of the row to set
  3066. * @param row defines the target vector4
  3067. * @returns the updated current matrix
  3068. */
  3069. setRow(index: number, row: Vector4): Matrix;
  3070. /**
  3071. * Compute the transpose of the matrix
  3072. * @returns the new transposed matrix
  3073. */
  3074. transpose(): Matrix;
  3075. /**
  3076. * Compute the transpose of the matrix and store it in a given matrix
  3077. * @param result defines the target matrix
  3078. * @returns the current matrix
  3079. */
  3080. transposeToRef(result: Matrix): Matrix;
  3081. /**
  3082. * Sets the index-th row of the current matrix with the given 4 x float values
  3083. * @param index defines the row index
  3084. * @param x defines the x component to set
  3085. * @param y defines the y component to set
  3086. * @param z defines the z component to set
  3087. * @param w defines the w component to set
  3088. * @returns the updated current matrix
  3089. */
  3090. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3091. /**
  3092. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3093. * @param scale defines the scale factor
  3094. * @returns a new matrix
  3095. */
  3096. scale(scale: number): Matrix;
  3097. /**
  3098. * Scale the current matrix values by a factor to a given result matrix
  3099. * @param scale defines the scale factor
  3100. * @param result defines the matrix to store the result
  3101. * @returns the current matrix
  3102. */
  3103. scaleToRef(scale: number, result: Matrix): Matrix;
  3104. /**
  3105. * Scale the current matrix values by a factor and add the result to a given matrix
  3106. * @param scale defines the scale factor
  3107. * @param result defines the Matrix to store the result
  3108. * @returns the current matrix
  3109. */
  3110. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3111. /**
  3112. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3113. * @param ref matrix to store the result
  3114. */
  3115. toNormalMatrix(ref: Matrix): void;
  3116. /**
  3117. * Gets only rotation part of the current matrix
  3118. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3119. */
  3120. getRotationMatrix(): Matrix;
  3121. /**
  3122. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3123. * @param result defines the target matrix to store data to
  3124. * @returns the current matrix
  3125. */
  3126. getRotationMatrixToRef(result: Matrix): Matrix;
  3127. /**
  3128. * Toggles model matrix from being right handed to left handed in place and vice versa
  3129. */
  3130. toggleModelMatrixHandInPlace(): void;
  3131. /**
  3132. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3133. */
  3134. toggleProjectionMatrixHandInPlace(): void;
  3135. /**
  3136. * Creates a matrix from an array
  3137. * @param array defines the source array
  3138. * @param offset defines an offset in the source array
  3139. * @returns a new Matrix set from the starting index of the given array
  3140. */
  3141. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3142. /**
  3143. * Copy the content of an array into a given matrix
  3144. * @param array defines the source array
  3145. * @param offset defines an offset in the source array
  3146. * @param result defines the target matrix
  3147. */
  3148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3149. /**
  3150. * Stores an array into a matrix after having multiplied each component by a given factor
  3151. * @param array defines the source array
  3152. * @param offset defines the offset in the source array
  3153. * @param scale defines the scaling factor
  3154. * @param result defines the target matrix
  3155. */
  3156. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3157. /**
  3158. * Gets an identity matrix that must not be updated
  3159. */
  3160. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3161. /**
  3162. * Stores a list of values (16) inside a given matrix
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @param result defines the target matrix
  3180. */
  3181. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3182. /**
  3183. * Creates new matrix from a list of values (16)
  3184. * @param initialM11 defines 1st value of 1st row
  3185. * @param initialM12 defines 2nd value of 1st row
  3186. * @param initialM13 defines 3rd value of 1st row
  3187. * @param initialM14 defines 4th value of 1st row
  3188. * @param initialM21 defines 1st value of 2nd row
  3189. * @param initialM22 defines 2nd value of 2nd row
  3190. * @param initialM23 defines 3rd value of 2nd row
  3191. * @param initialM24 defines 4th value of 2nd row
  3192. * @param initialM31 defines 1st value of 3rd row
  3193. * @param initialM32 defines 2nd value of 3rd row
  3194. * @param initialM33 defines 3rd value of 3rd row
  3195. * @param initialM34 defines 4th value of 3rd row
  3196. * @param initialM41 defines 1st value of 4th row
  3197. * @param initialM42 defines 2nd value of 4th row
  3198. * @param initialM43 defines 3rd value of 4th row
  3199. * @param initialM44 defines 4th value of 4th row
  3200. * @returns the new matrix
  3201. */
  3202. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3203. /**
  3204. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3205. * @param scale defines the scale vector3
  3206. * @param rotation defines the rotation quaternion
  3207. * @param translation defines the translation vector3
  3208. * @returns a new matrix
  3209. */
  3210. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3211. /**
  3212. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3213. * @param scale defines the scale vector3
  3214. * @param rotation defines the rotation quaternion
  3215. * @param translation defines the translation vector3
  3216. * @param result defines the target matrix
  3217. */
  3218. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3219. /**
  3220. * Creates a new identity matrix
  3221. * @returns a new identity matrix
  3222. */
  3223. static Identity(): Matrix;
  3224. /**
  3225. * Creates a new identity matrix and stores the result in a given matrix
  3226. * @param result defines the target matrix
  3227. */
  3228. static IdentityToRef(result: Matrix): void;
  3229. /**
  3230. * Creates a new zero matrix
  3231. * @returns a new zero matrix
  3232. */
  3233. static Zero(): Matrix;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the X axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationX(angle: number): Matrix;
  3240. /**
  3241. * Creates a new matrix as the invert of a given matrix
  3242. * @param source defines the source matrix
  3243. * @returns the new matrix
  3244. */
  3245. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3248. * @param angle defines the angle (in radians) to use
  3249. * @param result defines the target matrix
  3250. */
  3251. static RotationXToRef(angle: number, result: Matrix): void;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the Y axis
  3254. * @param angle defines the angle (in radians) to use
  3255. * @return the new matrix
  3256. */
  3257. static RotationY(angle: number): Matrix;
  3258. /**
  3259. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3260. * @param angle defines the angle (in radians) to use
  3261. * @param result defines the target matrix
  3262. */
  3263. static RotationYToRef(angle: number, result: Matrix): void;
  3264. /**
  3265. * Creates a new rotation matrix for "angle" radians around the Z axis
  3266. * @param angle defines the angle (in radians) to use
  3267. * @return the new matrix
  3268. */
  3269. static RotationZ(angle: number): Matrix;
  3270. /**
  3271. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3272. * @param angle defines the angle (in radians) to use
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationZToRef(angle: number, result: Matrix): void;
  3276. /**
  3277. * Creates a new rotation matrix for "angle" radians around the given axis
  3278. * @param axis defines the axis to use
  3279. * @param angle defines the angle (in radians) to use
  3280. * @return the new matrix
  3281. */
  3282. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3283. /**
  3284. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3285. * @param axis defines the axis to use
  3286. * @param angle defines the angle (in radians) to use
  3287. * @param result defines the target matrix
  3288. */
  3289. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3290. /**
  3291. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3292. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3293. * @param from defines the vector to align
  3294. * @param to defines the vector to align to
  3295. * @param result defines the target matrix
  3296. */
  3297. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3298. /**
  3299. * Creates a rotation matrix
  3300. * @param yaw defines the yaw angle in radians (Y axis)
  3301. * @param pitch defines the pitch angle in radians (X axis)
  3302. * @param roll defines the roll angle in radians (X axis)
  3303. * @returns the new rotation matrix
  3304. */
  3305. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3306. /**
  3307. * Creates a rotation matrix and stores it in a given matrix
  3308. * @param yaw defines the yaw angle in radians (Y axis)
  3309. * @param pitch defines the pitch angle in radians (X axis)
  3310. * @param roll defines the roll angle in radians (X axis)
  3311. * @param result defines the target matrix
  3312. */
  3313. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3314. /**
  3315. * Creates a scaling matrix
  3316. * @param x defines the scale factor on X axis
  3317. * @param y defines the scale factor on Y axis
  3318. * @param z defines the scale factor on Z axis
  3319. * @returns the new matrix
  3320. */
  3321. static Scaling(x: number, y: number, z: number): Matrix;
  3322. /**
  3323. * Creates a scaling matrix and stores it in a given matrix
  3324. * @param x defines the scale factor on X axis
  3325. * @param y defines the scale factor on Y axis
  3326. * @param z defines the scale factor on Z axis
  3327. * @param result defines the target matrix
  3328. */
  3329. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3330. /**
  3331. * Creates a translation matrix
  3332. * @param x defines the translation on X axis
  3333. * @param y defines the translation on Y axis
  3334. * @param z defines the translationon Z axis
  3335. * @returns the new matrix
  3336. */
  3337. static Translation(x: number, y: number, z: number): Matrix;
  3338. /**
  3339. * Creates a translation matrix and stores it in a given matrix
  3340. * @param x defines the translation on X axis
  3341. * @param y defines the translation on Y axis
  3342. * @param z defines the translationon Z axis
  3343. * @param result defines the target matrix
  3344. */
  3345. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3346. /**
  3347. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3348. * @param startValue defines the start value
  3349. * @param endValue defines the end value
  3350. * @param gradient defines the gradient factor
  3351. * @returns the new matrix
  3352. */
  3353. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3354. /**
  3355. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3356. * @param startValue defines the start value
  3357. * @param endValue defines the end value
  3358. * @param gradient defines the gradient factor
  3359. * @param result defines the Matrix object where to store data
  3360. */
  3361. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3362. /**
  3363. * Builds a new matrix whose values are computed by:
  3364. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3365. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3366. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3367. * @param startValue defines the first matrix
  3368. * @param endValue defines the second matrix
  3369. * @param gradient defines the gradient between the two matrices
  3370. * @returns the new matrix
  3371. */
  3372. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3373. /**
  3374. * Update a matrix to values which are computed by:
  3375. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3376. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3377. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3378. * @param startValue defines the first matrix
  3379. * @param endValue defines the second matrix
  3380. * @param gradient defines the gradient between the two matrices
  3381. * @param result defines the target matrix
  3382. */
  3383. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3384. /**
  3385. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3386. * This function works in left handed mode
  3387. * @param eye defines the final position of the entity
  3388. * @param target defines where the entity should look at
  3389. * @param up defines the up vector for the entity
  3390. * @returns the new matrix
  3391. */
  3392. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3393. /**
  3394. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3395. * This function works in left handed mode
  3396. * @param eye defines the final position of the entity
  3397. * @param target defines where the entity should look at
  3398. * @param up defines the up vector for the entity
  3399. * @param result defines the target matrix
  3400. */
  3401. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3402. /**
  3403. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3404. * This function works in right handed mode
  3405. * @param eye defines the final position of the entity
  3406. * @param target defines where the entity should look at
  3407. * @param up defines the up vector for the entity
  3408. * @returns the new matrix
  3409. */
  3410. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3411. /**
  3412. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3413. * This function works in right handed mode
  3414. * @param eye defines the final position of the entity
  3415. * @param target defines where the entity should look at
  3416. * @param up defines the up vector for the entity
  3417. * @param result defines the target matrix
  3418. */
  3419. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3420. /**
  3421. * Create a left-handed orthographic projection matrix
  3422. * @param width defines the viewport width
  3423. * @param height defines the viewport height
  3424. * @param znear defines the near clip plane
  3425. * @param zfar defines the far clip plane
  3426. * @returns a new matrix as a left-handed orthographic projection matrix
  3427. */
  3428. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3429. /**
  3430. * Store a left-handed orthographic projection to a given matrix
  3431. * @param width defines the viewport width
  3432. * @param height defines the viewport height
  3433. * @param znear defines the near clip plane
  3434. * @param zfar defines the far clip plane
  3435. * @param result defines the target matrix
  3436. */
  3437. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3438. /**
  3439. * Create a left-handed orthographic projection matrix
  3440. * @param left defines the viewport left coordinate
  3441. * @param right defines the viewport right coordinate
  3442. * @param bottom defines the viewport bottom coordinate
  3443. * @param top defines the viewport top coordinate
  3444. * @param znear defines the near clip plane
  3445. * @param zfar defines the far clip plane
  3446. * @returns a new matrix as a left-handed orthographic projection matrix
  3447. */
  3448. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3449. /**
  3450. * Stores a left-handed orthographic projection into a given matrix
  3451. * @param left defines the viewport left coordinate
  3452. * @param right defines the viewport right coordinate
  3453. * @param bottom defines the viewport bottom coordinate
  3454. * @param top defines the viewport top coordinate
  3455. * @param znear defines the near clip plane
  3456. * @param zfar defines the far clip plane
  3457. * @param result defines the target matrix
  3458. */
  3459. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3460. /**
  3461. * Creates a right-handed orthographic projection matrix
  3462. * @param left defines the viewport left coordinate
  3463. * @param right defines the viewport right coordinate
  3464. * @param bottom defines the viewport bottom coordinate
  3465. * @param top defines the viewport top coordinate
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @returns a new matrix as a right-handed orthographic projection matrix
  3469. */
  3470. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3471. /**
  3472. * Stores a right-handed orthographic projection into a given matrix
  3473. * @param left defines the viewport left coordinate
  3474. * @param right defines the viewport right coordinate
  3475. * @param bottom defines the viewport bottom coordinate
  3476. * @param top defines the viewport top coordinate
  3477. * @param znear defines the near clip plane
  3478. * @param zfar defines the far clip plane
  3479. * @param result defines the target matrix
  3480. */
  3481. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3482. /**
  3483. * Creates a left-handed perspective projection matrix
  3484. * @param width defines the viewport width
  3485. * @param height defines the viewport height
  3486. * @param znear defines the near clip plane
  3487. * @param zfar defines the far clip plane
  3488. * @returns a new matrix as a left-handed perspective projection matrix
  3489. */
  3490. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3491. /**
  3492. * Creates a left-handed perspective projection matrix
  3493. * @param fov defines the horizontal field of view
  3494. * @param aspect defines the aspect ratio
  3495. * @param znear defines the near clip plane
  3496. * @param zfar defines the far clip plane
  3497. * @returns a new matrix as a left-handed perspective projection matrix
  3498. */
  3499. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3500. /**
  3501. * Stores a left-handed perspective projection into a given matrix
  3502. * @param fov defines the horizontal field of view
  3503. * @param aspect defines the aspect ratio
  3504. * @param znear defines the near clip plane
  3505. * @param zfar defines the far clip plane
  3506. * @param result defines the target matrix
  3507. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3508. */
  3509. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3510. /**
  3511. * Creates a right-handed perspective projection matrix
  3512. * @param fov defines the horizontal field of view
  3513. * @param aspect defines the aspect ratio
  3514. * @param znear defines the near clip plane
  3515. * @param zfar defines the far clip plane
  3516. * @returns a new matrix as a right-handed perspective projection matrix
  3517. */
  3518. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3519. /**
  3520. * Stores a right-handed perspective projection into a given matrix
  3521. * @param fov defines the horizontal field of view
  3522. * @param aspect defines the aspect ratio
  3523. * @param znear defines the near clip plane
  3524. * @param zfar defines the far clip plane
  3525. * @param result defines the target matrix
  3526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3527. */
  3528. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3529. /**
  3530. * Stores a perspective projection for WebVR info a given matrix
  3531. * @param fov defines the field of view
  3532. * @param znear defines the near clip plane
  3533. * @param zfar defines the far clip plane
  3534. * @param result defines the target matrix
  3535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3536. */
  3537. static PerspectiveFovWebVRToRef(fov: {
  3538. upDegrees: number;
  3539. downDegrees: number;
  3540. leftDegrees: number;
  3541. rightDegrees: number;
  3542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3543. /**
  3544. * Computes a complete transformation matrix
  3545. * @param viewport defines the viewport to use
  3546. * @param world defines the world matrix
  3547. * @param view defines the view matrix
  3548. * @param projection defines the projection matrix
  3549. * @param zmin defines the near clip plane
  3550. * @param zmax defines the far clip plane
  3551. * @returns the transformation matrix
  3552. */
  3553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3554. /**
  3555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3556. * @param matrix defines the matrix to use
  3557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3558. */
  3559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3560. /**
  3561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3562. * @param matrix defines the matrix to use
  3563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3564. */
  3565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3566. /**
  3567. * Compute the transpose of a given matrix
  3568. * @param matrix defines the matrix to transpose
  3569. * @returns the new matrix
  3570. */
  3571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3572. /**
  3573. * Compute the transpose of a matrix and store it in a target matrix
  3574. * @param matrix defines the matrix to transpose
  3575. * @param result defines the target matrix
  3576. */
  3577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3578. /**
  3579. * Computes a reflection matrix from a plane
  3580. * @param plane defines the reflection plane
  3581. * @returns a new matrix
  3582. */
  3583. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3584. /**
  3585. * Computes a reflection matrix from a plane
  3586. * @param plane defines the reflection plane
  3587. * @param result defines the target matrix
  3588. */
  3589. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3590. /**
  3591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3592. * @param xaxis defines the value of the 1st axis
  3593. * @param yaxis defines the value of the 2nd axis
  3594. * @param zaxis defines the value of the 3rd axis
  3595. * @param result defines the target matrix
  3596. */
  3597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3598. /**
  3599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3600. * @param quat defines the quaternion to use
  3601. * @param result defines the target matrix
  3602. */
  3603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3604. }
  3605. /**
  3606. * Represens a plane by the equation ax + by + cz + d = 0
  3607. */
  3608. export class Plane {
  3609. /**
  3610. * Normal of the plane (a,b,c)
  3611. */
  3612. normal: Vector3;
  3613. /**
  3614. * d component of the plane
  3615. */
  3616. d: number;
  3617. /**
  3618. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3619. * @param a a component of the plane
  3620. * @param b b component of the plane
  3621. * @param c c component of the plane
  3622. * @param d d component of the plane
  3623. */
  3624. constructor(a: number, b: number, c: number, d: number);
  3625. /**
  3626. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3627. */
  3628. asArray(): number[];
  3629. /**
  3630. * @returns a new plane copied from the current Plane.
  3631. */
  3632. clone(): Plane;
  3633. /**
  3634. * @returns the string "Plane".
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * @returns the Plane hash code.
  3639. */
  3640. getHashCode(): number;
  3641. /**
  3642. * Normalize the current Plane in place.
  3643. * @returns the updated Plane.
  3644. */
  3645. normalize(): Plane;
  3646. /**
  3647. * Applies a transformation the plane and returns the result
  3648. * @param transformation the transformation matrix to be applied to the plane
  3649. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3650. */
  3651. transform(transformation: DeepImmutable<Matrix>): Plane;
  3652. /**
  3653. * Calcualtte the dot product between the point and the plane normal
  3654. * @param point point to calculate the dot product with
  3655. * @returns the dot product (float) of the point coordinates and the plane normal.
  3656. */
  3657. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Updates the current Plane from the plane defined by the three given points.
  3660. * @param point1 one of the points used to contruct the plane
  3661. * @param point2 one of the points used to contruct the plane
  3662. * @param point3 one of the points used to contruct the plane
  3663. * @returns the updated Plane.
  3664. */
  3665. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3666. /**
  3667. * Checks if the plane is facing a given direction
  3668. * @param direction the direction to check if the plane is facing
  3669. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3670. * @returns True is the vector "direction" is the same side than the plane normal.
  3671. */
  3672. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3673. /**
  3674. * Calculates the distance to a point
  3675. * @param point point to calculate distance to
  3676. * @returns the signed distance (float) from the given point to the Plane.
  3677. */
  3678. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3679. /**
  3680. * Creates a plane from an array
  3681. * @param array the array to create a plane from
  3682. * @returns a new Plane from the given array.
  3683. */
  3684. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3685. /**
  3686. * Creates a plane from three points
  3687. * @param point1 point used to create the plane
  3688. * @param point2 point used to create the plane
  3689. * @param point3 point used to create the plane
  3690. * @returns a new Plane defined by the three given points.
  3691. */
  3692. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3693. /**
  3694. * Creates a plane from an origin point and a normal
  3695. * @param origin origin of the plane to be constructed
  3696. * @param normal normal of the plane to be constructed
  3697. * @returns a new Plane the normal vector to this plane at the given origin point.
  3698. * Note : the vector "normal" is updated because normalized.
  3699. */
  3700. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3701. /**
  3702. * Calculates the distance from a plane and a point
  3703. * @param origin origin of the plane to be constructed
  3704. * @param normal normal of the plane to be constructed
  3705. * @param point point to calculate distance to
  3706. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3707. */
  3708. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3709. }
  3710. /**
  3711. * Class used to represent a viewport on screen
  3712. */
  3713. export class Viewport {
  3714. /** viewport left coordinate */
  3715. x: number;
  3716. /** viewport top coordinate */
  3717. y: number;
  3718. /**viewport width */
  3719. width: number;
  3720. /** viewport height */
  3721. height: number;
  3722. /**
  3723. * Creates a Viewport object located at (x, y) and sized (width, height)
  3724. * @param x defines viewport left coordinate
  3725. * @param y defines viewport top coordinate
  3726. * @param width defines the viewport width
  3727. * @param height defines the viewport height
  3728. */
  3729. constructor(
  3730. /** viewport left coordinate */
  3731. x: number,
  3732. /** viewport top coordinate */
  3733. y: number,
  3734. /**viewport width */
  3735. width: number,
  3736. /** viewport height */
  3737. height: number);
  3738. /**
  3739. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3740. * @param renderWidth defines the rendering width
  3741. * @param renderHeight defines the rendering height
  3742. * @returns a new Viewport
  3743. */
  3744. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3745. /**
  3746. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3747. * @param renderWidth defines the rendering width
  3748. * @param renderHeight defines the rendering height
  3749. * @param ref defines the target viewport
  3750. * @returns the current viewport
  3751. */
  3752. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3753. /**
  3754. * Returns a new Viewport copied from the current one
  3755. * @returns a new Viewport
  3756. */
  3757. clone(): Viewport;
  3758. }
  3759. /**
  3760. * Reprasents a camera frustum
  3761. */
  3762. export class Frustum {
  3763. /**
  3764. * Gets the planes representing the frustum
  3765. * @param transform matrix to be applied to the returned planes
  3766. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3767. */
  3768. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3769. /**
  3770. * Gets the near frustum plane transformed by the transform matrix
  3771. * @param transform transformation matrix to be applied to the resulting frustum plane
  3772. * @param frustumPlane the resuling frustum plane
  3773. */
  3774. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3775. /**
  3776. * Gets the far frustum plane transformed by the transform matrix
  3777. * @param transform transformation matrix to be applied to the resulting frustum plane
  3778. * @param frustumPlane the resuling frustum plane
  3779. */
  3780. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3781. /**
  3782. * Gets the left frustum plane transformed by the transform matrix
  3783. * @param transform transformation matrix to be applied to the resulting frustum plane
  3784. * @param frustumPlane the resuling frustum plane
  3785. */
  3786. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3787. /**
  3788. * Gets the right frustum plane transformed by the transform matrix
  3789. * @param transform transformation matrix to be applied to the resulting frustum plane
  3790. * @param frustumPlane the resuling frustum plane
  3791. */
  3792. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3793. /**
  3794. * Gets the top frustum plane transformed by the transform matrix
  3795. * @param transform transformation matrix to be applied to the resulting frustum plane
  3796. * @param frustumPlane the resuling frustum plane
  3797. */
  3798. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3799. /**
  3800. * Gets the bottom frustum plane transformed by the transform matrix
  3801. * @param transform transformation matrix to be applied to the resulting frustum plane
  3802. * @param frustumPlane the resuling frustum plane
  3803. */
  3804. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3805. /**
  3806. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3807. * @param transform transformation matrix to be applied to the resulting frustum planes
  3808. * @param frustumPlanes the resuling frustum planes
  3809. */
  3810. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3811. }
  3812. /** Defines supported spaces */
  3813. export enum Space {
  3814. /** Local (object) space */
  3815. LOCAL = 0,
  3816. /** World space */
  3817. WORLD = 1,
  3818. /** Bone space */
  3819. BONE = 2
  3820. }
  3821. /** Defines the 3 main axes */
  3822. export class Axis {
  3823. /** X axis */
  3824. static X: Vector3;
  3825. /** Y axis */
  3826. static Y: Vector3;
  3827. /** Z axis */
  3828. static Z: Vector3;
  3829. }
  3830. /** Class used to represent a Bezier curve */
  3831. export class BezierCurve {
  3832. /**
  3833. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3834. * @param t defines the time
  3835. * @param x1 defines the left coordinate on X axis
  3836. * @param y1 defines the left coordinate on Y axis
  3837. * @param x2 defines the right coordinate on X axis
  3838. * @param y2 defines the right coordinate on Y axis
  3839. * @returns the interpolated value
  3840. */
  3841. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3842. }
  3843. /**
  3844. * Defines potential orientation for back face culling
  3845. */
  3846. export enum Orientation {
  3847. /**
  3848. * Clockwise
  3849. */
  3850. CW = 0,
  3851. /** Counter clockwise */
  3852. CCW = 1
  3853. }
  3854. /**
  3855. * Defines angle representation
  3856. */
  3857. export class Angle {
  3858. private _radians;
  3859. /**
  3860. * Creates an Angle object of "radians" radians (float).
  3861. * @param radians the angle in radians
  3862. */
  3863. constructor(radians: number);
  3864. /**
  3865. * Get value in degrees
  3866. * @returns the Angle value in degrees (float)
  3867. */
  3868. degrees(): number;
  3869. /**
  3870. * Get value in radians
  3871. * @returns the Angle value in radians (float)
  3872. */
  3873. radians(): number;
  3874. /**
  3875. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3876. * @param a defines first vector
  3877. * @param b defines second vector
  3878. * @returns a new Angle
  3879. */
  3880. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3881. /**
  3882. * Gets a new Angle object from the given float in radians
  3883. * @param radians defines the angle value in radians
  3884. * @returns a new Angle
  3885. */
  3886. static FromRadians(radians: number): Angle;
  3887. /**
  3888. * Gets a new Angle object from the given float in degrees
  3889. * @param degrees defines the angle value in degrees
  3890. * @returns a new Angle
  3891. */
  3892. static FromDegrees(degrees: number): Angle;
  3893. }
  3894. /**
  3895. * This represents an arc in a 2d space.
  3896. */
  3897. export class Arc2 {
  3898. /** Defines the start point of the arc */
  3899. startPoint: Vector2;
  3900. /** Defines the mid point of the arc */
  3901. midPoint: Vector2;
  3902. /** Defines the end point of the arc */
  3903. endPoint: Vector2;
  3904. /**
  3905. * Defines the center point of the arc.
  3906. */
  3907. centerPoint: Vector2;
  3908. /**
  3909. * Defines the radius of the arc.
  3910. */
  3911. radius: number;
  3912. /**
  3913. * Defines the angle of the arc (from mid point to end point).
  3914. */
  3915. angle: Angle;
  3916. /**
  3917. * Defines the start angle of the arc (from start point to middle point).
  3918. */
  3919. startAngle: Angle;
  3920. /**
  3921. * Defines the orientation of the arc (clock wise/counter clock wise).
  3922. */
  3923. orientation: Orientation;
  3924. /**
  3925. * Creates an Arc object from the three given points : start, middle and end.
  3926. * @param startPoint Defines the start point of the arc
  3927. * @param midPoint Defines the midlle point of the arc
  3928. * @param endPoint Defines the end point of the arc
  3929. */
  3930. constructor(
  3931. /** Defines the start point of the arc */
  3932. startPoint: Vector2,
  3933. /** Defines the mid point of the arc */
  3934. midPoint: Vector2,
  3935. /** Defines the end point of the arc */
  3936. endPoint: Vector2);
  3937. }
  3938. /**
  3939. * Represents a 2D path made up of multiple 2D points
  3940. */
  3941. export class Path2 {
  3942. private _points;
  3943. private _length;
  3944. /**
  3945. * If the path start and end point are the same
  3946. */
  3947. closed: boolean;
  3948. /**
  3949. * Creates a Path2 object from the starting 2D coordinates x and y.
  3950. * @param x the starting points x value
  3951. * @param y the starting points y value
  3952. */
  3953. constructor(x: number, y: number);
  3954. /**
  3955. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3956. * @param x the added points x value
  3957. * @param y the added points y value
  3958. * @returns the updated Path2.
  3959. */
  3960. addLineTo(x: number, y: number): Path2;
  3961. /**
  3962. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3963. * @param midX middle point x value
  3964. * @param midY middle point y value
  3965. * @param endX end point x value
  3966. * @param endY end point y value
  3967. * @param numberOfSegments (default: 36)
  3968. * @returns the updated Path2.
  3969. */
  3970. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3971. /**
  3972. * Closes the Path2.
  3973. * @returns the Path2.
  3974. */
  3975. close(): Path2;
  3976. /**
  3977. * Gets the sum of the distance between each sequential point in the path
  3978. * @returns the Path2 total length (float).
  3979. */
  3980. length(): number;
  3981. /**
  3982. * Gets the points which construct the path
  3983. * @returns the Path2 internal array of points.
  3984. */
  3985. getPoints(): Vector2[];
  3986. /**
  3987. * Retreives the point at the distance aways from the starting point
  3988. * @param normalizedLengthPosition the length along the path to retreive the point from
  3989. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3990. */
  3991. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3992. /**
  3993. * Creates a new path starting from an x and y position
  3994. * @param x starting x value
  3995. * @param y starting y value
  3996. * @returns a new Path2 starting at the coordinates (x, y).
  3997. */
  3998. static StartingAt(x: number, y: number): Path2;
  3999. }
  4000. /**
  4001. * Represents a 3D path made up of multiple 3D points
  4002. */
  4003. export class Path3D {
  4004. /**
  4005. * an array of Vector3, the curve axis of the Path3D
  4006. */
  4007. path: Vector3[];
  4008. private _curve;
  4009. private _distances;
  4010. private _tangents;
  4011. private _normals;
  4012. private _binormals;
  4013. private _raw;
  4014. /**
  4015. * new Path3D(path, normal, raw)
  4016. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4017. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4018. * @param path an array of Vector3, the curve axis of the Path3D
  4019. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4020. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4021. */
  4022. constructor(
  4023. /**
  4024. * an array of Vector3, the curve axis of the Path3D
  4025. */
  4026. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4027. /**
  4028. * Returns the Path3D array of successive Vector3 designing its curve.
  4029. * @returns the Path3D array of successive Vector3 designing its curve.
  4030. */
  4031. getCurve(): Vector3[];
  4032. /**
  4033. * Returns an array populated with tangent vectors on each Path3D curve point.
  4034. * @returns an array populated with tangent vectors on each Path3D curve point.
  4035. */
  4036. getTangents(): Vector3[];
  4037. /**
  4038. * Returns an array populated with normal vectors on each Path3D curve point.
  4039. * @returns an array populated with normal vectors on each Path3D curve point.
  4040. */
  4041. getNormals(): Vector3[];
  4042. /**
  4043. * Returns an array populated with binormal vectors on each Path3D curve point.
  4044. * @returns an array populated with binormal vectors on each Path3D curve point.
  4045. */
  4046. getBinormals(): Vector3[];
  4047. /**
  4048. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4049. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4050. */
  4051. getDistances(): number[];
  4052. /**
  4053. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4054. * @param path path which all values are copied into the curves points
  4055. * @param firstNormal which should be projected onto the curve
  4056. * @returns the same object updated.
  4057. */
  4058. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4059. private _compute;
  4060. private _getFirstNonNullVector;
  4061. private _getLastNonNullVector;
  4062. private _normalVector;
  4063. }
  4064. /**
  4065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4066. * A Curve3 is designed from a series of successive Vector3.
  4067. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4068. */
  4069. export class Curve3 {
  4070. private _points;
  4071. private _length;
  4072. /**
  4073. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4074. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4075. * @param v1 (Vector3) the control point
  4076. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4077. * @param nbPoints (integer) the wanted number of points in the curve
  4078. * @returns the created Curve3
  4079. */
  4080. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4081. /**
  4082. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4083. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4084. * @param v1 (Vector3) the first control point
  4085. * @param v2 (Vector3) the second control point
  4086. * @param v3 (Vector3) the end point of the Cubic Bezier
  4087. * @param nbPoints (integer) the wanted number of points in the curve
  4088. * @returns the created Curve3
  4089. */
  4090. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4091. /**
  4092. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4093. * @param p1 (Vector3) the origin point of the Hermite Spline
  4094. * @param t1 (Vector3) the tangent vector at the origin point
  4095. * @param p2 (Vector3) the end point of the Hermite Spline
  4096. * @param t2 (Vector3) the tangent vector at the end point
  4097. * @param nbPoints (integer) the wanted number of points in the curve
  4098. * @returns the created Curve3
  4099. */
  4100. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4101. /**
  4102. * Returns a Curve3 object along a CatmullRom Spline curve :
  4103. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4104. * @param nbPoints (integer) the wanted number of points between each curve control points
  4105. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4106. * @returns the created Curve3
  4107. */
  4108. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4109. /**
  4110. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4111. * A Curve3 is designed from a series of successive Vector3.
  4112. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4113. * @param points points which make up the curve
  4114. */
  4115. constructor(points: Vector3[]);
  4116. /**
  4117. * @returns the Curve3 stored array of successive Vector3
  4118. */
  4119. getPoints(): Vector3[];
  4120. /**
  4121. * @returns the computed length (float) of the curve.
  4122. */
  4123. length(): number;
  4124. /**
  4125. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4126. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4127. * curveA and curveB keep unchanged.
  4128. * @param curve the curve to continue from this curve
  4129. * @returns the newly constructed curve
  4130. */
  4131. continue(curve: DeepImmutable<Curve3>): Curve3;
  4132. private _computeLength;
  4133. }
  4134. /**
  4135. * Contains position and normal vectors for a vertex
  4136. */
  4137. export class PositionNormalVertex {
  4138. /** the position of the vertex (defaut: 0,0,0) */
  4139. position: Vector3;
  4140. /** the normal of the vertex (defaut: 0,1,0) */
  4141. normal: Vector3;
  4142. /**
  4143. * Creates a PositionNormalVertex
  4144. * @param position the position of the vertex (defaut: 0,0,0)
  4145. * @param normal the normal of the vertex (defaut: 0,1,0)
  4146. */
  4147. constructor(
  4148. /** the position of the vertex (defaut: 0,0,0) */
  4149. position?: Vector3,
  4150. /** the normal of the vertex (defaut: 0,1,0) */
  4151. normal?: Vector3);
  4152. /**
  4153. * Clones the PositionNormalVertex
  4154. * @returns the cloned PositionNormalVertex
  4155. */
  4156. clone(): PositionNormalVertex;
  4157. }
  4158. /**
  4159. * Contains position, normal and uv vectors for a vertex
  4160. */
  4161. export class PositionNormalTextureVertex {
  4162. /** the position of the vertex (defaut: 0,0,0) */
  4163. position: Vector3;
  4164. /** the normal of the vertex (defaut: 0,1,0) */
  4165. normal: Vector3;
  4166. /** the uv of the vertex (default: 0,0) */
  4167. uv: Vector2;
  4168. /**
  4169. * Creates a PositionNormalTextureVertex
  4170. * @param position the position of the vertex (defaut: 0,0,0)
  4171. * @param normal the normal of the vertex (defaut: 0,1,0)
  4172. * @param uv the uv of the vertex (default: 0,0)
  4173. */
  4174. constructor(
  4175. /** the position of the vertex (defaut: 0,0,0) */
  4176. position?: Vector3,
  4177. /** the normal of the vertex (defaut: 0,1,0) */
  4178. normal?: Vector3,
  4179. /** the uv of the vertex (default: 0,0) */
  4180. uv?: Vector2);
  4181. /**
  4182. * Clones the PositionNormalTextureVertex
  4183. * @returns the cloned PositionNormalTextureVertex
  4184. */
  4185. clone(): PositionNormalTextureVertex;
  4186. }
  4187. /**
  4188. * @hidden
  4189. */
  4190. export class Tmp {
  4191. static Color3: Color3[];
  4192. static Color4: Color4[];
  4193. static Vector2: Vector2[];
  4194. static Vector3: Vector3[];
  4195. static Vector4: Vector4[];
  4196. static Quaternion: Quaternion[];
  4197. static Matrix: Matrix[];
  4198. }
  4199. }
  4200. declare module BABYLON {
  4201. /**
  4202. * Class used to enable access to offline support
  4203. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4204. */
  4205. export interface IOfflineProvider {
  4206. /**
  4207. * Gets a boolean indicating if scene must be saved in the database
  4208. */
  4209. enableSceneOffline: boolean;
  4210. /**
  4211. * Gets a boolean indicating if textures must be saved in the database
  4212. */
  4213. enableTexturesOffline: boolean;
  4214. /**
  4215. * Open the offline support and make it available
  4216. * @param successCallback defines the callback to call on success
  4217. * @param errorCallback defines the callback to call on error
  4218. */
  4219. open(successCallback: () => void, errorCallback: () => void): void;
  4220. /**
  4221. * Loads an image from the offline support
  4222. * @param url defines the url to load from
  4223. * @param image defines the target DOM image
  4224. */
  4225. loadImage(url: string, image: HTMLImageElement): void;
  4226. /**
  4227. * Loads a file from offline support
  4228. * @param url defines the URL to load from
  4229. * @param sceneLoaded defines a callback to call on success
  4230. * @param progressCallBack defines a callback to call when progress changed
  4231. * @param errorCallback defines a callback to call on error
  4232. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4233. */
  4234. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4235. }
  4236. }
  4237. declare module BABYLON {
  4238. /**
  4239. * A class serves as a medium between the observable and its observers
  4240. */
  4241. export class EventState {
  4242. /**
  4243. * Create a new EventState
  4244. * @param mask defines the mask associated with this state
  4245. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4246. * @param target defines the original target of the state
  4247. * @param currentTarget defines the current target of the state
  4248. */
  4249. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4250. /**
  4251. * Initialize the current event state
  4252. * @param mask defines the mask associated with this state
  4253. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4254. * @param target defines the original target of the state
  4255. * @param currentTarget defines the current target of the state
  4256. * @returns the current event state
  4257. */
  4258. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4259. /**
  4260. * An Observer can set this property to true to prevent subsequent observers of being notified
  4261. */
  4262. skipNextObservers: boolean;
  4263. /**
  4264. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4265. */
  4266. mask: number;
  4267. /**
  4268. * The object that originally notified the event
  4269. */
  4270. target?: any;
  4271. /**
  4272. * The current object in the bubbling phase
  4273. */
  4274. currentTarget?: any;
  4275. /**
  4276. * This will be populated with the return value of the last function that was executed.
  4277. * If it is the first function in the callback chain it will be the event data.
  4278. */
  4279. lastReturnValue?: any;
  4280. }
  4281. /**
  4282. * Represent an Observer registered to a given Observable object.
  4283. */
  4284. export class Observer<T> {
  4285. /**
  4286. * Defines the callback to call when the observer is notified
  4287. */
  4288. callback: (eventData: T, eventState: EventState) => void;
  4289. /**
  4290. * Defines the mask of the observer (used to filter notifications)
  4291. */
  4292. mask: number;
  4293. /**
  4294. * Defines the current scope used to restore the JS context
  4295. */
  4296. scope: any;
  4297. /** @hidden */
  4298. _willBeUnregistered: boolean;
  4299. /**
  4300. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4301. */
  4302. unregisterOnNextCall: boolean;
  4303. /**
  4304. * Creates a new observer
  4305. * @param callback defines the callback to call when the observer is notified
  4306. * @param mask defines the mask of the observer (used to filter notifications)
  4307. * @param scope defines the current scope used to restore the JS context
  4308. */
  4309. constructor(
  4310. /**
  4311. * Defines the callback to call when the observer is notified
  4312. */
  4313. callback: (eventData: T, eventState: EventState) => void,
  4314. /**
  4315. * Defines the mask of the observer (used to filter notifications)
  4316. */
  4317. mask: number,
  4318. /**
  4319. * Defines the current scope used to restore the JS context
  4320. */
  4321. scope?: any);
  4322. }
  4323. /**
  4324. * Represent a list of observers registered to multiple Observables object.
  4325. */
  4326. export class MultiObserver<T> {
  4327. private _observers;
  4328. private _observables;
  4329. /**
  4330. * Release associated resources
  4331. */
  4332. dispose(): void;
  4333. /**
  4334. * Raise a callback when one of the observable will notify
  4335. * @param observables defines a list of observables to watch
  4336. * @param callback defines the callback to call on notification
  4337. * @param mask defines the mask used to filter notifications
  4338. * @param scope defines the current scope used to restore the JS context
  4339. * @returns the new MultiObserver
  4340. */
  4341. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4342. }
  4343. /**
  4344. * The Observable class is a simple implementation of the Observable pattern.
  4345. *
  4346. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4347. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4348. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4349. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4350. */
  4351. export class Observable<T> {
  4352. private _observers;
  4353. private _eventState;
  4354. private _onObserverAdded;
  4355. /**
  4356. * Gets the list of observers
  4357. */
  4358. readonly observers: Array<Observer<T>>;
  4359. /**
  4360. * Creates a new observable
  4361. * @param onObserverAdded defines a callback to call when a new observer is added
  4362. */
  4363. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4364. /**
  4365. * Create a new Observer with the specified callback
  4366. * @param callback the callback that will be executed for that Observer
  4367. * @param mask the mask used to filter observers
  4368. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4369. * @param scope optional scope for the callback to be called from
  4370. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4371. * @returns the new observer created for the callback
  4372. */
  4373. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4374. /**
  4375. * Create a new Observer with the specified callback and unregisters after the next notification
  4376. * @param callback the callback that will be executed for that Observer
  4377. * @returns the new observer created for the callback
  4378. */
  4379. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4380. /**
  4381. * Remove an Observer from the Observable object
  4382. * @param observer the instance of the Observer to remove
  4383. * @returns false if it doesn't belong to this Observable
  4384. */
  4385. remove(observer: Nullable<Observer<T>>): boolean;
  4386. /**
  4387. * Remove a callback from the Observable object
  4388. * @param callback the callback to remove
  4389. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4390. * @returns false if it doesn't belong to this Observable
  4391. */
  4392. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4393. private _deferUnregister;
  4394. private _remove;
  4395. /**
  4396. * Moves the observable to the top of the observer list making it get called first when notified
  4397. * @param observer the observer to move
  4398. */
  4399. makeObserverTopPriority(observer: Observer<T>): void;
  4400. /**
  4401. * Moves the observable to the bottom of the observer list making it get called last when notified
  4402. * @param observer the observer to move
  4403. */
  4404. makeObserverBottomPriority(observer: Observer<T>): void;
  4405. /**
  4406. * Notify all Observers by calling their respective callback with the given data
  4407. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4408. * @param eventData defines the data to send to all observers
  4409. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4410. * @param target defines the original target of the state
  4411. * @param currentTarget defines the current target of the state
  4412. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4413. */
  4414. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4415. /**
  4416. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4417. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4418. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4419. * and it is crucial that all callbacks will be executed.
  4420. * The order of the callbacks is kept, callbacks are not executed parallel.
  4421. *
  4422. * @param eventData The data to be sent to each callback
  4423. * @param mask is used to filter observers defaults to -1
  4424. * @param target defines the callback target (see EventState)
  4425. * @param currentTarget defines he current object in the bubbling phase
  4426. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4427. */
  4428. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4429. /**
  4430. * Notify a specific observer
  4431. * @param observer defines the observer to notify
  4432. * @param eventData defines the data to be sent to each callback
  4433. * @param mask is used to filter observers defaults to -1
  4434. */
  4435. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4436. /**
  4437. * Gets a boolean indicating if the observable has at least one observer
  4438. * @returns true is the Observable has at least one Observer registered
  4439. */
  4440. hasObservers(): boolean;
  4441. /**
  4442. * Clear the list of observers
  4443. */
  4444. clear(): void;
  4445. /**
  4446. * Clone the current observable
  4447. * @returns a new observable
  4448. */
  4449. clone(): Observable<T>;
  4450. /**
  4451. * Does this observable handles observer registered with a given mask
  4452. * @param mask defines the mask to be tested
  4453. * @return whether or not one observer registered with the given mask is handeled
  4454. **/
  4455. hasSpecificMask(mask?: number): boolean;
  4456. }
  4457. }
  4458. declare module BABYLON {
  4459. /**
  4460. * Class used to help managing file picking and drag'n'drop
  4461. * File Storage
  4462. */
  4463. export class FilesInputStore {
  4464. /**
  4465. * List of files ready to be loaded
  4466. */
  4467. static FilesToLoad: {
  4468. [key: string]: File;
  4469. };
  4470. }
  4471. }
  4472. declare module BABYLON {
  4473. /** Defines the cross module used constants to avoid circular dependncies */
  4474. export class Constants {
  4475. /** Defines that alpha blending is disabled */
  4476. static readonly ALPHA_DISABLE: number;
  4477. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4478. static readonly ALPHA_ADD: number;
  4479. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4480. static readonly ALPHA_COMBINE: number;
  4481. /** Defines that alpha blending to DEST - SRC * DEST */
  4482. static readonly ALPHA_SUBTRACT: number;
  4483. /** Defines that alpha blending to SRC * DEST */
  4484. static readonly ALPHA_MULTIPLY: number;
  4485. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4486. static readonly ALPHA_MAXIMIZED: number;
  4487. /** Defines that alpha blending to SRC + DEST */
  4488. static readonly ALPHA_ONEONE: number;
  4489. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4490. static readonly ALPHA_PREMULTIPLIED: number;
  4491. /**
  4492. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4493. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4494. */
  4495. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4496. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4497. static readonly ALPHA_INTERPOLATE: number;
  4498. /**
  4499. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4500. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4501. */
  4502. static readonly ALPHA_SCREENMODE: number;
  4503. /** Defines that the ressource is not delayed*/
  4504. static readonly DELAYLOADSTATE_NONE: number;
  4505. /** Defines that the ressource was successfully delay loaded */
  4506. static readonly DELAYLOADSTATE_LOADED: number;
  4507. /** Defines that the ressource is currently delay loading */
  4508. static readonly DELAYLOADSTATE_LOADING: number;
  4509. /** Defines that the ressource is delayed and has not started loading */
  4510. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4511. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4512. static readonly NEVER: number;
  4513. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4514. static readonly ALWAYS: number;
  4515. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4516. static readonly LESS: number;
  4517. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4518. static readonly EQUAL: number;
  4519. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4520. static readonly LEQUAL: number;
  4521. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4522. static readonly GREATER: number;
  4523. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4524. static readonly GEQUAL: number;
  4525. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4526. static readonly NOTEQUAL: number;
  4527. /** Passed to stencilOperation to specify that stencil value must be kept */
  4528. static readonly KEEP: number;
  4529. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4530. static readonly REPLACE: number;
  4531. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4532. static readonly INCR: number;
  4533. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4534. static readonly DECR: number;
  4535. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4536. static readonly INVERT: number;
  4537. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4538. static readonly INCR_WRAP: number;
  4539. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4540. static readonly DECR_WRAP: number;
  4541. /** Texture is not repeating outside of 0..1 UVs */
  4542. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4543. /** Texture is repeating outside of 0..1 UVs */
  4544. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4545. /** Texture is repeating and mirrored */
  4546. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4547. /** ALPHA */
  4548. static readonly TEXTUREFORMAT_ALPHA: number;
  4549. /** LUMINANCE */
  4550. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4551. /** LUMINANCE_ALPHA */
  4552. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4553. /** RGB */
  4554. static readonly TEXTUREFORMAT_RGB: number;
  4555. /** RGBA */
  4556. static readonly TEXTUREFORMAT_RGBA: number;
  4557. /** RED */
  4558. static readonly TEXTUREFORMAT_RED: number;
  4559. /** RED (2nd reference) */
  4560. static readonly TEXTUREFORMAT_R: number;
  4561. /** RG */
  4562. static readonly TEXTUREFORMAT_RG: number;
  4563. /** RED_INTEGER */
  4564. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4565. /** RED_INTEGER (2nd reference) */
  4566. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4567. /** RG_INTEGER */
  4568. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4569. /** RGB_INTEGER */
  4570. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4571. /** RGBA_INTEGER */
  4572. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4573. /** UNSIGNED_BYTE */
  4574. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4575. /** UNSIGNED_BYTE (2nd reference) */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4577. /** FLOAT */
  4578. static readonly TEXTURETYPE_FLOAT: number;
  4579. /** HALF_FLOAT */
  4580. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4581. /** BYTE */
  4582. static readonly TEXTURETYPE_BYTE: number;
  4583. /** SHORT */
  4584. static readonly TEXTURETYPE_SHORT: number;
  4585. /** UNSIGNED_SHORT */
  4586. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4587. /** INT */
  4588. static readonly TEXTURETYPE_INT: number;
  4589. /** UNSIGNED_INT */
  4590. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4591. /** UNSIGNED_SHORT_4_4_4_4 */
  4592. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4593. /** UNSIGNED_SHORT_5_5_5_1 */
  4594. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4595. /** UNSIGNED_SHORT_5_6_5 */
  4596. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4597. /** UNSIGNED_INT_2_10_10_10_REV */
  4598. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4599. /** UNSIGNED_INT_24_8 */
  4600. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4601. /** UNSIGNED_INT_10F_11F_11F_REV */
  4602. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4603. /** UNSIGNED_INT_5_9_9_9_REV */
  4604. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4605. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4606. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4607. /** nearest is mag = nearest and min = nearest and mip = linear */
  4608. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4609. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4610. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4611. /** Trilinear is mag = linear and min = linear and mip = linear */
  4612. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4613. /** nearest is mag = nearest and min = nearest and mip = linear */
  4614. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4615. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4616. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4617. /** Trilinear is mag = linear and min = linear and mip = linear */
  4618. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4619. /** mag = nearest and min = nearest and mip = nearest */
  4620. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4621. /** mag = nearest and min = linear and mip = nearest */
  4622. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4623. /** mag = nearest and min = linear and mip = linear */
  4624. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4625. /** mag = nearest and min = linear and mip = none */
  4626. static readonly TEXTURE_NEAREST_LINEAR: number;
  4627. /** mag = nearest and min = nearest and mip = none */
  4628. static readonly TEXTURE_NEAREST_NEAREST: number;
  4629. /** mag = linear and min = nearest and mip = nearest */
  4630. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4631. /** mag = linear and min = nearest and mip = linear */
  4632. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4633. /** mag = linear and min = linear and mip = none */
  4634. static readonly TEXTURE_LINEAR_LINEAR: number;
  4635. /** mag = linear and min = nearest and mip = none */
  4636. static readonly TEXTURE_LINEAR_NEAREST: number;
  4637. /** Explicit coordinates mode */
  4638. static readonly TEXTURE_EXPLICIT_MODE: number;
  4639. /** Spherical coordinates mode */
  4640. static readonly TEXTURE_SPHERICAL_MODE: number;
  4641. /** Planar coordinates mode */
  4642. static readonly TEXTURE_PLANAR_MODE: number;
  4643. /** Cubic coordinates mode */
  4644. static readonly TEXTURE_CUBIC_MODE: number;
  4645. /** Projection coordinates mode */
  4646. static readonly TEXTURE_PROJECTION_MODE: number;
  4647. /** Skybox coordinates mode */
  4648. static readonly TEXTURE_SKYBOX_MODE: number;
  4649. /** Inverse Cubic coordinates mode */
  4650. static readonly TEXTURE_INVCUBIC_MODE: number;
  4651. /** Equirectangular coordinates mode */
  4652. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4653. /** Equirectangular Fixed coordinates mode */
  4654. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4655. /** Equirectangular Fixed Mirrored coordinates mode */
  4656. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4657. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4658. static readonly SCALEMODE_FLOOR: number;
  4659. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4660. static readonly SCALEMODE_NEAREST: number;
  4661. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4662. static readonly SCALEMODE_CEILING: number;
  4663. /**
  4664. * The dirty texture flag value
  4665. */
  4666. static readonly MATERIAL_TextureDirtyFlag: number;
  4667. /**
  4668. * The dirty light flag value
  4669. */
  4670. static readonly MATERIAL_LightDirtyFlag: number;
  4671. /**
  4672. * The dirty fresnel flag value
  4673. */
  4674. static readonly MATERIAL_FresnelDirtyFlag: number;
  4675. /**
  4676. * The dirty attribute flag value
  4677. */
  4678. static readonly MATERIAL_AttributesDirtyFlag: number;
  4679. /**
  4680. * The dirty misc flag value
  4681. */
  4682. static readonly MATERIAL_MiscDirtyFlag: number;
  4683. /**
  4684. * The all dirty flag value
  4685. */
  4686. static readonly MATERIAL_AllDirtyFlag: number;
  4687. /**
  4688. * Returns the triangle fill mode
  4689. */
  4690. static readonly MATERIAL_TriangleFillMode: number;
  4691. /**
  4692. * Returns the wireframe mode
  4693. */
  4694. static readonly MATERIAL_WireFrameFillMode: number;
  4695. /**
  4696. * Returns the point fill mode
  4697. */
  4698. static readonly MATERIAL_PointFillMode: number;
  4699. /**
  4700. * Returns the point list draw mode
  4701. */
  4702. static readonly MATERIAL_PointListDrawMode: number;
  4703. /**
  4704. * Returns the line list draw mode
  4705. */
  4706. static readonly MATERIAL_LineListDrawMode: number;
  4707. /**
  4708. * Returns the line loop draw mode
  4709. */
  4710. static readonly MATERIAL_LineLoopDrawMode: number;
  4711. /**
  4712. * Returns the line strip draw mode
  4713. */
  4714. static readonly MATERIAL_LineStripDrawMode: number;
  4715. /**
  4716. * Returns the triangle strip draw mode
  4717. */
  4718. static readonly MATERIAL_TriangleStripDrawMode: number;
  4719. /**
  4720. * Returns the triangle fan draw mode
  4721. */
  4722. static readonly MATERIAL_TriangleFanDrawMode: number;
  4723. /**
  4724. * Stores the clock-wise side orientation
  4725. */
  4726. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4727. /**
  4728. * Stores the counter clock-wise side orientation
  4729. */
  4730. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4731. /**
  4732. * Nothing
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_NothingTrigger: number;
  4736. /**
  4737. * On pick
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPickTrigger: number;
  4741. /**
  4742. * On left pick
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnLeftPickTrigger: number;
  4746. /**
  4747. * On right pick
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnRightPickTrigger: number;
  4751. /**
  4752. * On center pick
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnCenterPickTrigger: number;
  4756. /**
  4757. * On pick down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnPickDownTrigger: number;
  4761. /**
  4762. * On double pick
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnDoublePickTrigger: number;
  4766. /**
  4767. * On pick up
  4768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4769. */
  4770. static readonly ACTION_OnPickUpTrigger: number;
  4771. /**
  4772. * On pick out.
  4773. * This trigger will only be raised if you also declared a OnPickDown
  4774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4775. */
  4776. static readonly ACTION_OnPickOutTrigger: number;
  4777. /**
  4778. * On long press
  4779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4780. */
  4781. static readonly ACTION_OnLongPressTrigger: number;
  4782. /**
  4783. * On pointer over
  4784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4785. */
  4786. static readonly ACTION_OnPointerOverTrigger: number;
  4787. /**
  4788. * On pointer out
  4789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4790. */
  4791. static readonly ACTION_OnPointerOutTrigger: number;
  4792. /**
  4793. * On every frame
  4794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4795. */
  4796. static readonly ACTION_OnEveryFrameTrigger: number;
  4797. /**
  4798. * On intersection enter
  4799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4800. */
  4801. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4802. /**
  4803. * On intersection exit
  4804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4805. */
  4806. static readonly ACTION_OnIntersectionExitTrigger: number;
  4807. /**
  4808. * On key down
  4809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4810. */
  4811. static readonly ACTION_OnKeyDownTrigger: number;
  4812. /**
  4813. * On key up
  4814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4815. */
  4816. static readonly ACTION_OnKeyUpTrigger: number;
  4817. /**
  4818. * Billboard mode will only apply to Y axis
  4819. */
  4820. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4821. /**
  4822. * Billboard mode will apply to all axes
  4823. */
  4824. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4825. /**
  4826. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4827. */
  4828. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4829. /**
  4830. * Gets or sets base Assets URL
  4831. */
  4832. static PARTICLES_BaseAssetsUrl: string;
  4833. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4834. * Test order :
  4835. * Is the bounding sphere outside the frustum ?
  4836. * If not, are the bounding box vertices outside the frustum ?
  4837. * It not, then the cullable object is in the frustum.
  4838. */
  4839. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4840. /** Culling strategy : Bounding Sphere Only.
  4841. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4842. * It's also less accurate than the standard because some not visible objects can still be selected.
  4843. * Test : is the bounding sphere outside the frustum ?
  4844. * If not, then the cullable object is in the frustum.
  4845. */
  4846. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4847. /** Culling strategy : Optimistic Inclusion.
  4848. * This in an inclusion test first, then the standard exclusion test.
  4849. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4850. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4851. * Anyway, it's as accurate as the standard strategy.
  4852. * Test :
  4853. * Is the cullable object bounding sphere center in the frustum ?
  4854. * If not, apply the default culling strategy.
  4855. */
  4856. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4857. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4858. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4859. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4860. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4861. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4862. * Test :
  4863. * Is the cullable object bounding sphere center in the frustum ?
  4864. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4865. */
  4866. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4867. /**
  4868. * No logging while loading
  4869. */
  4870. static readonly SCENELOADER_NO_LOGGING: number;
  4871. /**
  4872. * Minimal logging while loading
  4873. */
  4874. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4875. /**
  4876. * Summary logging while loading
  4877. */
  4878. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4879. /**
  4880. * Detailled logging while loading
  4881. */
  4882. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4883. }
  4884. }
  4885. declare module BABYLON {
  4886. /**
  4887. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4888. * Babylon.js
  4889. */
  4890. export class DomManagement {
  4891. /**
  4892. * Checks if the window object exists
  4893. * @returns true if the window object exists
  4894. */
  4895. static IsWindowObjectExist(): boolean;
  4896. /**
  4897. * Extracts text content from a DOM element hierarchy
  4898. * @param element defines the root element
  4899. * @returns a string
  4900. */
  4901. static GetDOMTextContent(element: HTMLElement): string;
  4902. }
  4903. }
  4904. declare module BABYLON {
  4905. /**
  4906. * Logger used througouht the application to allow configuration of
  4907. * the log level required for the messages.
  4908. */
  4909. export class Logger {
  4910. /**
  4911. * No log
  4912. */
  4913. static readonly NoneLogLevel: number;
  4914. /**
  4915. * Only message logs
  4916. */
  4917. static readonly MessageLogLevel: number;
  4918. /**
  4919. * Only warning logs
  4920. */
  4921. static readonly WarningLogLevel: number;
  4922. /**
  4923. * Only error logs
  4924. */
  4925. static readonly ErrorLogLevel: number;
  4926. /**
  4927. * All logs
  4928. */
  4929. static readonly AllLogLevel: number;
  4930. private static _LogCache;
  4931. /**
  4932. * Gets a value indicating the number of loading errors
  4933. * @ignorenaming
  4934. */
  4935. static errorsCount: number;
  4936. /**
  4937. * Callback called when a new log is added
  4938. */
  4939. static OnNewCacheEntry: (entry: string) => void;
  4940. private static _AddLogEntry;
  4941. private static _FormatMessage;
  4942. private static _LogDisabled;
  4943. private static _LogEnabled;
  4944. private static _WarnDisabled;
  4945. private static _WarnEnabled;
  4946. private static _ErrorDisabled;
  4947. private static _ErrorEnabled;
  4948. /**
  4949. * Log a message to the console
  4950. */
  4951. static Log: (message: string) => void;
  4952. /**
  4953. * Write a warning message to the console
  4954. */
  4955. static Warn: (message: string) => void;
  4956. /**
  4957. * Write an error message to the console
  4958. */
  4959. static Error: (message: string) => void;
  4960. /**
  4961. * Gets current log cache (list of logs)
  4962. */
  4963. static readonly LogCache: string;
  4964. /**
  4965. * Clears the log cache
  4966. */
  4967. static ClearLogCache(): void;
  4968. /**
  4969. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4970. */
  4971. static LogLevels: number;
  4972. }
  4973. }
  4974. declare module BABYLON {
  4975. /** @hidden */
  4976. export class _TypeStore {
  4977. /** @hidden */
  4978. static RegisteredTypes: {
  4979. [key: string]: Object;
  4980. };
  4981. /** @hidden */
  4982. static GetClass(fqdn: string): any;
  4983. }
  4984. }
  4985. declare module BABYLON {
  4986. /**
  4987. * Class containing a set of static utilities functions for deep copy.
  4988. */
  4989. export class DeepCopier {
  4990. /**
  4991. * Tries to copy an object by duplicating every property
  4992. * @param source defines the source object
  4993. * @param destination defines the target object
  4994. * @param doNotCopyList defines a list of properties to avoid
  4995. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4996. */
  4997. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4998. }
  4999. }
  5000. declare module BABYLON {
  5001. /**
  5002. * Class containing a set of static utilities functions for precision date
  5003. */
  5004. export class PrecisionDate {
  5005. /**
  5006. * Gets either window.performance.now() if supported or Date.now() else
  5007. */
  5008. static readonly Now: number;
  5009. }
  5010. }
  5011. declare module BABYLON {
  5012. /** @hidden */
  5013. export class _DevTools {
  5014. static WarnImport(name: string): string;
  5015. }
  5016. }
  5017. declare module BABYLON {
  5018. /**
  5019. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5020. */
  5021. export class WebRequest {
  5022. private _xhr;
  5023. /**
  5024. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5025. * i.e. when loading files, where the server/service expects an Authorization header
  5026. */
  5027. static CustomRequestHeaders: {
  5028. [key: string]: string;
  5029. };
  5030. /**
  5031. * Add callback functions in this array to update all the requests before they get sent to the network
  5032. */
  5033. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  5034. private _injectCustomRequestHeaders;
  5035. /**
  5036. * Gets or sets a function to be called when loading progress changes
  5037. */
  5038. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5039. /**
  5040. * Returns client's state
  5041. */
  5042. readonly readyState: number;
  5043. /**
  5044. * Returns client's status
  5045. */
  5046. readonly status: number;
  5047. /**
  5048. * Returns client's status as a text
  5049. */
  5050. readonly statusText: string;
  5051. /**
  5052. * Returns client's response
  5053. */
  5054. readonly response: any;
  5055. /**
  5056. * Returns client's response url
  5057. */
  5058. readonly responseURL: string;
  5059. /**
  5060. * Returns client's response as text
  5061. */
  5062. readonly responseText: string;
  5063. /**
  5064. * Gets or sets the expected response type
  5065. */
  5066. responseType: XMLHttpRequestResponseType;
  5067. /** @hidden */
  5068. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5069. /** @hidden */
  5070. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5071. /**
  5072. * Cancels any network activity
  5073. */
  5074. abort(): void;
  5075. /**
  5076. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5077. * @param body defines an optional request body
  5078. */
  5079. send(body?: Document | BodyInit | null): void;
  5080. /**
  5081. * Sets the request method, request URL
  5082. * @param method defines the method to use (GET, POST, etc..)
  5083. * @param url defines the url to connect with
  5084. */
  5085. open(method: string, url: string): void;
  5086. }
  5087. }
  5088. declare module BABYLON {
  5089. /**
  5090. * Class used to evalaute queries containing `and` and `or` operators
  5091. */
  5092. export class AndOrNotEvaluator {
  5093. /**
  5094. * Evaluate a query
  5095. * @param query defines the query to evaluate
  5096. * @param evaluateCallback defines the callback used to filter result
  5097. * @returns true if the query matches
  5098. */
  5099. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5100. private static _HandleParenthesisContent;
  5101. private static _SimplifyNegation;
  5102. }
  5103. }
  5104. declare module BABYLON {
  5105. /**
  5106. * Class used to store custom tags
  5107. */
  5108. export class Tags {
  5109. /**
  5110. * Adds support for tags on the given object
  5111. * @param obj defines the object to use
  5112. */
  5113. static EnableFor(obj: any): void;
  5114. /**
  5115. * Removes tags support
  5116. * @param obj defines the object to use
  5117. */
  5118. static DisableFor(obj: any): void;
  5119. /**
  5120. * Gets a boolean indicating if the given object has tags
  5121. * @param obj defines the object to use
  5122. * @returns a boolean
  5123. */
  5124. static HasTags(obj: any): boolean;
  5125. /**
  5126. * Gets the tags available on a given object
  5127. * @param obj defines the object to use
  5128. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5129. * @returns the tags
  5130. */
  5131. static GetTags(obj: any, asString?: boolean): any;
  5132. /**
  5133. * Adds tags to an object
  5134. * @param obj defines the object to use
  5135. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5136. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5137. */
  5138. static AddTagsTo(obj: any, tagsString: string): void;
  5139. /**
  5140. * @hidden
  5141. */
  5142. static _AddTagTo(obj: any, tag: string): void;
  5143. /**
  5144. * Removes specific tags from a specific object
  5145. * @param obj defines the object to use
  5146. * @param tagsString defines the tags to remove
  5147. */
  5148. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5149. /**
  5150. * @hidden
  5151. */
  5152. static _RemoveTagFrom(obj: any, tag: string): void;
  5153. /**
  5154. * Defines if tags hosted on an object match a given query
  5155. * @param obj defines the object to use
  5156. * @param tagsQuery defines the tag query
  5157. * @returns a boolean
  5158. */
  5159. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5160. }
  5161. }
  5162. declare module BABYLON {
  5163. /**
  5164. * Manages the defines for the Material
  5165. */
  5166. export class MaterialDefines {
  5167. /** @hidden */
  5168. protected _keys: string[];
  5169. private _isDirty;
  5170. /** @hidden */
  5171. _renderId: number;
  5172. /** @hidden */
  5173. _areLightsDirty: boolean;
  5174. /** @hidden */
  5175. _areAttributesDirty: boolean;
  5176. /** @hidden */
  5177. _areTexturesDirty: boolean;
  5178. /** @hidden */
  5179. _areFresnelDirty: boolean;
  5180. /** @hidden */
  5181. _areMiscDirty: boolean;
  5182. /** @hidden */
  5183. _areImageProcessingDirty: boolean;
  5184. /** @hidden */
  5185. _normals: boolean;
  5186. /** @hidden */
  5187. _uvs: boolean;
  5188. /** @hidden */
  5189. _needNormals: boolean;
  5190. /** @hidden */
  5191. _needUVs: boolean;
  5192. [id: string]: any;
  5193. /**
  5194. * Specifies if the material needs to be re-calculated
  5195. */
  5196. readonly isDirty: boolean;
  5197. /**
  5198. * Marks the material to indicate that it has been re-calculated
  5199. */
  5200. markAsProcessed(): void;
  5201. /**
  5202. * Marks the material to indicate that it needs to be re-calculated
  5203. */
  5204. markAsUnprocessed(): void;
  5205. /**
  5206. * Marks the material to indicate all of its defines need to be re-calculated
  5207. */
  5208. markAllAsDirty(): void;
  5209. /**
  5210. * Marks the material to indicate that image processing needs to be re-calculated
  5211. */
  5212. markAsImageProcessingDirty(): void;
  5213. /**
  5214. * Marks the material to indicate the lights need to be re-calculated
  5215. */
  5216. markAsLightDirty(): void;
  5217. /**
  5218. * Marks the attribute state as changed
  5219. */
  5220. markAsAttributesDirty(): void;
  5221. /**
  5222. * Marks the texture state as changed
  5223. */
  5224. markAsTexturesDirty(): void;
  5225. /**
  5226. * Marks the fresnel state as changed
  5227. */
  5228. markAsFresnelDirty(): void;
  5229. /**
  5230. * Marks the misc state as changed
  5231. */
  5232. markAsMiscDirty(): void;
  5233. /**
  5234. * Rebuilds the material defines
  5235. */
  5236. rebuild(): void;
  5237. /**
  5238. * Specifies if two material defines are equal
  5239. * @param other - A material define instance to compare to
  5240. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5241. */
  5242. isEqual(other: MaterialDefines): boolean;
  5243. /**
  5244. * Clones this instance's defines to another instance
  5245. * @param other - material defines to clone values to
  5246. */
  5247. cloneTo(other: MaterialDefines): void;
  5248. /**
  5249. * Resets the material define values
  5250. */
  5251. reset(): void;
  5252. /**
  5253. * Converts the material define values to a string
  5254. * @returns - String of material define information
  5255. */
  5256. toString(): string;
  5257. }
  5258. }
  5259. declare module BABYLON {
  5260. /**
  5261. * Class used to store and describe the pipeline context associated with an effect
  5262. */
  5263. export interface IPipelineContext {
  5264. /**
  5265. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5266. */
  5267. isAsync: boolean;
  5268. /**
  5269. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5270. */
  5271. isReady: boolean;
  5272. /** @hidden */
  5273. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5274. }
  5275. }
  5276. declare module BABYLON {
  5277. /**
  5278. * Class used to store gfx data (like WebGLBuffer)
  5279. */
  5280. export class DataBuffer {
  5281. /**
  5282. * Gets or sets the number of objects referencing this buffer
  5283. */
  5284. references: number;
  5285. /** Gets or sets the size of the underlying buffer */
  5286. capacity: number;
  5287. /**
  5288. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5289. */
  5290. is32Bits: boolean;
  5291. /**
  5292. * Gets the underlying buffer
  5293. */
  5294. readonly underlyingResource: any;
  5295. }
  5296. }
  5297. declare module BABYLON {
  5298. /** @hidden */
  5299. export interface IShaderProcessor {
  5300. attributeProcessor?: (attribute: string) => string;
  5301. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5302. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5303. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5304. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5305. lineProcessor?: (line: string, isFragment: boolean) => string;
  5306. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5307. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5308. }
  5309. }
  5310. declare module BABYLON {
  5311. /** @hidden */
  5312. export interface ProcessingOptions {
  5313. defines: string[];
  5314. indexParameters: any;
  5315. isFragment: boolean;
  5316. shouldUseHighPrecisionShader: boolean;
  5317. supportsUniformBuffers: boolean;
  5318. shadersRepository: string;
  5319. includesShadersStore: {
  5320. [key: string]: string;
  5321. };
  5322. processor?: IShaderProcessor;
  5323. version: string;
  5324. platformName: string;
  5325. lookForClosingBracketForUniformBuffer?: boolean;
  5326. }
  5327. }
  5328. declare module BABYLON {
  5329. /** @hidden */
  5330. export class ShaderCodeNode {
  5331. line: string;
  5332. children: ShaderCodeNode[];
  5333. additionalDefineKey?: string;
  5334. additionalDefineValue?: string;
  5335. isValid(preprocessors: {
  5336. [key: string]: string;
  5337. }): boolean;
  5338. process(preprocessors: {
  5339. [key: string]: string;
  5340. }, options: ProcessingOptions): string;
  5341. }
  5342. }
  5343. declare module BABYLON {
  5344. /** @hidden */
  5345. export class ShaderCodeCursor {
  5346. private _lines;
  5347. lineIndex: number;
  5348. readonly currentLine: string;
  5349. readonly canRead: boolean;
  5350. lines: string[];
  5351. }
  5352. }
  5353. declare module BABYLON {
  5354. /** @hidden */
  5355. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5356. process(preprocessors: {
  5357. [key: string]: string;
  5358. }, options: ProcessingOptions): string;
  5359. }
  5360. }
  5361. declare module BABYLON {
  5362. /** @hidden */
  5363. export class ShaderDefineExpression {
  5364. isTrue(preprocessors: {
  5365. [key: string]: string;
  5366. }): boolean;
  5367. }
  5368. }
  5369. declare module BABYLON {
  5370. /** @hidden */
  5371. export class ShaderCodeTestNode extends ShaderCodeNode {
  5372. testExpression: ShaderDefineExpression;
  5373. isValid(preprocessors: {
  5374. [key: string]: string;
  5375. }): boolean;
  5376. }
  5377. }
  5378. declare module BABYLON {
  5379. /** @hidden */
  5380. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5381. define: string;
  5382. not: boolean;
  5383. constructor(define: string, not?: boolean);
  5384. isTrue(preprocessors: {
  5385. [key: string]: string;
  5386. }): boolean;
  5387. }
  5388. }
  5389. declare module BABYLON {
  5390. /** @hidden */
  5391. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5392. leftOperand: ShaderDefineExpression;
  5393. rightOperand: ShaderDefineExpression;
  5394. isTrue(preprocessors: {
  5395. [key: string]: string;
  5396. }): boolean;
  5397. }
  5398. }
  5399. declare module BABYLON {
  5400. /** @hidden */
  5401. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5402. leftOperand: ShaderDefineExpression;
  5403. rightOperand: ShaderDefineExpression;
  5404. isTrue(preprocessors: {
  5405. [key: string]: string;
  5406. }): boolean;
  5407. }
  5408. }
  5409. declare module BABYLON {
  5410. /** @hidden */
  5411. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5412. define: string;
  5413. operand: string;
  5414. testValue: string;
  5415. constructor(define: string, operand: string, testValue: string);
  5416. isTrue(preprocessors: {
  5417. [key: string]: string;
  5418. }): boolean;
  5419. }
  5420. }
  5421. declare module BABYLON {
  5422. /** @hidden */
  5423. export class ShaderProcessor {
  5424. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5425. private static _ProcessPrecision;
  5426. private static _ExtractOperation;
  5427. private static _BuildSubExpression;
  5428. private static _BuildExpression;
  5429. private static _MoveCursorWithinIf;
  5430. private static _MoveCursor;
  5431. private static _EvaluatePreProcessors;
  5432. private static _PreparePreProcessors;
  5433. private static _ProcessShaderConversion;
  5434. private static _ProcessIncludes;
  5435. }
  5436. }
  5437. declare module BABYLON {
  5438. /**
  5439. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5440. */
  5441. export class PerformanceMonitor {
  5442. private _enabled;
  5443. private _rollingFrameTime;
  5444. private _lastFrameTimeMs;
  5445. /**
  5446. * constructor
  5447. * @param frameSampleSize The number of samples required to saturate the sliding window
  5448. */
  5449. constructor(frameSampleSize?: number);
  5450. /**
  5451. * Samples current frame
  5452. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5453. */
  5454. sampleFrame(timeMs?: number): void;
  5455. /**
  5456. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5457. */
  5458. readonly averageFrameTime: number;
  5459. /**
  5460. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5461. */
  5462. readonly averageFrameTimeVariance: number;
  5463. /**
  5464. * Returns the frame time of the most recent frame
  5465. */
  5466. readonly instantaneousFrameTime: number;
  5467. /**
  5468. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5469. */
  5470. readonly averageFPS: number;
  5471. /**
  5472. * Returns the average framerate in frames per second using the most recent frame time
  5473. */
  5474. readonly instantaneousFPS: number;
  5475. /**
  5476. * Returns true if enough samples have been taken to completely fill the sliding window
  5477. */
  5478. readonly isSaturated: boolean;
  5479. /**
  5480. * Enables contributions to the sliding window sample set
  5481. */
  5482. enable(): void;
  5483. /**
  5484. * Disables contributions to the sliding window sample set
  5485. * Samples will not be interpolated over the disabled period
  5486. */
  5487. disable(): void;
  5488. /**
  5489. * Returns true if sampling is enabled
  5490. */
  5491. readonly isEnabled: boolean;
  5492. /**
  5493. * Resets performance monitor
  5494. */
  5495. reset(): void;
  5496. }
  5497. /**
  5498. * RollingAverage
  5499. *
  5500. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5501. */
  5502. export class RollingAverage {
  5503. /**
  5504. * Current average
  5505. */
  5506. average: number;
  5507. /**
  5508. * Current variance
  5509. */
  5510. variance: number;
  5511. protected _samples: Array<number>;
  5512. protected _sampleCount: number;
  5513. protected _pos: number;
  5514. protected _m2: number;
  5515. /**
  5516. * constructor
  5517. * @param length The number of samples required to saturate the sliding window
  5518. */
  5519. constructor(length: number);
  5520. /**
  5521. * Adds a sample to the sample set
  5522. * @param v The sample value
  5523. */
  5524. add(v: number): void;
  5525. /**
  5526. * Returns previously added values or null if outside of history or outside the sliding window domain
  5527. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5528. * @return Value previously recorded with add() or null if outside of range
  5529. */
  5530. history(i: number): number;
  5531. /**
  5532. * Returns true if enough samples have been taken to completely fill the sliding window
  5533. * @return true if sample-set saturated
  5534. */
  5535. isSaturated(): boolean;
  5536. /**
  5537. * Resets the rolling average (equivalent to 0 samples taken so far)
  5538. */
  5539. reset(): void;
  5540. /**
  5541. * Wraps a value around the sample range boundaries
  5542. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5543. * @return Wrapped position in sample range
  5544. */
  5545. protected _wrapPosition(i: number): number;
  5546. }
  5547. }
  5548. declare module BABYLON {
  5549. /**
  5550. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5551. * The underlying implementation relies on an associative array to ensure the best performances.
  5552. * The value can be anything including 'null' but except 'undefined'
  5553. */
  5554. export class StringDictionary<T> {
  5555. /**
  5556. * This will clear this dictionary and copy the content from the 'source' one.
  5557. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5558. * @param source the dictionary to take the content from and copy to this dictionary
  5559. */
  5560. copyFrom(source: StringDictionary<T>): void;
  5561. /**
  5562. * Get a value based from its key
  5563. * @param key the given key to get the matching value from
  5564. * @return the value if found, otherwise undefined is returned
  5565. */
  5566. get(key: string): T | undefined;
  5567. /**
  5568. * Get a value from its key or add it if it doesn't exist.
  5569. * This method will ensure you that a given key/data will be present in the dictionary.
  5570. * @param key the given key to get the matching value from
  5571. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5572. * The factory will only be invoked if there's no data for the given key.
  5573. * @return the value corresponding to the key.
  5574. */
  5575. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5576. /**
  5577. * Get a value from its key if present in the dictionary otherwise add it
  5578. * @param key the key to get the value from
  5579. * @param val if there's no such key/value pair in the dictionary add it with this value
  5580. * @return the value corresponding to the key
  5581. */
  5582. getOrAdd(key: string, val: T): T;
  5583. /**
  5584. * Check if there's a given key in the dictionary
  5585. * @param key the key to check for
  5586. * @return true if the key is present, false otherwise
  5587. */
  5588. contains(key: string): boolean;
  5589. /**
  5590. * Add a new key and its corresponding value
  5591. * @param key the key to add
  5592. * @param value the value corresponding to the key
  5593. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5594. */
  5595. add(key: string, value: T): boolean;
  5596. /**
  5597. * Update a specific value associated to a key
  5598. * @param key defines the key to use
  5599. * @param value defines the value to store
  5600. * @returns true if the value was updated (or false if the key was not found)
  5601. */
  5602. set(key: string, value: T): boolean;
  5603. /**
  5604. * Get the element of the given key and remove it from the dictionary
  5605. * @param key defines the key to search
  5606. * @returns the value associated with the key or null if not found
  5607. */
  5608. getAndRemove(key: string): Nullable<T>;
  5609. /**
  5610. * Remove a key/value from the dictionary.
  5611. * @param key the key to remove
  5612. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5613. */
  5614. remove(key: string): boolean;
  5615. /**
  5616. * Clear the whole content of the dictionary
  5617. */
  5618. clear(): void;
  5619. /**
  5620. * Gets the current count
  5621. */
  5622. readonly count: number;
  5623. /**
  5624. * Execute a callback on each key/val of the dictionary.
  5625. * Note that you can remove any element in this dictionary in the callback implementation
  5626. * @param callback the callback to execute on a given key/value pair
  5627. */
  5628. forEach(callback: (key: string, val: T) => void): void;
  5629. /**
  5630. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5631. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5632. * Note that you can remove any element in this dictionary in the callback implementation
  5633. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5634. * @returns the first item
  5635. */
  5636. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5637. private _count;
  5638. private _data;
  5639. }
  5640. }
  5641. declare module BABYLON {
  5642. /**
  5643. * Helper class that provides a small promise polyfill
  5644. */
  5645. export class PromisePolyfill {
  5646. /**
  5647. * Static function used to check if the polyfill is required
  5648. * If this is the case then the function will inject the polyfill to window.Promise
  5649. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5650. */
  5651. static Apply(force?: boolean): void;
  5652. }
  5653. }
  5654. declare module BABYLON {
  5655. /**
  5656. * Class used to store data that will be store in GPU memory
  5657. */
  5658. export class Buffer {
  5659. private _engine;
  5660. private _buffer;
  5661. /** @hidden */
  5662. _data: Nullable<DataArray>;
  5663. private _updatable;
  5664. private _instanced;
  5665. /**
  5666. * Gets the byte stride.
  5667. */
  5668. readonly byteStride: number;
  5669. /**
  5670. * Constructor
  5671. * @param engine the engine
  5672. * @param data the data to use for this buffer
  5673. * @param updatable whether the data is updatable
  5674. * @param stride the stride (optional)
  5675. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5676. * @param instanced whether the buffer is instanced (optional)
  5677. * @param useBytes set to true if the stride in in bytes (optional)
  5678. */
  5679. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5680. /**
  5681. * Create a new VertexBuffer based on the current buffer
  5682. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5683. * @param offset defines offset in the buffer (0 by default)
  5684. * @param size defines the size in floats of attributes (position is 3 for instance)
  5685. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5686. * @param instanced defines if the vertex buffer contains indexed data
  5687. * @param useBytes defines if the offset and stride are in bytes
  5688. * @returns the new vertex buffer
  5689. */
  5690. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5691. /**
  5692. * Gets a boolean indicating if the Buffer is updatable?
  5693. * @returns true if the buffer is updatable
  5694. */
  5695. isUpdatable(): boolean;
  5696. /**
  5697. * Gets current buffer's data
  5698. * @returns a DataArray or null
  5699. */
  5700. getData(): Nullable<DataArray>;
  5701. /**
  5702. * Gets underlying native buffer
  5703. * @returns underlying native buffer
  5704. */
  5705. getBuffer(): Nullable<DataBuffer>;
  5706. /**
  5707. * Gets the stride in float32 units (i.e. byte stride / 4).
  5708. * May not be an integer if the byte stride is not divisible by 4.
  5709. * DEPRECATED. Use byteStride instead.
  5710. * @returns the stride in float32 units
  5711. */
  5712. getStrideSize(): number;
  5713. /**
  5714. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5715. * @param data defines the data to store
  5716. */
  5717. create(data?: Nullable<DataArray>): void;
  5718. /** @hidden */
  5719. _rebuild(): void;
  5720. /**
  5721. * Update current buffer data
  5722. * @param data defines the data to store
  5723. */
  5724. update(data: DataArray): void;
  5725. /**
  5726. * Updates the data directly.
  5727. * @param data the new data
  5728. * @param offset the new offset
  5729. * @param vertexCount the vertex count (optional)
  5730. * @param useBytes set to true if the offset is in bytes
  5731. */
  5732. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5733. /**
  5734. * Release all resources
  5735. */
  5736. dispose(): void;
  5737. }
  5738. /**
  5739. * Specialized buffer used to store vertex data
  5740. */
  5741. export class VertexBuffer {
  5742. /** @hidden */
  5743. _buffer: Buffer;
  5744. private _kind;
  5745. private _size;
  5746. private _ownsBuffer;
  5747. private _instanced;
  5748. private _instanceDivisor;
  5749. /**
  5750. * The byte type.
  5751. */
  5752. static readonly BYTE: number;
  5753. /**
  5754. * The unsigned byte type.
  5755. */
  5756. static readonly UNSIGNED_BYTE: number;
  5757. /**
  5758. * The short type.
  5759. */
  5760. static readonly SHORT: number;
  5761. /**
  5762. * The unsigned short type.
  5763. */
  5764. static readonly UNSIGNED_SHORT: number;
  5765. /**
  5766. * The integer type.
  5767. */
  5768. static readonly INT: number;
  5769. /**
  5770. * The unsigned integer type.
  5771. */
  5772. static readonly UNSIGNED_INT: number;
  5773. /**
  5774. * The float type.
  5775. */
  5776. static readonly FLOAT: number;
  5777. /**
  5778. * Gets or sets the instance divisor when in instanced mode
  5779. */
  5780. instanceDivisor: number;
  5781. /**
  5782. * Gets the byte stride.
  5783. */
  5784. readonly byteStride: number;
  5785. /**
  5786. * Gets the byte offset.
  5787. */
  5788. readonly byteOffset: number;
  5789. /**
  5790. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5791. */
  5792. readonly normalized: boolean;
  5793. /**
  5794. * Gets the data type of each component in the array.
  5795. */
  5796. readonly type: number;
  5797. /**
  5798. * Constructor
  5799. * @param engine the engine
  5800. * @param data the data to use for this vertex buffer
  5801. * @param kind the vertex buffer kind
  5802. * @param updatable whether the data is updatable
  5803. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5804. * @param stride the stride (optional)
  5805. * @param instanced whether the buffer is instanced (optional)
  5806. * @param offset the offset of the data (optional)
  5807. * @param size the number of components (optional)
  5808. * @param type the type of the component (optional)
  5809. * @param normalized whether the data contains normalized data (optional)
  5810. * @param useBytes set to true if stride and offset are in bytes (optional)
  5811. */
  5812. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5813. /** @hidden */
  5814. _rebuild(): void;
  5815. /**
  5816. * Returns the kind of the VertexBuffer (string)
  5817. * @returns a string
  5818. */
  5819. getKind(): string;
  5820. /**
  5821. * Gets a boolean indicating if the VertexBuffer is updatable?
  5822. * @returns true if the buffer is updatable
  5823. */
  5824. isUpdatable(): boolean;
  5825. /**
  5826. * Gets current buffer's data
  5827. * @returns a DataArray or null
  5828. */
  5829. getData(): Nullable<DataArray>;
  5830. /**
  5831. * Gets underlying native buffer
  5832. * @returns underlying native buffer
  5833. */
  5834. getBuffer(): Nullable<DataBuffer>;
  5835. /**
  5836. * Gets the stride in float32 units (i.e. byte stride / 4).
  5837. * May not be an integer if the byte stride is not divisible by 4.
  5838. * DEPRECATED. Use byteStride instead.
  5839. * @returns the stride in float32 units
  5840. */
  5841. getStrideSize(): number;
  5842. /**
  5843. * Returns the offset as a multiple of the type byte length.
  5844. * DEPRECATED. Use byteOffset instead.
  5845. * @returns the offset in bytes
  5846. */
  5847. getOffset(): number;
  5848. /**
  5849. * Returns the number of components per vertex attribute (integer)
  5850. * @returns the size in float
  5851. */
  5852. getSize(): number;
  5853. /**
  5854. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5855. * @returns true if this buffer is instanced
  5856. */
  5857. getIsInstanced(): boolean;
  5858. /**
  5859. * Returns the instancing divisor, zero for non-instanced (integer).
  5860. * @returns a number
  5861. */
  5862. getInstanceDivisor(): number;
  5863. /**
  5864. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5865. * @param data defines the data to store
  5866. */
  5867. create(data?: DataArray): void;
  5868. /**
  5869. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5870. * This function will create a new buffer if the current one is not updatable
  5871. * @param data defines the data to store
  5872. */
  5873. update(data: DataArray): void;
  5874. /**
  5875. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5876. * Returns the directly updated WebGLBuffer.
  5877. * @param data the new data
  5878. * @param offset the new offset
  5879. * @param useBytes set to true if the offset is in bytes
  5880. */
  5881. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5882. /**
  5883. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5884. */
  5885. dispose(): void;
  5886. /**
  5887. * Enumerates each value of this vertex buffer as numbers.
  5888. * @param count the number of values to enumerate
  5889. * @param callback the callback function called for each value
  5890. */
  5891. forEach(count: number, callback: (value: number, index: number) => void): void;
  5892. /**
  5893. * Positions
  5894. */
  5895. static readonly PositionKind: string;
  5896. /**
  5897. * Normals
  5898. */
  5899. static readonly NormalKind: string;
  5900. /**
  5901. * Tangents
  5902. */
  5903. static readonly TangentKind: string;
  5904. /**
  5905. * Texture coordinates
  5906. */
  5907. static readonly UVKind: string;
  5908. /**
  5909. * Texture coordinates 2
  5910. */
  5911. static readonly UV2Kind: string;
  5912. /**
  5913. * Texture coordinates 3
  5914. */
  5915. static readonly UV3Kind: string;
  5916. /**
  5917. * Texture coordinates 4
  5918. */
  5919. static readonly UV4Kind: string;
  5920. /**
  5921. * Texture coordinates 5
  5922. */
  5923. static readonly UV5Kind: string;
  5924. /**
  5925. * Texture coordinates 6
  5926. */
  5927. static readonly UV6Kind: string;
  5928. /**
  5929. * Colors
  5930. */
  5931. static readonly ColorKind: string;
  5932. /**
  5933. * Matrix indices (for bones)
  5934. */
  5935. static readonly MatricesIndicesKind: string;
  5936. /**
  5937. * Matrix weights (for bones)
  5938. */
  5939. static readonly MatricesWeightsKind: string;
  5940. /**
  5941. * Additional matrix indices (for bones)
  5942. */
  5943. static readonly MatricesIndicesExtraKind: string;
  5944. /**
  5945. * Additional matrix weights (for bones)
  5946. */
  5947. static readonly MatricesWeightsExtraKind: string;
  5948. /**
  5949. * Deduces the stride given a kind.
  5950. * @param kind The kind string to deduce
  5951. * @returns The deduced stride
  5952. */
  5953. static DeduceStride(kind: string): number;
  5954. /**
  5955. * Gets the byte length of the given type.
  5956. * @param type the type
  5957. * @returns the number of bytes
  5958. */
  5959. static GetTypeByteLength(type: number): number;
  5960. /**
  5961. * Enumerates each value of the given parameters as numbers.
  5962. * @param data the data to enumerate
  5963. * @param byteOffset the byte offset of the data
  5964. * @param byteStride the byte stride of the data
  5965. * @param componentCount the number of components per element
  5966. * @param componentType the type of the component
  5967. * @param count the number of values to enumerate
  5968. * @param normalized whether the data is normalized
  5969. * @param callback the callback function called for each value
  5970. */
  5971. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5972. private static _GetFloatValue;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * Class representing spherical harmonics coefficients to the 3rd degree
  5978. */
  5979. export class SphericalHarmonics {
  5980. /**
  5981. * Defines whether or not the harmonics have been prescaled for rendering.
  5982. */
  5983. preScaled: boolean;
  5984. /**
  5985. * The l0,0 coefficients of the spherical harmonics
  5986. */
  5987. l00: Vector3;
  5988. /**
  5989. * The l1,-1 coefficients of the spherical harmonics
  5990. */
  5991. l1_1: Vector3;
  5992. /**
  5993. * The l1,0 coefficients of the spherical harmonics
  5994. */
  5995. l10: Vector3;
  5996. /**
  5997. * The l1,1 coefficients of the spherical harmonics
  5998. */
  5999. l11: Vector3;
  6000. /**
  6001. * The l2,-2 coefficients of the spherical harmonics
  6002. */
  6003. l2_2: Vector3;
  6004. /**
  6005. * The l2,-1 coefficients of the spherical harmonics
  6006. */
  6007. l2_1: Vector3;
  6008. /**
  6009. * The l2,0 coefficients of the spherical harmonics
  6010. */
  6011. l20: Vector3;
  6012. /**
  6013. * The l2,1 coefficients of the spherical harmonics
  6014. */
  6015. l21: Vector3;
  6016. /**
  6017. * The l2,2 coefficients of the spherical harmonics
  6018. */
  6019. l22: Vector3;
  6020. /**
  6021. * Adds a light to the spherical harmonics
  6022. * @param direction the direction of the light
  6023. * @param color the color of the light
  6024. * @param deltaSolidAngle the delta solid angle of the light
  6025. */
  6026. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6027. /**
  6028. * Scales the spherical harmonics by the given amount
  6029. * @param scale the amount to scale
  6030. */
  6031. scaleInPlace(scale: number): void;
  6032. /**
  6033. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6034. *
  6035. * ```
  6036. * E_lm = A_l * L_lm
  6037. * ```
  6038. *
  6039. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6040. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6041. * the scaling factors are given in equation 9.
  6042. */
  6043. convertIncidentRadianceToIrradiance(): void;
  6044. /**
  6045. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6046. *
  6047. * ```
  6048. * L = (1/pi) * E * rho
  6049. * ```
  6050. *
  6051. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6052. */
  6053. convertIrradianceToLambertianRadiance(): void;
  6054. /**
  6055. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6056. * required operations at run time.
  6057. *
  6058. * This is simply done by scaling back the SH with Ylm constants parameter.
  6059. * The trigonometric part being applied by the shader at run time.
  6060. */
  6061. preScaleForRendering(): void;
  6062. /**
  6063. * Constructs a spherical harmonics from an array.
  6064. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6065. * @returns the spherical harmonics
  6066. */
  6067. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6068. /**
  6069. * Gets the spherical harmonics from polynomial
  6070. * @param polynomial the spherical polynomial
  6071. * @returns the spherical harmonics
  6072. */
  6073. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6074. }
  6075. /**
  6076. * Class representing spherical polynomial coefficients to the 3rd degree
  6077. */
  6078. export class SphericalPolynomial {
  6079. private _harmonics;
  6080. /**
  6081. * The spherical harmonics used to create the polynomials.
  6082. */
  6083. readonly preScaledHarmonics: SphericalHarmonics;
  6084. /**
  6085. * The x coefficients of the spherical polynomial
  6086. */
  6087. x: Vector3;
  6088. /**
  6089. * The y coefficients of the spherical polynomial
  6090. */
  6091. y: Vector3;
  6092. /**
  6093. * The z coefficients of the spherical polynomial
  6094. */
  6095. z: Vector3;
  6096. /**
  6097. * The xx coefficients of the spherical polynomial
  6098. */
  6099. xx: Vector3;
  6100. /**
  6101. * The yy coefficients of the spherical polynomial
  6102. */
  6103. yy: Vector3;
  6104. /**
  6105. * The zz coefficients of the spherical polynomial
  6106. */
  6107. zz: Vector3;
  6108. /**
  6109. * The xy coefficients of the spherical polynomial
  6110. */
  6111. xy: Vector3;
  6112. /**
  6113. * The yz coefficients of the spherical polynomial
  6114. */
  6115. yz: Vector3;
  6116. /**
  6117. * The zx coefficients of the spherical polynomial
  6118. */
  6119. zx: Vector3;
  6120. /**
  6121. * Adds an ambient color to the spherical polynomial
  6122. * @param color the color to add
  6123. */
  6124. addAmbient(color: Color3): void;
  6125. /**
  6126. * Scales the spherical polynomial by the given amount
  6127. * @param scale the amount to scale
  6128. */
  6129. scaleInPlace(scale: number): void;
  6130. /**
  6131. * Gets the spherical polynomial from harmonics
  6132. * @param harmonics the spherical harmonics
  6133. * @returns the spherical polynomial
  6134. */
  6135. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6136. /**
  6137. * Constructs a spherical polynomial from an array.
  6138. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6139. * @returns the spherical polynomial
  6140. */
  6141. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6142. }
  6143. }
  6144. declare module BABYLON {
  6145. /**
  6146. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6147. */
  6148. export interface CubeMapInfo {
  6149. /**
  6150. * The pixel array for the front face.
  6151. * This is stored in format, left to right, up to down format.
  6152. */
  6153. front: Nullable<ArrayBufferView>;
  6154. /**
  6155. * The pixel array for the back face.
  6156. * This is stored in format, left to right, up to down format.
  6157. */
  6158. back: Nullable<ArrayBufferView>;
  6159. /**
  6160. * The pixel array for the left face.
  6161. * This is stored in format, left to right, up to down format.
  6162. */
  6163. left: Nullable<ArrayBufferView>;
  6164. /**
  6165. * The pixel array for the right face.
  6166. * This is stored in format, left to right, up to down format.
  6167. */
  6168. right: Nullable<ArrayBufferView>;
  6169. /**
  6170. * The pixel array for the up face.
  6171. * This is stored in format, left to right, up to down format.
  6172. */
  6173. up: Nullable<ArrayBufferView>;
  6174. /**
  6175. * The pixel array for the down face.
  6176. * This is stored in format, left to right, up to down format.
  6177. */
  6178. down: Nullable<ArrayBufferView>;
  6179. /**
  6180. * The size of the cubemap stored.
  6181. *
  6182. * Each faces will be size * size pixels.
  6183. */
  6184. size: number;
  6185. /**
  6186. * The format of the texture.
  6187. *
  6188. * RGBA, RGB.
  6189. */
  6190. format: number;
  6191. /**
  6192. * The type of the texture data.
  6193. *
  6194. * UNSIGNED_INT, FLOAT.
  6195. */
  6196. type: number;
  6197. /**
  6198. * Specifies whether the texture is in gamma space.
  6199. */
  6200. gammaSpace: boolean;
  6201. }
  6202. /**
  6203. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6204. */
  6205. export class PanoramaToCubeMapTools {
  6206. private static FACE_FRONT;
  6207. private static FACE_BACK;
  6208. private static FACE_RIGHT;
  6209. private static FACE_LEFT;
  6210. private static FACE_DOWN;
  6211. private static FACE_UP;
  6212. /**
  6213. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6214. *
  6215. * @param float32Array The source data.
  6216. * @param inputWidth The width of the input panorama.
  6217. * @param inputHeight The height of the input panorama.
  6218. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6219. * @return The cubemap data
  6220. */
  6221. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6222. private static CreateCubemapTexture;
  6223. private static CalcProjectionSpherical;
  6224. }
  6225. }
  6226. declare module BABYLON {
  6227. /**
  6228. * Helper class dealing with the extraction of spherical polynomial dataArray
  6229. * from a cube map.
  6230. */
  6231. export class CubeMapToSphericalPolynomialTools {
  6232. private static FileFaces;
  6233. /**
  6234. * Converts a texture to the according Spherical Polynomial data.
  6235. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6236. *
  6237. * @param texture The texture to extract the information from.
  6238. * @return The Spherical Polynomial data.
  6239. */
  6240. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6241. /**
  6242. * Converts a cubemap to the according Spherical Polynomial data.
  6243. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6244. *
  6245. * @param cubeInfo The Cube map to extract the information from.
  6246. * @return The Spherical Polynomial data.
  6247. */
  6248. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6249. }
  6250. }
  6251. declare module BABYLON {
  6252. /**
  6253. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6254. * during the life time of the application.
  6255. */
  6256. export class EngineStore {
  6257. /** Gets the list of created engines */
  6258. static Instances: Engine[];
  6259. /** @hidden */
  6260. static _LastCreatedScene: Nullable<Scene>;
  6261. /**
  6262. * Gets the latest created engine
  6263. */
  6264. static readonly LastCreatedEngine: Nullable<Engine>;
  6265. /**
  6266. * Gets the latest created scene
  6267. */
  6268. static readonly LastCreatedScene: Nullable<Scene>;
  6269. }
  6270. }
  6271. declare module BABYLON {
  6272. /**
  6273. * Define options used to create a render target texture
  6274. */
  6275. export class RenderTargetCreationOptions {
  6276. /**
  6277. * Specifies is mipmaps must be generated
  6278. */
  6279. generateMipMaps?: boolean;
  6280. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6281. generateDepthBuffer?: boolean;
  6282. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6283. generateStencilBuffer?: boolean;
  6284. /** Defines texture type (int by default) */
  6285. type?: number;
  6286. /** Defines sampling mode (trilinear by default) */
  6287. samplingMode?: number;
  6288. /** Defines format (RGBA by default) */
  6289. format?: number;
  6290. }
  6291. }
  6292. declare module BABYLON {
  6293. /**
  6294. * @hidden
  6295. **/
  6296. export class _AlphaState {
  6297. private _isAlphaBlendDirty;
  6298. private _isBlendFunctionParametersDirty;
  6299. private _isBlendEquationParametersDirty;
  6300. private _isBlendConstantsDirty;
  6301. private _alphaBlend;
  6302. private _blendFunctionParameters;
  6303. private _blendEquationParameters;
  6304. private _blendConstants;
  6305. /**
  6306. * Initializes the state.
  6307. */
  6308. constructor();
  6309. readonly isDirty: boolean;
  6310. alphaBlend: boolean;
  6311. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6312. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6313. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6314. reset(): void;
  6315. apply(gl: WebGLRenderingContext): void;
  6316. }
  6317. }
  6318. declare module BABYLON {
  6319. /**
  6320. * @hidden
  6321. **/
  6322. export class _DepthCullingState {
  6323. private _isDepthTestDirty;
  6324. private _isDepthMaskDirty;
  6325. private _isDepthFuncDirty;
  6326. private _isCullFaceDirty;
  6327. private _isCullDirty;
  6328. private _isZOffsetDirty;
  6329. private _isFrontFaceDirty;
  6330. private _depthTest;
  6331. private _depthMask;
  6332. private _depthFunc;
  6333. private _cull;
  6334. private _cullFace;
  6335. private _zOffset;
  6336. private _frontFace;
  6337. /**
  6338. * Initializes the state.
  6339. */
  6340. constructor();
  6341. readonly isDirty: boolean;
  6342. zOffset: number;
  6343. cullFace: Nullable<number>;
  6344. cull: Nullable<boolean>;
  6345. depthFunc: Nullable<number>;
  6346. depthMask: boolean;
  6347. depthTest: boolean;
  6348. frontFace: Nullable<number>;
  6349. reset(): void;
  6350. apply(gl: WebGLRenderingContext): void;
  6351. }
  6352. }
  6353. declare module BABYLON {
  6354. /**
  6355. * @hidden
  6356. **/
  6357. export class _StencilState {
  6358. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6359. static readonly ALWAYS: number;
  6360. /** Passed to stencilOperation to specify that stencil value must be kept */
  6361. static readonly KEEP: number;
  6362. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6363. static readonly REPLACE: number;
  6364. private _isStencilTestDirty;
  6365. private _isStencilMaskDirty;
  6366. private _isStencilFuncDirty;
  6367. private _isStencilOpDirty;
  6368. private _stencilTest;
  6369. private _stencilMask;
  6370. private _stencilFunc;
  6371. private _stencilFuncRef;
  6372. private _stencilFuncMask;
  6373. private _stencilOpStencilFail;
  6374. private _stencilOpDepthFail;
  6375. private _stencilOpStencilDepthPass;
  6376. readonly isDirty: boolean;
  6377. stencilFunc: number;
  6378. stencilFuncRef: number;
  6379. stencilFuncMask: number;
  6380. stencilOpStencilFail: number;
  6381. stencilOpDepthFail: number;
  6382. stencilOpStencilDepthPass: number;
  6383. stencilMask: number;
  6384. stencilTest: boolean;
  6385. constructor();
  6386. reset(): void;
  6387. apply(gl: WebGLRenderingContext): void;
  6388. }
  6389. }
  6390. declare module BABYLON {
  6391. /**
  6392. * @hidden
  6393. **/
  6394. export class _TimeToken {
  6395. _startTimeQuery: Nullable<WebGLQuery>;
  6396. _endTimeQuery: Nullable<WebGLQuery>;
  6397. _timeElapsedQuery: Nullable<WebGLQuery>;
  6398. _timeElapsedQueryEnded: boolean;
  6399. }
  6400. }
  6401. declare module BABYLON {
  6402. /**
  6403. * Class used to store data associated with WebGL texture data for the engine
  6404. * This class should not be used directly
  6405. */
  6406. export class InternalTexture {
  6407. /** @hidden */
  6408. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6409. /**
  6410. * The source of the texture data is unknown
  6411. */
  6412. static DATASOURCE_UNKNOWN: number;
  6413. /**
  6414. * Texture data comes from an URL
  6415. */
  6416. static DATASOURCE_URL: number;
  6417. /**
  6418. * Texture data is only used for temporary storage
  6419. */
  6420. static DATASOURCE_TEMP: number;
  6421. /**
  6422. * Texture data comes from raw data (ArrayBuffer)
  6423. */
  6424. static DATASOURCE_RAW: number;
  6425. /**
  6426. * Texture content is dynamic (video or dynamic texture)
  6427. */
  6428. static DATASOURCE_DYNAMIC: number;
  6429. /**
  6430. * Texture content is generated by rendering to it
  6431. */
  6432. static DATASOURCE_RENDERTARGET: number;
  6433. /**
  6434. * Texture content is part of a multi render target process
  6435. */
  6436. static DATASOURCE_MULTIRENDERTARGET: number;
  6437. /**
  6438. * Texture data comes from a cube data file
  6439. */
  6440. static DATASOURCE_CUBE: number;
  6441. /**
  6442. * Texture data comes from a raw cube data
  6443. */
  6444. static DATASOURCE_CUBERAW: number;
  6445. /**
  6446. * Texture data come from a prefiltered cube data file
  6447. */
  6448. static DATASOURCE_CUBEPREFILTERED: number;
  6449. /**
  6450. * Texture content is raw 3D data
  6451. */
  6452. static DATASOURCE_RAW3D: number;
  6453. /**
  6454. * Texture content is a depth texture
  6455. */
  6456. static DATASOURCE_DEPTHTEXTURE: number;
  6457. /**
  6458. * Texture data comes from a raw cube data encoded with RGBD
  6459. */
  6460. static DATASOURCE_CUBERAW_RGBD: number;
  6461. /**
  6462. * Defines if the texture is ready
  6463. */
  6464. isReady: boolean;
  6465. /**
  6466. * Defines if the texture is a cube texture
  6467. */
  6468. isCube: boolean;
  6469. /**
  6470. * Defines if the texture contains 3D data
  6471. */
  6472. is3D: boolean;
  6473. /**
  6474. * Defines if the texture contains multiview data
  6475. */
  6476. isMultiview: boolean;
  6477. /**
  6478. * Gets the URL used to load this texture
  6479. */
  6480. url: string;
  6481. /**
  6482. * Gets the sampling mode of the texture
  6483. */
  6484. samplingMode: number;
  6485. /**
  6486. * Gets a boolean indicating if the texture needs mipmaps generation
  6487. */
  6488. generateMipMaps: boolean;
  6489. /**
  6490. * Gets the number of samples used by the texture (WebGL2+ only)
  6491. */
  6492. samples: number;
  6493. /**
  6494. * Gets the type of the texture (int, float...)
  6495. */
  6496. type: number;
  6497. /**
  6498. * Gets the format of the texture (RGB, RGBA...)
  6499. */
  6500. format: number;
  6501. /**
  6502. * Observable called when the texture is loaded
  6503. */
  6504. onLoadedObservable: Observable<InternalTexture>;
  6505. /**
  6506. * Gets the width of the texture
  6507. */
  6508. width: number;
  6509. /**
  6510. * Gets the height of the texture
  6511. */
  6512. height: number;
  6513. /**
  6514. * Gets the depth of the texture
  6515. */
  6516. depth: number;
  6517. /**
  6518. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6519. */
  6520. baseWidth: number;
  6521. /**
  6522. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6523. */
  6524. baseHeight: number;
  6525. /**
  6526. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6527. */
  6528. baseDepth: number;
  6529. /**
  6530. * Gets a boolean indicating if the texture is inverted on Y axis
  6531. */
  6532. invertY: boolean;
  6533. /** @hidden */
  6534. _invertVScale: boolean;
  6535. /** @hidden */
  6536. _associatedChannel: number;
  6537. /** @hidden */
  6538. _dataSource: number;
  6539. /** @hidden */
  6540. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6541. /** @hidden */
  6542. _bufferView: Nullable<ArrayBufferView>;
  6543. /** @hidden */
  6544. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6545. /** @hidden */
  6546. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6547. /** @hidden */
  6548. _size: number;
  6549. /** @hidden */
  6550. _extension: string;
  6551. /** @hidden */
  6552. _files: Nullable<string[]>;
  6553. /** @hidden */
  6554. _workingCanvas: Nullable<HTMLCanvasElement>;
  6555. /** @hidden */
  6556. _workingContext: Nullable<CanvasRenderingContext2D>;
  6557. /** @hidden */
  6558. _framebuffer: Nullable<WebGLFramebuffer>;
  6559. /** @hidden */
  6560. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6561. /** @hidden */
  6562. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6563. /** @hidden */
  6564. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6565. /** @hidden */
  6566. _attachments: Nullable<number[]>;
  6567. /** @hidden */
  6568. _cachedCoordinatesMode: Nullable<number>;
  6569. /** @hidden */
  6570. _cachedWrapU: Nullable<number>;
  6571. /** @hidden */
  6572. _cachedWrapV: Nullable<number>;
  6573. /** @hidden */
  6574. _cachedWrapR: Nullable<number>;
  6575. /** @hidden */
  6576. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6577. /** @hidden */
  6578. _isDisabled: boolean;
  6579. /** @hidden */
  6580. _compression: Nullable<string>;
  6581. /** @hidden */
  6582. _generateStencilBuffer: boolean;
  6583. /** @hidden */
  6584. _generateDepthBuffer: boolean;
  6585. /** @hidden */
  6586. _comparisonFunction: number;
  6587. /** @hidden */
  6588. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6589. /** @hidden */
  6590. _lodGenerationScale: number;
  6591. /** @hidden */
  6592. _lodGenerationOffset: number;
  6593. /** @hidden */
  6594. _colorTextureArray: Nullable<WebGLTexture>;
  6595. /** @hidden */
  6596. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6597. /** @hidden */
  6598. _lodTextureHigh: Nullable<BaseTexture>;
  6599. /** @hidden */
  6600. _lodTextureMid: Nullable<BaseTexture>;
  6601. /** @hidden */
  6602. _lodTextureLow: Nullable<BaseTexture>;
  6603. /** @hidden */
  6604. _isRGBD: boolean;
  6605. /** @hidden */
  6606. _linearSpecularLOD: boolean;
  6607. /** @hidden */
  6608. _irradianceTexture: Nullable<BaseTexture>;
  6609. /** @hidden */
  6610. _webGLTexture: Nullable<WebGLTexture>;
  6611. /** @hidden */
  6612. _references: number;
  6613. private _engine;
  6614. /**
  6615. * Gets the Engine the texture belongs to.
  6616. * @returns The babylon engine
  6617. */
  6618. getEngine(): Engine;
  6619. /**
  6620. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6621. */
  6622. readonly dataSource: number;
  6623. /**
  6624. * Creates a new InternalTexture
  6625. * @param engine defines the engine to use
  6626. * @param dataSource defines the type of data that will be used
  6627. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6628. */
  6629. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6630. /**
  6631. * Increments the number of references (ie. the number of Texture that point to it)
  6632. */
  6633. incrementReferences(): void;
  6634. /**
  6635. * Change the size of the texture (not the size of the content)
  6636. * @param width defines the new width
  6637. * @param height defines the new height
  6638. * @param depth defines the new depth (1 by default)
  6639. */
  6640. updateSize(width: int, height: int, depth?: int): void;
  6641. /** @hidden */
  6642. _rebuild(): void;
  6643. /** @hidden */
  6644. _swapAndDie(target: InternalTexture): void;
  6645. /**
  6646. * Dispose the current allocated resources
  6647. */
  6648. dispose(): void;
  6649. }
  6650. }
  6651. declare module BABYLON {
  6652. /**
  6653. * This represents the main contract an easing function should follow.
  6654. * Easing functions are used throughout the animation system.
  6655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6656. */
  6657. export interface IEasingFunction {
  6658. /**
  6659. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6660. * of the easing function.
  6661. * The link below provides some of the most common examples of easing functions.
  6662. * @see https://easings.net/
  6663. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6664. * @returns the corresponding value on the curve defined by the easing function
  6665. */
  6666. ease(gradient: number): number;
  6667. }
  6668. /**
  6669. * Base class used for every default easing function.
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class EasingFunction implements IEasingFunction {
  6673. /**
  6674. * Interpolation follows the mathematical formula associated with the easing function.
  6675. */
  6676. static readonly EASINGMODE_EASEIN: number;
  6677. /**
  6678. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6679. */
  6680. static readonly EASINGMODE_EASEOUT: number;
  6681. /**
  6682. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6683. */
  6684. static readonly EASINGMODE_EASEINOUT: number;
  6685. private _easingMode;
  6686. /**
  6687. * Sets the easing mode of the current function.
  6688. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6689. */
  6690. setEasingMode(easingMode: number): void;
  6691. /**
  6692. * Gets the current easing mode.
  6693. * @returns the easing mode
  6694. */
  6695. getEasingMode(): number;
  6696. /**
  6697. * @hidden
  6698. */
  6699. easeInCore(gradient: number): number;
  6700. /**
  6701. * Given an input gradient between 0 and 1, this returns the corresponding value
  6702. * of the easing function.
  6703. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6704. * @returns the corresponding value on the curve defined by the easing function
  6705. */
  6706. ease(gradient: number): number;
  6707. }
  6708. /**
  6709. * Easing function with a circle shape (see link below).
  6710. * @see https://easings.net/#easeInCirc
  6711. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6712. */
  6713. export class CircleEase extends EasingFunction implements IEasingFunction {
  6714. /** @hidden */
  6715. easeInCore(gradient: number): number;
  6716. }
  6717. /**
  6718. * Easing function with a ease back shape (see link below).
  6719. * @see https://easings.net/#easeInBack
  6720. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6721. */
  6722. export class BackEase extends EasingFunction implements IEasingFunction {
  6723. /** Defines the amplitude of the function */
  6724. amplitude: number;
  6725. /**
  6726. * Instantiates a back ease easing
  6727. * @see https://easings.net/#easeInBack
  6728. * @param amplitude Defines the amplitude of the function
  6729. */
  6730. constructor(
  6731. /** Defines the amplitude of the function */
  6732. amplitude?: number);
  6733. /** @hidden */
  6734. easeInCore(gradient: number): number;
  6735. }
  6736. /**
  6737. * Easing function with a bouncing shape (see link below).
  6738. * @see https://easings.net/#easeInBounce
  6739. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6740. */
  6741. export class BounceEase extends EasingFunction implements IEasingFunction {
  6742. /** Defines the number of bounces */
  6743. bounces: number;
  6744. /** Defines the amplitude of the bounce */
  6745. bounciness: number;
  6746. /**
  6747. * Instantiates a bounce easing
  6748. * @see https://easings.net/#easeInBounce
  6749. * @param bounces Defines the number of bounces
  6750. * @param bounciness Defines the amplitude of the bounce
  6751. */
  6752. constructor(
  6753. /** Defines the number of bounces */
  6754. bounces?: number,
  6755. /** Defines the amplitude of the bounce */
  6756. bounciness?: number);
  6757. /** @hidden */
  6758. easeInCore(gradient: number): number;
  6759. }
  6760. /**
  6761. * Easing function with a power of 3 shape (see link below).
  6762. * @see https://easings.net/#easeInCubic
  6763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6764. */
  6765. export class CubicEase extends EasingFunction implements IEasingFunction {
  6766. /** @hidden */
  6767. easeInCore(gradient: number): number;
  6768. }
  6769. /**
  6770. * Easing function with an elastic shape (see link below).
  6771. * @see https://easings.net/#easeInElastic
  6772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6773. */
  6774. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6775. /** Defines the number of oscillations*/
  6776. oscillations: number;
  6777. /** Defines the amplitude of the oscillations*/
  6778. springiness: number;
  6779. /**
  6780. * Instantiates an elastic easing function
  6781. * @see https://easings.net/#easeInElastic
  6782. * @param oscillations Defines the number of oscillations
  6783. * @param springiness Defines the amplitude of the oscillations
  6784. */
  6785. constructor(
  6786. /** Defines the number of oscillations*/
  6787. oscillations?: number,
  6788. /** Defines the amplitude of the oscillations*/
  6789. springiness?: number);
  6790. /** @hidden */
  6791. easeInCore(gradient: number): number;
  6792. }
  6793. /**
  6794. * Easing function with an exponential shape (see link below).
  6795. * @see https://easings.net/#easeInExpo
  6796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6797. */
  6798. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6799. /** Defines the exponent of the function */
  6800. exponent: number;
  6801. /**
  6802. * Instantiates an exponential easing function
  6803. * @see https://easings.net/#easeInExpo
  6804. * @param exponent Defines the exponent of the function
  6805. */
  6806. constructor(
  6807. /** Defines the exponent of the function */
  6808. exponent?: number);
  6809. /** @hidden */
  6810. easeInCore(gradient: number): number;
  6811. }
  6812. /**
  6813. * Easing function with a power shape (see link below).
  6814. * @see https://easings.net/#easeInQuad
  6815. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6816. */
  6817. export class PowerEase extends EasingFunction implements IEasingFunction {
  6818. /** Defines the power of the function */
  6819. power: number;
  6820. /**
  6821. * Instantiates an power base easing function
  6822. * @see https://easings.net/#easeInQuad
  6823. * @param power Defines the power of the function
  6824. */
  6825. constructor(
  6826. /** Defines the power of the function */
  6827. power?: number);
  6828. /** @hidden */
  6829. easeInCore(gradient: number): number;
  6830. }
  6831. /**
  6832. * Easing function with a power of 2 shape (see link below).
  6833. * @see https://easings.net/#easeInQuad
  6834. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6835. */
  6836. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6837. /** @hidden */
  6838. easeInCore(gradient: number): number;
  6839. }
  6840. /**
  6841. * Easing function with a power of 4 shape (see link below).
  6842. * @see https://easings.net/#easeInQuart
  6843. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6844. */
  6845. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6846. /** @hidden */
  6847. easeInCore(gradient: number): number;
  6848. }
  6849. /**
  6850. * Easing function with a power of 5 shape (see link below).
  6851. * @see https://easings.net/#easeInQuint
  6852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6853. */
  6854. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6855. /** @hidden */
  6856. easeInCore(gradient: number): number;
  6857. }
  6858. /**
  6859. * Easing function with a sin shape (see link below).
  6860. * @see https://easings.net/#easeInSine
  6861. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6862. */
  6863. export class SineEase extends EasingFunction implements IEasingFunction {
  6864. /** @hidden */
  6865. easeInCore(gradient: number): number;
  6866. }
  6867. /**
  6868. * Easing function with a bezier shape (see link below).
  6869. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6870. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6871. */
  6872. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6873. /** Defines the x component of the start tangent in the bezier curve */
  6874. x1: number;
  6875. /** Defines the y component of the start tangent in the bezier curve */
  6876. y1: number;
  6877. /** Defines the x component of the end tangent in the bezier curve */
  6878. x2: number;
  6879. /** Defines the y component of the end tangent in the bezier curve */
  6880. y2: number;
  6881. /**
  6882. * Instantiates a bezier function
  6883. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6884. * @param x1 Defines the x component of the start tangent in the bezier curve
  6885. * @param y1 Defines the y component of the start tangent in the bezier curve
  6886. * @param x2 Defines the x component of the end tangent in the bezier curve
  6887. * @param y2 Defines the y component of the end tangent in the bezier curve
  6888. */
  6889. constructor(
  6890. /** Defines the x component of the start tangent in the bezier curve */
  6891. x1?: number,
  6892. /** Defines the y component of the start tangent in the bezier curve */
  6893. y1?: number,
  6894. /** Defines the x component of the end tangent in the bezier curve */
  6895. x2?: number,
  6896. /** Defines the y component of the end tangent in the bezier curve */
  6897. y2?: number);
  6898. /** @hidden */
  6899. easeInCore(gradient: number): number;
  6900. }
  6901. }
  6902. declare module BABYLON {
  6903. /**
  6904. * Defines an interface which represents an animation key frame
  6905. */
  6906. export interface IAnimationKey {
  6907. /**
  6908. * Frame of the key frame
  6909. */
  6910. frame: number;
  6911. /**
  6912. * Value at the specifies key frame
  6913. */
  6914. value: any;
  6915. /**
  6916. * The input tangent for the cubic hermite spline
  6917. */
  6918. inTangent?: any;
  6919. /**
  6920. * The output tangent for the cubic hermite spline
  6921. */
  6922. outTangent?: any;
  6923. /**
  6924. * The animation interpolation type
  6925. */
  6926. interpolation?: AnimationKeyInterpolation;
  6927. }
  6928. /**
  6929. * Enum for the animation key frame interpolation type
  6930. */
  6931. export enum AnimationKeyInterpolation {
  6932. /**
  6933. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6934. */
  6935. STEP = 1
  6936. }
  6937. }
  6938. declare module BABYLON {
  6939. /**
  6940. * Represents the range of an animation
  6941. */
  6942. export class AnimationRange {
  6943. /**The name of the animation range**/
  6944. name: string;
  6945. /**The starting frame of the animation */
  6946. from: number;
  6947. /**The ending frame of the animation*/
  6948. to: number;
  6949. /**
  6950. * Initializes the range of an animation
  6951. * @param name The name of the animation range
  6952. * @param from The starting frame of the animation
  6953. * @param to The ending frame of the animation
  6954. */
  6955. constructor(
  6956. /**The name of the animation range**/
  6957. name: string,
  6958. /**The starting frame of the animation */
  6959. from: number,
  6960. /**The ending frame of the animation*/
  6961. to: number);
  6962. /**
  6963. * Makes a copy of the animation range
  6964. * @returns A copy of the animation range
  6965. */
  6966. clone(): AnimationRange;
  6967. }
  6968. }
  6969. declare module BABYLON {
  6970. /**
  6971. * Composed of a frame, and an action function
  6972. */
  6973. export class AnimationEvent {
  6974. /** The frame for which the event is triggered **/
  6975. frame: number;
  6976. /** The event to perform when triggered **/
  6977. action: (currentFrame: number) => void;
  6978. /** Specifies if the event should be triggered only once**/
  6979. onlyOnce?: boolean | undefined;
  6980. /**
  6981. * Specifies if the animation event is done
  6982. */
  6983. isDone: boolean;
  6984. /**
  6985. * Initializes the animation event
  6986. * @param frame The frame for which the event is triggered
  6987. * @param action The event to perform when triggered
  6988. * @param onlyOnce Specifies if the event should be triggered only once
  6989. */
  6990. constructor(
  6991. /** The frame for which the event is triggered **/
  6992. frame: number,
  6993. /** The event to perform when triggered **/
  6994. action: (currentFrame: number) => void,
  6995. /** Specifies if the event should be triggered only once**/
  6996. onlyOnce?: boolean | undefined);
  6997. /** @hidden */
  6998. _clone(): AnimationEvent;
  6999. }
  7000. }
  7001. declare module BABYLON {
  7002. /**
  7003. * Interface used to define a behavior
  7004. */
  7005. export interface Behavior<T> {
  7006. /** gets or sets behavior's name */
  7007. name: string;
  7008. /**
  7009. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7010. */
  7011. init(): void;
  7012. /**
  7013. * Called when the behavior is attached to a target
  7014. * @param target defines the target where the behavior is attached to
  7015. */
  7016. attach(target: T): void;
  7017. /**
  7018. * Called when the behavior is detached from its target
  7019. */
  7020. detach(): void;
  7021. }
  7022. /**
  7023. * Interface implemented by classes supporting behaviors
  7024. */
  7025. export interface IBehaviorAware<T> {
  7026. /**
  7027. * Attach a behavior
  7028. * @param behavior defines the behavior to attach
  7029. * @returns the current host
  7030. */
  7031. addBehavior(behavior: Behavior<T>): T;
  7032. /**
  7033. * Remove a behavior from the current object
  7034. * @param behavior defines the behavior to detach
  7035. * @returns the current host
  7036. */
  7037. removeBehavior(behavior: Behavior<T>): T;
  7038. /**
  7039. * Gets a behavior using its name to search
  7040. * @param name defines the name to search
  7041. * @returns the behavior or null if not found
  7042. */
  7043. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7044. }
  7045. }
  7046. declare module BABYLON {
  7047. /**
  7048. * @hidden
  7049. */
  7050. export class IntersectionInfo {
  7051. bu: Nullable<number>;
  7052. bv: Nullable<number>;
  7053. distance: number;
  7054. faceId: number;
  7055. subMeshId: number;
  7056. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7057. }
  7058. }
  7059. declare module BABYLON {
  7060. /**
  7061. * Class used to store bounding sphere information
  7062. */
  7063. export class BoundingSphere {
  7064. /**
  7065. * Gets the center of the bounding sphere in local space
  7066. */
  7067. readonly center: Vector3;
  7068. /**
  7069. * Radius of the bounding sphere in local space
  7070. */
  7071. radius: number;
  7072. /**
  7073. * Gets the center of the bounding sphere in world space
  7074. */
  7075. readonly centerWorld: Vector3;
  7076. /**
  7077. * Radius of the bounding sphere in world space
  7078. */
  7079. radiusWorld: number;
  7080. /**
  7081. * Gets the minimum vector in local space
  7082. */
  7083. readonly minimum: Vector3;
  7084. /**
  7085. * Gets the maximum vector in local space
  7086. */
  7087. readonly maximum: Vector3;
  7088. private _worldMatrix;
  7089. private static readonly TmpVector3;
  7090. /**
  7091. * Creates a new bounding sphere
  7092. * @param min defines the minimum vector (in local space)
  7093. * @param max defines the maximum vector (in local space)
  7094. * @param worldMatrix defines the new world matrix
  7095. */
  7096. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7097. /**
  7098. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7099. * @param min defines the new minimum vector (in local space)
  7100. * @param max defines the new maximum vector (in local space)
  7101. * @param worldMatrix defines the new world matrix
  7102. */
  7103. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7104. /**
  7105. * Scale the current bounding sphere by applying a scale factor
  7106. * @param factor defines the scale factor to apply
  7107. * @returns the current bounding box
  7108. */
  7109. scale(factor: number): BoundingSphere;
  7110. /**
  7111. * Gets the world matrix of the bounding box
  7112. * @returns a matrix
  7113. */
  7114. getWorldMatrix(): DeepImmutable<Matrix>;
  7115. /** @hidden */
  7116. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7117. /**
  7118. * Tests if the bounding sphere is intersecting the frustum planes
  7119. * @param frustumPlanes defines the frustum planes to test
  7120. * @returns true if there is an intersection
  7121. */
  7122. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7123. /**
  7124. * Tests if the bounding sphere center is in between the frustum planes.
  7125. * Used for optimistic fast inclusion.
  7126. * @param frustumPlanes defines the frustum planes to test
  7127. * @returns true if the sphere center is in between the frustum planes
  7128. */
  7129. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7130. /**
  7131. * Tests if a point is inside the bounding sphere
  7132. * @param point defines the point to test
  7133. * @returns true if the point is inside the bounding sphere
  7134. */
  7135. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7136. /**
  7137. * Checks if two sphere intersct
  7138. * @param sphere0 sphere 0
  7139. * @param sphere1 sphere 1
  7140. * @returns true if the speres intersect
  7141. */
  7142. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7143. }
  7144. }
  7145. declare module BABYLON {
  7146. /**
  7147. * Class used to store bounding box information
  7148. */
  7149. export class BoundingBox implements ICullable {
  7150. /**
  7151. * Gets the 8 vectors representing the bounding box in local space
  7152. */
  7153. readonly vectors: Vector3[];
  7154. /**
  7155. * Gets the center of the bounding box in local space
  7156. */
  7157. readonly center: Vector3;
  7158. /**
  7159. * Gets the center of the bounding box in world space
  7160. */
  7161. readonly centerWorld: Vector3;
  7162. /**
  7163. * Gets the extend size in local space
  7164. */
  7165. readonly extendSize: Vector3;
  7166. /**
  7167. * Gets the extend size in world space
  7168. */
  7169. readonly extendSizeWorld: Vector3;
  7170. /**
  7171. * Gets the OBB (object bounding box) directions
  7172. */
  7173. readonly directions: Vector3[];
  7174. /**
  7175. * Gets the 8 vectors representing the bounding box in world space
  7176. */
  7177. readonly vectorsWorld: Vector3[];
  7178. /**
  7179. * Gets the minimum vector in world space
  7180. */
  7181. readonly minimumWorld: Vector3;
  7182. /**
  7183. * Gets the maximum vector in world space
  7184. */
  7185. readonly maximumWorld: Vector3;
  7186. /**
  7187. * Gets the minimum vector in local space
  7188. */
  7189. readonly minimum: Vector3;
  7190. /**
  7191. * Gets the maximum vector in local space
  7192. */
  7193. readonly maximum: Vector3;
  7194. private _worldMatrix;
  7195. private static readonly TmpVector3;
  7196. /**
  7197. * @hidden
  7198. */
  7199. _tag: number;
  7200. /**
  7201. * Creates a new bounding box
  7202. * @param min defines the minimum vector (in local space)
  7203. * @param max defines the maximum vector (in local space)
  7204. * @param worldMatrix defines the new world matrix
  7205. */
  7206. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7207. /**
  7208. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7209. * @param min defines the new minimum vector (in local space)
  7210. * @param max defines the new maximum vector (in local space)
  7211. * @param worldMatrix defines the new world matrix
  7212. */
  7213. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7214. /**
  7215. * Scale the current bounding box by applying a scale factor
  7216. * @param factor defines the scale factor to apply
  7217. * @returns the current bounding box
  7218. */
  7219. scale(factor: number): BoundingBox;
  7220. /**
  7221. * Gets the world matrix of the bounding box
  7222. * @returns a matrix
  7223. */
  7224. getWorldMatrix(): DeepImmutable<Matrix>;
  7225. /** @hidden */
  7226. _update(world: DeepImmutable<Matrix>): void;
  7227. /**
  7228. * Tests if the bounding box is intersecting the frustum planes
  7229. * @param frustumPlanes defines the frustum planes to test
  7230. * @returns true if there is an intersection
  7231. */
  7232. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7233. /**
  7234. * Tests if the bounding box is entirely inside the frustum planes
  7235. * @param frustumPlanes defines the frustum planes to test
  7236. * @returns true if there is an inclusion
  7237. */
  7238. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7239. /**
  7240. * Tests if a point is inside the bounding box
  7241. * @param point defines the point to test
  7242. * @returns true if the point is inside the bounding box
  7243. */
  7244. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7245. /**
  7246. * Tests if the bounding box intersects with a bounding sphere
  7247. * @param sphere defines the sphere to test
  7248. * @returns true if there is an intersection
  7249. */
  7250. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7251. /**
  7252. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7253. * @param min defines the min vector to use
  7254. * @param max defines the max vector to use
  7255. * @returns true if there is an intersection
  7256. */
  7257. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7258. /**
  7259. * Tests if two bounding boxes are intersections
  7260. * @param box0 defines the first box to test
  7261. * @param box1 defines the second box to test
  7262. * @returns true if there is an intersection
  7263. */
  7264. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7265. /**
  7266. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7267. * @param minPoint defines the minimum vector of the bounding box
  7268. * @param maxPoint defines the maximum vector of the bounding box
  7269. * @param sphereCenter defines the sphere center
  7270. * @param sphereRadius defines the sphere radius
  7271. * @returns true if there is an intersection
  7272. */
  7273. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7274. /**
  7275. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7276. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7277. * @param frustumPlanes defines the frustum planes to test
  7278. * @return true if there is an inclusion
  7279. */
  7280. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7281. /**
  7282. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7283. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7284. * @param frustumPlanes defines the frustum planes to test
  7285. * @return true if there is an intersection
  7286. */
  7287. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7288. }
  7289. }
  7290. declare module BABYLON {
  7291. /** @hidden */
  7292. export class Collider {
  7293. /** Define if a collision was found */
  7294. collisionFound: boolean;
  7295. /**
  7296. * Define last intersection point in local space
  7297. */
  7298. intersectionPoint: Vector3;
  7299. /**
  7300. * Define last collided mesh
  7301. */
  7302. collidedMesh: Nullable<AbstractMesh>;
  7303. private _collisionPoint;
  7304. private _planeIntersectionPoint;
  7305. private _tempVector;
  7306. private _tempVector2;
  7307. private _tempVector3;
  7308. private _tempVector4;
  7309. private _edge;
  7310. private _baseToVertex;
  7311. private _destinationPoint;
  7312. private _slidePlaneNormal;
  7313. private _displacementVector;
  7314. /** @hidden */
  7315. _radius: Vector3;
  7316. /** @hidden */
  7317. _retry: number;
  7318. private _velocity;
  7319. private _basePoint;
  7320. private _epsilon;
  7321. /** @hidden */
  7322. _velocityWorldLength: number;
  7323. /** @hidden */
  7324. _basePointWorld: Vector3;
  7325. private _velocityWorld;
  7326. private _normalizedVelocity;
  7327. /** @hidden */
  7328. _initialVelocity: Vector3;
  7329. /** @hidden */
  7330. _initialPosition: Vector3;
  7331. private _nearestDistance;
  7332. private _collisionMask;
  7333. collisionMask: number;
  7334. /**
  7335. * Gets the plane normal used to compute the sliding response (in local space)
  7336. */
  7337. readonly slidePlaneNormal: Vector3;
  7338. /** @hidden */
  7339. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7340. /** @hidden */
  7341. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7342. /** @hidden */
  7343. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7344. /** @hidden */
  7345. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7346. /** @hidden */
  7347. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7348. /** @hidden */
  7349. _getResponse(pos: Vector3, vel: Vector3): void;
  7350. }
  7351. }
  7352. declare module BABYLON {
  7353. /**
  7354. * Interface for cullable objects
  7355. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7356. */
  7357. export interface ICullable {
  7358. /**
  7359. * Checks if the object or part of the object is in the frustum
  7360. * @param frustumPlanes Camera near/planes
  7361. * @returns true if the object is in frustum otherwise false
  7362. */
  7363. isInFrustum(frustumPlanes: Plane[]): boolean;
  7364. /**
  7365. * Checks if a cullable object (mesh...) is in the camera frustum
  7366. * Unlike isInFrustum this cheks the full bounding box
  7367. * @param frustumPlanes Camera near/planes
  7368. * @returns true if the object is in frustum otherwise false
  7369. */
  7370. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7371. }
  7372. /**
  7373. * Info for a bounding data of a mesh
  7374. */
  7375. export class BoundingInfo implements ICullable {
  7376. /**
  7377. * Bounding box for the mesh
  7378. */
  7379. readonly boundingBox: BoundingBox;
  7380. /**
  7381. * Bounding sphere for the mesh
  7382. */
  7383. readonly boundingSphere: BoundingSphere;
  7384. private _isLocked;
  7385. private static readonly TmpVector3;
  7386. /**
  7387. * Constructs bounding info
  7388. * @param minimum min vector of the bounding box/sphere
  7389. * @param maximum max vector of the bounding box/sphere
  7390. * @param worldMatrix defines the new world matrix
  7391. */
  7392. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7393. /**
  7394. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7395. * @param min defines the new minimum vector (in local space)
  7396. * @param max defines the new maximum vector (in local space)
  7397. * @param worldMatrix defines the new world matrix
  7398. */
  7399. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7400. /**
  7401. * min vector of the bounding box/sphere
  7402. */
  7403. readonly minimum: Vector3;
  7404. /**
  7405. * max vector of the bounding box/sphere
  7406. */
  7407. readonly maximum: Vector3;
  7408. /**
  7409. * If the info is locked and won't be updated to avoid perf overhead
  7410. */
  7411. isLocked: boolean;
  7412. /**
  7413. * Updates the bounding sphere and box
  7414. * @param world world matrix to be used to update
  7415. */
  7416. update(world: DeepImmutable<Matrix>): void;
  7417. /**
  7418. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7419. * @param center New center of the bounding info
  7420. * @param extend New extend of the bounding info
  7421. * @returns the current bounding info
  7422. */
  7423. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7424. /**
  7425. * Scale the current bounding info by applying a scale factor
  7426. * @param factor defines the scale factor to apply
  7427. * @returns the current bounding info
  7428. */
  7429. scale(factor: number): BoundingInfo;
  7430. /**
  7431. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7432. * @param frustumPlanes defines the frustum to test
  7433. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7434. * @returns true if the bounding info is in the frustum planes
  7435. */
  7436. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7437. /**
  7438. * Gets the world distance between the min and max points of the bounding box
  7439. */
  7440. readonly diagonalLength: number;
  7441. /**
  7442. * Checks if a cullable object (mesh...) is in the camera frustum
  7443. * Unlike isInFrustum this cheks the full bounding box
  7444. * @param frustumPlanes Camera near/planes
  7445. * @returns true if the object is in frustum otherwise false
  7446. */
  7447. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7448. /** @hidden */
  7449. _checkCollision(collider: Collider): boolean;
  7450. /**
  7451. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7452. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7453. * @param point the point to check intersection with
  7454. * @returns if the point intersects
  7455. */
  7456. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7457. /**
  7458. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7459. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7460. * @param boundingInfo the bounding info to check intersection with
  7461. * @param precise if the intersection should be done using OBB
  7462. * @returns if the bounding info intersects
  7463. */
  7464. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7465. }
  7466. }
  7467. declare module BABYLON {
  7468. /**
  7469. * Defines an array and its length.
  7470. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7471. */
  7472. export interface ISmartArrayLike<T> {
  7473. /**
  7474. * The data of the array.
  7475. */
  7476. data: Array<T>;
  7477. /**
  7478. * The active length of the array.
  7479. */
  7480. length: number;
  7481. }
  7482. /**
  7483. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7484. */
  7485. export class SmartArray<T> implements ISmartArrayLike<T> {
  7486. /**
  7487. * The full set of data from the array.
  7488. */
  7489. data: Array<T>;
  7490. /**
  7491. * The active length of the array.
  7492. */
  7493. length: number;
  7494. protected _id: number;
  7495. /**
  7496. * Instantiates a Smart Array.
  7497. * @param capacity defines the default capacity of the array.
  7498. */
  7499. constructor(capacity: number);
  7500. /**
  7501. * Pushes a value at the end of the active data.
  7502. * @param value defines the object to push in the array.
  7503. */
  7504. push(value: T): void;
  7505. /**
  7506. * Iterates over the active data and apply the lambda to them.
  7507. * @param func defines the action to apply on each value.
  7508. */
  7509. forEach(func: (content: T) => void): void;
  7510. /**
  7511. * Sorts the full sets of data.
  7512. * @param compareFn defines the comparison function to apply.
  7513. */
  7514. sort(compareFn: (a: T, b: T) => number): void;
  7515. /**
  7516. * Resets the active data to an empty array.
  7517. */
  7518. reset(): void;
  7519. /**
  7520. * Releases all the data from the array as well as the array.
  7521. */
  7522. dispose(): void;
  7523. /**
  7524. * Concats the active data with a given array.
  7525. * @param array defines the data to concatenate with.
  7526. */
  7527. concat(array: any): void;
  7528. /**
  7529. * Returns the position of a value in the active data.
  7530. * @param value defines the value to find the index for
  7531. * @returns the index if found in the active data otherwise -1
  7532. */
  7533. indexOf(value: T): number;
  7534. /**
  7535. * Returns whether an element is part of the active data.
  7536. * @param value defines the value to look for
  7537. * @returns true if found in the active data otherwise false
  7538. */
  7539. contains(value: T): boolean;
  7540. private static _GlobalId;
  7541. }
  7542. /**
  7543. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7544. * The data in this array can only be present once
  7545. */
  7546. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7547. private _duplicateId;
  7548. /**
  7549. * Pushes a value at the end of the active data.
  7550. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7551. * @param value defines the object to push in the array.
  7552. */
  7553. push(value: T): void;
  7554. /**
  7555. * Pushes a value at the end of the active data.
  7556. * If the data is already present, it won t be added again
  7557. * @param value defines the object to push in the array.
  7558. * @returns true if added false if it was already present
  7559. */
  7560. pushNoDuplicate(value: T): boolean;
  7561. /**
  7562. * Resets the active data to an empty array.
  7563. */
  7564. reset(): void;
  7565. /**
  7566. * Concats the active data with a given array.
  7567. * This ensures no dupplicate will be present in the result.
  7568. * @param array defines the data to concatenate with.
  7569. */
  7570. concatWithNoDuplicate(array: any): void;
  7571. }
  7572. }
  7573. declare module BABYLON {
  7574. /**
  7575. * Enum that determines the text-wrapping mode to use.
  7576. */
  7577. export enum InspectableType {
  7578. /**
  7579. * Checkbox for booleans
  7580. */
  7581. Checkbox = 0,
  7582. /**
  7583. * Sliders for numbers
  7584. */
  7585. Slider = 1,
  7586. /**
  7587. * Vector3
  7588. */
  7589. Vector3 = 2,
  7590. /**
  7591. * Quaternions
  7592. */
  7593. Quaternion = 3,
  7594. /**
  7595. * Color3
  7596. */
  7597. Color3 = 4,
  7598. /**
  7599. * String
  7600. */
  7601. String = 5
  7602. }
  7603. /**
  7604. * Interface used to define custom inspectable properties.
  7605. * This interface is used by the inspector to display custom property grids
  7606. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7607. */
  7608. export interface IInspectable {
  7609. /**
  7610. * Gets the label to display
  7611. */
  7612. label: string;
  7613. /**
  7614. * Gets the name of the property to edit
  7615. */
  7616. propertyName: string;
  7617. /**
  7618. * Gets the type of the editor to use
  7619. */
  7620. type: InspectableType;
  7621. /**
  7622. * Gets the minimum value of the property when using in "slider" mode
  7623. */
  7624. min?: number;
  7625. /**
  7626. * Gets the maximum value of the property when using in "slider" mode
  7627. */
  7628. max?: number;
  7629. /**
  7630. * Gets the setp to use when using in "slider" mode
  7631. */
  7632. step?: number;
  7633. }
  7634. }
  7635. declare module BABYLON {
  7636. /**
  7637. * This represents the required contract to create a new type of texture loader.
  7638. */
  7639. export interface IInternalTextureLoader {
  7640. /**
  7641. * Defines wether the loader supports cascade loading the different faces.
  7642. */
  7643. supportCascades: boolean;
  7644. /**
  7645. * This returns if the loader support the current file information.
  7646. * @param extension defines the file extension of the file being loaded
  7647. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7648. * @param fallback defines the fallback internal texture if any
  7649. * @param isBase64 defines whether the texture is encoded as a base64
  7650. * @param isBuffer defines whether the texture data are stored as a buffer
  7651. * @returns true if the loader can load the specified file
  7652. */
  7653. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7654. /**
  7655. * Transform the url before loading if required.
  7656. * @param rootUrl the url of the texture
  7657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7658. * @returns the transformed texture
  7659. */
  7660. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7661. /**
  7662. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7663. * @param rootUrl the url of the texture
  7664. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7665. * @returns the fallback texture
  7666. */
  7667. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7668. /**
  7669. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7670. * @param data contains the texture data
  7671. * @param texture defines the BabylonJS internal texture
  7672. * @param createPolynomials will be true if polynomials have been requested
  7673. * @param onLoad defines the callback to trigger once the texture is ready
  7674. * @param onError defines the callback to trigger in case of error
  7675. */
  7676. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7677. /**
  7678. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7679. * @param data contains the texture data
  7680. * @param texture defines the BabylonJS internal texture
  7681. * @param callback defines the method to call once ready to upload
  7682. */
  7683. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7684. }
  7685. }
  7686. declare module BABYLON {
  7687. interface Engine {
  7688. /**
  7689. * Creates a depth stencil cube texture.
  7690. * This is only available in WebGL 2.
  7691. * @param size The size of face edge in the cube texture.
  7692. * @param options The options defining the cube texture.
  7693. * @returns The cube texture
  7694. */
  7695. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7696. /**
  7697. * Creates a cube texture
  7698. * @param rootUrl defines the url where the files to load is located
  7699. * @param scene defines the current scene
  7700. * @param files defines the list of files to load (1 per face)
  7701. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7702. * @param onLoad defines an optional callback raised when the texture is loaded
  7703. * @param onError defines an optional callback raised if there is an issue to load the texture
  7704. * @param format defines the format of the data
  7705. * @param forcedExtension defines the extension to use to pick the right loader
  7706. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7707. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7708. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7709. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7710. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7711. * @returns the cube texture as an InternalTexture
  7712. */
  7713. 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;
  7714. /**
  7715. * Creates a cube texture
  7716. * @param rootUrl defines the url where the files to load is located
  7717. * @param scene defines the current scene
  7718. * @param files defines the list of files to load (1 per face)
  7719. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7720. * @param onLoad defines an optional callback raised when the texture is loaded
  7721. * @param onError defines an optional callback raised if there is an issue to load the texture
  7722. * @param format defines the format of the data
  7723. * @param forcedExtension defines the extension to use to pick the right loader
  7724. * @returns the cube texture as an InternalTexture
  7725. */
  7726. 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;
  7727. /**
  7728. * Creates a cube texture
  7729. * @param rootUrl defines the url where the files to load is located
  7730. * @param scene defines the current scene
  7731. * @param files defines the list of files to load (1 per face)
  7732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7733. * @param onLoad defines an optional callback raised when the texture is loaded
  7734. * @param onError defines an optional callback raised if there is an issue to load the texture
  7735. * @param format defines the format of the data
  7736. * @param forcedExtension defines the extension to use to pick the right loader
  7737. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7738. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7739. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7740. * @returns the cube texture as an InternalTexture
  7741. */
  7742. 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;
  7743. /** @hidden */
  7744. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7745. /** @hidden */
  7746. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7747. /** @hidden */
  7748. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7749. /** @hidden */
  7750. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7751. }
  7752. }
  7753. declare module BABYLON {
  7754. /**
  7755. * Class for creating a cube texture
  7756. */
  7757. export class CubeTexture extends BaseTexture {
  7758. private _delayedOnLoad;
  7759. /**
  7760. * The url of the texture
  7761. */
  7762. url: string;
  7763. /**
  7764. * Gets or sets the center of the bounding box associated with the cube texture.
  7765. * It must define where the camera used to render the texture was set
  7766. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7767. */
  7768. boundingBoxPosition: Vector3;
  7769. private _boundingBoxSize;
  7770. /**
  7771. * Gets or sets the size of the bounding box associated with the cube texture
  7772. * When defined, the cubemap will switch to local mode
  7773. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7774. * @example https://www.babylonjs-playground.com/#RNASML
  7775. */
  7776. /**
  7777. * Returns the bounding box size
  7778. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7779. */
  7780. boundingBoxSize: Vector3;
  7781. protected _rotationY: number;
  7782. /**
  7783. * Sets texture matrix rotation angle around Y axis in radians.
  7784. */
  7785. /**
  7786. * Gets texture matrix rotation angle around Y axis radians.
  7787. */
  7788. rotationY: number;
  7789. /**
  7790. * Are mip maps generated for this texture or not.
  7791. */
  7792. readonly noMipmap: boolean;
  7793. private _noMipmap;
  7794. private _files;
  7795. private _extensions;
  7796. private _textureMatrix;
  7797. private _format;
  7798. private _createPolynomials;
  7799. /** @hidden */
  7800. _prefiltered: boolean;
  7801. /**
  7802. * Creates a cube texture from an array of image urls
  7803. * @param files defines an array of image urls
  7804. * @param scene defines the hosting scene
  7805. * @param noMipmap specifies if mip maps are not used
  7806. * @returns a cube texture
  7807. */
  7808. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7809. /**
  7810. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7811. * @param url defines the url of the prefiltered texture
  7812. * @param scene defines the scene the texture is attached to
  7813. * @param forcedExtension defines the extension of the file if different from the url
  7814. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7815. * @return the prefiltered texture
  7816. */
  7817. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7818. /**
  7819. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7820. * as prefiltered data.
  7821. * @param rootUrl defines the url of the texture or the root name of the six images
  7822. * @param scene defines the scene the texture is attached to
  7823. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7824. * @param noMipmap defines if mipmaps should be created or not
  7825. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7826. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7827. * @param onError defines a callback triggered in case of error during load
  7828. * @param format defines the internal format to use for the texture once loaded
  7829. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7830. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7831. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7832. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7833. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7834. * @return the cube texture
  7835. */
  7836. 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);
  7837. /**
  7838. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7839. */
  7840. readonly isPrefiltered: boolean;
  7841. /**
  7842. * Get the current class name of the texture useful for serialization or dynamic coding.
  7843. * @returns "CubeTexture"
  7844. */
  7845. getClassName(): string;
  7846. /**
  7847. * Update the url (and optional buffer) of this texture if url was null during construction.
  7848. * @param url the url of the texture
  7849. * @param forcedExtension defines the extension to use
  7850. * @param onLoad callback called when the texture is loaded (defaults to null)
  7851. */
  7852. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7853. /**
  7854. * Delays loading of the cube texture
  7855. * @param forcedExtension defines the extension to use
  7856. */
  7857. delayLoad(forcedExtension?: string): void;
  7858. /**
  7859. * Returns the reflection texture matrix
  7860. * @returns the reflection texture matrix
  7861. */
  7862. getReflectionTextureMatrix(): Matrix;
  7863. /**
  7864. * Sets the reflection texture matrix
  7865. * @param value Reflection texture matrix
  7866. */
  7867. setReflectionTextureMatrix(value: Matrix): void;
  7868. /**
  7869. * Parses text to create a cube texture
  7870. * @param parsedTexture define the serialized text to read from
  7871. * @param scene defines the hosting scene
  7872. * @param rootUrl defines the root url of the cube texture
  7873. * @returns a cube texture
  7874. */
  7875. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7876. /**
  7877. * Makes a clone, or deep copy, of the cube texture
  7878. * @returns a new cube texture
  7879. */
  7880. clone(): CubeTexture;
  7881. }
  7882. }
  7883. declare module BABYLON {
  7884. /** @hidden */
  7885. export var postprocessVertexShader: {
  7886. name: string;
  7887. shader: string;
  7888. };
  7889. }
  7890. declare module BABYLON {
  7891. /**
  7892. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7893. * This is the base of the follow, arc rotate cameras and Free camera
  7894. * @see http://doc.babylonjs.com/features/cameras
  7895. */
  7896. export class TargetCamera extends Camera {
  7897. private static _RigCamTransformMatrix;
  7898. private static _TargetTransformMatrix;
  7899. private static _TargetFocalPoint;
  7900. /**
  7901. * Define the current direction the camera is moving to
  7902. */
  7903. cameraDirection: Vector3;
  7904. /**
  7905. * Define the current rotation the camera is rotating to
  7906. */
  7907. cameraRotation: Vector2;
  7908. /**
  7909. * When set, the up vector of the camera will be updated by the rotation of the camera
  7910. */
  7911. updateUpVectorFromRotation: boolean;
  7912. private _tmpQuaternion;
  7913. /**
  7914. * Define the current rotation of the camera
  7915. */
  7916. rotation: Vector3;
  7917. /**
  7918. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7919. */
  7920. rotationQuaternion: Quaternion;
  7921. /**
  7922. * Define the current speed of the camera
  7923. */
  7924. speed: number;
  7925. /**
  7926. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7927. * around all axis.
  7928. */
  7929. noRotationConstraint: boolean;
  7930. /**
  7931. * Define the current target of the camera as an object or a position.
  7932. */
  7933. lockedTarget: any;
  7934. /** @hidden */
  7935. _currentTarget: Vector3;
  7936. /** @hidden */
  7937. _initialFocalDistance: number;
  7938. /** @hidden */
  7939. _viewMatrix: Matrix;
  7940. /** @hidden */
  7941. _camMatrix: Matrix;
  7942. /** @hidden */
  7943. _cameraTransformMatrix: Matrix;
  7944. /** @hidden */
  7945. _cameraRotationMatrix: Matrix;
  7946. /** @hidden */
  7947. _referencePoint: Vector3;
  7948. /** @hidden */
  7949. _transformedReferencePoint: Vector3;
  7950. protected _globalCurrentTarget: Vector3;
  7951. protected _globalCurrentUpVector: Vector3;
  7952. /** @hidden */
  7953. _reset: () => void;
  7954. private _defaultUp;
  7955. /**
  7956. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7957. * This is the base of the follow, arc rotate cameras and Free camera
  7958. * @see http://doc.babylonjs.com/features/cameras
  7959. * @param name Defines the name of the camera in the scene
  7960. * @param position Defines the start position of the camera in the scene
  7961. * @param scene Defines the scene the camera belongs to
  7962. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7963. */
  7964. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7965. /**
  7966. * Gets the position in front of the camera at a given distance.
  7967. * @param distance The distance from the camera we want the position to be
  7968. * @returns the position
  7969. */
  7970. getFrontPosition(distance: number): Vector3;
  7971. /** @hidden */
  7972. _getLockedTargetPosition(): Nullable<Vector3>;
  7973. private _storedPosition;
  7974. private _storedRotation;
  7975. private _storedRotationQuaternion;
  7976. /**
  7977. * Store current camera state of the camera (fov, position, rotation, etc..)
  7978. * @returns the camera
  7979. */
  7980. storeState(): Camera;
  7981. /**
  7982. * Restored camera state. You must call storeState() first
  7983. * @returns whether it was successful or not
  7984. * @hidden
  7985. */
  7986. _restoreStateValues(): boolean;
  7987. /** @hidden */
  7988. _initCache(): void;
  7989. /** @hidden */
  7990. _updateCache(ignoreParentClass?: boolean): void;
  7991. /** @hidden */
  7992. _isSynchronizedViewMatrix(): boolean;
  7993. /** @hidden */
  7994. _computeLocalCameraSpeed(): number;
  7995. /**
  7996. * Defines the target the camera should look at.
  7997. * @param target Defines the new target as a Vector or a mesh
  7998. */
  7999. setTarget(target: Vector3): void;
  8000. /**
  8001. * Return the current target position of the camera. This value is expressed in local space.
  8002. * @returns the target position
  8003. */
  8004. getTarget(): Vector3;
  8005. /** @hidden */
  8006. _decideIfNeedsToMove(): boolean;
  8007. /** @hidden */
  8008. _updatePosition(): void;
  8009. /** @hidden */
  8010. _checkInputs(): void;
  8011. protected _updateCameraRotationMatrix(): void;
  8012. /**
  8013. * 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)
  8014. * @returns the current camera
  8015. */
  8016. private _rotateUpVectorWithCameraRotationMatrix;
  8017. private _cachedRotationZ;
  8018. private _cachedQuaternionRotationZ;
  8019. /** @hidden */
  8020. _getViewMatrix(): Matrix;
  8021. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8022. /**
  8023. * @hidden
  8024. */
  8025. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8026. /**
  8027. * @hidden
  8028. */
  8029. _updateRigCameras(): void;
  8030. private _getRigCamPositionAndTarget;
  8031. /**
  8032. * Gets the current object class name.
  8033. * @return the class name
  8034. */
  8035. getClassName(): string;
  8036. }
  8037. }
  8038. declare module BABYLON {
  8039. /**
  8040. * @ignore
  8041. * This is a list of all the different input types that are available in the application.
  8042. * Fo instance: ArcRotateCameraGamepadInput...
  8043. */
  8044. export var CameraInputTypes: {};
  8045. /**
  8046. * This is the contract to implement in order to create a new input class.
  8047. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8048. */
  8049. export interface ICameraInput<TCamera extends Camera> {
  8050. /**
  8051. * Defines the camera the input is attached to.
  8052. */
  8053. camera: Nullable<TCamera>;
  8054. /**
  8055. * Gets the class name of the current intput.
  8056. * @returns the class name
  8057. */
  8058. getClassName(): string;
  8059. /**
  8060. * Get the friendly name associated with the input class.
  8061. * @returns the input friendly name
  8062. */
  8063. getSimpleName(): string;
  8064. /**
  8065. * Attach the input controls to a specific dom element to get the input from.
  8066. * @param element Defines the element the controls should be listened from
  8067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8068. */
  8069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8070. /**
  8071. * Detach the current controls from the specified dom element.
  8072. * @param element Defines the element to stop listening the inputs from
  8073. */
  8074. detachControl(element: Nullable<HTMLElement>): void;
  8075. /**
  8076. * Update the current camera state depending on the inputs that have been used this frame.
  8077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8078. */
  8079. checkInputs?: () => void;
  8080. }
  8081. /**
  8082. * Represents a map of input types to input instance or input index to input instance.
  8083. */
  8084. export interface CameraInputsMap<TCamera extends Camera> {
  8085. /**
  8086. * Accessor to the input by input type.
  8087. */
  8088. [name: string]: ICameraInput<TCamera>;
  8089. /**
  8090. * Accessor to the input by input index.
  8091. */
  8092. [idx: number]: ICameraInput<TCamera>;
  8093. }
  8094. /**
  8095. * This represents the input manager used within a camera.
  8096. * It helps dealing with all the different kind of input attached to a camera.
  8097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8098. */
  8099. export class CameraInputsManager<TCamera extends Camera> {
  8100. /**
  8101. * Defines the list of inputs attahed to the camera.
  8102. */
  8103. attached: CameraInputsMap<TCamera>;
  8104. /**
  8105. * Defines the dom element the camera is collecting inputs from.
  8106. * This is null if the controls have not been attached.
  8107. */
  8108. attachedElement: Nullable<HTMLElement>;
  8109. /**
  8110. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8111. */
  8112. noPreventDefault: boolean;
  8113. /**
  8114. * Defined the camera the input manager belongs to.
  8115. */
  8116. camera: TCamera;
  8117. /**
  8118. * Update the current camera state depending on the inputs that have been used this frame.
  8119. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8120. */
  8121. checkInputs: () => void;
  8122. /**
  8123. * Instantiate a new Camera Input Manager.
  8124. * @param camera Defines the camera the input manager blongs to
  8125. */
  8126. constructor(camera: TCamera);
  8127. /**
  8128. * Add an input method to a camera
  8129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8130. * @param input camera input method
  8131. */
  8132. add(input: ICameraInput<TCamera>): void;
  8133. /**
  8134. * Remove a specific input method from a camera
  8135. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8136. * @param inputToRemove camera input method
  8137. */
  8138. remove(inputToRemove: ICameraInput<TCamera>): void;
  8139. /**
  8140. * Remove a specific input type from a camera
  8141. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8142. * @param inputType the type of the input to remove
  8143. */
  8144. removeByType(inputType: string): void;
  8145. private _addCheckInputs;
  8146. /**
  8147. * Attach the input controls to the currently attached dom element to listen the events from.
  8148. * @param input Defines the input to attach
  8149. */
  8150. attachInput(input: ICameraInput<TCamera>): void;
  8151. /**
  8152. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8153. * @param element Defines the dom element to collect the events from
  8154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8155. */
  8156. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8157. /**
  8158. * Detach the current manager inputs controls from a specific dom element.
  8159. * @param element Defines the dom element to collect the events from
  8160. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8161. */
  8162. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8163. /**
  8164. * Rebuild the dynamic inputCheck function from the current list of
  8165. * defined inputs in the manager.
  8166. */
  8167. rebuildInputCheck(): void;
  8168. /**
  8169. * Remove all attached input methods from a camera
  8170. */
  8171. clear(): void;
  8172. /**
  8173. * Serialize the current input manager attached to a camera.
  8174. * This ensures than once parsed,
  8175. * the input associated to the camera will be identical to the current ones
  8176. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8177. */
  8178. serialize(serializedCamera: any): void;
  8179. /**
  8180. * Parses an input manager serialized JSON to restore the previous list of inputs
  8181. * and states associated to a camera.
  8182. * @param parsedCamera Defines the JSON to parse
  8183. */
  8184. parse(parsedCamera: any): void;
  8185. }
  8186. }
  8187. declare module BABYLON {
  8188. /**
  8189. * Gather the list of keyboard event types as constants.
  8190. */
  8191. export class KeyboardEventTypes {
  8192. /**
  8193. * The keydown event is fired when a key becomes active (pressed).
  8194. */
  8195. static readonly KEYDOWN: number;
  8196. /**
  8197. * The keyup event is fired when a key has been released.
  8198. */
  8199. static readonly KEYUP: number;
  8200. }
  8201. /**
  8202. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8203. */
  8204. export class KeyboardInfo {
  8205. /**
  8206. * Defines the type of event (KeyboardEventTypes)
  8207. */
  8208. type: number;
  8209. /**
  8210. * Defines the related dom event
  8211. */
  8212. event: KeyboardEvent;
  8213. /**
  8214. * Instantiates a new keyboard info.
  8215. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8216. * @param type Defines the type of event (KeyboardEventTypes)
  8217. * @param event Defines the related dom event
  8218. */
  8219. constructor(
  8220. /**
  8221. * Defines the type of event (KeyboardEventTypes)
  8222. */
  8223. type: number,
  8224. /**
  8225. * Defines the related dom event
  8226. */
  8227. event: KeyboardEvent);
  8228. }
  8229. /**
  8230. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8231. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8232. */
  8233. export class KeyboardInfoPre extends KeyboardInfo {
  8234. /**
  8235. * Defines the type of event (KeyboardEventTypes)
  8236. */
  8237. type: number;
  8238. /**
  8239. * Defines the related dom event
  8240. */
  8241. event: KeyboardEvent;
  8242. /**
  8243. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8244. */
  8245. skipOnPointerObservable: boolean;
  8246. /**
  8247. * Instantiates a new keyboard pre info.
  8248. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8249. * @param type Defines the type of event (KeyboardEventTypes)
  8250. * @param event Defines the related dom event
  8251. */
  8252. constructor(
  8253. /**
  8254. * Defines the type of event (KeyboardEventTypes)
  8255. */
  8256. type: number,
  8257. /**
  8258. * Defines the related dom event
  8259. */
  8260. event: KeyboardEvent);
  8261. }
  8262. }
  8263. declare module BABYLON {
  8264. /**
  8265. * Manage the keyboard inputs to control the movement of a free camera.
  8266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8267. */
  8268. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8269. /**
  8270. * Defines the camera the input is attached to.
  8271. */
  8272. camera: FreeCamera;
  8273. /**
  8274. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8275. */
  8276. keysUp: number[];
  8277. /**
  8278. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8279. */
  8280. keysDown: number[];
  8281. /**
  8282. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8283. */
  8284. keysLeft: number[];
  8285. /**
  8286. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8287. */
  8288. keysRight: number[];
  8289. private _keys;
  8290. private _onCanvasBlurObserver;
  8291. private _onKeyboardObserver;
  8292. private _engine;
  8293. private _scene;
  8294. /**
  8295. * Attach the input controls to a specific dom element to get the input from.
  8296. * @param element Defines the element the controls should be listened from
  8297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8298. */
  8299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8300. /**
  8301. * Detach the current controls from the specified dom element.
  8302. * @param element Defines the element to stop listening the inputs from
  8303. */
  8304. detachControl(element: Nullable<HTMLElement>): void;
  8305. /**
  8306. * Update the current camera state depending on the inputs that have been used this frame.
  8307. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8308. */
  8309. checkInputs(): void;
  8310. /**
  8311. * Gets the class name of the current intput.
  8312. * @returns the class name
  8313. */
  8314. getClassName(): string;
  8315. /** @hidden */
  8316. _onLostFocus(): void;
  8317. /**
  8318. * Get the friendly name associated with the input class.
  8319. * @returns the input friendly name
  8320. */
  8321. getSimpleName(): string;
  8322. }
  8323. }
  8324. declare module BABYLON {
  8325. /**
  8326. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8327. * separate meshes. This can be use to improve performances.
  8328. * @see http://doc.babylonjs.com/how_to/multi_materials
  8329. */
  8330. export class MultiMaterial extends Material {
  8331. private _subMaterials;
  8332. /**
  8333. * Gets or Sets the list of Materials used within the multi material.
  8334. * They need to be ordered according to the submeshes order in the associated mesh
  8335. */
  8336. subMaterials: Nullable<Material>[];
  8337. /**
  8338. * Function used to align with Node.getChildren()
  8339. * @returns the list of Materials used within the multi material
  8340. */
  8341. getChildren(): Nullable<Material>[];
  8342. /**
  8343. * Instantiates a new Multi Material
  8344. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8345. * separate meshes. This can be use to improve performances.
  8346. * @see http://doc.babylonjs.com/how_to/multi_materials
  8347. * @param name Define the name in the scene
  8348. * @param scene Define the scene the material belongs to
  8349. */
  8350. constructor(name: string, scene: Scene);
  8351. private _hookArray;
  8352. /**
  8353. * Get one of the submaterial by its index in the submaterials array
  8354. * @param index The index to look the sub material at
  8355. * @returns The Material if the index has been defined
  8356. */
  8357. getSubMaterial(index: number): Nullable<Material>;
  8358. /**
  8359. * Get the list of active textures for the whole sub materials list.
  8360. * @returns All the textures that will be used during the rendering
  8361. */
  8362. getActiveTextures(): BaseTexture[];
  8363. /**
  8364. * Gets the current class name of the material e.g. "MultiMaterial"
  8365. * Mainly use in serialization.
  8366. * @returns the class name
  8367. */
  8368. getClassName(): string;
  8369. /**
  8370. * Checks if the material is ready to render the requested sub mesh
  8371. * @param mesh Define the mesh the submesh belongs to
  8372. * @param subMesh Define the sub mesh to look readyness for
  8373. * @param useInstances Define whether or not the material is used with instances
  8374. * @returns true if ready, otherwise false
  8375. */
  8376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8377. /**
  8378. * Clones the current material and its related sub materials
  8379. * @param name Define the name of the newly cloned material
  8380. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8381. * @returns the cloned material
  8382. */
  8383. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8384. /**
  8385. * Serializes the materials into a JSON representation.
  8386. * @returns the JSON representation
  8387. */
  8388. serialize(): any;
  8389. /**
  8390. * Dispose the material and release its associated resources
  8391. * @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)
  8392. * @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)
  8393. * @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)
  8394. */
  8395. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8396. /**
  8397. * Creates a MultiMaterial from parsed MultiMaterial data.
  8398. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8399. * @param scene defines the hosting scene
  8400. * @returns a new MultiMaterial
  8401. */
  8402. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8403. }
  8404. }
  8405. declare module BABYLON {
  8406. /**
  8407. * Class used to represent data loading progression
  8408. */
  8409. export class SceneLoaderFlags {
  8410. private static _ForceFullSceneLoadingForIncremental;
  8411. private static _ShowLoadingScreen;
  8412. private static _CleanBoneMatrixWeights;
  8413. private static _loggingLevel;
  8414. /**
  8415. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8416. */
  8417. static ForceFullSceneLoadingForIncremental: boolean;
  8418. /**
  8419. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8420. */
  8421. static ShowLoadingScreen: boolean;
  8422. /**
  8423. * Defines the current logging level (while loading the scene)
  8424. * @ignorenaming
  8425. */
  8426. static loggingLevel: number;
  8427. /**
  8428. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8429. */
  8430. static CleanBoneMatrixWeights: boolean;
  8431. }
  8432. }
  8433. declare module BABYLON {
  8434. /**
  8435. * 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.
  8436. * @see https://doc.babylonjs.com/how_to/transformnode
  8437. */
  8438. export class TransformNode extends Node {
  8439. /**
  8440. * Object will not rotate to face the camera
  8441. */
  8442. static BILLBOARDMODE_NONE: number;
  8443. /**
  8444. * Object will rotate to face the camera but only on the x axis
  8445. */
  8446. static BILLBOARDMODE_X: number;
  8447. /**
  8448. * Object will rotate to face the camera but only on the y axis
  8449. */
  8450. static BILLBOARDMODE_Y: number;
  8451. /**
  8452. * Object will rotate to face the camera but only on the z axis
  8453. */
  8454. static BILLBOARDMODE_Z: number;
  8455. /**
  8456. * Object will rotate to face the camera
  8457. */
  8458. static BILLBOARDMODE_ALL: number;
  8459. private _forward;
  8460. private _forwardInverted;
  8461. private _up;
  8462. private _right;
  8463. private _rightInverted;
  8464. private _position;
  8465. private _rotation;
  8466. private _rotationQuaternion;
  8467. protected _scaling: Vector3;
  8468. protected _isDirty: boolean;
  8469. private _transformToBoneReferal;
  8470. private _billboardMode;
  8471. /**
  8472. * Gets or sets the billboard mode. Default is 0.
  8473. *
  8474. * | Value | Type | Description |
  8475. * | --- | --- | --- |
  8476. * | 0 | BILLBOARDMODE_NONE | |
  8477. * | 1 | BILLBOARDMODE_X | |
  8478. * | 2 | BILLBOARDMODE_Y | |
  8479. * | 4 | BILLBOARDMODE_Z | |
  8480. * | 7 | BILLBOARDMODE_ALL | |
  8481. *
  8482. */
  8483. billboardMode: number;
  8484. private _preserveParentRotationForBillboard;
  8485. /**
  8486. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8487. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8488. */
  8489. preserveParentRotationForBillboard: boolean;
  8490. /**
  8491. * 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
  8492. */
  8493. scalingDeterminant: number;
  8494. private _infiniteDistance;
  8495. /**
  8496. * Gets or sets the distance of the object to max, often used by skybox
  8497. */
  8498. infiniteDistance: boolean;
  8499. /**
  8500. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8501. * By default the system will update normals to compensate
  8502. */
  8503. ignoreNonUniformScaling: boolean;
  8504. /**
  8505. * 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
  8506. */
  8507. reIntegrateRotationIntoRotationQuaternion: boolean;
  8508. /** @hidden */
  8509. _poseMatrix: Nullable<Matrix>;
  8510. /** @hidden */
  8511. _localMatrix: Matrix;
  8512. private _usePivotMatrix;
  8513. private _absolutePosition;
  8514. private _pivotMatrix;
  8515. private _pivotMatrixInverse;
  8516. protected _postMultiplyPivotMatrix: boolean;
  8517. protected _isWorldMatrixFrozen: boolean;
  8518. /** @hidden */
  8519. _indexInSceneTransformNodesArray: number;
  8520. /**
  8521. * An event triggered after the world matrix is updated
  8522. */
  8523. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8524. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8525. /**
  8526. * Gets a string identifying the name of the class
  8527. * @returns "TransformNode" string
  8528. */
  8529. getClassName(): string;
  8530. /**
  8531. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8532. */
  8533. position: Vector3;
  8534. /**
  8535. * 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)).
  8536. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8537. */
  8538. rotation: Vector3;
  8539. /**
  8540. * 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)).
  8541. */
  8542. scaling: Vector3;
  8543. /**
  8544. * 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).
  8545. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8546. */
  8547. rotationQuaternion: Nullable<Quaternion>;
  8548. /**
  8549. * The forward direction of that transform in world space.
  8550. */
  8551. readonly forward: Vector3;
  8552. /**
  8553. * The up direction of that transform in world space.
  8554. */
  8555. readonly up: Vector3;
  8556. /**
  8557. * The right direction of that transform in world space.
  8558. */
  8559. readonly right: Vector3;
  8560. /**
  8561. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8562. * @param matrix the matrix to copy the pose from
  8563. * @returns this TransformNode.
  8564. */
  8565. updatePoseMatrix(matrix: Matrix): TransformNode;
  8566. /**
  8567. * Returns the mesh Pose matrix.
  8568. * @returns the pose matrix
  8569. */
  8570. getPoseMatrix(): Matrix;
  8571. /** @hidden */
  8572. _isSynchronized(): boolean;
  8573. /** @hidden */
  8574. _initCache(): void;
  8575. /**
  8576. * Flag the transform node as dirty (Forcing it to update everything)
  8577. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8578. * @returns this transform node
  8579. */
  8580. markAsDirty(property: string): TransformNode;
  8581. /**
  8582. * Returns the current mesh absolute position.
  8583. * Returns a Vector3.
  8584. */
  8585. readonly absolutePosition: Vector3;
  8586. /**
  8587. * Sets a new matrix to apply before all other transformation
  8588. * @param matrix defines the transform matrix
  8589. * @returns the current TransformNode
  8590. */
  8591. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8592. /**
  8593. * Sets a new pivot matrix to the current node
  8594. * @param matrix defines the new pivot matrix to use
  8595. * @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
  8596. * @returns the current TransformNode
  8597. */
  8598. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8599. /**
  8600. * Returns the mesh pivot matrix.
  8601. * Default : Identity.
  8602. * @returns the matrix
  8603. */
  8604. getPivotMatrix(): Matrix;
  8605. /**
  8606. * Prevents the World matrix to be computed any longer.
  8607. * @returns the TransformNode.
  8608. */
  8609. freezeWorldMatrix(): TransformNode;
  8610. /**
  8611. * Allows back the World matrix computation.
  8612. * @returns the TransformNode.
  8613. */
  8614. unfreezeWorldMatrix(): this;
  8615. /**
  8616. * True if the World matrix has been frozen.
  8617. */
  8618. readonly isWorldMatrixFrozen: boolean;
  8619. /**
  8620. * Retuns the mesh absolute position in the World.
  8621. * @returns a Vector3.
  8622. */
  8623. getAbsolutePosition(): Vector3;
  8624. /**
  8625. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8626. * @param absolutePosition the absolute position to set
  8627. * @returns the TransformNode.
  8628. */
  8629. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8630. /**
  8631. * Sets the mesh position in its local space.
  8632. * @param vector3 the position to set in localspace
  8633. * @returns the TransformNode.
  8634. */
  8635. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8636. /**
  8637. * Returns the mesh position in the local space from the current World matrix values.
  8638. * @returns a new Vector3.
  8639. */
  8640. getPositionExpressedInLocalSpace(): Vector3;
  8641. /**
  8642. * Translates the mesh along the passed Vector3 in its local space.
  8643. * @param vector3 the distance to translate in localspace
  8644. * @returns the TransformNode.
  8645. */
  8646. locallyTranslate(vector3: Vector3): TransformNode;
  8647. private static _lookAtVectorCache;
  8648. /**
  8649. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8650. * @param targetPoint the position (must be in same space as current mesh) to look at
  8651. * @param yawCor optional yaw (y-axis) correction in radians
  8652. * @param pitchCor optional pitch (x-axis) correction in radians
  8653. * @param rollCor optional roll (z-axis) correction in radians
  8654. * @param space the choosen space of the target
  8655. * @returns the TransformNode.
  8656. */
  8657. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8658. /**
  8659. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8660. * This Vector3 is expressed in the World space.
  8661. * @param localAxis axis to rotate
  8662. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8663. */
  8664. getDirection(localAxis: Vector3): Vector3;
  8665. /**
  8666. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8667. * localAxis is expressed in the mesh local space.
  8668. * result is computed in the Wordl space from the mesh World matrix.
  8669. * @param localAxis axis to rotate
  8670. * @param result the resulting transformnode
  8671. * @returns this TransformNode.
  8672. */
  8673. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8674. /**
  8675. * Sets this transform node rotation to the given local axis.
  8676. * @param localAxis the axis in local space
  8677. * @param yawCor optional yaw (y-axis) correction in radians
  8678. * @param pitchCor optional pitch (x-axis) correction in radians
  8679. * @param rollCor optional roll (z-axis) correction in radians
  8680. * @returns this TransformNode
  8681. */
  8682. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8683. /**
  8684. * Sets a new pivot point to the current node
  8685. * @param point defines the new pivot point to use
  8686. * @param space defines if the point is in world or local space (local by default)
  8687. * @returns the current TransformNode
  8688. */
  8689. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8690. /**
  8691. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8692. * @returns the pivot point
  8693. */
  8694. getPivotPoint(): Vector3;
  8695. /**
  8696. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8697. * @param result the vector3 to store the result
  8698. * @returns this TransformNode.
  8699. */
  8700. getPivotPointToRef(result: Vector3): TransformNode;
  8701. /**
  8702. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8703. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8704. */
  8705. getAbsolutePivotPoint(): Vector3;
  8706. /**
  8707. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8708. * @param result vector3 to store the result
  8709. * @returns this TransformNode.
  8710. */
  8711. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8712. /**
  8713. * Defines the passed node as the parent of the current node.
  8714. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8715. * @see https://doc.babylonjs.com/how_to/parenting
  8716. * @param node the node ot set as the parent
  8717. * @returns this TransformNode.
  8718. */
  8719. setParent(node: Nullable<Node>): TransformNode;
  8720. private _nonUniformScaling;
  8721. /**
  8722. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8723. */
  8724. readonly nonUniformScaling: boolean;
  8725. /** @hidden */
  8726. _updateNonUniformScalingState(value: boolean): boolean;
  8727. /**
  8728. * Attach the current TransformNode to another TransformNode associated with a bone
  8729. * @param bone Bone affecting the TransformNode
  8730. * @param affectedTransformNode TransformNode associated with the bone
  8731. * @returns this object
  8732. */
  8733. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8734. /**
  8735. * Detach the transform node if its associated with a bone
  8736. * @returns this object
  8737. */
  8738. detachFromBone(): TransformNode;
  8739. private static _rotationAxisCache;
  8740. /**
  8741. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8742. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8743. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8744. * The passed axis is also normalized.
  8745. * @param axis the axis to rotate around
  8746. * @param amount the amount to rotate in radians
  8747. * @param space Space to rotate in (Default: local)
  8748. * @returns the TransformNode.
  8749. */
  8750. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8751. /**
  8752. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8753. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8754. * The passed axis is also normalized. .
  8755. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8756. * @param point the point to rotate around
  8757. * @param axis the axis to rotate around
  8758. * @param amount the amount to rotate in radians
  8759. * @returns the TransformNode
  8760. */
  8761. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8762. /**
  8763. * Translates the mesh along the axis vector for the passed distance in the given space.
  8764. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8765. * @param axis the axis to translate in
  8766. * @param distance the distance to translate
  8767. * @param space Space to rotate in (Default: local)
  8768. * @returns the TransformNode.
  8769. */
  8770. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8771. /**
  8772. * Adds a rotation step to the mesh current rotation.
  8773. * x, y, z are Euler angles expressed in radians.
  8774. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8775. * This means this rotation is made in the mesh local space only.
  8776. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8777. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8778. * ```javascript
  8779. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8780. * ```
  8781. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8782. * 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.
  8783. * @param x Rotation to add
  8784. * @param y Rotation to add
  8785. * @param z Rotation to add
  8786. * @returns the TransformNode.
  8787. */
  8788. addRotation(x: number, y: number, z: number): TransformNode;
  8789. /**
  8790. * @hidden
  8791. */
  8792. protected _getEffectiveParent(): Nullable<Node>;
  8793. /**
  8794. * Computes the world matrix of the node
  8795. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8796. * @returns the world matrix
  8797. */
  8798. computeWorldMatrix(force?: boolean): Matrix;
  8799. protected _afterComputeWorldMatrix(): void;
  8800. /**
  8801. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8802. * @param func callback function to add
  8803. *
  8804. * @returns the TransformNode.
  8805. */
  8806. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8807. /**
  8808. * Removes a registered callback function.
  8809. * @param func callback function to remove
  8810. * @returns the TransformNode.
  8811. */
  8812. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8813. /**
  8814. * Gets the position of the current mesh in camera space
  8815. * @param camera defines the camera to use
  8816. * @returns a position
  8817. */
  8818. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8819. /**
  8820. * Returns the distance from the mesh to the active camera
  8821. * @param camera defines the camera to use
  8822. * @returns the distance
  8823. */
  8824. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8825. /**
  8826. * Clone the current transform node
  8827. * @param name Name of the new clone
  8828. * @param newParent New parent for the clone
  8829. * @param doNotCloneChildren Do not clone children hierarchy
  8830. * @returns the new transform node
  8831. */
  8832. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8833. /**
  8834. * Serializes the objects information.
  8835. * @param currentSerializationObject defines the object to serialize in
  8836. * @returns the serialized object
  8837. */
  8838. serialize(currentSerializationObject?: any): any;
  8839. /**
  8840. * Returns a new TransformNode object parsed from the source provided.
  8841. * @param parsedTransformNode is the source.
  8842. * @param scene the scne the object belongs to
  8843. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8844. * @returns a new TransformNode object parsed from the source provided.
  8845. */
  8846. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8847. /**
  8848. * Get all child-transformNodes of this node
  8849. * @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
  8850. * @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
  8851. * @returns an array of TransformNode
  8852. */
  8853. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8854. /**
  8855. * Releases resources associated with this transform node.
  8856. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8857. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8858. */
  8859. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8860. /**
  8861. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8862. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8863. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8864. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8865. * @returns the current mesh
  8866. */
  8867. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8868. }
  8869. }
  8870. declare module BABYLON {
  8871. /**
  8872. * Class used to override all child animations of a given target
  8873. */
  8874. export class AnimationPropertiesOverride {
  8875. /**
  8876. * Gets or sets a value indicating if animation blending must be used
  8877. */
  8878. enableBlending: boolean;
  8879. /**
  8880. * Gets or sets the blending speed to use when enableBlending is true
  8881. */
  8882. blendingSpeed: number;
  8883. /**
  8884. * Gets or sets the default loop mode to use
  8885. */
  8886. loopMode: number;
  8887. }
  8888. }
  8889. declare module BABYLON {
  8890. /**
  8891. * Class used to store bone information
  8892. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8893. */
  8894. export class Bone extends Node {
  8895. /**
  8896. * defines the bone name
  8897. */
  8898. name: string;
  8899. private static _tmpVecs;
  8900. private static _tmpQuat;
  8901. private static _tmpMats;
  8902. /**
  8903. * Gets the list of child bones
  8904. */
  8905. children: Bone[];
  8906. /** Gets the animations associated with this bone */
  8907. animations: Animation[];
  8908. /**
  8909. * Gets or sets bone length
  8910. */
  8911. length: number;
  8912. /**
  8913. * @hidden Internal only
  8914. * Set this value to map this bone to a different index in the transform matrices
  8915. * Set this value to -1 to exclude the bone from the transform matrices
  8916. */
  8917. _index: Nullable<number>;
  8918. private _skeleton;
  8919. private _localMatrix;
  8920. private _restPose;
  8921. private _baseMatrix;
  8922. private _absoluteTransform;
  8923. private _invertedAbsoluteTransform;
  8924. private _parent;
  8925. private _scalingDeterminant;
  8926. private _worldTransform;
  8927. private _localScaling;
  8928. private _localRotation;
  8929. private _localPosition;
  8930. private _needToDecompose;
  8931. private _needToCompose;
  8932. /** @hidden */
  8933. _linkedTransformNode: Nullable<TransformNode>;
  8934. /** @hidden */
  8935. _waitingTransformNodeId: Nullable<string>;
  8936. /** @hidden */
  8937. /** @hidden */
  8938. _matrix: Matrix;
  8939. /**
  8940. * Create a new bone
  8941. * @param name defines the bone name
  8942. * @param skeleton defines the parent skeleton
  8943. * @param parentBone defines the parent (can be null if the bone is the root)
  8944. * @param localMatrix defines the local matrix
  8945. * @param restPose defines the rest pose matrix
  8946. * @param baseMatrix defines the base matrix
  8947. * @param index defines index of the bone in the hiearchy
  8948. */
  8949. constructor(
  8950. /**
  8951. * defines the bone name
  8952. */
  8953. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8954. /**
  8955. * Gets the current object class name.
  8956. * @return the class name
  8957. */
  8958. getClassName(): string;
  8959. /**
  8960. * Gets the parent skeleton
  8961. * @returns a skeleton
  8962. */
  8963. getSkeleton(): Skeleton;
  8964. /**
  8965. * Gets parent bone
  8966. * @returns a bone or null if the bone is the root of the bone hierarchy
  8967. */
  8968. getParent(): Nullable<Bone>;
  8969. /**
  8970. * Returns an array containing the root bones
  8971. * @returns an array containing the root bones
  8972. */
  8973. getChildren(): Array<Bone>;
  8974. /**
  8975. * Sets the parent bone
  8976. * @param parent defines the parent (can be null if the bone is the root)
  8977. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8978. */
  8979. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8980. /**
  8981. * Gets the local matrix
  8982. * @returns a matrix
  8983. */
  8984. getLocalMatrix(): Matrix;
  8985. /**
  8986. * Gets the base matrix (initial matrix which remains unchanged)
  8987. * @returns a matrix
  8988. */
  8989. getBaseMatrix(): Matrix;
  8990. /**
  8991. * Gets the rest pose matrix
  8992. * @returns a matrix
  8993. */
  8994. getRestPose(): Matrix;
  8995. /**
  8996. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8997. */
  8998. getWorldMatrix(): Matrix;
  8999. /**
  9000. * Sets the local matrix to rest pose matrix
  9001. */
  9002. returnToRest(): void;
  9003. /**
  9004. * Gets the inverse of the absolute transform matrix.
  9005. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9006. * @returns a matrix
  9007. */
  9008. getInvertedAbsoluteTransform(): Matrix;
  9009. /**
  9010. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9011. * @returns a matrix
  9012. */
  9013. getAbsoluteTransform(): Matrix;
  9014. /**
  9015. * Links with the given transform node.
  9016. * The local matrix of this bone is copied from the transform node every frame.
  9017. * @param transformNode defines the transform node to link to
  9018. */
  9019. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9020. /** Gets or sets current position (in local space) */
  9021. position: Vector3;
  9022. /** Gets or sets current rotation (in local space) */
  9023. rotation: Vector3;
  9024. /** Gets or sets current rotation quaternion (in local space) */
  9025. rotationQuaternion: Quaternion;
  9026. /** Gets or sets current scaling (in local space) */
  9027. scaling: Vector3;
  9028. /**
  9029. * Gets the animation properties override
  9030. */
  9031. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9032. private _decompose;
  9033. private _compose;
  9034. /**
  9035. * Update the base and local matrices
  9036. * @param matrix defines the new base or local matrix
  9037. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9038. * @param updateLocalMatrix defines if the local matrix should be updated
  9039. */
  9040. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9041. /** @hidden */
  9042. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9043. /**
  9044. * Flag the bone as dirty (Forcing it to update everything)
  9045. */
  9046. markAsDirty(): void;
  9047. /** @hidden */
  9048. _markAsDirtyAndCompose(): void;
  9049. private _markAsDirtyAndDecompose;
  9050. /**
  9051. * Translate the bone in local or world space
  9052. * @param vec The amount to translate the bone
  9053. * @param space The space that the translation is in
  9054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9055. */
  9056. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9057. /**
  9058. * Set the postion of the bone in local or world space
  9059. * @param position The position to set the bone
  9060. * @param space The space that the position is in
  9061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9062. */
  9063. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9064. /**
  9065. * Set the absolute position of the bone (world space)
  9066. * @param position The position to set the bone
  9067. * @param mesh The mesh that this bone is attached to
  9068. */
  9069. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9070. /**
  9071. * Scale the bone on the x, y and z axes (in local space)
  9072. * @param x The amount to scale the bone on the x axis
  9073. * @param y The amount to scale the bone on the y axis
  9074. * @param z The amount to scale the bone on the z axis
  9075. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9076. */
  9077. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9078. /**
  9079. * Set the bone scaling in local space
  9080. * @param scale defines the scaling vector
  9081. */
  9082. setScale(scale: Vector3): void;
  9083. /**
  9084. * Gets the current scaling in local space
  9085. * @returns the current scaling vector
  9086. */
  9087. getScale(): Vector3;
  9088. /**
  9089. * Gets the current scaling in local space and stores it in a target vector
  9090. * @param result defines the target vector
  9091. */
  9092. getScaleToRef(result: Vector3): void;
  9093. /**
  9094. * Set the yaw, pitch, and roll of the bone in local or world space
  9095. * @param yaw The rotation of the bone on the y axis
  9096. * @param pitch The rotation of the bone on the x axis
  9097. * @param roll The rotation of the bone on the z axis
  9098. * @param space The space that the axes of rotation are in
  9099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9100. */
  9101. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9102. /**
  9103. * Add a rotation to the bone on an axis in local or world space
  9104. * @param axis The axis to rotate the bone on
  9105. * @param amount The amount to rotate the bone
  9106. * @param space The space that the axis is in
  9107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9108. */
  9109. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9110. /**
  9111. * Set the rotation of the bone to a particular axis angle in local or world space
  9112. * @param axis The axis to rotate the bone on
  9113. * @param angle The angle that the bone should be rotated to
  9114. * @param space The space that the axis is in
  9115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9116. */
  9117. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9118. /**
  9119. * Set the euler rotation of the bone in local of world space
  9120. * @param rotation The euler rotation that the bone should be set to
  9121. * @param space The space that the rotation is in
  9122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9123. */
  9124. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9125. /**
  9126. * Set the quaternion rotation of the bone in local of world space
  9127. * @param quat The quaternion rotation that the bone should be set to
  9128. * @param space The space that the rotation is in
  9129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9130. */
  9131. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9132. /**
  9133. * Set the rotation matrix of the bone in local of world space
  9134. * @param rotMat The rotation matrix that the bone should be set to
  9135. * @param space The space that the rotation is in
  9136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9137. */
  9138. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9139. private _rotateWithMatrix;
  9140. private _getNegativeRotationToRef;
  9141. /**
  9142. * Get the position of the bone in local or world space
  9143. * @param space The space that the returned position is in
  9144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9145. * @returns The position of the bone
  9146. */
  9147. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9148. /**
  9149. * Copy the position of the bone to a vector3 in local or world space
  9150. * @param space The space that the returned position is in
  9151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9152. * @param result The vector3 to copy the position to
  9153. */
  9154. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9155. /**
  9156. * Get the absolute position of the bone (world space)
  9157. * @param mesh The mesh that this bone is attached to
  9158. * @returns The absolute position of the bone
  9159. */
  9160. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9161. /**
  9162. * Copy the absolute position of the bone (world space) to the result param
  9163. * @param mesh The mesh that this bone is attached to
  9164. * @param result The vector3 to copy the absolute position to
  9165. */
  9166. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9167. /**
  9168. * Compute the absolute transforms of this bone and its children
  9169. */
  9170. computeAbsoluteTransforms(): void;
  9171. /**
  9172. * Get the world direction from an axis that is in the local space of the bone
  9173. * @param localAxis The local direction that is used to compute the world direction
  9174. * @param mesh The mesh that this bone is attached to
  9175. * @returns The world direction
  9176. */
  9177. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9178. /**
  9179. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9180. * @param localAxis The local direction that is used to compute the world direction
  9181. * @param mesh The mesh that this bone is attached to
  9182. * @param result The vector3 that the world direction will be copied to
  9183. */
  9184. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9185. /**
  9186. * Get the euler rotation of the bone in local or world space
  9187. * @param space The space that the rotation should be in
  9188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9189. * @returns The euler rotation
  9190. */
  9191. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9192. /**
  9193. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9194. * @param space The space that the rotation should be in
  9195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9196. * @param result The vector3 that the rotation should be copied to
  9197. */
  9198. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9199. /**
  9200. * Get the quaternion rotation of the bone in either local or world space
  9201. * @param space The space that the rotation should be in
  9202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9203. * @returns The quaternion rotation
  9204. */
  9205. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9206. /**
  9207. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9208. * @param space The space that the rotation should be in
  9209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9210. * @param result The quaternion that the rotation should be copied to
  9211. */
  9212. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9213. /**
  9214. * Get the rotation matrix of the bone in local or world space
  9215. * @param space The space that the rotation should be in
  9216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9217. * @returns The rotation matrix
  9218. */
  9219. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9220. /**
  9221. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9222. * @param space The space that the rotation should be in
  9223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9224. * @param result The quaternion that the rotation should be copied to
  9225. */
  9226. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9227. /**
  9228. * Get the world position of a point that is in the local space of the bone
  9229. * @param position The local position
  9230. * @param mesh The mesh that this bone is attached to
  9231. * @returns The world position
  9232. */
  9233. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9234. /**
  9235. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9236. * @param position The local position
  9237. * @param mesh The mesh that this bone is attached to
  9238. * @param result The vector3 that the world position should be copied to
  9239. */
  9240. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9241. /**
  9242. * Get the local position of a point that is in world space
  9243. * @param position The world position
  9244. * @param mesh The mesh that this bone is attached to
  9245. * @returns The local position
  9246. */
  9247. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9248. /**
  9249. * Get the local position of a point that is in world space and copy it to the result param
  9250. * @param position The world position
  9251. * @param mesh The mesh that this bone is attached to
  9252. * @param result The vector3 that the local position should be copied to
  9253. */
  9254. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9255. }
  9256. }
  9257. declare module BABYLON {
  9258. interface Engine {
  9259. /**
  9260. * Creates a raw texture
  9261. * @param data defines the data to store in the texture
  9262. * @param width defines the width of the texture
  9263. * @param height defines the height of the texture
  9264. * @param format defines the format of the data
  9265. * @param generateMipMaps defines if the engine should generate the mip levels
  9266. * @param invertY defines if data must be stored with Y axis inverted
  9267. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9268. * @param compression defines the compression used (null by default)
  9269. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9270. * @returns the raw texture inside an InternalTexture
  9271. */
  9272. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9273. /**
  9274. * Update a raw texture
  9275. * @param texture defines the texture to update
  9276. * @param data defines the data to store in the texture
  9277. * @param format defines the format of the data
  9278. * @param invertY defines if data must be stored with Y axis inverted
  9279. */
  9280. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9281. /**
  9282. * Update a raw texture
  9283. * @param texture defines the texture to update
  9284. * @param data defines the data to store in the texture
  9285. * @param format defines the format of the data
  9286. * @param invertY defines if data must be stored with Y axis inverted
  9287. * @param compression defines the compression used (null by default)
  9288. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9289. */
  9290. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9291. /**
  9292. * Creates a new raw cube texture
  9293. * @param data defines the array of data to use to create each face
  9294. * @param size defines the size of the textures
  9295. * @param format defines the format of the data
  9296. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9297. * @param generateMipMaps defines if the engine should generate the mip levels
  9298. * @param invertY defines if data must be stored with Y axis inverted
  9299. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9300. * @param compression defines the compression used (null by default)
  9301. * @returns the cube texture as an InternalTexture
  9302. */
  9303. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9304. /**
  9305. * Update a raw cube texture
  9306. * @param texture defines the texture to udpdate
  9307. * @param data defines the data to store
  9308. * @param format defines the data format
  9309. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9310. * @param invertY defines if data must be stored with Y axis inverted
  9311. */
  9312. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9313. /**
  9314. * Update a raw cube texture
  9315. * @param texture defines the texture to udpdate
  9316. * @param data defines the data to store
  9317. * @param format defines the data format
  9318. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9319. * @param invertY defines if data must be stored with Y axis inverted
  9320. * @param compression defines the compression used (null by default)
  9321. */
  9322. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9323. /**
  9324. * Update a raw cube texture
  9325. * @param texture defines the texture to udpdate
  9326. * @param data defines the data to store
  9327. * @param format defines the data format
  9328. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9329. * @param invertY defines if data must be stored with Y axis inverted
  9330. * @param compression defines the compression used (null by default)
  9331. * @param level defines which level of the texture to update
  9332. */
  9333. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9334. /**
  9335. * Creates a new raw cube texture from a specified url
  9336. * @param url defines the url where the data is located
  9337. * @param scene defines the current scene
  9338. * @param size defines the size of the textures
  9339. * @param format defines the format of the data
  9340. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9341. * @param noMipmap defines if the engine should avoid generating the mip levels
  9342. * @param callback defines a callback used to extract texture data from loaded data
  9343. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9344. * @param onLoad defines a callback called when texture is loaded
  9345. * @param onError defines a callback called if there is an error
  9346. * @returns the cube texture as an InternalTexture
  9347. */
  9348. 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;
  9349. /**
  9350. * Creates a new raw cube texture from a specified url
  9351. * @param url defines the url where the data is located
  9352. * @param scene defines the current scene
  9353. * @param size defines the size of the textures
  9354. * @param format defines the format of the data
  9355. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9356. * @param noMipmap defines if the engine should avoid generating the mip levels
  9357. * @param callback defines a callback used to extract texture data from loaded data
  9358. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9359. * @param onLoad defines a callback called when texture is loaded
  9360. * @param onError defines a callback called if there is an error
  9361. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9362. * @param invertY defines if data must be stored with Y axis inverted
  9363. * @returns the cube texture as an InternalTexture
  9364. */
  9365. 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;
  9366. /**
  9367. * Creates a new raw 3D texture
  9368. * @param data defines the data used to create the texture
  9369. * @param width defines the width of the texture
  9370. * @param height defines the height of the texture
  9371. * @param depth defines the depth of the texture
  9372. * @param format defines the format of the texture
  9373. * @param generateMipMaps defines if the engine must generate mip levels
  9374. * @param invertY defines if data must be stored with Y axis inverted
  9375. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9376. * @param compression defines the compressed used (can be null)
  9377. * @param textureType defines the compressed used (can be null)
  9378. * @returns a new raw 3D texture (stored in an InternalTexture)
  9379. */
  9380. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9381. /**
  9382. * Update a raw 3D texture
  9383. * @param texture defines the texture to update
  9384. * @param data defines the data to store
  9385. * @param format defines the data format
  9386. * @param invertY defines if data must be stored with Y axis inverted
  9387. */
  9388. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9389. /**
  9390. * Update a raw 3D texture
  9391. * @param texture defines the texture to update
  9392. * @param data defines the data to store
  9393. * @param format defines the data format
  9394. * @param invertY defines if data must be stored with Y axis inverted
  9395. * @param compression defines the used compression (can be null)
  9396. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9397. */
  9398. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9399. }
  9400. }
  9401. declare module BABYLON {
  9402. /**
  9403. * Raw texture can help creating a texture directly from an array of data.
  9404. * This can be super useful if you either get the data from an uncompressed source or
  9405. * if you wish to create your texture pixel by pixel.
  9406. */
  9407. export class RawTexture extends Texture {
  9408. /**
  9409. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9410. */
  9411. format: number;
  9412. private _engine;
  9413. /**
  9414. * Instantiates a new RawTexture.
  9415. * Raw texture can help creating a texture directly from an array of data.
  9416. * This can be super useful if you either get the data from an uncompressed source or
  9417. * if you wish to create your texture pixel by pixel.
  9418. * @param data define the array of data to use to create the texture
  9419. * @param width define the width of the texture
  9420. * @param height define the height of the texture
  9421. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9422. * @param scene define the scene the texture belongs to
  9423. * @param generateMipMaps define whether mip maps should be generated or not
  9424. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9425. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9426. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9427. */
  9428. constructor(data: ArrayBufferView, width: number, height: number,
  9429. /**
  9430. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9431. */
  9432. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9433. /**
  9434. * Updates the texture underlying data.
  9435. * @param data Define the new data of the texture
  9436. */
  9437. update(data: ArrayBufferView): void;
  9438. /**
  9439. * Creates a luminance texture from some data.
  9440. * @param data Define the texture data
  9441. * @param width Define the width of the texture
  9442. * @param height Define the height of the texture
  9443. * @param scene Define the scene the texture belongs to
  9444. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9445. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9446. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9447. * @returns the luminance texture
  9448. */
  9449. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9450. /**
  9451. * Creates a luminance alpha texture from some data.
  9452. * @param data Define the texture data
  9453. * @param width Define the width of the texture
  9454. * @param height Define the height of the texture
  9455. * @param scene Define the scene the texture belongs to
  9456. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9457. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9458. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9459. * @returns the luminance alpha texture
  9460. */
  9461. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9462. /**
  9463. * Creates an alpha texture from some data.
  9464. * @param data Define the texture data
  9465. * @param width Define the width of the texture
  9466. * @param height Define the height of the texture
  9467. * @param scene Define the scene the texture belongs to
  9468. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9469. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9470. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9471. * @returns the alpha texture
  9472. */
  9473. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9474. /**
  9475. * Creates a RGB texture from some data.
  9476. * @param data Define the texture data
  9477. * @param width Define the width of the texture
  9478. * @param height Define the height of the texture
  9479. * @param scene Define the scene the texture belongs to
  9480. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9481. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9482. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9483. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9484. * @returns the RGB alpha texture
  9485. */
  9486. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9487. /**
  9488. * Creates a RGBA texture from some data.
  9489. * @param data Define the texture data
  9490. * @param width Define the width of the texture
  9491. * @param height Define the height of the texture
  9492. * @param scene Define the scene the texture belongs to
  9493. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9494. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9495. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9496. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9497. * @returns the RGBA texture
  9498. */
  9499. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9500. /**
  9501. * Creates a R texture from some data.
  9502. * @param data Define the texture data
  9503. * @param width Define the width of the texture
  9504. * @param height Define the height of the texture
  9505. * @param scene Define the scene the texture belongs to
  9506. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9507. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9508. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9509. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9510. * @returns the R texture
  9511. */
  9512. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9513. }
  9514. }
  9515. declare module BABYLON {
  9516. /**
  9517. * Defines a runtime animation
  9518. */
  9519. export class RuntimeAnimation {
  9520. private _events;
  9521. /**
  9522. * The current frame of the runtime animation
  9523. */
  9524. private _currentFrame;
  9525. /**
  9526. * The animation used by the runtime animation
  9527. */
  9528. private _animation;
  9529. /**
  9530. * The target of the runtime animation
  9531. */
  9532. private _target;
  9533. /**
  9534. * The initiating animatable
  9535. */
  9536. private _host;
  9537. /**
  9538. * The original value of the runtime animation
  9539. */
  9540. private _originalValue;
  9541. /**
  9542. * The original blend value of the runtime animation
  9543. */
  9544. private _originalBlendValue;
  9545. /**
  9546. * The offsets cache of the runtime animation
  9547. */
  9548. private _offsetsCache;
  9549. /**
  9550. * The high limits cache of the runtime animation
  9551. */
  9552. private _highLimitsCache;
  9553. /**
  9554. * Specifies if the runtime animation has been stopped
  9555. */
  9556. private _stopped;
  9557. /**
  9558. * The blending factor of the runtime animation
  9559. */
  9560. private _blendingFactor;
  9561. /**
  9562. * The BabylonJS scene
  9563. */
  9564. private _scene;
  9565. /**
  9566. * The current value of the runtime animation
  9567. */
  9568. private _currentValue;
  9569. /** @hidden */
  9570. _animationState: _IAnimationState;
  9571. /**
  9572. * The active target of the runtime animation
  9573. */
  9574. private _activeTargets;
  9575. private _currentActiveTarget;
  9576. private _directTarget;
  9577. /**
  9578. * The target path of the runtime animation
  9579. */
  9580. private _targetPath;
  9581. /**
  9582. * The weight of the runtime animation
  9583. */
  9584. private _weight;
  9585. /**
  9586. * The ratio offset of the runtime animation
  9587. */
  9588. private _ratioOffset;
  9589. /**
  9590. * The previous delay of the runtime animation
  9591. */
  9592. private _previousDelay;
  9593. /**
  9594. * The previous ratio of the runtime animation
  9595. */
  9596. private _previousRatio;
  9597. private _enableBlending;
  9598. private _keys;
  9599. private _minFrame;
  9600. private _maxFrame;
  9601. private _minValue;
  9602. private _maxValue;
  9603. private _targetIsArray;
  9604. /**
  9605. * Gets the current frame of the runtime animation
  9606. */
  9607. readonly currentFrame: number;
  9608. /**
  9609. * Gets the weight of the runtime animation
  9610. */
  9611. readonly weight: number;
  9612. /**
  9613. * Gets the current value of the runtime animation
  9614. */
  9615. readonly currentValue: any;
  9616. /**
  9617. * Gets the target path of the runtime animation
  9618. */
  9619. readonly targetPath: string;
  9620. /**
  9621. * Gets the actual target of the runtime animation
  9622. */
  9623. readonly target: any;
  9624. /** @hidden */
  9625. _onLoop: () => void;
  9626. /**
  9627. * Create a new RuntimeAnimation object
  9628. * @param target defines the target of the animation
  9629. * @param animation defines the source animation object
  9630. * @param scene defines the hosting scene
  9631. * @param host defines the initiating Animatable
  9632. */
  9633. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9634. private _preparePath;
  9635. /**
  9636. * Gets the animation from the runtime animation
  9637. */
  9638. readonly animation: Animation;
  9639. /**
  9640. * Resets the runtime animation to the beginning
  9641. * @param restoreOriginal defines whether to restore the target property to the original value
  9642. */
  9643. reset(restoreOriginal?: boolean): void;
  9644. /**
  9645. * Specifies if the runtime animation is stopped
  9646. * @returns Boolean specifying if the runtime animation is stopped
  9647. */
  9648. isStopped(): boolean;
  9649. /**
  9650. * Disposes of the runtime animation
  9651. */
  9652. dispose(): void;
  9653. /**
  9654. * Apply the interpolated value to the target
  9655. * @param currentValue defines the value computed by the animation
  9656. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9657. */
  9658. setValue(currentValue: any, weight: number): void;
  9659. private _getOriginalValues;
  9660. private _setValue;
  9661. /**
  9662. * Gets the loop pmode of the runtime animation
  9663. * @returns Loop Mode
  9664. */
  9665. private _getCorrectLoopMode;
  9666. /**
  9667. * Move the current animation to a given frame
  9668. * @param frame defines the frame to move to
  9669. */
  9670. goToFrame(frame: number): void;
  9671. /**
  9672. * @hidden Internal use only
  9673. */
  9674. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9675. /**
  9676. * Execute the current animation
  9677. * @param delay defines the delay to add to the current frame
  9678. * @param from defines the lower bound of the animation range
  9679. * @param to defines the upper bound of the animation range
  9680. * @param loop defines if the current animation must loop
  9681. * @param speedRatio defines the current speed ratio
  9682. * @param weight defines the weight of the animation (default is -1 so no weight)
  9683. * @param onLoop optional callback called when animation loops
  9684. * @returns a boolean indicating if the animation is running
  9685. */
  9686. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9687. }
  9688. }
  9689. declare module BABYLON {
  9690. /**
  9691. * Class used to store an actual running animation
  9692. */
  9693. export class Animatable {
  9694. /** defines the target object */
  9695. target: any;
  9696. /** defines the starting frame number (default is 0) */
  9697. fromFrame: number;
  9698. /** defines the ending frame number (default is 100) */
  9699. toFrame: number;
  9700. /** defines if the animation must loop (default is false) */
  9701. loopAnimation: boolean;
  9702. /** defines a callback to call when animation ends if it is not looping */
  9703. onAnimationEnd?: (() => void) | null | undefined;
  9704. /** defines a callback to call when animation loops */
  9705. onAnimationLoop?: (() => void) | null | undefined;
  9706. private _localDelayOffset;
  9707. private _pausedDelay;
  9708. private _runtimeAnimations;
  9709. private _paused;
  9710. private _scene;
  9711. private _speedRatio;
  9712. private _weight;
  9713. private _syncRoot;
  9714. /**
  9715. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9716. * This will only apply for non looping animation (default is true)
  9717. */
  9718. disposeOnEnd: boolean;
  9719. /**
  9720. * Gets a boolean indicating if the animation has started
  9721. */
  9722. animationStarted: boolean;
  9723. /**
  9724. * Observer raised when the animation ends
  9725. */
  9726. onAnimationEndObservable: Observable<Animatable>;
  9727. /**
  9728. * Observer raised when the animation loops
  9729. */
  9730. onAnimationLoopObservable: Observable<Animatable>;
  9731. /**
  9732. * Gets the root Animatable used to synchronize and normalize animations
  9733. */
  9734. readonly syncRoot: Nullable<Animatable>;
  9735. /**
  9736. * Gets the current frame of the first RuntimeAnimation
  9737. * Used to synchronize Animatables
  9738. */
  9739. readonly masterFrame: number;
  9740. /**
  9741. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9742. */
  9743. weight: number;
  9744. /**
  9745. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9746. */
  9747. speedRatio: number;
  9748. /**
  9749. * Creates a new Animatable
  9750. * @param scene defines the hosting scene
  9751. * @param target defines the target object
  9752. * @param fromFrame defines the starting frame number (default is 0)
  9753. * @param toFrame defines the ending frame number (default is 100)
  9754. * @param loopAnimation defines if the animation must loop (default is false)
  9755. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9756. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9757. * @param animations defines a group of animation to add to the new Animatable
  9758. * @param onAnimationLoop defines a callback to call when animation loops
  9759. */
  9760. constructor(scene: Scene,
  9761. /** defines the target object */
  9762. target: any,
  9763. /** defines the starting frame number (default is 0) */
  9764. fromFrame?: number,
  9765. /** defines the ending frame number (default is 100) */
  9766. toFrame?: number,
  9767. /** defines if the animation must loop (default is false) */
  9768. loopAnimation?: boolean, speedRatio?: number,
  9769. /** defines a callback to call when animation ends if it is not looping */
  9770. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9771. /** defines a callback to call when animation loops */
  9772. onAnimationLoop?: (() => void) | null | undefined);
  9773. /**
  9774. * Synchronize and normalize current Animatable with a source Animatable
  9775. * This is useful when using animation weights and when animations are not of the same length
  9776. * @param root defines the root Animatable to synchronize with
  9777. * @returns the current Animatable
  9778. */
  9779. syncWith(root: Animatable): Animatable;
  9780. /**
  9781. * Gets the list of runtime animations
  9782. * @returns an array of RuntimeAnimation
  9783. */
  9784. getAnimations(): RuntimeAnimation[];
  9785. /**
  9786. * Adds more animations to the current animatable
  9787. * @param target defines the target of the animations
  9788. * @param animations defines the new animations to add
  9789. */
  9790. appendAnimations(target: any, animations: Animation[]): void;
  9791. /**
  9792. * Gets the source animation for a specific property
  9793. * @param property defines the propertyu to look for
  9794. * @returns null or the source animation for the given property
  9795. */
  9796. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9797. /**
  9798. * Gets the runtime animation for a specific property
  9799. * @param property defines the propertyu to look for
  9800. * @returns null or the runtime animation for the given property
  9801. */
  9802. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9803. /**
  9804. * Resets the animatable to its original state
  9805. */
  9806. reset(): void;
  9807. /**
  9808. * Allows the animatable to blend with current running animations
  9809. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9810. * @param blendingSpeed defines the blending speed to use
  9811. */
  9812. enableBlending(blendingSpeed: number): void;
  9813. /**
  9814. * Disable animation blending
  9815. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9816. */
  9817. disableBlending(): void;
  9818. /**
  9819. * Jump directly to a given frame
  9820. * @param frame defines the frame to jump to
  9821. */
  9822. goToFrame(frame: number): void;
  9823. /**
  9824. * Pause the animation
  9825. */
  9826. pause(): void;
  9827. /**
  9828. * Restart the animation
  9829. */
  9830. restart(): void;
  9831. private _raiseOnAnimationEnd;
  9832. /**
  9833. * Stop and delete the current animation
  9834. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9835. * @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)
  9836. */
  9837. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9838. /**
  9839. * Wait asynchronously for the animation to end
  9840. * @returns a promise which will be fullfilled when the animation ends
  9841. */
  9842. waitAsync(): Promise<Animatable>;
  9843. /** @hidden */
  9844. _animate(delay: number): boolean;
  9845. }
  9846. interface Scene {
  9847. /** @hidden */
  9848. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9849. /** @hidden */
  9850. _processLateAnimationBindingsForMatrices(holder: {
  9851. totalWeight: number;
  9852. animations: RuntimeAnimation[];
  9853. originalValue: Matrix;
  9854. }): any;
  9855. /** @hidden */
  9856. _processLateAnimationBindingsForQuaternions(holder: {
  9857. totalWeight: number;
  9858. animations: RuntimeAnimation[];
  9859. originalValue: Quaternion;
  9860. }, refQuaternion: Quaternion): Quaternion;
  9861. /** @hidden */
  9862. _processLateAnimationBindings(): void;
  9863. /**
  9864. * Will start the animation sequence of a given target
  9865. * @param target defines the target
  9866. * @param from defines from which frame should animation start
  9867. * @param to defines until which frame should animation run.
  9868. * @param weight defines the weight to apply to the animation (1.0 by default)
  9869. * @param loop defines if the animation loops
  9870. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9871. * @param onAnimationEnd defines the function to be executed when the animation ends
  9872. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9873. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9874. * @param onAnimationLoop defines the callback to call when an animation loops
  9875. * @returns the animatable object created for this animation
  9876. */
  9877. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9878. /**
  9879. * Will start the animation sequence of a given target
  9880. * @param target defines the target
  9881. * @param from defines from which frame should animation start
  9882. * @param to defines until which frame should animation run.
  9883. * @param loop defines if the animation loops
  9884. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9885. * @param onAnimationEnd defines the function to be executed when the animation ends
  9886. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9887. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9888. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9889. * @param onAnimationLoop defines the callback to call when an animation loops
  9890. * @returns the animatable object created for this animation
  9891. */
  9892. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9893. /**
  9894. * Will start the animation sequence of a given target and its hierarchy
  9895. * @param target defines the target
  9896. * @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.
  9897. * @param from defines from which frame should animation start
  9898. * @param to defines until which frame should animation run.
  9899. * @param loop defines if the animation loops
  9900. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9901. * @param onAnimationEnd defines the function to be executed when the animation ends
  9902. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9903. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9904. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9905. * @param onAnimationLoop defines the callback to call when an animation loops
  9906. * @returns the list of created animatables
  9907. */
  9908. 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[];
  9909. /**
  9910. * Begin a new animation on a given node
  9911. * @param target defines the target where the animation will take place
  9912. * @param animations defines the list of animations to start
  9913. * @param from defines the initial value
  9914. * @param to defines the final value
  9915. * @param loop defines if you want animation to loop (off by default)
  9916. * @param speedRatio defines the speed ratio to apply to all animations
  9917. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9918. * @param onAnimationLoop defines the callback to call when an animation loops
  9919. * @returns the list of created animatables
  9920. */
  9921. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  9922. /**
  9923. * Begin a new animation on a given node and its hierarchy
  9924. * @param target defines the root node where the animation will take place
  9925. * @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.
  9926. * @param animations defines the list of animations to start
  9927. * @param from defines the initial value
  9928. * @param to defines the final value
  9929. * @param loop defines if you want animation to loop (off by default)
  9930. * @param speedRatio defines the speed ratio to apply to all animations
  9931. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9932. * @param onAnimationLoop defines the callback to call when an animation loops
  9933. * @returns the list of animatables created for all nodes
  9934. */
  9935. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  9936. /**
  9937. * Gets the animatable associated with a specific target
  9938. * @param target defines the target of the animatable
  9939. * @returns the required animatable if found
  9940. */
  9941. getAnimatableByTarget(target: any): Nullable<Animatable>;
  9942. /**
  9943. * Gets all animatables associated with a given target
  9944. * @param target defines the target to look animatables for
  9945. * @returns an array of Animatables
  9946. */
  9947. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  9948. /**
  9949. * Stops and removes all animations that have been applied to the scene
  9950. */
  9951. stopAllAnimations(): void;
  9952. }
  9953. interface Bone {
  9954. /**
  9955. * Copy an animation range from another bone
  9956. * @param source defines the source bone
  9957. * @param rangeName defines the range name to copy
  9958. * @param frameOffset defines the frame offset
  9959. * @param rescaleAsRequired defines if rescaling must be applied if required
  9960. * @param skelDimensionsRatio defines the scaling ratio
  9961. * @returns true if operation was successful
  9962. */
  9963. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  9964. }
  9965. }
  9966. declare module BABYLON {
  9967. /**
  9968. * Class used to handle skinning animations
  9969. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9970. */
  9971. export class Skeleton implements IAnimatable {
  9972. /** defines the skeleton name */
  9973. name: string;
  9974. /** defines the skeleton Id */
  9975. id: string;
  9976. /**
  9977. * Defines the list of child bones
  9978. */
  9979. bones: Bone[];
  9980. /**
  9981. * Defines an estimate of the dimension of the skeleton at rest
  9982. */
  9983. dimensionsAtRest: Vector3;
  9984. /**
  9985. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  9986. */
  9987. needInitialSkinMatrix: boolean;
  9988. /**
  9989. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  9990. */
  9991. overrideMesh: Nullable<AbstractMesh>;
  9992. /**
  9993. * Gets the list of animations attached to this skeleton
  9994. */
  9995. animations: Array<Animation>;
  9996. private _scene;
  9997. private _isDirty;
  9998. private _transformMatrices;
  9999. private _transformMatrixTexture;
  10000. private _meshesWithPoseMatrix;
  10001. private _animatables;
  10002. private _identity;
  10003. private _synchronizedWithMesh;
  10004. private _ranges;
  10005. private _lastAbsoluteTransformsUpdateId;
  10006. private _canUseTextureForBones;
  10007. private _uniqueId;
  10008. /** @hidden */
  10009. _numBonesWithLinkedTransformNode: number;
  10010. /** @hidden */
  10011. _hasWaitingData: Nullable<boolean>;
  10012. /**
  10013. * Specifies if the skeleton should be serialized
  10014. */
  10015. doNotSerialize: boolean;
  10016. private _useTextureToStoreBoneMatrices;
  10017. /**
  10018. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10019. * Please note that this option is not available if the hardware does not support it
  10020. */
  10021. useTextureToStoreBoneMatrices: boolean;
  10022. private _animationPropertiesOverride;
  10023. /**
  10024. * Gets or sets the animation properties override
  10025. */
  10026. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10027. /**
  10028. * List of inspectable custom properties (used by the Inspector)
  10029. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10030. */
  10031. inspectableCustomProperties: IInspectable[];
  10032. /**
  10033. * An observable triggered before computing the skeleton's matrices
  10034. */
  10035. onBeforeComputeObservable: Observable<Skeleton>;
  10036. /**
  10037. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10038. */
  10039. readonly isUsingTextureForMatrices: boolean;
  10040. /**
  10041. * Gets the unique ID of this skeleton
  10042. */
  10043. readonly uniqueId: number;
  10044. /**
  10045. * Creates a new skeleton
  10046. * @param name defines the skeleton name
  10047. * @param id defines the skeleton Id
  10048. * @param scene defines the hosting scene
  10049. */
  10050. constructor(
  10051. /** defines the skeleton name */
  10052. name: string,
  10053. /** defines the skeleton Id */
  10054. id: string, scene: Scene);
  10055. /**
  10056. * Gets the current object class name.
  10057. * @return the class name
  10058. */
  10059. getClassName(): string;
  10060. /**
  10061. * Returns an array containing the root bones
  10062. * @returns an array containing the root bones
  10063. */
  10064. getChildren(): Array<Bone>;
  10065. /**
  10066. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10067. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10068. * @returns a Float32Array containing matrices data
  10069. */
  10070. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10071. /**
  10072. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10073. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10074. * @returns a raw texture containing the data
  10075. */
  10076. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  10077. /**
  10078. * Gets the current hosting scene
  10079. * @returns a scene object
  10080. */
  10081. getScene(): Scene;
  10082. /**
  10083. * Gets a string representing the current skeleton data
  10084. * @param fullDetails defines a boolean indicating if we want a verbose version
  10085. * @returns a string representing the current skeleton data
  10086. */
  10087. toString(fullDetails?: boolean): string;
  10088. /**
  10089. * Get bone's index searching by name
  10090. * @param name defines bone's name to search for
  10091. * @return the indice of the bone. Returns -1 if not found
  10092. */
  10093. getBoneIndexByName(name: string): number;
  10094. /**
  10095. * Creater a new animation range
  10096. * @param name defines the name of the range
  10097. * @param from defines the start key
  10098. * @param to defines the end key
  10099. */
  10100. createAnimationRange(name: string, from: number, to: number): void;
  10101. /**
  10102. * Delete a specific animation range
  10103. * @param name defines the name of the range
  10104. * @param deleteFrames defines if frames must be removed as well
  10105. */
  10106. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10107. /**
  10108. * Gets a specific animation range
  10109. * @param name defines the name of the range to look for
  10110. * @returns the requested animation range or null if not found
  10111. */
  10112. getAnimationRange(name: string): Nullable<AnimationRange>;
  10113. /**
  10114. * Gets the list of all animation ranges defined on this skeleton
  10115. * @returns an array
  10116. */
  10117. getAnimationRanges(): Nullable<AnimationRange>[];
  10118. /**
  10119. * Copy animation range from a source skeleton.
  10120. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10121. * @param source defines the source skeleton
  10122. * @param name defines the name of the range to copy
  10123. * @param rescaleAsRequired defines if rescaling must be applied if required
  10124. * @returns true if operation was successful
  10125. */
  10126. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10127. /**
  10128. * Forces the skeleton to go to rest pose
  10129. */
  10130. returnToRest(): void;
  10131. private _getHighestAnimationFrame;
  10132. /**
  10133. * Begin a specific animation range
  10134. * @param name defines the name of the range to start
  10135. * @param loop defines if looping must be turned on (false by default)
  10136. * @param speedRatio defines the speed ratio to apply (1 by default)
  10137. * @param onAnimationEnd defines a callback which will be called when animation will end
  10138. * @returns a new animatable
  10139. */
  10140. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10141. /** @hidden */
  10142. _markAsDirty(): void;
  10143. /** @hidden */
  10144. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10145. /** @hidden */
  10146. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10147. private _computeTransformMatrices;
  10148. /**
  10149. * Build all resources required to render a skeleton
  10150. */
  10151. prepare(): void;
  10152. /**
  10153. * Gets the list of animatables currently running for this skeleton
  10154. * @returns an array of animatables
  10155. */
  10156. getAnimatables(): IAnimatable[];
  10157. /**
  10158. * Clone the current skeleton
  10159. * @param name defines the name of the new skeleton
  10160. * @param id defines the id of the new skeleton
  10161. * @returns the new skeleton
  10162. */
  10163. clone(name: string, id: string): Skeleton;
  10164. /**
  10165. * Enable animation blending for this skeleton
  10166. * @param blendingSpeed defines the blending speed to apply
  10167. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10168. */
  10169. enableBlending(blendingSpeed?: number): void;
  10170. /**
  10171. * Releases all resources associated with the current skeleton
  10172. */
  10173. dispose(): void;
  10174. /**
  10175. * Serialize the skeleton in a JSON object
  10176. * @returns a JSON object
  10177. */
  10178. serialize(): any;
  10179. /**
  10180. * Creates a new skeleton from serialized data
  10181. * @param parsedSkeleton defines the serialized data
  10182. * @param scene defines the hosting scene
  10183. * @returns a new skeleton
  10184. */
  10185. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10186. /**
  10187. * Compute all node absolute transforms
  10188. * @param forceUpdate defines if computation must be done even if cache is up to date
  10189. */
  10190. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10191. /**
  10192. * Gets the root pose matrix
  10193. * @returns a matrix
  10194. */
  10195. getPoseMatrix(): Nullable<Matrix>;
  10196. /**
  10197. * Sorts bones per internal index
  10198. */
  10199. sortBones(): void;
  10200. private _sortBones;
  10201. }
  10202. }
  10203. declare module BABYLON {
  10204. /**
  10205. * Defines a target to use with MorphTargetManager
  10206. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10207. */
  10208. export class MorphTarget implements IAnimatable {
  10209. /** defines the name of the target */
  10210. name: string;
  10211. /**
  10212. * Gets or sets the list of animations
  10213. */
  10214. animations: Animation[];
  10215. private _scene;
  10216. private _positions;
  10217. private _normals;
  10218. private _tangents;
  10219. private _uvs;
  10220. private _influence;
  10221. /**
  10222. * Observable raised when the influence changes
  10223. */
  10224. onInfluenceChanged: Observable<boolean>;
  10225. /** @hidden */
  10226. _onDataLayoutChanged: Observable<void>;
  10227. /**
  10228. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10229. */
  10230. influence: number;
  10231. /**
  10232. * Gets or sets the id of the morph Target
  10233. */
  10234. id: string;
  10235. private _animationPropertiesOverride;
  10236. /**
  10237. * Gets or sets the animation properties override
  10238. */
  10239. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10240. /**
  10241. * Creates a new MorphTarget
  10242. * @param name defines the name of the target
  10243. * @param influence defines the influence to use
  10244. * @param scene defines the scene the morphtarget belongs to
  10245. */
  10246. constructor(
  10247. /** defines the name of the target */
  10248. name: string, influence?: number, scene?: Nullable<Scene>);
  10249. /**
  10250. * Gets a boolean defining if the target contains position data
  10251. */
  10252. readonly hasPositions: boolean;
  10253. /**
  10254. * Gets a boolean defining if the target contains normal data
  10255. */
  10256. readonly hasNormals: boolean;
  10257. /**
  10258. * Gets a boolean defining if the target contains tangent data
  10259. */
  10260. readonly hasTangents: boolean;
  10261. /**
  10262. * Gets a boolean defining if the target contains texture coordinates data
  10263. */
  10264. readonly hasUVs: boolean;
  10265. /**
  10266. * Affects position data to this target
  10267. * @param data defines the position data to use
  10268. */
  10269. setPositions(data: Nullable<FloatArray>): void;
  10270. /**
  10271. * Gets the position data stored in this target
  10272. * @returns a FloatArray containing the position data (or null if not present)
  10273. */
  10274. getPositions(): Nullable<FloatArray>;
  10275. /**
  10276. * Affects normal data to this target
  10277. * @param data defines the normal data to use
  10278. */
  10279. setNormals(data: Nullable<FloatArray>): void;
  10280. /**
  10281. * Gets the normal data stored in this target
  10282. * @returns a FloatArray containing the normal data (or null if not present)
  10283. */
  10284. getNormals(): Nullable<FloatArray>;
  10285. /**
  10286. * Affects tangent data to this target
  10287. * @param data defines the tangent data to use
  10288. */
  10289. setTangents(data: Nullable<FloatArray>): void;
  10290. /**
  10291. * Gets the tangent data stored in this target
  10292. * @returns a FloatArray containing the tangent data (or null if not present)
  10293. */
  10294. getTangents(): Nullable<FloatArray>;
  10295. /**
  10296. * Affects texture coordinates data to this target
  10297. * @param data defines the texture coordinates data to use
  10298. */
  10299. setUVs(data: Nullable<FloatArray>): void;
  10300. /**
  10301. * Gets the texture coordinates data stored in this target
  10302. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10303. */
  10304. getUVs(): Nullable<FloatArray>;
  10305. /**
  10306. * Serializes the current target into a Serialization object
  10307. * @returns the serialized object
  10308. */
  10309. serialize(): any;
  10310. /**
  10311. * Returns the string "MorphTarget"
  10312. * @returns "MorphTarget"
  10313. */
  10314. getClassName(): string;
  10315. /**
  10316. * Creates a new target from serialized data
  10317. * @param serializationObject defines the serialized data to use
  10318. * @returns a new MorphTarget
  10319. */
  10320. static Parse(serializationObject: any): MorphTarget;
  10321. /**
  10322. * Creates a MorphTarget from mesh data
  10323. * @param mesh defines the source mesh
  10324. * @param name defines the name to use for the new target
  10325. * @param influence defines the influence to attach to the target
  10326. * @returns a new MorphTarget
  10327. */
  10328. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10329. }
  10330. }
  10331. declare module BABYLON {
  10332. /**
  10333. * This class is used to deform meshes using morphing between different targets
  10334. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10335. */
  10336. export class MorphTargetManager {
  10337. private _targets;
  10338. private _targetInfluenceChangedObservers;
  10339. private _targetDataLayoutChangedObservers;
  10340. private _activeTargets;
  10341. private _scene;
  10342. private _influences;
  10343. private _supportsNormals;
  10344. private _supportsTangents;
  10345. private _supportsUVs;
  10346. private _vertexCount;
  10347. private _uniqueId;
  10348. private _tempInfluences;
  10349. /**
  10350. * Gets or sets a boolean indicating if normals must be morphed
  10351. */
  10352. enableNormalMorphing: boolean;
  10353. /**
  10354. * Gets or sets a boolean indicating if tangents must be morphed
  10355. */
  10356. enableTangentMorphing: boolean;
  10357. /**
  10358. * Gets or sets a boolean indicating if UV must be morphed
  10359. */
  10360. enableUVMorphing: boolean;
  10361. /**
  10362. * Creates a new MorphTargetManager
  10363. * @param scene defines the current scene
  10364. */
  10365. constructor(scene?: Nullable<Scene>);
  10366. /**
  10367. * Gets the unique ID of this manager
  10368. */
  10369. readonly uniqueId: number;
  10370. /**
  10371. * Gets the number of vertices handled by this manager
  10372. */
  10373. readonly vertexCount: number;
  10374. /**
  10375. * Gets a boolean indicating if this manager supports morphing of normals
  10376. */
  10377. readonly supportsNormals: boolean;
  10378. /**
  10379. * Gets a boolean indicating if this manager supports morphing of tangents
  10380. */
  10381. readonly supportsTangents: boolean;
  10382. /**
  10383. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10384. */
  10385. readonly supportsUVs: boolean;
  10386. /**
  10387. * Gets the number of targets stored in this manager
  10388. */
  10389. readonly numTargets: number;
  10390. /**
  10391. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10392. */
  10393. readonly numInfluencers: number;
  10394. /**
  10395. * Gets the list of influences (one per target)
  10396. */
  10397. readonly influences: Float32Array;
  10398. /**
  10399. * Gets the active target at specified index. An active target is a target with an influence > 0
  10400. * @param index defines the index to check
  10401. * @returns the requested target
  10402. */
  10403. getActiveTarget(index: number): MorphTarget;
  10404. /**
  10405. * Gets the target at specified index
  10406. * @param index defines the index to check
  10407. * @returns the requested target
  10408. */
  10409. getTarget(index: number): MorphTarget;
  10410. /**
  10411. * Add a new target to this manager
  10412. * @param target defines the target to add
  10413. */
  10414. addTarget(target: MorphTarget): void;
  10415. /**
  10416. * Removes a target from the manager
  10417. * @param target defines the target to remove
  10418. */
  10419. removeTarget(target: MorphTarget): void;
  10420. /**
  10421. * Serializes the current manager into a Serialization object
  10422. * @returns the serialized object
  10423. */
  10424. serialize(): any;
  10425. private _syncActiveTargets;
  10426. /**
  10427. * Syncrhonize the targets with all the meshes using this morph target manager
  10428. */
  10429. synchronize(): void;
  10430. /**
  10431. * Creates a new MorphTargetManager from serialized data
  10432. * @param serializationObject defines the serialized data
  10433. * @param scene defines the hosting scene
  10434. * @returns the new MorphTargetManager
  10435. */
  10436. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10437. }
  10438. }
  10439. declare module BABYLON {
  10440. /**
  10441. * Groups all the scene component constants in one place to ease maintenance.
  10442. * @hidden
  10443. */
  10444. export class SceneComponentConstants {
  10445. static readonly NAME_EFFECTLAYER: string;
  10446. static readonly NAME_LAYER: string;
  10447. static readonly NAME_LENSFLARESYSTEM: string;
  10448. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10449. static readonly NAME_PARTICLESYSTEM: string;
  10450. static readonly NAME_GAMEPAD: string;
  10451. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10452. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10453. static readonly NAME_DEPTHRENDERER: string;
  10454. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10455. static readonly NAME_SPRITE: string;
  10456. static readonly NAME_OUTLINERENDERER: string;
  10457. static readonly NAME_PROCEDURALTEXTURE: string;
  10458. static readonly NAME_SHADOWGENERATOR: string;
  10459. static readonly NAME_OCTREE: string;
  10460. static readonly NAME_PHYSICSENGINE: string;
  10461. static readonly NAME_AUDIO: string;
  10462. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10463. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10464. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10465. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10466. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10467. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10468. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10469. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10470. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10471. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10472. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10473. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10474. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10475. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10476. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10477. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10478. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10479. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10480. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10481. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10482. static readonly STEP_AFTERRENDER_AUDIO: number;
  10483. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10484. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10485. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10486. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10487. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10488. static readonly STEP_POINTERMOVE_SPRITE: number;
  10489. static readonly STEP_POINTERDOWN_SPRITE: number;
  10490. static readonly STEP_POINTERUP_SPRITE: number;
  10491. }
  10492. /**
  10493. * This represents a scene component.
  10494. *
  10495. * This is used to decouple the dependency the scene is having on the different workloads like
  10496. * layers, post processes...
  10497. */
  10498. export interface ISceneComponent {
  10499. /**
  10500. * The name of the component. Each component must have a unique name.
  10501. */
  10502. name: string;
  10503. /**
  10504. * The scene the component belongs to.
  10505. */
  10506. scene: Scene;
  10507. /**
  10508. * Register the component to one instance of a scene.
  10509. */
  10510. register(): void;
  10511. /**
  10512. * Rebuilds the elements related to this component in case of
  10513. * context lost for instance.
  10514. */
  10515. rebuild(): void;
  10516. /**
  10517. * Disposes the component and the associated ressources.
  10518. */
  10519. dispose(): void;
  10520. }
  10521. /**
  10522. * This represents a SERIALIZABLE scene component.
  10523. *
  10524. * This extends Scene Component to add Serialization methods on top.
  10525. */
  10526. export interface ISceneSerializableComponent extends ISceneComponent {
  10527. /**
  10528. * Adds all the elements from the container to the scene
  10529. * @param container the container holding the elements
  10530. */
  10531. addFromContainer(container: AbstractScene): void;
  10532. /**
  10533. * Removes all the elements in the container from the scene
  10534. * @param container contains the elements to remove
  10535. * @param dispose if the removed element should be disposed (default: false)
  10536. */
  10537. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10538. /**
  10539. * Serializes the component data to the specified json object
  10540. * @param serializationObject The object to serialize to
  10541. */
  10542. serialize(serializationObject: any): void;
  10543. }
  10544. /**
  10545. * Strong typing of a Mesh related stage step action
  10546. */
  10547. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10548. /**
  10549. * Strong typing of a Evaluate Sub Mesh related stage step action
  10550. */
  10551. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10552. /**
  10553. * Strong typing of a Active Mesh related stage step action
  10554. */
  10555. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10556. /**
  10557. * Strong typing of a Camera related stage step action
  10558. */
  10559. export type CameraStageAction = (camera: Camera) => void;
  10560. /**
  10561. * Strong typing of a Camera Frame buffer related stage step action
  10562. */
  10563. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10564. /**
  10565. * Strong typing of a Render Target related stage step action
  10566. */
  10567. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10568. /**
  10569. * Strong typing of a RenderingGroup related stage step action
  10570. */
  10571. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10572. /**
  10573. * Strong typing of a Mesh Render related stage step action
  10574. */
  10575. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10576. /**
  10577. * Strong typing of a simple stage step action
  10578. */
  10579. export type SimpleStageAction = () => void;
  10580. /**
  10581. * Strong typing of a render target action.
  10582. */
  10583. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10584. /**
  10585. * Strong typing of a pointer move action.
  10586. */
  10587. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10588. /**
  10589. * Strong typing of a pointer up/down action.
  10590. */
  10591. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10592. /**
  10593. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10594. * @hidden
  10595. */
  10596. export class Stage<T extends Function> extends Array<{
  10597. index: number;
  10598. component: ISceneComponent;
  10599. action: T;
  10600. }> {
  10601. /**
  10602. * Hide ctor from the rest of the world.
  10603. * @param items The items to add.
  10604. */
  10605. private constructor();
  10606. /**
  10607. * Creates a new Stage.
  10608. * @returns A new instance of a Stage
  10609. */
  10610. static Create<T extends Function>(): Stage<T>;
  10611. /**
  10612. * Registers a step in an ordered way in the targeted stage.
  10613. * @param index Defines the position to register the step in
  10614. * @param component Defines the component attached to the step
  10615. * @param action Defines the action to launch during the step
  10616. */
  10617. registerStep(index: number, component: ISceneComponent, action: T): void;
  10618. /**
  10619. * Clears all the steps from the stage.
  10620. */
  10621. clear(): void;
  10622. }
  10623. }
  10624. declare module BABYLON {
  10625. /**
  10626. * Class used to represent a specific level of detail of a mesh
  10627. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10628. */
  10629. export class MeshLODLevel {
  10630. /** Defines the distance where this level should star being displayed */
  10631. distance: number;
  10632. /** Defines the mesh to use to render this level */
  10633. mesh: Nullable<Mesh>;
  10634. /**
  10635. * Creates a new LOD level
  10636. * @param distance defines the distance where this level should star being displayed
  10637. * @param mesh defines the mesh to use to render this level
  10638. */
  10639. constructor(
  10640. /** Defines the distance where this level should star being displayed */
  10641. distance: number,
  10642. /** Defines the mesh to use to render this level */
  10643. mesh: Nullable<Mesh>);
  10644. }
  10645. }
  10646. declare module BABYLON {
  10647. /**
  10648. * Interface describing all the common properties and methods a shadow light needs to implement.
  10649. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10650. * as well as binding the different shadow properties to the effects.
  10651. */
  10652. export interface IShadowLight extends Light {
  10653. /**
  10654. * The light id in the scene (used in scene.findLighById for instance)
  10655. */
  10656. id: string;
  10657. /**
  10658. * The position the shdow will be casted from.
  10659. */
  10660. position: Vector3;
  10661. /**
  10662. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10663. */
  10664. direction: Vector3;
  10665. /**
  10666. * The transformed position. Position of the light in world space taking parenting in account.
  10667. */
  10668. transformedPosition: Vector3;
  10669. /**
  10670. * The transformed direction. Direction of the light in world space taking parenting in account.
  10671. */
  10672. transformedDirection: Vector3;
  10673. /**
  10674. * The friendly name of the light in the scene.
  10675. */
  10676. name: string;
  10677. /**
  10678. * Defines the shadow projection clipping minimum z value.
  10679. */
  10680. shadowMinZ: number;
  10681. /**
  10682. * Defines the shadow projection clipping maximum z value.
  10683. */
  10684. shadowMaxZ: number;
  10685. /**
  10686. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10687. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10688. */
  10689. computeTransformedInformation(): boolean;
  10690. /**
  10691. * Gets the scene the light belongs to.
  10692. * @returns The scene
  10693. */
  10694. getScene(): Scene;
  10695. /**
  10696. * Callback defining a custom Projection Matrix Builder.
  10697. * This can be used to override the default projection matrix computation.
  10698. */
  10699. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10700. /**
  10701. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10702. * @param matrix The materix to updated with the projection information
  10703. * @param viewMatrix The transform matrix of the light
  10704. * @param renderList The list of mesh to render in the map
  10705. * @returns The current light
  10706. */
  10707. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10708. /**
  10709. * Gets the current depth scale used in ESM.
  10710. * @returns The scale
  10711. */
  10712. getDepthScale(): number;
  10713. /**
  10714. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10715. * @returns true if a cube texture needs to be use
  10716. */
  10717. needCube(): boolean;
  10718. /**
  10719. * Detects if the projection matrix requires to be recomputed this frame.
  10720. * @returns true if it requires to be recomputed otherwise, false.
  10721. */
  10722. needProjectionMatrixCompute(): boolean;
  10723. /**
  10724. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10725. */
  10726. forceProjectionMatrixCompute(): void;
  10727. /**
  10728. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10729. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10730. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10731. */
  10732. getShadowDirection(faceIndex?: number): Vector3;
  10733. /**
  10734. * Gets the minZ used for shadow according to both the scene and the light.
  10735. * @param activeCamera The camera we are returning the min for
  10736. * @returns the depth min z
  10737. */
  10738. getDepthMinZ(activeCamera: Camera): number;
  10739. /**
  10740. * Gets the maxZ used for shadow according to both the scene and the light.
  10741. * @param activeCamera The camera we are returning the max for
  10742. * @returns the depth max z
  10743. */
  10744. getDepthMaxZ(activeCamera: Camera): number;
  10745. }
  10746. /**
  10747. * Base implementation IShadowLight
  10748. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10749. */
  10750. export abstract class ShadowLight extends Light implements IShadowLight {
  10751. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10752. protected _position: Vector3;
  10753. protected _setPosition(value: Vector3): void;
  10754. /**
  10755. * Sets the position the shadow will be casted from. Also use as the light position for both
  10756. * point and spot lights.
  10757. */
  10758. /**
  10759. * Sets the position the shadow will be casted from. Also use as the light position for both
  10760. * point and spot lights.
  10761. */
  10762. position: Vector3;
  10763. protected _direction: Vector3;
  10764. protected _setDirection(value: Vector3): void;
  10765. /**
  10766. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10767. * Also use as the light direction on spot and directional lights.
  10768. */
  10769. /**
  10770. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10771. * Also use as the light direction on spot and directional lights.
  10772. */
  10773. direction: Vector3;
  10774. private _shadowMinZ;
  10775. /**
  10776. * Gets the shadow projection clipping minimum z value.
  10777. */
  10778. /**
  10779. * Sets the shadow projection clipping minimum z value.
  10780. */
  10781. shadowMinZ: number;
  10782. private _shadowMaxZ;
  10783. /**
  10784. * Sets the shadow projection clipping maximum z value.
  10785. */
  10786. /**
  10787. * Gets the shadow projection clipping maximum z value.
  10788. */
  10789. shadowMaxZ: number;
  10790. /**
  10791. * Callback defining a custom Projection Matrix Builder.
  10792. * This can be used to override the default projection matrix computation.
  10793. */
  10794. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10795. /**
  10796. * The transformed position. Position of the light in world space taking parenting in account.
  10797. */
  10798. transformedPosition: Vector3;
  10799. /**
  10800. * The transformed direction. Direction of the light in world space taking parenting in account.
  10801. */
  10802. transformedDirection: Vector3;
  10803. private _needProjectionMatrixCompute;
  10804. /**
  10805. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10806. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10807. */
  10808. computeTransformedInformation(): boolean;
  10809. /**
  10810. * Return the depth scale used for the shadow map.
  10811. * @returns the depth scale.
  10812. */
  10813. getDepthScale(): number;
  10814. /**
  10815. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10816. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10817. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10818. */
  10819. getShadowDirection(faceIndex?: number): Vector3;
  10820. /**
  10821. * Returns the ShadowLight absolute position in the World.
  10822. * @returns the position vector in world space
  10823. */
  10824. getAbsolutePosition(): Vector3;
  10825. /**
  10826. * Sets the ShadowLight direction toward the passed target.
  10827. * @param target The point to target in local space
  10828. * @returns the updated ShadowLight direction
  10829. */
  10830. setDirectionToTarget(target: Vector3): Vector3;
  10831. /**
  10832. * Returns the light rotation in euler definition.
  10833. * @returns the x y z rotation in local space.
  10834. */
  10835. getRotation(): Vector3;
  10836. /**
  10837. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10838. * @returns true if a cube texture needs to be use
  10839. */
  10840. needCube(): boolean;
  10841. /**
  10842. * Detects if the projection matrix requires to be recomputed this frame.
  10843. * @returns true if it requires to be recomputed otherwise, false.
  10844. */
  10845. needProjectionMatrixCompute(): boolean;
  10846. /**
  10847. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10848. */
  10849. forceProjectionMatrixCompute(): void;
  10850. /** @hidden */
  10851. _initCache(): void;
  10852. /** @hidden */
  10853. _isSynchronized(): boolean;
  10854. /**
  10855. * Computes the world matrix of the node
  10856. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10857. * @returns the world matrix
  10858. */
  10859. computeWorldMatrix(force?: boolean): Matrix;
  10860. /**
  10861. * Gets the minZ used for shadow according to both the scene and the light.
  10862. * @param activeCamera The camera we are returning the min for
  10863. * @returns the depth min z
  10864. */
  10865. getDepthMinZ(activeCamera: Camera): number;
  10866. /**
  10867. * Gets the maxZ used for shadow according to both the scene and the light.
  10868. * @param activeCamera The camera we are returning the max for
  10869. * @returns the depth max z
  10870. */
  10871. getDepthMaxZ(activeCamera: Camera): number;
  10872. /**
  10873. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10874. * @param matrix The materix to updated with the projection information
  10875. * @param viewMatrix The transform matrix of the light
  10876. * @param renderList The list of mesh to render in the map
  10877. * @returns The current light
  10878. */
  10879. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10880. }
  10881. }
  10882. declare module BABYLON {
  10883. /**
  10884. * "Static Class" containing the most commonly used helper while dealing with material for
  10885. * rendering purpose.
  10886. *
  10887. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10888. *
  10889. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10890. */
  10891. export class MaterialHelper {
  10892. /**
  10893. * Bind the current view position to an effect.
  10894. * @param effect The effect to be bound
  10895. * @param scene The scene the eyes position is used from
  10896. */
  10897. static BindEyePosition(effect: Effect, scene: Scene): void;
  10898. /**
  10899. * Helps preparing the defines values about the UVs in used in the effect.
  10900. * UVs are shared as much as we can accross channels in the shaders.
  10901. * @param texture The texture we are preparing the UVs for
  10902. * @param defines The defines to update
  10903. * @param key The channel key "diffuse", "specular"... used in the shader
  10904. */
  10905. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10906. /**
  10907. * Binds a texture matrix value to its corrsponding uniform
  10908. * @param texture The texture to bind the matrix for
  10909. * @param uniformBuffer The uniform buffer receivin the data
  10910. * @param key The channel key "diffuse", "specular"... used in the shader
  10911. */
  10912. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10913. /**
  10914. * Gets the current status of the fog (should it be enabled?)
  10915. * @param mesh defines the mesh to evaluate for fog support
  10916. * @param scene defines the hosting scene
  10917. * @returns true if fog must be enabled
  10918. */
  10919. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  10920. /**
  10921. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10922. * @param mesh defines the current mesh
  10923. * @param scene defines the current scene
  10924. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10925. * @param pointsCloud defines if point cloud rendering has to be turned on
  10926. * @param fogEnabled defines if fog has to be turned on
  10927. * @param alphaTest defines if alpha testing has to be turned on
  10928. * @param defines defines the current list of defines
  10929. */
  10930. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10931. /**
  10932. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10933. * @param scene defines the current scene
  10934. * @param engine defines the current engine
  10935. * @param defines specifies the list of active defines
  10936. * @param useInstances defines if instances have to be turned on
  10937. * @param useClipPlane defines if clip plane have to be turned on
  10938. */
  10939. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10940. /**
  10941. * Prepares the defines for bones
  10942. * @param mesh The mesh containing the geometry data we will draw
  10943. * @param defines The defines to update
  10944. */
  10945. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  10946. /**
  10947. * Prepares the defines for morph targets
  10948. * @param mesh The mesh containing the geometry data we will draw
  10949. * @param defines The defines to update
  10950. */
  10951. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  10952. /**
  10953. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10954. * @param mesh The mesh containing the geometry data we will draw
  10955. * @param defines The defines to update
  10956. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10957. * @param useBones Precise whether bones should be used or not (override mesh info)
  10958. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10959. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10960. * @returns false if defines are considered not dirty and have not been checked
  10961. */
  10962. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10963. /**
  10964. * Prepares the defines related to multiview
  10965. * @param scene The scene we are intending to draw
  10966. * @param defines The defines to update
  10967. */
  10968. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  10969. /**
  10970. * Prepares the defines related to the light information passed in parameter
  10971. * @param scene The scene we are intending to draw
  10972. * @param mesh The mesh the effect is compiling for
  10973. * @param light The light the effect is compiling for
  10974. * @param lightIndex The index of the light
  10975. * @param defines The defines to update
  10976. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10977. * @param state Defines the current state regarding what is needed (normals, etc...)
  10978. */
  10979. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  10980. needNormals: boolean;
  10981. needRebuild: boolean;
  10982. shadowEnabled: boolean;
  10983. specularEnabled: boolean;
  10984. lightmapMode: boolean;
  10985. }): void;
  10986. /**
  10987. * Prepares the defines related to the light information passed in parameter
  10988. * @param scene The scene we are intending to draw
  10989. * @param mesh The mesh the effect is compiling for
  10990. * @param defines The defines to update
  10991. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10992. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10993. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10994. * @returns true if normals will be required for the rest of the effect
  10995. */
  10996. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10997. /**
  10998. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  10999. * @param lightIndex defines the light index
  11000. * @param uniformsList The uniform list
  11001. * @param samplersList The sampler list
  11002. * @param projectedLightTexture defines if projected texture must be used
  11003. * @param uniformBuffersList defines an optional list of uniform buffers
  11004. */
  11005. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  11006. /**
  11007. * Prepares the uniforms and samplers list to be used in the effect
  11008. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11009. * @param samplersList The sampler list
  11010. * @param defines The defines helping in the list generation
  11011. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11012. */
  11013. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11014. /**
  11015. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11016. * @param defines The defines to update while falling back
  11017. * @param fallbacks The authorized effect fallbacks
  11018. * @param maxSimultaneousLights The maximum number of lights allowed
  11019. * @param rank the current rank of the Effect
  11020. * @returns The newly affected rank
  11021. */
  11022. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11023. private static _TmpMorphInfluencers;
  11024. /**
  11025. * Prepares the list of attributes required for morph targets according to the effect defines.
  11026. * @param attribs The current list of supported attribs
  11027. * @param mesh The mesh to prepare the morph targets attributes for
  11028. * @param influencers The number of influencers
  11029. */
  11030. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11031. /**
  11032. * Prepares the list of attributes required for morph targets according to the effect defines.
  11033. * @param attribs The current list of supported attribs
  11034. * @param mesh The mesh to prepare the morph targets attributes for
  11035. * @param defines The current Defines of the effect
  11036. */
  11037. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11038. /**
  11039. * Prepares the list of attributes required for bones according to the effect defines.
  11040. * @param attribs The current list of supported attribs
  11041. * @param mesh The mesh to prepare the bones attributes for
  11042. * @param defines The current Defines of the effect
  11043. * @param fallbacks The current efffect fallback strategy
  11044. */
  11045. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11046. /**
  11047. * Check and prepare the list of attributes required for instances according to the effect defines.
  11048. * @param attribs The current list of supported attribs
  11049. * @param defines The current MaterialDefines of the effect
  11050. */
  11051. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11052. /**
  11053. * Add the list of attributes required for instances to the attribs array.
  11054. * @param attribs The current list of supported attribs
  11055. */
  11056. static PushAttributesForInstances(attribs: string[]): void;
  11057. /**
  11058. * Binds the light shadow information to the effect for the given mesh.
  11059. * @param light The light containing the generator
  11060. * @param scene The scene the lights belongs to
  11061. * @param mesh The mesh we are binding the information to render
  11062. * @param lightIndex The light index in the effect used to render the mesh
  11063. * @param effect The effect we are binding the data to
  11064. */
  11065. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11066. /**
  11067. * Binds the light information to the effect.
  11068. * @param light The light containing the generator
  11069. * @param effect The effect we are binding the data to
  11070. * @param lightIndex The light index in the effect used to render
  11071. */
  11072. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11073. /**
  11074. * Binds the lights information from the scene to the effect for the given mesh.
  11075. * @param light Light to bind
  11076. * @param lightIndex Light index
  11077. * @param scene The scene where the light belongs to
  11078. * @param mesh The mesh we are binding the information to render
  11079. * @param effect The effect we are binding the data to
  11080. * @param useSpecular Defines if specular is supported
  11081. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11082. */
  11083. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11084. /**
  11085. * Binds the lights information from the scene to the effect for the given mesh.
  11086. * @param scene The scene the lights belongs to
  11087. * @param mesh The mesh we are binding the information to render
  11088. * @param effect The effect we are binding the data to
  11089. * @param defines The generated defines for the effect
  11090. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11091. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11092. */
  11093. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11094. private static _tempFogColor;
  11095. /**
  11096. * Binds the fog information from the scene to the effect for the given mesh.
  11097. * @param scene The scene the lights belongs to
  11098. * @param mesh The mesh we are binding the information to render
  11099. * @param effect The effect we are binding the data to
  11100. * @param linearSpace Defines if the fog effect is applied in linear space
  11101. */
  11102. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11103. /**
  11104. * Binds the bones information from the mesh to the effect.
  11105. * @param mesh The mesh we are binding the information to render
  11106. * @param effect The effect we are binding the data to
  11107. */
  11108. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11109. /**
  11110. * Binds the morph targets information from the mesh to the effect.
  11111. * @param abstractMesh The mesh we are binding the information to render
  11112. * @param effect The effect we are binding the data to
  11113. */
  11114. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11115. /**
  11116. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11117. * @param defines The generated defines used in the effect
  11118. * @param effect The effect we are binding the data to
  11119. * @param scene The scene we are willing to render with logarithmic scale for
  11120. */
  11121. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11122. /**
  11123. * Binds the clip plane information from the scene to the effect.
  11124. * @param scene The scene the clip plane information are extracted from
  11125. * @param effect The effect we are binding the data to
  11126. */
  11127. static BindClipPlane(effect: Effect, scene: Scene): void;
  11128. }
  11129. }
  11130. declare module BABYLON {
  11131. /** @hidden */
  11132. export var packingFunctions: {
  11133. name: string;
  11134. shader: string;
  11135. };
  11136. }
  11137. declare module BABYLON {
  11138. /** @hidden */
  11139. export var shadowMapPixelShader: {
  11140. name: string;
  11141. shader: string;
  11142. };
  11143. }
  11144. declare module BABYLON {
  11145. /** @hidden */
  11146. export var bonesDeclaration: {
  11147. name: string;
  11148. shader: string;
  11149. };
  11150. }
  11151. declare module BABYLON {
  11152. /** @hidden */
  11153. export var morphTargetsVertexGlobalDeclaration: {
  11154. name: string;
  11155. shader: string;
  11156. };
  11157. }
  11158. declare module BABYLON {
  11159. /** @hidden */
  11160. export var morphTargetsVertexDeclaration: {
  11161. name: string;
  11162. shader: string;
  11163. };
  11164. }
  11165. declare module BABYLON {
  11166. /** @hidden */
  11167. export var instancesDeclaration: {
  11168. name: string;
  11169. shader: string;
  11170. };
  11171. }
  11172. declare module BABYLON {
  11173. /** @hidden */
  11174. export var helperFunctions: {
  11175. name: string;
  11176. shader: string;
  11177. };
  11178. }
  11179. declare module BABYLON {
  11180. /** @hidden */
  11181. export var morphTargetsVertex: {
  11182. name: string;
  11183. shader: string;
  11184. };
  11185. }
  11186. declare module BABYLON {
  11187. /** @hidden */
  11188. export var instancesVertex: {
  11189. name: string;
  11190. shader: string;
  11191. };
  11192. }
  11193. declare module BABYLON {
  11194. /** @hidden */
  11195. export var bonesVertex: {
  11196. name: string;
  11197. shader: string;
  11198. };
  11199. }
  11200. declare module BABYLON {
  11201. /** @hidden */
  11202. export var shadowMapVertexShader: {
  11203. name: string;
  11204. shader: string;
  11205. };
  11206. }
  11207. declare module BABYLON {
  11208. /** @hidden */
  11209. export var depthBoxBlurPixelShader: {
  11210. name: string;
  11211. shader: string;
  11212. };
  11213. }
  11214. declare module BABYLON {
  11215. /**
  11216. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11217. */
  11218. export interface ICustomShaderOptions {
  11219. /**
  11220. * Gets or sets the custom shader name to use
  11221. */
  11222. shaderName: string;
  11223. /**
  11224. * The list of attribute names used in the shader
  11225. */
  11226. attributes?: string[];
  11227. /**
  11228. * The list of unifrom names used in the shader
  11229. */
  11230. uniforms?: string[];
  11231. /**
  11232. * The list of sampler names used in the shader
  11233. */
  11234. samplers?: string[];
  11235. /**
  11236. * The list of defines used in the shader
  11237. */
  11238. defines?: string[];
  11239. }
  11240. /**
  11241. * Interface to implement to create a shadow generator compatible with BJS.
  11242. */
  11243. export interface IShadowGenerator {
  11244. /**
  11245. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11246. * @returns The render target texture if present otherwise, null
  11247. */
  11248. getShadowMap(): Nullable<RenderTargetTexture>;
  11249. /**
  11250. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11251. * @returns The render target texture if the shadow map is present otherwise, null
  11252. */
  11253. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11254. /**
  11255. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11256. * @param subMesh The submesh we want to render in the shadow map
  11257. * @param useInstances Defines wether will draw in the map using instances
  11258. * @returns true if ready otherwise, false
  11259. */
  11260. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11261. /**
  11262. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11263. * @param defines Defines of the material we want to update
  11264. * @param lightIndex Index of the light in the enabled light list of the material
  11265. */
  11266. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11267. /**
  11268. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11269. * defined in the generator but impacting the effect).
  11270. * It implies the unifroms available on the materials are the standard BJS ones.
  11271. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11272. * @param effect The effect we are binfing the information for
  11273. */
  11274. bindShadowLight(lightIndex: string, effect: Effect): void;
  11275. /**
  11276. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11277. * (eq to shadow prjection matrix * light transform matrix)
  11278. * @returns The transform matrix used to create the shadow map
  11279. */
  11280. getTransformMatrix(): Matrix;
  11281. /**
  11282. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11283. * Cube and 2D textures for instance.
  11284. */
  11285. recreateShadowMap(): void;
  11286. /**
  11287. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11288. * @param onCompiled Callback triggered at the and of the effects compilation
  11289. * @param options Sets of optional options forcing the compilation with different modes
  11290. */
  11291. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11292. useInstances: boolean;
  11293. }>): void;
  11294. /**
  11295. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11296. * @param options Sets of optional options forcing the compilation with different modes
  11297. * @returns A promise that resolves when the compilation completes
  11298. */
  11299. forceCompilationAsync(options?: Partial<{
  11300. useInstances: boolean;
  11301. }>): Promise<void>;
  11302. /**
  11303. * Serializes the shadow generator setup to a json object.
  11304. * @returns The serialized JSON object
  11305. */
  11306. serialize(): any;
  11307. /**
  11308. * Disposes the Shadow map and related Textures and effects.
  11309. */
  11310. dispose(): void;
  11311. }
  11312. /**
  11313. * Default implementation IShadowGenerator.
  11314. * This is the main object responsible of generating shadows in the framework.
  11315. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11316. */
  11317. export class ShadowGenerator implements IShadowGenerator {
  11318. /**
  11319. * Shadow generator mode None: no filtering applied.
  11320. */
  11321. static readonly FILTER_NONE: number;
  11322. /**
  11323. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11324. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11325. */
  11326. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11327. /**
  11328. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11329. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11330. */
  11331. static readonly FILTER_POISSONSAMPLING: number;
  11332. /**
  11333. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11334. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11335. */
  11336. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11337. /**
  11338. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11339. * edge artifacts on steep falloff.
  11340. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11341. */
  11342. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11343. /**
  11344. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11345. * edge artifacts on steep falloff.
  11346. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11347. */
  11348. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11349. /**
  11350. * Shadow generator mode PCF: Percentage Closer Filtering
  11351. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11352. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11353. */
  11354. static readonly FILTER_PCF: number;
  11355. /**
  11356. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11357. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11358. * Contact Hardening
  11359. */
  11360. static readonly FILTER_PCSS: number;
  11361. /**
  11362. * Reserved for PCF and PCSS
  11363. * Highest Quality.
  11364. *
  11365. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11366. *
  11367. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11368. */
  11369. static readonly QUALITY_HIGH: number;
  11370. /**
  11371. * Reserved for PCF and PCSS
  11372. * Good tradeoff for quality/perf cross devices
  11373. *
  11374. * Execute PCF on a 3*3 kernel.
  11375. *
  11376. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11377. */
  11378. static readonly QUALITY_MEDIUM: number;
  11379. /**
  11380. * Reserved for PCF and PCSS
  11381. * The lowest quality but the fastest.
  11382. *
  11383. * Execute PCF on a 1*1 kernel.
  11384. *
  11385. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11386. */
  11387. static readonly QUALITY_LOW: number;
  11388. /** Gets or sets the custom shader name to use */
  11389. customShaderOptions: ICustomShaderOptions;
  11390. /**
  11391. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11392. */
  11393. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11394. /**
  11395. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11396. */
  11397. onAfterShadowMapRenderObservable: Observable<Effect>;
  11398. /**
  11399. * Observable triggered before a mesh is rendered in the shadow map.
  11400. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11401. */
  11402. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11403. /**
  11404. * Observable triggered after a mesh is rendered in the shadow map.
  11405. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11406. */
  11407. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11408. private _bias;
  11409. /**
  11410. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11411. */
  11412. /**
  11413. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11414. */
  11415. bias: number;
  11416. private _normalBias;
  11417. /**
  11418. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11419. */
  11420. /**
  11421. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11422. */
  11423. normalBias: number;
  11424. private _blurBoxOffset;
  11425. /**
  11426. * Gets the blur box offset: offset applied during the blur pass.
  11427. * Only useful if useKernelBlur = false
  11428. */
  11429. /**
  11430. * Sets the blur box offset: offset applied during the blur pass.
  11431. * Only useful if useKernelBlur = false
  11432. */
  11433. blurBoxOffset: number;
  11434. private _blurScale;
  11435. /**
  11436. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11437. * 2 means half of the size.
  11438. */
  11439. /**
  11440. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11441. * 2 means half of the size.
  11442. */
  11443. blurScale: number;
  11444. private _blurKernel;
  11445. /**
  11446. * Gets the blur kernel: kernel size of the blur pass.
  11447. * Only useful if useKernelBlur = true
  11448. */
  11449. /**
  11450. * Sets the blur kernel: kernel size of the blur pass.
  11451. * Only useful if useKernelBlur = true
  11452. */
  11453. blurKernel: number;
  11454. private _useKernelBlur;
  11455. /**
  11456. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11457. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11458. */
  11459. /**
  11460. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11461. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11462. */
  11463. useKernelBlur: boolean;
  11464. private _depthScale;
  11465. /**
  11466. * Gets the depth scale used in ESM mode.
  11467. */
  11468. /**
  11469. * Sets the depth scale used in ESM mode.
  11470. * This can override the scale stored on the light.
  11471. */
  11472. depthScale: number;
  11473. private _filter;
  11474. /**
  11475. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11476. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11477. */
  11478. /**
  11479. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11480. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11481. */
  11482. filter: number;
  11483. /**
  11484. * Gets if the current filter is set to Poisson Sampling.
  11485. */
  11486. /**
  11487. * Sets the current filter to Poisson Sampling.
  11488. */
  11489. usePoissonSampling: boolean;
  11490. /**
  11491. * Gets if the current filter is set to ESM.
  11492. */
  11493. /**
  11494. * Sets the current filter is to ESM.
  11495. */
  11496. useExponentialShadowMap: boolean;
  11497. /**
  11498. * Gets if the current filter is set to filtered ESM.
  11499. */
  11500. /**
  11501. * Gets if the current filter is set to filtered ESM.
  11502. */
  11503. useBlurExponentialShadowMap: boolean;
  11504. /**
  11505. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11506. * exponential to prevent steep falloff artifacts).
  11507. */
  11508. /**
  11509. * Sets the current filter to "close ESM" (using the inverse of the
  11510. * exponential to prevent steep falloff artifacts).
  11511. */
  11512. useCloseExponentialShadowMap: boolean;
  11513. /**
  11514. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11515. * exponential to prevent steep falloff artifacts).
  11516. */
  11517. /**
  11518. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11519. * exponential to prevent steep falloff artifacts).
  11520. */
  11521. useBlurCloseExponentialShadowMap: boolean;
  11522. /**
  11523. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11524. */
  11525. /**
  11526. * Sets the current filter to "PCF" (percentage closer filtering).
  11527. */
  11528. usePercentageCloserFiltering: boolean;
  11529. private _filteringQuality;
  11530. /**
  11531. * Gets the PCF or PCSS Quality.
  11532. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11533. */
  11534. /**
  11535. * Sets the PCF or PCSS Quality.
  11536. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11537. */
  11538. filteringQuality: number;
  11539. /**
  11540. * Gets if the current filter is set to "PCSS" (contact hardening).
  11541. */
  11542. /**
  11543. * Sets the current filter to "PCSS" (contact hardening).
  11544. */
  11545. useContactHardeningShadow: boolean;
  11546. private _contactHardeningLightSizeUVRatio;
  11547. /**
  11548. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11549. * Using a ratio helps keeping shape stability independently of the map size.
  11550. *
  11551. * It does not account for the light projection as it was having too much
  11552. * instability during the light setup or during light position changes.
  11553. *
  11554. * Only valid if useContactHardeningShadow is true.
  11555. */
  11556. /**
  11557. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11558. * Using a ratio helps keeping shape stability independently of the map size.
  11559. *
  11560. * It does not account for the light projection as it was having too much
  11561. * instability during the light setup or during light position changes.
  11562. *
  11563. * Only valid if useContactHardeningShadow is true.
  11564. */
  11565. contactHardeningLightSizeUVRatio: number;
  11566. private _darkness;
  11567. /** Gets or sets the actual darkness of a shadow */
  11568. darkness: number;
  11569. /**
  11570. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11571. * 0 means strongest and 1 would means no shadow.
  11572. * @returns the darkness.
  11573. */
  11574. getDarkness(): number;
  11575. /**
  11576. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11577. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11578. * @returns the shadow generator allowing fluent coding.
  11579. */
  11580. setDarkness(darkness: number): ShadowGenerator;
  11581. private _transparencyShadow;
  11582. /** Gets or sets the ability to have transparent shadow */
  11583. transparencyShadow: boolean;
  11584. /**
  11585. * Sets the ability to have transparent shadow (boolean).
  11586. * @param transparent True if transparent else False
  11587. * @returns the shadow generator allowing fluent coding
  11588. */
  11589. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11590. private _shadowMap;
  11591. private _shadowMap2;
  11592. /**
  11593. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11594. * @returns The render target texture if present otherwise, null
  11595. */
  11596. getShadowMap(): Nullable<RenderTargetTexture>;
  11597. /**
  11598. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11599. * @returns The render target texture if the shadow map is present otherwise, null
  11600. */
  11601. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11602. /**
  11603. * Gets the class name of that object
  11604. * @returns "ShadowGenerator"
  11605. */
  11606. getClassName(): string;
  11607. /**
  11608. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11609. * @param mesh Mesh to add
  11610. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11611. * @returns the Shadow Generator itself
  11612. */
  11613. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11614. /**
  11615. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11616. * @param mesh Mesh to remove
  11617. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11618. * @returns the Shadow Generator itself
  11619. */
  11620. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11621. /**
  11622. * Controls the extent to which the shadows fade out at the edge of the frustum
  11623. * Used only by directionals and spots
  11624. */
  11625. frustumEdgeFalloff: number;
  11626. private _light;
  11627. /**
  11628. * Returns the associated light object.
  11629. * @returns the light generating the shadow
  11630. */
  11631. getLight(): IShadowLight;
  11632. /**
  11633. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11634. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11635. * It might on the other hand introduce peter panning.
  11636. */
  11637. forceBackFacesOnly: boolean;
  11638. private _scene;
  11639. private _lightDirection;
  11640. private _effect;
  11641. private _viewMatrix;
  11642. private _projectionMatrix;
  11643. private _transformMatrix;
  11644. private _cachedPosition;
  11645. private _cachedDirection;
  11646. private _cachedDefines;
  11647. private _currentRenderID;
  11648. private _boxBlurPostprocess;
  11649. private _kernelBlurXPostprocess;
  11650. private _kernelBlurYPostprocess;
  11651. private _blurPostProcesses;
  11652. private _mapSize;
  11653. private _currentFaceIndex;
  11654. private _currentFaceIndexCache;
  11655. private _textureType;
  11656. private _defaultTextureMatrix;
  11657. /** @hidden */
  11658. static _SceneComponentInitialization: (scene: Scene) => void;
  11659. /**
  11660. * Creates a ShadowGenerator object.
  11661. * A ShadowGenerator is the required tool to use the shadows.
  11662. * Each light casting shadows needs to use its own ShadowGenerator.
  11663. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11664. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11665. * @param light The light object generating the shadows.
  11666. * @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.
  11667. */
  11668. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11669. private _initializeGenerator;
  11670. private _initializeShadowMap;
  11671. private _initializeBlurRTTAndPostProcesses;
  11672. private _renderForShadowMap;
  11673. private _renderSubMeshForShadowMap;
  11674. private _applyFilterValues;
  11675. /**
  11676. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11677. * @param onCompiled Callback triggered at the and of the effects compilation
  11678. * @param options Sets of optional options forcing the compilation with different modes
  11679. */
  11680. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11681. useInstances: boolean;
  11682. }>): void;
  11683. /**
  11684. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11685. * @param options Sets of optional options forcing the compilation with different modes
  11686. * @returns A promise that resolves when the compilation completes
  11687. */
  11688. forceCompilationAsync(options?: Partial<{
  11689. useInstances: boolean;
  11690. }>): Promise<void>;
  11691. /**
  11692. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11693. * @param subMesh The submesh we want to render in the shadow map
  11694. * @param useInstances Defines wether will draw in the map using instances
  11695. * @returns true if ready otherwise, false
  11696. */
  11697. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11698. /**
  11699. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11700. * @param defines Defines of the material we want to update
  11701. * @param lightIndex Index of the light in the enabled light list of the material
  11702. */
  11703. prepareDefines(defines: any, lightIndex: number): void;
  11704. /**
  11705. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11706. * defined in the generator but impacting the effect).
  11707. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11708. * @param effect The effect we are binfing the information for
  11709. */
  11710. bindShadowLight(lightIndex: string, effect: Effect): void;
  11711. /**
  11712. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11713. * (eq to shadow prjection matrix * light transform matrix)
  11714. * @returns The transform matrix used to create the shadow map
  11715. */
  11716. getTransformMatrix(): Matrix;
  11717. /**
  11718. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11719. * Cube and 2D textures for instance.
  11720. */
  11721. recreateShadowMap(): void;
  11722. private _disposeBlurPostProcesses;
  11723. private _disposeRTTandPostProcesses;
  11724. /**
  11725. * Disposes the ShadowGenerator.
  11726. * Returns nothing.
  11727. */
  11728. dispose(): void;
  11729. /**
  11730. * Serializes the shadow generator setup to a json object.
  11731. * @returns The serialized JSON object
  11732. */
  11733. serialize(): any;
  11734. /**
  11735. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11736. * @param parsedShadowGenerator The JSON object to parse
  11737. * @param scene The scene to create the shadow map for
  11738. * @returns The parsed shadow generator
  11739. */
  11740. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11741. }
  11742. }
  11743. declare module BABYLON {
  11744. /**
  11745. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11746. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11747. * 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.
  11748. */
  11749. export abstract class Light extends Node {
  11750. /**
  11751. * Falloff Default: light is falling off following the material specification:
  11752. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11753. */
  11754. static readonly FALLOFF_DEFAULT: number;
  11755. /**
  11756. * Falloff Physical: light is falling off following the inverse squared distance law.
  11757. */
  11758. static readonly FALLOFF_PHYSICAL: number;
  11759. /**
  11760. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11761. * to enhance interoperability with other engines.
  11762. */
  11763. static readonly FALLOFF_GLTF: number;
  11764. /**
  11765. * Falloff Standard: light is falling off like in the standard material
  11766. * to enhance interoperability with other materials.
  11767. */
  11768. static readonly FALLOFF_STANDARD: number;
  11769. /**
  11770. * If every light affecting the material is in this lightmapMode,
  11771. * material.lightmapTexture adds or multiplies
  11772. * (depends on material.useLightmapAsShadowmap)
  11773. * after every other light calculations.
  11774. */
  11775. static readonly LIGHTMAP_DEFAULT: number;
  11776. /**
  11777. * material.lightmapTexture as only diffuse lighting from this light
  11778. * adds only specular lighting from this light
  11779. * adds dynamic shadows
  11780. */
  11781. static readonly LIGHTMAP_SPECULAR: number;
  11782. /**
  11783. * material.lightmapTexture as only lighting
  11784. * no light calculation from this light
  11785. * only adds dynamic shadows from this light
  11786. */
  11787. static readonly LIGHTMAP_SHADOWSONLY: number;
  11788. /**
  11789. * Each light type uses the default quantity according to its type:
  11790. * point/spot lights use luminous intensity
  11791. * directional lights use illuminance
  11792. */
  11793. static readonly INTENSITYMODE_AUTOMATIC: number;
  11794. /**
  11795. * lumen (lm)
  11796. */
  11797. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11798. /**
  11799. * candela (lm/sr)
  11800. */
  11801. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11802. /**
  11803. * lux (lm/m^2)
  11804. */
  11805. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11806. /**
  11807. * nit (cd/m^2)
  11808. */
  11809. static readonly INTENSITYMODE_LUMINANCE: number;
  11810. /**
  11811. * Light type const id of the point light.
  11812. */
  11813. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11814. /**
  11815. * Light type const id of the directional light.
  11816. */
  11817. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11818. /**
  11819. * Light type const id of the spot light.
  11820. */
  11821. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11822. /**
  11823. * Light type const id of the hemispheric light.
  11824. */
  11825. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11826. /**
  11827. * Diffuse gives the basic color to an object.
  11828. */
  11829. diffuse: Color3;
  11830. /**
  11831. * Specular produces a highlight color on an object.
  11832. * Note: This is note affecting PBR materials.
  11833. */
  11834. specular: Color3;
  11835. /**
  11836. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11837. * falling off base on range or angle.
  11838. * This can be set to any values in Light.FALLOFF_x.
  11839. *
  11840. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11841. * other types of materials.
  11842. */
  11843. falloffType: number;
  11844. /**
  11845. * Strength of the light.
  11846. * Note: By default it is define in the framework own unit.
  11847. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11848. */
  11849. intensity: number;
  11850. private _range;
  11851. protected _inverseSquaredRange: number;
  11852. /**
  11853. * Defines how far from the source the light is impacting in scene units.
  11854. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11855. */
  11856. /**
  11857. * Defines how far from the source the light is impacting in scene units.
  11858. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11859. */
  11860. range: number;
  11861. /**
  11862. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11863. * of light.
  11864. */
  11865. private _photometricScale;
  11866. private _intensityMode;
  11867. /**
  11868. * Gets the photometric scale used to interpret the intensity.
  11869. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11870. */
  11871. /**
  11872. * Sets the photometric scale used to interpret the intensity.
  11873. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11874. */
  11875. intensityMode: number;
  11876. private _radius;
  11877. /**
  11878. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11879. */
  11880. /**
  11881. * sets the light radius used by PBR Materials to simulate soft area lights.
  11882. */
  11883. radius: number;
  11884. private _renderPriority;
  11885. /**
  11886. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11887. * exceeding the number allowed of the materials.
  11888. */
  11889. renderPriority: number;
  11890. private _shadowEnabled;
  11891. /**
  11892. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11893. * the current shadow generator.
  11894. */
  11895. /**
  11896. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11897. * the current shadow generator.
  11898. */
  11899. shadowEnabled: boolean;
  11900. private _includedOnlyMeshes;
  11901. /**
  11902. * Gets the only meshes impacted by this light.
  11903. */
  11904. /**
  11905. * Sets the only meshes impacted by this light.
  11906. */
  11907. includedOnlyMeshes: AbstractMesh[];
  11908. private _excludedMeshes;
  11909. /**
  11910. * Gets the meshes not impacted by this light.
  11911. */
  11912. /**
  11913. * Sets the meshes not impacted by this light.
  11914. */
  11915. excludedMeshes: AbstractMesh[];
  11916. private _excludeWithLayerMask;
  11917. /**
  11918. * Gets the layer id use to find what meshes are not impacted by the light.
  11919. * Inactive if 0
  11920. */
  11921. /**
  11922. * Sets the layer id use to find what meshes are not impacted by the light.
  11923. * Inactive if 0
  11924. */
  11925. excludeWithLayerMask: number;
  11926. private _includeOnlyWithLayerMask;
  11927. /**
  11928. * Gets the layer id use to find what meshes are impacted by the light.
  11929. * Inactive if 0
  11930. */
  11931. /**
  11932. * Sets the layer id use to find what meshes are impacted by the light.
  11933. * Inactive if 0
  11934. */
  11935. includeOnlyWithLayerMask: number;
  11936. private _lightmapMode;
  11937. /**
  11938. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11939. */
  11940. /**
  11941. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11942. */
  11943. lightmapMode: number;
  11944. /**
  11945. * Shadow generator associted to the light.
  11946. * @hidden Internal use only.
  11947. */
  11948. _shadowGenerator: Nullable<IShadowGenerator>;
  11949. /**
  11950. * @hidden Internal use only.
  11951. */
  11952. _excludedMeshesIds: string[];
  11953. /**
  11954. * @hidden Internal use only.
  11955. */
  11956. _includedOnlyMeshesIds: string[];
  11957. /**
  11958. * The current light unifom buffer.
  11959. * @hidden Internal use only.
  11960. */
  11961. _uniformBuffer: UniformBuffer;
  11962. /**
  11963. * Creates a Light object in the scene.
  11964. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11965. * @param name The firendly name of the light
  11966. * @param scene The scene the light belongs too
  11967. */
  11968. constructor(name: string, scene: Scene);
  11969. protected abstract _buildUniformLayout(): void;
  11970. /**
  11971. * Sets the passed Effect "effect" with the Light information.
  11972. * @param effect The effect to update
  11973. * @param lightIndex The index of the light in the effect to update
  11974. * @returns The light
  11975. */
  11976. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11977. /**
  11978. * Returns the string "Light".
  11979. * @returns the class name
  11980. */
  11981. getClassName(): string;
  11982. /** @hidden */
  11983. readonly _isLight: boolean;
  11984. /**
  11985. * Converts the light information to a readable string for debug purpose.
  11986. * @param fullDetails Supports for multiple levels of logging within scene loading
  11987. * @returns the human readable light info
  11988. */
  11989. toString(fullDetails?: boolean): string;
  11990. /** @hidden */
  11991. protected _syncParentEnabledState(): void;
  11992. /**
  11993. * Set the enabled state of this node.
  11994. * @param value - the new enabled state
  11995. */
  11996. setEnabled(value: boolean): void;
  11997. /**
  11998. * Returns the Light associated shadow generator if any.
  11999. * @return the associated shadow generator.
  12000. */
  12001. getShadowGenerator(): Nullable<IShadowGenerator>;
  12002. /**
  12003. * Returns a Vector3, the absolute light position in the World.
  12004. * @returns the world space position of the light
  12005. */
  12006. getAbsolutePosition(): Vector3;
  12007. /**
  12008. * Specifies if the light will affect the passed mesh.
  12009. * @param mesh The mesh to test against the light
  12010. * @return true the mesh is affected otherwise, false.
  12011. */
  12012. canAffectMesh(mesh: AbstractMesh): boolean;
  12013. /**
  12014. * Sort function to order lights for rendering.
  12015. * @param a First Light object to compare to second.
  12016. * @param b Second Light object to compare first.
  12017. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12018. */
  12019. static CompareLightsPriority(a: Light, b: Light): number;
  12020. /**
  12021. * Releases resources associated with this node.
  12022. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12023. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12024. */
  12025. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12026. /**
  12027. * Returns the light type ID (integer).
  12028. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12029. */
  12030. getTypeID(): number;
  12031. /**
  12032. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12033. * @returns the scaled intensity in intensity mode unit
  12034. */
  12035. getScaledIntensity(): number;
  12036. /**
  12037. * Returns a new Light object, named "name", from the current one.
  12038. * @param name The name of the cloned light
  12039. * @returns the new created light
  12040. */
  12041. clone(name: string): Nullable<Light>;
  12042. /**
  12043. * Serializes the current light into a Serialization object.
  12044. * @returns the serialized object.
  12045. */
  12046. serialize(): any;
  12047. /**
  12048. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12049. * This new light is named "name" and added to the passed scene.
  12050. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12051. * @param name The friendly name of the light
  12052. * @param scene The scene the new light will belong to
  12053. * @returns the constructor function
  12054. */
  12055. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12056. /**
  12057. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12058. * @param parsedLight The JSON representation of the light
  12059. * @param scene The scene to create the parsed light in
  12060. * @returns the created light after parsing
  12061. */
  12062. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12063. private _hookArrayForExcluded;
  12064. private _hookArrayForIncludedOnly;
  12065. private _resyncMeshes;
  12066. /**
  12067. * Forces the meshes to update their light related information in their rendering used effects
  12068. * @hidden Internal Use Only
  12069. */
  12070. _markMeshesAsLightDirty(): void;
  12071. /**
  12072. * Recomputes the cached photometric scale if needed.
  12073. */
  12074. private _computePhotometricScale;
  12075. /**
  12076. * Returns the Photometric Scale according to the light type and intensity mode.
  12077. */
  12078. private _getPhotometricScale;
  12079. /**
  12080. * Reorder the light in the scene according to their defined priority.
  12081. * @hidden Internal Use Only
  12082. */
  12083. _reorderLightsInScene(): void;
  12084. /**
  12085. * Prepares the list of defines specific to the light type.
  12086. * @param defines the list of defines
  12087. * @param lightIndex defines the index of the light for the effect
  12088. */
  12089. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12090. }
  12091. }
  12092. declare module BABYLON {
  12093. /**
  12094. * Creates an instance based on a source mesh.
  12095. */
  12096. export class InstancedMesh extends AbstractMesh {
  12097. private _sourceMesh;
  12098. private _currentLOD;
  12099. /** @hidden */
  12100. _indexInSourceMeshInstanceArray: number;
  12101. constructor(name: string, source: Mesh);
  12102. /**
  12103. * Returns the string "InstancedMesh".
  12104. */
  12105. getClassName(): string;
  12106. /** Gets the list of lights affecting that mesh */
  12107. readonly lightSources: Light[];
  12108. _resyncLightSources(): void;
  12109. _resyncLighSource(light: Light): void;
  12110. _removeLightSource(light: Light): void;
  12111. /**
  12112. * If the source mesh receives shadows
  12113. */
  12114. readonly receiveShadows: boolean;
  12115. /**
  12116. * The material of the source mesh
  12117. */
  12118. readonly material: Nullable<Material>;
  12119. /**
  12120. * Visibility of the source mesh
  12121. */
  12122. readonly visibility: number;
  12123. /**
  12124. * Skeleton of the source mesh
  12125. */
  12126. readonly skeleton: Nullable<Skeleton>;
  12127. /**
  12128. * Rendering ground id of the source mesh
  12129. */
  12130. renderingGroupId: number;
  12131. /**
  12132. * Returns the total number of vertices (integer).
  12133. */
  12134. getTotalVertices(): number;
  12135. /**
  12136. * Returns a positive integer : the total number of indices in this mesh geometry.
  12137. * @returns the numner of indices or zero if the mesh has no geometry.
  12138. */
  12139. getTotalIndices(): number;
  12140. /**
  12141. * The source mesh of the instance
  12142. */
  12143. readonly sourceMesh: Mesh;
  12144. /**
  12145. * Is this node ready to be used/rendered
  12146. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12147. * @return {boolean} is it ready
  12148. */
  12149. isReady(completeCheck?: boolean): boolean;
  12150. /**
  12151. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12152. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12153. * @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.
  12154. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12155. */
  12156. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12157. /**
  12158. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12159. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12160. * The `data` are either a numeric array either a Float32Array.
  12161. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12162. * 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).
  12163. * Note that a new underlying VertexBuffer object is created each call.
  12164. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12165. *
  12166. * Possible `kind` values :
  12167. * - VertexBuffer.PositionKind
  12168. * - VertexBuffer.UVKind
  12169. * - VertexBuffer.UV2Kind
  12170. * - VertexBuffer.UV3Kind
  12171. * - VertexBuffer.UV4Kind
  12172. * - VertexBuffer.UV5Kind
  12173. * - VertexBuffer.UV6Kind
  12174. * - VertexBuffer.ColorKind
  12175. * - VertexBuffer.MatricesIndicesKind
  12176. * - VertexBuffer.MatricesIndicesExtraKind
  12177. * - VertexBuffer.MatricesWeightsKind
  12178. * - VertexBuffer.MatricesWeightsExtraKind
  12179. *
  12180. * Returns the Mesh.
  12181. */
  12182. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12183. /**
  12184. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12185. * If the mesh has no geometry, it is simply returned as it is.
  12186. * The `data` are either a numeric array either a Float32Array.
  12187. * No new underlying VertexBuffer object is created.
  12188. * 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.
  12189. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12190. *
  12191. * Possible `kind` values :
  12192. * - VertexBuffer.PositionKind
  12193. * - VertexBuffer.UVKind
  12194. * - VertexBuffer.UV2Kind
  12195. * - VertexBuffer.UV3Kind
  12196. * - VertexBuffer.UV4Kind
  12197. * - VertexBuffer.UV5Kind
  12198. * - VertexBuffer.UV6Kind
  12199. * - VertexBuffer.ColorKind
  12200. * - VertexBuffer.MatricesIndicesKind
  12201. * - VertexBuffer.MatricesIndicesExtraKind
  12202. * - VertexBuffer.MatricesWeightsKind
  12203. * - VertexBuffer.MatricesWeightsExtraKind
  12204. *
  12205. * Returns the Mesh.
  12206. */
  12207. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12208. /**
  12209. * Sets the mesh indices.
  12210. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12211. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12212. * This method creates a new index buffer each call.
  12213. * Returns the Mesh.
  12214. */
  12215. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12216. /**
  12217. * Boolean : True if the mesh owns the requested kind of data.
  12218. */
  12219. isVerticesDataPresent(kind: string): boolean;
  12220. /**
  12221. * Returns an array of indices (IndicesArray).
  12222. */
  12223. getIndices(): Nullable<IndicesArray>;
  12224. readonly _positions: Nullable<Vector3[]>;
  12225. /**
  12226. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12227. * This means the mesh underlying bounding box and sphere are recomputed.
  12228. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12229. * @returns the current mesh
  12230. */
  12231. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12232. /** @hidden */
  12233. _preActivate(): InstancedMesh;
  12234. /** @hidden */
  12235. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12236. /** @hidden */
  12237. _postActivate(): void;
  12238. getWorldMatrix(): Matrix;
  12239. readonly isAnInstance: boolean;
  12240. /**
  12241. * Returns the current associated LOD AbstractMesh.
  12242. */
  12243. getLOD(camera: Camera): AbstractMesh;
  12244. /** @hidden */
  12245. _syncSubMeshes(): InstancedMesh;
  12246. /** @hidden */
  12247. _generatePointsArray(): boolean;
  12248. /**
  12249. * Creates a new InstancedMesh from the current mesh.
  12250. * - name (string) : the cloned mesh name
  12251. * - newParent (optional Node) : the optional Node to parent the clone to.
  12252. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12253. *
  12254. * Returns the clone.
  12255. */
  12256. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12257. /**
  12258. * Disposes the InstancedMesh.
  12259. * Returns nothing.
  12260. */
  12261. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12262. }
  12263. }
  12264. declare module BABYLON {
  12265. /**
  12266. * Defines the options associated with the creation of a shader material.
  12267. */
  12268. export interface IShaderMaterialOptions {
  12269. /**
  12270. * Does the material work in alpha blend mode
  12271. */
  12272. needAlphaBlending: boolean;
  12273. /**
  12274. * Does the material work in alpha test mode
  12275. */
  12276. needAlphaTesting: boolean;
  12277. /**
  12278. * The list of attribute names used in the shader
  12279. */
  12280. attributes: string[];
  12281. /**
  12282. * The list of unifrom names used in the shader
  12283. */
  12284. uniforms: string[];
  12285. /**
  12286. * The list of UBO names used in the shader
  12287. */
  12288. uniformBuffers: string[];
  12289. /**
  12290. * The list of sampler names used in the shader
  12291. */
  12292. samplers: string[];
  12293. /**
  12294. * The list of defines used in the shader
  12295. */
  12296. defines: string[];
  12297. }
  12298. /**
  12299. * 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.
  12300. *
  12301. * This returned material effects how the mesh will look based on the code in the shaders.
  12302. *
  12303. * @see http://doc.babylonjs.com/how_to/shader_material
  12304. */
  12305. export class ShaderMaterial extends Material {
  12306. private _shaderPath;
  12307. private _options;
  12308. private _textures;
  12309. private _textureArrays;
  12310. private _floats;
  12311. private _ints;
  12312. private _floatsArrays;
  12313. private _colors3;
  12314. private _colors3Arrays;
  12315. private _colors4;
  12316. private _colors4Arrays;
  12317. private _vectors2;
  12318. private _vectors3;
  12319. private _vectors4;
  12320. private _matrices;
  12321. private _matrices3x3;
  12322. private _matrices2x2;
  12323. private _vectors2Arrays;
  12324. private _vectors3Arrays;
  12325. private _vectors4Arrays;
  12326. private _cachedWorldViewMatrix;
  12327. private _cachedWorldViewProjectionMatrix;
  12328. private _renderId;
  12329. /**
  12330. * Instantiate a new shader material.
  12331. * 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.
  12332. * This returned material effects how the mesh will look based on the code in the shaders.
  12333. * @see http://doc.babylonjs.com/how_to/shader_material
  12334. * @param name Define the name of the material in the scene
  12335. * @param scene Define the scene the material belongs to
  12336. * @param shaderPath Defines the route to the shader code in one of three ways:
  12337. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12338. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12339. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12340. * @param options Define the options used to create the shader
  12341. */
  12342. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12343. /**
  12344. * Gets the options used to compile the shader.
  12345. * They can be modified to trigger a new compilation
  12346. */
  12347. readonly options: IShaderMaterialOptions;
  12348. /**
  12349. * Gets the current class name of the material e.g. "ShaderMaterial"
  12350. * Mainly use in serialization.
  12351. * @returns the class name
  12352. */
  12353. getClassName(): string;
  12354. /**
  12355. * Specifies if the material will require alpha blending
  12356. * @returns a boolean specifying if alpha blending is needed
  12357. */
  12358. needAlphaBlending(): boolean;
  12359. /**
  12360. * Specifies if this material should be rendered in alpha test mode
  12361. * @returns a boolean specifying if an alpha test is needed.
  12362. */
  12363. needAlphaTesting(): boolean;
  12364. private _checkUniform;
  12365. /**
  12366. * Set a texture in the shader.
  12367. * @param name Define the name of the uniform samplers as defined in the shader
  12368. * @param texture Define the texture to bind to this sampler
  12369. * @return the material itself allowing "fluent" like uniform updates
  12370. */
  12371. setTexture(name: string, texture: Texture): ShaderMaterial;
  12372. /**
  12373. * Set a texture array in the shader.
  12374. * @param name Define the name of the uniform sampler array as defined in the shader
  12375. * @param textures Define the list of textures to bind to this sampler
  12376. * @return the material itself allowing "fluent" like uniform updates
  12377. */
  12378. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12379. /**
  12380. * Set a float in the shader.
  12381. * @param name Define the name of the uniform as defined in the shader
  12382. * @param value Define the value to give to the uniform
  12383. * @return the material itself allowing "fluent" like uniform updates
  12384. */
  12385. setFloat(name: string, value: number): ShaderMaterial;
  12386. /**
  12387. * Set a int in the shader.
  12388. * @param name Define the name of the uniform as defined in the shader
  12389. * @param value Define the value to give to the uniform
  12390. * @return the material itself allowing "fluent" like uniform updates
  12391. */
  12392. setInt(name: string, value: number): ShaderMaterial;
  12393. /**
  12394. * Set an array of floats in the shader.
  12395. * @param name Define the name of the uniform as defined in the shader
  12396. * @param value Define the value to give to the uniform
  12397. * @return the material itself allowing "fluent" like uniform updates
  12398. */
  12399. setFloats(name: string, value: number[]): ShaderMaterial;
  12400. /**
  12401. * Set a vec3 in the shader from a Color3.
  12402. * @param name Define the name of the uniform as defined in the shader
  12403. * @param value Define the value to give to the uniform
  12404. * @return the material itself allowing "fluent" like uniform updates
  12405. */
  12406. setColor3(name: string, value: Color3): ShaderMaterial;
  12407. /**
  12408. * Set a vec3 array in the shader from a Color3 array.
  12409. * @param name Define the name of the uniform as defined in the shader
  12410. * @param value Define the value to give to the uniform
  12411. * @return the material itself allowing "fluent" like uniform updates
  12412. */
  12413. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12414. /**
  12415. * Set a vec4 in the shader from a Color4.
  12416. * @param name Define the name of the uniform as defined in the shader
  12417. * @param value Define the value to give to the uniform
  12418. * @return the material itself allowing "fluent" like uniform updates
  12419. */
  12420. setColor4(name: string, value: Color4): ShaderMaterial;
  12421. /**
  12422. * Set a vec4 array in the shader from a Color4 array.
  12423. * @param name Define the name of the uniform as defined in the shader
  12424. * @param value Define the value to give to the uniform
  12425. * @return the material itself allowing "fluent" like uniform updates
  12426. */
  12427. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12428. /**
  12429. * Set a vec2 in the shader from a Vector2.
  12430. * @param name Define the name of the uniform as defined in the shader
  12431. * @param value Define the value to give to the uniform
  12432. * @return the material itself allowing "fluent" like uniform updates
  12433. */
  12434. setVector2(name: string, value: Vector2): ShaderMaterial;
  12435. /**
  12436. * Set a vec3 in the shader from a Vector3.
  12437. * @param name Define the name of the uniform as defined in the shader
  12438. * @param value Define the value to give to the uniform
  12439. * @return the material itself allowing "fluent" like uniform updates
  12440. */
  12441. setVector3(name: string, value: Vector3): ShaderMaterial;
  12442. /**
  12443. * Set a vec4 in the shader from a Vector4.
  12444. * @param name Define the name of the uniform as defined in the shader
  12445. * @param value Define the value to give to the uniform
  12446. * @return the material itself allowing "fluent" like uniform updates
  12447. */
  12448. setVector4(name: string, value: Vector4): ShaderMaterial;
  12449. /**
  12450. * Set a mat4 in the shader from a Matrix.
  12451. * @param name Define the name of the uniform as defined in the shader
  12452. * @param value Define the value to give to the uniform
  12453. * @return the material itself allowing "fluent" like uniform updates
  12454. */
  12455. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12456. /**
  12457. * Set a mat3 in the shader from a Float32Array.
  12458. * @param name Define the name of the uniform as defined in the shader
  12459. * @param value Define the value to give to the uniform
  12460. * @return the material itself allowing "fluent" like uniform updates
  12461. */
  12462. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12463. /**
  12464. * Set a mat2 in the shader from a Float32Array.
  12465. * @param name Define the name of the uniform as defined in the shader
  12466. * @param value Define the value to give to the uniform
  12467. * @return the material itself allowing "fluent" like uniform updates
  12468. */
  12469. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12470. /**
  12471. * Set a vec2 array in the shader from a number array.
  12472. * @param name Define the name of the uniform as defined in the shader
  12473. * @param value Define the value to give to the uniform
  12474. * @return the material itself allowing "fluent" like uniform updates
  12475. */
  12476. setArray2(name: string, value: number[]): ShaderMaterial;
  12477. /**
  12478. * Set a vec3 array in the shader from a number array.
  12479. * @param name Define the name of the uniform as defined in the shader
  12480. * @param value Define the value to give to the uniform
  12481. * @return the material itself allowing "fluent" like uniform updates
  12482. */
  12483. setArray3(name: string, value: number[]): ShaderMaterial;
  12484. /**
  12485. * Set a vec4 array in the shader from a number array.
  12486. * @param name Define the name of the uniform as defined in the shader
  12487. * @param value Define the value to give to the uniform
  12488. * @return the material itself allowing "fluent" like uniform updates
  12489. */
  12490. setArray4(name: string, value: number[]): ShaderMaterial;
  12491. private _checkCache;
  12492. /**
  12493. * Specifies that the submesh is ready to be used
  12494. * @param mesh defines the mesh to check
  12495. * @param subMesh defines which submesh to check
  12496. * @param useInstances specifies that instances should be used
  12497. * @returns a boolean indicating that the submesh is ready or not
  12498. */
  12499. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12500. /**
  12501. * Checks if the material is ready to render the requested mesh
  12502. * @param mesh Define the mesh to render
  12503. * @param useInstances Define whether or not the material is used with instances
  12504. * @returns true if ready, otherwise false
  12505. */
  12506. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12507. /**
  12508. * Binds the world matrix to the material
  12509. * @param world defines the world transformation matrix
  12510. */
  12511. bindOnlyWorldMatrix(world: Matrix): void;
  12512. /**
  12513. * Binds the material to the mesh
  12514. * @param world defines the world transformation matrix
  12515. * @param mesh defines the mesh to bind the material to
  12516. */
  12517. bind(world: Matrix, mesh?: Mesh): void;
  12518. /**
  12519. * Gets the active textures from the material
  12520. * @returns an array of textures
  12521. */
  12522. getActiveTextures(): BaseTexture[];
  12523. /**
  12524. * Specifies if the material uses a texture
  12525. * @param texture defines the texture to check against the material
  12526. * @returns a boolean specifying if the material uses the texture
  12527. */
  12528. hasTexture(texture: BaseTexture): boolean;
  12529. /**
  12530. * Makes a duplicate of the material, and gives it a new name
  12531. * @param name defines the new name for the duplicated material
  12532. * @returns the cloned material
  12533. */
  12534. clone(name: string): ShaderMaterial;
  12535. /**
  12536. * Disposes the material
  12537. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12538. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12539. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12540. */
  12541. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12542. /**
  12543. * Serializes this material in a JSON representation
  12544. * @returns the serialized material object
  12545. */
  12546. serialize(): any;
  12547. /**
  12548. * Creates a shader material from parsed shader material data
  12549. * @param source defines the JSON represnetation of the material
  12550. * @param scene defines the hosting scene
  12551. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12552. * @returns a new material
  12553. */
  12554. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12555. }
  12556. }
  12557. declare module BABYLON {
  12558. /** @hidden */
  12559. export var clipPlaneFragmentDeclaration: {
  12560. name: string;
  12561. shader: string;
  12562. };
  12563. }
  12564. declare module BABYLON {
  12565. /** @hidden */
  12566. export var clipPlaneFragment: {
  12567. name: string;
  12568. shader: string;
  12569. };
  12570. }
  12571. declare module BABYLON {
  12572. /** @hidden */
  12573. export var colorPixelShader: {
  12574. name: string;
  12575. shader: string;
  12576. };
  12577. }
  12578. declare module BABYLON {
  12579. /** @hidden */
  12580. export var clipPlaneVertexDeclaration: {
  12581. name: string;
  12582. shader: string;
  12583. };
  12584. }
  12585. declare module BABYLON {
  12586. /** @hidden */
  12587. export var clipPlaneVertex: {
  12588. name: string;
  12589. shader: string;
  12590. };
  12591. }
  12592. declare module BABYLON {
  12593. /** @hidden */
  12594. export var colorVertexShader: {
  12595. name: string;
  12596. shader: string;
  12597. };
  12598. }
  12599. declare module BABYLON {
  12600. /**
  12601. * Line mesh
  12602. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12603. */
  12604. export class LinesMesh extends Mesh {
  12605. /**
  12606. * If vertex color should be applied to the mesh
  12607. */
  12608. readonly useVertexColor?: boolean | undefined;
  12609. /**
  12610. * If vertex alpha should be applied to the mesh
  12611. */
  12612. readonly useVertexAlpha?: boolean | undefined;
  12613. /**
  12614. * Color of the line (Default: White)
  12615. */
  12616. color: Color3;
  12617. /**
  12618. * Alpha of the line (Default: 1)
  12619. */
  12620. alpha: number;
  12621. /**
  12622. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12623. * This margin is expressed in world space coordinates, so its value may vary.
  12624. * Default value is 0.1
  12625. */
  12626. intersectionThreshold: number;
  12627. private _colorShader;
  12628. private color4;
  12629. /**
  12630. * Creates a new LinesMesh
  12631. * @param name defines the name
  12632. * @param scene defines the hosting scene
  12633. * @param parent defines the parent mesh if any
  12634. * @param source defines the optional source LinesMesh used to clone data from
  12635. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12636. * When false, achieved by calling a clone(), also passing False.
  12637. * This will make creation of children, recursive.
  12638. * @param useVertexColor defines if this LinesMesh supports vertex color
  12639. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12640. */
  12641. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12642. /**
  12643. * If vertex color should be applied to the mesh
  12644. */
  12645. useVertexColor?: boolean | undefined,
  12646. /**
  12647. * If vertex alpha should be applied to the mesh
  12648. */
  12649. useVertexAlpha?: boolean | undefined);
  12650. private _addClipPlaneDefine;
  12651. private _removeClipPlaneDefine;
  12652. isReady(): boolean;
  12653. /**
  12654. * Returns the string "LineMesh"
  12655. */
  12656. getClassName(): string;
  12657. /**
  12658. * @hidden
  12659. */
  12660. /**
  12661. * @hidden
  12662. */
  12663. material: Material;
  12664. /**
  12665. * @hidden
  12666. */
  12667. readonly checkCollisions: boolean;
  12668. /** @hidden */
  12669. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12670. /** @hidden */
  12671. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12672. /**
  12673. * Disposes of the line mesh
  12674. * @param doNotRecurse If children should be disposed
  12675. */
  12676. dispose(doNotRecurse?: boolean): void;
  12677. /**
  12678. * Returns a new LineMesh object cloned from the current one.
  12679. */
  12680. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12681. /**
  12682. * Creates a new InstancedLinesMesh object from the mesh model.
  12683. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12684. * @param name defines the name of the new instance
  12685. * @returns a new InstancedLinesMesh
  12686. */
  12687. createInstance(name: string): InstancedLinesMesh;
  12688. }
  12689. /**
  12690. * Creates an instance based on a source LinesMesh
  12691. */
  12692. export class InstancedLinesMesh extends InstancedMesh {
  12693. /**
  12694. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12695. * This margin is expressed in world space coordinates, so its value may vary.
  12696. * Initilized with the intersectionThreshold value of the source LinesMesh
  12697. */
  12698. intersectionThreshold: number;
  12699. constructor(name: string, source: LinesMesh);
  12700. /**
  12701. * Returns the string "InstancedLinesMesh".
  12702. */
  12703. getClassName(): string;
  12704. }
  12705. }
  12706. declare module BABYLON {
  12707. /**
  12708. * Mesh representing the gorund
  12709. */
  12710. export class GroundMesh extends Mesh {
  12711. /** If octree should be generated */
  12712. generateOctree: boolean;
  12713. private _heightQuads;
  12714. /** @hidden */
  12715. _subdivisionsX: number;
  12716. /** @hidden */
  12717. _subdivisionsY: number;
  12718. /** @hidden */
  12719. _width: number;
  12720. /** @hidden */
  12721. _height: number;
  12722. /** @hidden */
  12723. _minX: number;
  12724. /** @hidden */
  12725. _maxX: number;
  12726. /** @hidden */
  12727. _minZ: number;
  12728. /** @hidden */
  12729. _maxZ: number;
  12730. constructor(name: string, scene: Scene);
  12731. /**
  12732. * "GroundMesh"
  12733. * @returns "GroundMesh"
  12734. */
  12735. getClassName(): string;
  12736. /**
  12737. * The minimum of x and y subdivisions
  12738. */
  12739. readonly subdivisions: number;
  12740. /**
  12741. * X subdivisions
  12742. */
  12743. readonly subdivisionsX: number;
  12744. /**
  12745. * Y subdivisions
  12746. */
  12747. readonly subdivisionsY: number;
  12748. /**
  12749. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12750. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12751. * @param chunksCount the number of subdivisions for x and y
  12752. * @param octreeBlocksSize (Default: 32)
  12753. */
  12754. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12755. /**
  12756. * Returns a height (y) value in the Worl system :
  12757. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12758. * @param x x coordinate
  12759. * @param z z coordinate
  12760. * @returns the ground y position if (x, z) are outside the ground surface.
  12761. */
  12762. getHeightAtCoordinates(x: number, z: number): number;
  12763. /**
  12764. * Returns a normalized vector (Vector3) orthogonal to the ground
  12765. * at the ground coordinates (x, z) expressed in the World system.
  12766. * @param x x coordinate
  12767. * @param z z coordinate
  12768. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12769. */
  12770. getNormalAtCoordinates(x: number, z: number): Vector3;
  12771. /**
  12772. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12773. * at the ground coordinates (x, z) expressed in the World system.
  12774. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12775. * @param x x coordinate
  12776. * @param z z coordinate
  12777. * @param ref vector to store the result
  12778. * @returns the GroundMesh.
  12779. */
  12780. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12781. /**
  12782. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12783. * if the ground has been updated.
  12784. * This can be used in the render loop.
  12785. * @returns the GroundMesh.
  12786. */
  12787. updateCoordinateHeights(): GroundMesh;
  12788. private _getFacetAt;
  12789. private _initHeightQuads;
  12790. private _computeHeightQuads;
  12791. /**
  12792. * Serializes this ground mesh
  12793. * @param serializationObject object to write serialization to
  12794. */
  12795. serialize(serializationObject: any): void;
  12796. /**
  12797. * Parses a serialized ground mesh
  12798. * @param parsedMesh the serialized mesh
  12799. * @param scene the scene to create the ground mesh in
  12800. * @returns the created ground mesh
  12801. */
  12802. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12803. }
  12804. }
  12805. declare module BABYLON {
  12806. /**
  12807. * Interface for Physics-Joint data
  12808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12809. */
  12810. export interface PhysicsJointData {
  12811. /**
  12812. * The main pivot of the joint
  12813. */
  12814. mainPivot?: Vector3;
  12815. /**
  12816. * The connected pivot of the joint
  12817. */
  12818. connectedPivot?: Vector3;
  12819. /**
  12820. * The main axis of the joint
  12821. */
  12822. mainAxis?: Vector3;
  12823. /**
  12824. * The connected axis of the joint
  12825. */
  12826. connectedAxis?: Vector3;
  12827. /**
  12828. * The collision of the joint
  12829. */
  12830. collision?: boolean;
  12831. /**
  12832. * Native Oimo/Cannon/Energy data
  12833. */
  12834. nativeParams?: any;
  12835. }
  12836. /**
  12837. * This is a holder class for the physics joint created by the physics plugin
  12838. * It holds a set of functions to control the underlying joint
  12839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12840. */
  12841. export class PhysicsJoint {
  12842. /**
  12843. * The type of the physics joint
  12844. */
  12845. type: number;
  12846. /**
  12847. * The data for the physics joint
  12848. */
  12849. jointData: PhysicsJointData;
  12850. private _physicsJoint;
  12851. protected _physicsPlugin: IPhysicsEnginePlugin;
  12852. /**
  12853. * Initializes the physics joint
  12854. * @param type The type of the physics joint
  12855. * @param jointData The data for the physics joint
  12856. */
  12857. constructor(
  12858. /**
  12859. * The type of the physics joint
  12860. */
  12861. type: number,
  12862. /**
  12863. * The data for the physics joint
  12864. */
  12865. jointData: PhysicsJointData);
  12866. /**
  12867. * Gets the physics joint
  12868. */
  12869. /**
  12870. * Sets the physics joint
  12871. */
  12872. physicsJoint: any;
  12873. /**
  12874. * Sets the physics plugin
  12875. */
  12876. physicsPlugin: IPhysicsEnginePlugin;
  12877. /**
  12878. * Execute a function that is physics-plugin specific.
  12879. * @param {Function} func the function that will be executed.
  12880. * It accepts two parameters: the physics world and the physics joint
  12881. */
  12882. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  12883. /**
  12884. * Distance-Joint type
  12885. */
  12886. static DistanceJoint: number;
  12887. /**
  12888. * Hinge-Joint type
  12889. */
  12890. static HingeJoint: number;
  12891. /**
  12892. * Ball-and-Socket joint type
  12893. */
  12894. static BallAndSocketJoint: number;
  12895. /**
  12896. * Wheel-Joint type
  12897. */
  12898. static WheelJoint: number;
  12899. /**
  12900. * Slider-Joint type
  12901. */
  12902. static SliderJoint: number;
  12903. /**
  12904. * Prismatic-Joint type
  12905. */
  12906. static PrismaticJoint: number;
  12907. /**
  12908. * Universal-Joint type
  12909. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  12910. */
  12911. static UniversalJoint: number;
  12912. /**
  12913. * Hinge-Joint 2 type
  12914. */
  12915. static Hinge2Joint: number;
  12916. /**
  12917. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  12918. */
  12919. static PointToPointJoint: number;
  12920. /**
  12921. * Spring-Joint type
  12922. */
  12923. static SpringJoint: number;
  12924. /**
  12925. * Lock-Joint type
  12926. */
  12927. static LockJoint: number;
  12928. }
  12929. /**
  12930. * A class representing a physics distance joint
  12931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12932. */
  12933. export class DistanceJoint extends PhysicsJoint {
  12934. /**
  12935. *
  12936. * @param jointData The data for the Distance-Joint
  12937. */
  12938. constructor(jointData: DistanceJointData);
  12939. /**
  12940. * Update the predefined distance.
  12941. * @param maxDistance The maximum preferred distance
  12942. * @param minDistance The minimum preferred distance
  12943. */
  12944. updateDistance(maxDistance: number, minDistance?: number): void;
  12945. }
  12946. /**
  12947. * Represents a Motor-Enabled Joint
  12948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12949. */
  12950. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  12951. /**
  12952. * Initializes the Motor-Enabled Joint
  12953. * @param type The type of the joint
  12954. * @param jointData The physica joint data for the joint
  12955. */
  12956. constructor(type: number, jointData: PhysicsJointData);
  12957. /**
  12958. * Set the motor values.
  12959. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12960. * @param force the force to apply
  12961. * @param maxForce max force for this motor.
  12962. */
  12963. setMotor(force?: number, maxForce?: number): void;
  12964. /**
  12965. * Set the motor's limits.
  12966. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12967. * @param upperLimit The upper limit of the motor
  12968. * @param lowerLimit The lower limit of the motor
  12969. */
  12970. setLimit(upperLimit: number, lowerLimit?: number): void;
  12971. }
  12972. /**
  12973. * This class represents a single physics Hinge-Joint
  12974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12975. */
  12976. export class HingeJoint extends MotorEnabledJoint {
  12977. /**
  12978. * Initializes the Hinge-Joint
  12979. * @param jointData The joint data for the Hinge-Joint
  12980. */
  12981. constructor(jointData: PhysicsJointData);
  12982. /**
  12983. * Set the motor values.
  12984. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12985. * @param {number} force the force to apply
  12986. * @param {number} maxForce max force for this motor.
  12987. */
  12988. setMotor(force?: number, maxForce?: number): void;
  12989. /**
  12990. * Set the motor's limits.
  12991. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12992. * @param upperLimit The upper limit of the motor
  12993. * @param lowerLimit The lower limit of the motor
  12994. */
  12995. setLimit(upperLimit: number, lowerLimit?: number): void;
  12996. }
  12997. /**
  12998. * This class represents a dual hinge physics joint (same as wheel joint)
  12999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13000. */
  13001. export class Hinge2Joint extends MotorEnabledJoint {
  13002. /**
  13003. * Initializes the Hinge2-Joint
  13004. * @param jointData The joint data for the Hinge2-Joint
  13005. */
  13006. constructor(jointData: PhysicsJointData);
  13007. /**
  13008. * Set the motor values.
  13009. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13010. * @param {number} targetSpeed the speed the motor is to reach
  13011. * @param {number} maxForce max force for this motor.
  13012. * @param {motorIndex} the motor's index, 0 or 1.
  13013. */
  13014. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13015. /**
  13016. * Set the motor limits.
  13017. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13018. * @param {number} upperLimit the upper limit
  13019. * @param {number} lowerLimit lower limit
  13020. * @param {motorIndex} the motor's index, 0 or 1.
  13021. */
  13022. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13023. }
  13024. /**
  13025. * Interface for a motor enabled joint
  13026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13027. */
  13028. export interface IMotorEnabledJoint {
  13029. /**
  13030. * Physics joint
  13031. */
  13032. physicsJoint: any;
  13033. /**
  13034. * Sets the motor of the motor-enabled joint
  13035. * @param force The force of the motor
  13036. * @param maxForce The maximum force of the motor
  13037. * @param motorIndex The index of the motor
  13038. */
  13039. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13040. /**
  13041. * Sets the limit of the motor
  13042. * @param upperLimit The upper limit of the motor
  13043. * @param lowerLimit The lower limit of the motor
  13044. * @param motorIndex The index of the motor
  13045. */
  13046. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13047. }
  13048. /**
  13049. * Joint data for a Distance-Joint
  13050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13051. */
  13052. export interface DistanceJointData extends PhysicsJointData {
  13053. /**
  13054. * Max distance the 2 joint objects can be apart
  13055. */
  13056. maxDistance: number;
  13057. }
  13058. /**
  13059. * Joint data from a spring joint
  13060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13061. */
  13062. export interface SpringJointData extends PhysicsJointData {
  13063. /**
  13064. * Length of the spring
  13065. */
  13066. length: number;
  13067. /**
  13068. * Stiffness of the spring
  13069. */
  13070. stiffness: number;
  13071. /**
  13072. * Damping of the spring
  13073. */
  13074. damping: number;
  13075. /** this callback will be called when applying the force to the impostors. */
  13076. forceApplicationCallback: () => void;
  13077. }
  13078. }
  13079. declare module BABYLON {
  13080. /**
  13081. * Holds the data for the raycast result
  13082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13083. */
  13084. export class PhysicsRaycastResult {
  13085. private _hasHit;
  13086. private _hitDistance;
  13087. private _hitNormalWorld;
  13088. private _hitPointWorld;
  13089. private _rayFromWorld;
  13090. private _rayToWorld;
  13091. /**
  13092. * Gets if there was a hit
  13093. */
  13094. readonly hasHit: boolean;
  13095. /**
  13096. * Gets the distance from the hit
  13097. */
  13098. readonly hitDistance: number;
  13099. /**
  13100. * Gets the hit normal/direction in the world
  13101. */
  13102. readonly hitNormalWorld: Vector3;
  13103. /**
  13104. * Gets the hit point in the world
  13105. */
  13106. readonly hitPointWorld: Vector3;
  13107. /**
  13108. * Gets the ray "start point" of the ray in the world
  13109. */
  13110. readonly rayFromWorld: Vector3;
  13111. /**
  13112. * Gets the ray "end point" of the ray in the world
  13113. */
  13114. readonly rayToWorld: Vector3;
  13115. /**
  13116. * Sets the hit data (normal & point in world space)
  13117. * @param hitNormalWorld defines the normal in world space
  13118. * @param hitPointWorld defines the point in world space
  13119. */
  13120. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13121. /**
  13122. * Sets the distance from the start point to the hit point
  13123. * @param distance
  13124. */
  13125. setHitDistance(distance: number): void;
  13126. /**
  13127. * Calculates the distance manually
  13128. */
  13129. calculateHitDistance(): void;
  13130. /**
  13131. * Resets all the values to default
  13132. * @param from The from point on world space
  13133. * @param to The to point on world space
  13134. */
  13135. reset(from?: Vector3, to?: Vector3): void;
  13136. }
  13137. /**
  13138. * Interface for the size containing width and height
  13139. */
  13140. interface IXYZ {
  13141. /**
  13142. * X
  13143. */
  13144. x: number;
  13145. /**
  13146. * Y
  13147. */
  13148. y: number;
  13149. /**
  13150. * Z
  13151. */
  13152. z: number;
  13153. }
  13154. }
  13155. declare module BABYLON {
  13156. /**
  13157. * Interface used to describe a physics joint
  13158. */
  13159. export interface PhysicsImpostorJoint {
  13160. /** Defines the main impostor to which the joint is linked */
  13161. mainImpostor: PhysicsImpostor;
  13162. /** Defines the impostor that is connected to the main impostor using this joint */
  13163. connectedImpostor: PhysicsImpostor;
  13164. /** Defines the joint itself */
  13165. joint: PhysicsJoint;
  13166. }
  13167. /** @hidden */
  13168. export interface IPhysicsEnginePlugin {
  13169. world: any;
  13170. name: string;
  13171. setGravity(gravity: Vector3): void;
  13172. setTimeStep(timeStep: number): void;
  13173. getTimeStep(): number;
  13174. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13175. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13176. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13177. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13178. removePhysicsBody(impostor: PhysicsImpostor): void;
  13179. generateJoint(joint: PhysicsImpostorJoint): void;
  13180. removeJoint(joint: PhysicsImpostorJoint): void;
  13181. isSupported(): boolean;
  13182. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13183. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13184. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13185. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13186. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13187. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13188. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13189. getBodyMass(impostor: PhysicsImpostor): number;
  13190. getBodyFriction(impostor: PhysicsImpostor): number;
  13191. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13192. getBodyRestitution(impostor: PhysicsImpostor): number;
  13193. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13194. getBodyPressure?(impostor: PhysicsImpostor): number;
  13195. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13196. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13197. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13198. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13199. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13200. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13201. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13202. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13203. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13204. sleepBody(impostor: PhysicsImpostor): void;
  13205. wakeUpBody(impostor: PhysicsImpostor): void;
  13206. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13207. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13208. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13209. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13210. getRadius(impostor: PhysicsImpostor): number;
  13211. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13212. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13213. dispose(): void;
  13214. }
  13215. /**
  13216. * Interface used to define a physics engine
  13217. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13218. */
  13219. export interface IPhysicsEngine {
  13220. /**
  13221. * Gets the gravity vector used by the simulation
  13222. */
  13223. gravity: Vector3;
  13224. /**
  13225. * Sets the gravity vector used by the simulation
  13226. * @param gravity defines the gravity vector to use
  13227. */
  13228. setGravity(gravity: Vector3): void;
  13229. /**
  13230. * Set the time step of the physics engine.
  13231. * Default is 1/60.
  13232. * To slow it down, enter 1/600 for example.
  13233. * To speed it up, 1/30
  13234. * @param newTimeStep the new timestep to apply to this world.
  13235. */
  13236. setTimeStep(newTimeStep: number): void;
  13237. /**
  13238. * Get the time step of the physics engine.
  13239. * @returns the current time step
  13240. */
  13241. getTimeStep(): number;
  13242. /**
  13243. * Release all resources
  13244. */
  13245. dispose(): void;
  13246. /**
  13247. * Gets the name of the current physics plugin
  13248. * @returns the name of the plugin
  13249. */
  13250. getPhysicsPluginName(): string;
  13251. /**
  13252. * Adding a new impostor for the impostor tracking.
  13253. * This will be done by the impostor itself.
  13254. * @param impostor the impostor to add
  13255. */
  13256. addImpostor(impostor: PhysicsImpostor): void;
  13257. /**
  13258. * Remove an impostor from the engine.
  13259. * This impostor and its mesh will not longer be updated by the physics engine.
  13260. * @param impostor the impostor to remove
  13261. */
  13262. removeImpostor(impostor: PhysicsImpostor): void;
  13263. /**
  13264. * Add a joint to the physics engine
  13265. * @param mainImpostor defines the main impostor to which the joint is added.
  13266. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13267. * @param joint defines the joint that will connect both impostors.
  13268. */
  13269. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13270. /**
  13271. * Removes a joint from the simulation
  13272. * @param mainImpostor defines the impostor used with the joint
  13273. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13274. * @param joint defines the joint to remove
  13275. */
  13276. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13277. /**
  13278. * Gets the current plugin used to run the simulation
  13279. * @returns current plugin
  13280. */
  13281. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13282. /**
  13283. * Gets the list of physic impostors
  13284. * @returns an array of PhysicsImpostor
  13285. */
  13286. getImpostors(): Array<PhysicsImpostor>;
  13287. /**
  13288. * Gets the impostor for a physics enabled object
  13289. * @param object defines the object impersonated by the impostor
  13290. * @returns the PhysicsImpostor or null if not found
  13291. */
  13292. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13293. /**
  13294. * Gets the impostor for a physics body object
  13295. * @param body defines physics body used by the impostor
  13296. * @returns the PhysicsImpostor or null if not found
  13297. */
  13298. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13299. /**
  13300. * Does a raycast in the physics world
  13301. * @param from when should the ray start?
  13302. * @param to when should the ray end?
  13303. * @returns PhysicsRaycastResult
  13304. */
  13305. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13306. /**
  13307. * Called by the scene. No need to call it.
  13308. * @param delta defines the timespam between frames
  13309. */
  13310. _step(delta: number): void;
  13311. }
  13312. }
  13313. declare module BABYLON {
  13314. /**
  13315. * The interface for the physics imposter parameters
  13316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13317. */
  13318. export interface PhysicsImpostorParameters {
  13319. /**
  13320. * The mass of the physics imposter
  13321. */
  13322. mass: number;
  13323. /**
  13324. * The friction of the physics imposter
  13325. */
  13326. friction?: number;
  13327. /**
  13328. * The coefficient of restitution of the physics imposter
  13329. */
  13330. restitution?: number;
  13331. /**
  13332. * The native options of the physics imposter
  13333. */
  13334. nativeOptions?: any;
  13335. /**
  13336. * Specifies if the parent should be ignored
  13337. */
  13338. ignoreParent?: boolean;
  13339. /**
  13340. * Specifies if bi-directional transformations should be disabled
  13341. */
  13342. disableBidirectionalTransformation?: boolean;
  13343. /**
  13344. * The pressure inside the physics imposter, soft object only
  13345. */
  13346. pressure?: number;
  13347. /**
  13348. * The stiffness the physics imposter, soft object only
  13349. */
  13350. stiffness?: number;
  13351. /**
  13352. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13353. */
  13354. velocityIterations?: number;
  13355. /**
  13356. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13357. */
  13358. positionIterations?: number;
  13359. /**
  13360. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13361. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13362. * Add to fix multiple points
  13363. */
  13364. fixedPoints?: number;
  13365. /**
  13366. * The collision margin around a soft object
  13367. */
  13368. margin?: number;
  13369. /**
  13370. * The collision margin around a soft object
  13371. */
  13372. damping?: number;
  13373. /**
  13374. * The path for a rope based on an extrusion
  13375. */
  13376. path?: any;
  13377. /**
  13378. * The shape of an extrusion used for a rope based on an extrusion
  13379. */
  13380. shape?: any;
  13381. }
  13382. /**
  13383. * Interface for a physics-enabled object
  13384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13385. */
  13386. export interface IPhysicsEnabledObject {
  13387. /**
  13388. * The position of the physics-enabled object
  13389. */
  13390. position: Vector3;
  13391. /**
  13392. * The rotation of the physics-enabled object
  13393. */
  13394. rotationQuaternion: Nullable<Quaternion>;
  13395. /**
  13396. * The scale of the physics-enabled object
  13397. */
  13398. scaling: Vector3;
  13399. /**
  13400. * The rotation of the physics-enabled object
  13401. */
  13402. rotation?: Vector3;
  13403. /**
  13404. * The parent of the physics-enabled object
  13405. */
  13406. parent?: any;
  13407. /**
  13408. * The bounding info of the physics-enabled object
  13409. * @returns The bounding info of the physics-enabled object
  13410. */
  13411. getBoundingInfo(): BoundingInfo;
  13412. /**
  13413. * Computes the world matrix
  13414. * @param force Specifies if the world matrix should be computed by force
  13415. * @returns A world matrix
  13416. */
  13417. computeWorldMatrix(force: boolean): Matrix;
  13418. /**
  13419. * Gets the world matrix
  13420. * @returns A world matrix
  13421. */
  13422. getWorldMatrix?(): Matrix;
  13423. /**
  13424. * Gets the child meshes
  13425. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13426. * @returns An array of abstract meshes
  13427. */
  13428. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13429. /**
  13430. * Gets the vertex data
  13431. * @param kind The type of vertex data
  13432. * @returns A nullable array of numbers, or a float32 array
  13433. */
  13434. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13435. /**
  13436. * Gets the indices from the mesh
  13437. * @returns A nullable array of index arrays
  13438. */
  13439. getIndices?(): Nullable<IndicesArray>;
  13440. /**
  13441. * Gets the scene from the mesh
  13442. * @returns the indices array or null
  13443. */
  13444. getScene?(): Scene;
  13445. /**
  13446. * Gets the absolute position from the mesh
  13447. * @returns the absolute position
  13448. */
  13449. getAbsolutePosition(): Vector3;
  13450. /**
  13451. * Gets the absolute pivot point from the mesh
  13452. * @returns the absolute pivot point
  13453. */
  13454. getAbsolutePivotPoint(): Vector3;
  13455. /**
  13456. * Rotates the mesh
  13457. * @param axis The axis of rotation
  13458. * @param amount The amount of rotation
  13459. * @param space The space of the rotation
  13460. * @returns The rotation transform node
  13461. */
  13462. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13463. /**
  13464. * Translates the mesh
  13465. * @param axis The axis of translation
  13466. * @param distance The distance of translation
  13467. * @param space The space of the translation
  13468. * @returns The transform node
  13469. */
  13470. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13471. /**
  13472. * Sets the absolute position of the mesh
  13473. * @param absolutePosition The absolute position of the mesh
  13474. * @returns The transform node
  13475. */
  13476. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13477. /**
  13478. * Gets the class name of the mesh
  13479. * @returns The class name
  13480. */
  13481. getClassName(): string;
  13482. }
  13483. /**
  13484. * Represents a physics imposter
  13485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13486. */
  13487. export class PhysicsImpostor {
  13488. /**
  13489. * The physics-enabled object used as the physics imposter
  13490. */
  13491. object: IPhysicsEnabledObject;
  13492. /**
  13493. * The type of the physics imposter
  13494. */
  13495. type: number;
  13496. private _options;
  13497. private _scene?;
  13498. /**
  13499. * The default object size of the imposter
  13500. */
  13501. static DEFAULT_OBJECT_SIZE: Vector3;
  13502. /**
  13503. * The identity quaternion of the imposter
  13504. */
  13505. static IDENTITY_QUATERNION: Quaternion;
  13506. /** @hidden */
  13507. _pluginData: any;
  13508. private _physicsEngine;
  13509. private _physicsBody;
  13510. private _bodyUpdateRequired;
  13511. private _onBeforePhysicsStepCallbacks;
  13512. private _onAfterPhysicsStepCallbacks;
  13513. /** @hidden */
  13514. _onPhysicsCollideCallbacks: Array<{
  13515. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13516. otherImpostors: Array<PhysicsImpostor>;
  13517. }>;
  13518. private _deltaPosition;
  13519. private _deltaRotation;
  13520. private _deltaRotationConjugated;
  13521. /** @hidden */
  13522. _isFromLine: boolean;
  13523. private _parent;
  13524. private _isDisposed;
  13525. private static _tmpVecs;
  13526. private static _tmpQuat;
  13527. /**
  13528. * Specifies if the physics imposter is disposed
  13529. */
  13530. readonly isDisposed: boolean;
  13531. /**
  13532. * Gets the mass of the physics imposter
  13533. */
  13534. mass: number;
  13535. /**
  13536. * Gets the coefficient of friction
  13537. */
  13538. /**
  13539. * Sets the coefficient of friction
  13540. */
  13541. friction: number;
  13542. /**
  13543. * Gets the coefficient of restitution
  13544. */
  13545. /**
  13546. * Sets the coefficient of restitution
  13547. */
  13548. restitution: number;
  13549. /**
  13550. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13551. */
  13552. /**
  13553. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13554. */
  13555. pressure: number;
  13556. /**
  13557. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13558. */
  13559. /**
  13560. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13561. */
  13562. stiffness: number;
  13563. /**
  13564. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13565. */
  13566. /**
  13567. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13568. */
  13569. velocityIterations: number;
  13570. /**
  13571. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13572. */
  13573. /**
  13574. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13575. */
  13576. positionIterations: number;
  13577. /**
  13578. * The unique id of the physics imposter
  13579. * set by the physics engine when adding this impostor to the array
  13580. */
  13581. uniqueId: number;
  13582. /**
  13583. * @hidden
  13584. */
  13585. soft: boolean;
  13586. /**
  13587. * @hidden
  13588. */
  13589. segments: number;
  13590. private _joints;
  13591. /**
  13592. * Initializes the physics imposter
  13593. * @param object The physics-enabled object used as the physics imposter
  13594. * @param type The type of the physics imposter
  13595. * @param _options The options for the physics imposter
  13596. * @param _scene The Babylon scene
  13597. */
  13598. constructor(
  13599. /**
  13600. * The physics-enabled object used as the physics imposter
  13601. */
  13602. object: IPhysicsEnabledObject,
  13603. /**
  13604. * The type of the physics imposter
  13605. */
  13606. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13607. /**
  13608. * This function will completly initialize this impostor.
  13609. * It will create a new body - but only if this mesh has no parent.
  13610. * If it has, this impostor will not be used other than to define the impostor
  13611. * of the child mesh.
  13612. * @hidden
  13613. */
  13614. _init(): void;
  13615. private _getPhysicsParent;
  13616. /**
  13617. * Should a new body be generated.
  13618. * @returns boolean specifying if body initialization is required
  13619. */
  13620. isBodyInitRequired(): boolean;
  13621. /**
  13622. * Sets the updated scaling
  13623. * @param updated Specifies if the scaling is updated
  13624. */
  13625. setScalingUpdated(): void;
  13626. /**
  13627. * Force a regeneration of this or the parent's impostor's body.
  13628. * Use under cautious - This will remove all joints already implemented.
  13629. */
  13630. forceUpdate(): void;
  13631. /**
  13632. * Gets the body that holds this impostor. Either its own, or its parent.
  13633. */
  13634. /**
  13635. * Set the physics body. Used mainly by the physics engine/plugin
  13636. */
  13637. physicsBody: any;
  13638. /**
  13639. * Get the parent of the physics imposter
  13640. * @returns Physics imposter or null
  13641. */
  13642. /**
  13643. * Sets the parent of the physics imposter
  13644. */
  13645. parent: Nullable<PhysicsImpostor>;
  13646. /**
  13647. * Resets the update flags
  13648. */
  13649. resetUpdateFlags(): void;
  13650. /**
  13651. * Gets the object extend size
  13652. * @returns the object extend size
  13653. */
  13654. getObjectExtendSize(): Vector3;
  13655. /**
  13656. * Gets the object center
  13657. * @returns The object center
  13658. */
  13659. getObjectCenter(): Vector3;
  13660. /**
  13661. * Get a specific parametes from the options parameter
  13662. * @param paramName The object parameter name
  13663. * @returns The object parameter
  13664. */
  13665. getParam(paramName: string): any;
  13666. /**
  13667. * Sets a specific parameter in the options given to the physics plugin
  13668. * @param paramName The parameter name
  13669. * @param value The value of the parameter
  13670. */
  13671. setParam(paramName: string, value: number): void;
  13672. /**
  13673. * Specifically change the body's mass option. Won't recreate the physics body object
  13674. * @param mass The mass of the physics imposter
  13675. */
  13676. setMass(mass: number): void;
  13677. /**
  13678. * Gets the linear velocity
  13679. * @returns linear velocity or null
  13680. */
  13681. getLinearVelocity(): Nullable<Vector3>;
  13682. /**
  13683. * Sets the linear velocity
  13684. * @param velocity linear velocity or null
  13685. */
  13686. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13687. /**
  13688. * Gets the angular velocity
  13689. * @returns angular velocity or null
  13690. */
  13691. getAngularVelocity(): Nullable<Vector3>;
  13692. /**
  13693. * Sets the angular velocity
  13694. * @param velocity The velocity or null
  13695. */
  13696. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13697. /**
  13698. * Execute a function with the physics plugin native code
  13699. * Provide a function the will have two variables - the world object and the physics body object
  13700. * @param func The function to execute with the physics plugin native code
  13701. */
  13702. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13703. /**
  13704. * Register a function that will be executed before the physics world is stepping forward
  13705. * @param func The function to execute before the physics world is stepped forward
  13706. */
  13707. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13708. /**
  13709. * Unregister a function that will be executed before the physics world is stepping forward
  13710. * @param func The function to execute before the physics world is stepped forward
  13711. */
  13712. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13713. /**
  13714. * Register a function that will be executed after the physics step
  13715. * @param func The function to execute after physics step
  13716. */
  13717. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13718. /**
  13719. * Unregisters a function that will be executed after the physics step
  13720. * @param func The function to execute after physics step
  13721. */
  13722. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13723. /**
  13724. * register a function that will be executed when this impostor collides against a different body
  13725. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13726. * @param func Callback that is executed on collision
  13727. */
  13728. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13729. /**
  13730. * Unregisters the physics imposter on contact
  13731. * @param collideAgainst The physics object to collide against
  13732. * @param func Callback to execute on collision
  13733. */
  13734. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13735. private _tmpQuat;
  13736. private _tmpQuat2;
  13737. /**
  13738. * Get the parent rotation
  13739. * @returns The parent rotation
  13740. */
  13741. getParentsRotation(): Quaternion;
  13742. /**
  13743. * this function is executed by the physics engine.
  13744. */
  13745. beforeStep: () => void;
  13746. /**
  13747. * this function is executed by the physics engine
  13748. */
  13749. afterStep: () => void;
  13750. /**
  13751. * Legacy collision detection event support
  13752. */
  13753. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13754. /**
  13755. * event and body object due to cannon's event-based architecture.
  13756. */
  13757. onCollide: (e: {
  13758. body: any;
  13759. }) => void;
  13760. /**
  13761. * Apply a force
  13762. * @param force The force to apply
  13763. * @param contactPoint The contact point for the force
  13764. * @returns The physics imposter
  13765. */
  13766. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13767. /**
  13768. * Apply an impulse
  13769. * @param force The impulse force
  13770. * @param contactPoint The contact point for the impulse force
  13771. * @returns The physics imposter
  13772. */
  13773. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13774. /**
  13775. * A help function to create a joint
  13776. * @param otherImpostor A physics imposter used to create a joint
  13777. * @param jointType The type of joint
  13778. * @param jointData The data for the joint
  13779. * @returns The physics imposter
  13780. */
  13781. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13782. /**
  13783. * Add a joint to this impostor with a different impostor
  13784. * @param otherImpostor A physics imposter used to add a joint
  13785. * @param joint The joint to add
  13786. * @returns The physics imposter
  13787. */
  13788. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13789. /**
  13790. * Add an anchor to a cloth impostor
  13791. * @param otherImpostor rigid impostor to anchor to
  13792. * @param width ratio across width from 0 to 1
  13793. * @param height ratio up height from 0 to 1
  13794. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13795. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13796. * @returns impostor the soft imposter
  13797. */
  13798. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13799. /**
  13800. * Add a hook to a rope impostor
  13801. * @param otherImpostor rigid impostor to anchor to
  13802. * @param length ratio across rope from 0 to 1
  13803. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13804. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13805. * @returns impostor the rope imposter
  13806. */
  13807. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13808. /**
  13809. * Will keep this body still, in a sleep mode.
  13810. * @returns the physics imposter
  13811. */
  13812. sleep(): PhysicsImpostor;
  13813. /**
  13814. * Wake the body up.
  13815. * @returns The physics imposter
  13816. */
  13817. wakeUp(): PhysicsImpostor;
  13818. /**
  13819. * Clones the physics imposter
  13820. * @param newObject The physics imposter clones to this physics-enabled object
  13821. * @returns A nullable physics imposter
  13822. */
  13823. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13824. /**
  13825. * Disposes the physics imposter
  13826. */
  13827. dispose(): void;
  13828. /**
  13829. * Sets the delta position
  13830. * @param position The delta position amount
  13831. */
  13832. setDeltaPosition(position: Vector3): void;
  13833. /**
  13834. * Sets the delta rotation
  13835. * @param rotation The delta rotation amount
  13836. */
  13837. setDeltaRotation(rotation: Quaternion): void;
  13838. /**
  13839. * Gets the box size of the physics imposter and stores the result in the input parameter
  13840. * @param result Stores the box size
  13841. * @returns The physics imposter
  13842. */
  13843. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13844. /**
  13845. * Gets the radius of the physics imposter
  13846. * @returns Radius of the physics imposter
  13847. */
  13848. getRadius(): number;
  13849. /**
  13850. * Sync a bone with this impostor
  13851. * @param bone The bone to sync to the impostor.
  13852. * @param boneMesh The mesh that the bone is influencing.
  13853. * @param jointPivot The pivot of the joint / bone in local space.
  13854. * @param distToJoint Optional distance from the impostor to the joint.
  13855. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13856. */
  13857. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  13858. /**
  13859. * Sync impostor to a bone
  13860. * @param bone The bone that the impostor will be synced to.
  13861. * @param boneMesh The mesh that the bone is influencing.
  13862. * @param jointPivot The pivot of the joint / bone in local space.
  13863. * @param distToJoint Optional distance from the impostor to the joint.
  13864. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13865. * @param boneAxis Optional vector3 axis the bone is aligned with
  13866. */
  13867. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  13868. /**
  13869. * No-Imposter type
  13870. */
  13871. static NoImpostor: number;
  13872. /**
  13873. * Sphere-Imposter type
  13874. */
  13875. static SphereImpostor: number;
  13876. /**
  13877. * Box-Imposter type
  13878. */
  13879. static BoxImpostor: number;
  13880. /**
  13881. * Plane-Imposter type
  13882. */
  13883. static PlaneImpostor: number;
  13884. /**
  13885. * Mesh-imposter type
  13886. */
  13887. static MeshImpostor: number;
  13888. /**
  13889. * Capsule-Impostor type (Ammo.js plugin only)
  13890. */
  13891. static CapsuleImpostor: number;
  13892. /**
  13893. * Cylinder-Imposter type
  13894. */
  13895. static CylinderImpostor: number;
  13896. /**
  13897. * Particle-Imposter type
  13898. */
  13899. static ParticleImpostor: number;
  13900. /**
  13901. * Heightmap-Imposter type
  13902. */
  13903. static HeightmapImpostor: number;
  13904. /**
  13905. * ConvexHull-Impostor type (Ammo.js plugin only)
  13906. */
  13907. static ConvexHullImpostor: number;
  13908. /**
  13909. * Rope-Imposter type
  13910. */
  13911. static RopeImpostor: number;
  13912. /**
  13913. * Cloth-Imposter type
  13914. */
  13915. static ClothImpostor: number;
  13916. /**
  13917. * Softbody-Imposter type
  13918. */
  13919. static SoftbodyImpostor: number;
  13920. }
  13921. }
  13922. declare module BABYLON {
  13923. /**
  13924. * @hidden
  13925. **/
  13926. export class _CreationDataStorage {
  13927. closePath?: boolean;
  13928. closeArray?: boolean;
  13929. idx: number[];
  13930. dashSize: number;
  13931. gapSize: number;
  13932. path3D: Path3D;
  13933. pathArray: Vector3[][];
  13934. arc: number;
  13935. radius: number;
  13936. cap: number;
  13937. tessellation: number;
  13938. }
  13939. /**
  13940. * @hidden
  13941. **/
  13942. class _InstanceDataStorage {
  13943. visibleInstances: any;
  13944. batchCache: _InstancesBatch;
  13945. instancesBufferSize: number;
  13946. instancesBuffer: Nullable<Buffer>;
  13947. instancesData: Float32Array;
  13948. overridenInstanceCount: number;
  13949. isFrozen: boolean;
  13950. previousBatch: Nullable<_InstancesBatch>;
  13951. hardwareInstancedRendering: boolean;
  13952. sideOrientation: number;
  13953. }
  13954. /**
  13955. * @hidden
  13956. **/
  13957. export class _InstancesBatch {
  13958. mustReturn: boolean;
  13959. visibleInstances: Nullable<InstancedMesh[]>[];
  13960. renderSelf: boolean[];
  13961. hardwareInstancedRendering: boolean[];
  13962. }
  13963. /**
  13964. * Class used to represent renderable models
  13965. */
  13966. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  13967. /**
  13968. * Mesh side orientation : usually the external or front surface
  13969. */
  13970. static readonly FRONTSIDE: number;
  13971. /**
  13972. * Mesh side orientation : usually the internal or back surface
  13973. */
  13974. static readonly BACKSIDE: number;
  13975. /**
  13976. * Mesh side orientation : both internal and external or front and back surfaces
  13977. */
  13978. static readonly DOUBLESIDE: number;
  13979. /**
  13980. * Mesh side orientation : by default, `FRONTSIDE`
  13981. */
  13982. static readonly DEFAULTSIDE: number;
  13983. /**
  13984. * Mesh cap setting : no cap
  13985. */
  13986. static readonly NO_CAP: number;
  13987. /**
  13988. * Mesh cap setting : one cap at the beginning of the mesh
  13989. */
  13990. static readonly CAP_START: number;
  13991. /**
  13992. * Mesh cap setting : one cap at the end of the mesh
  13993. */
  13994. static readonly CAP_END: number;
  13995. /**
  13996. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  13997. */
  13998. static readonly CAP_ALL: number;
  13999. /**
  14000. * Mesh pattern setting : no flip or rotate
  14001. */
  14002. static readonly NO_FLIP: number;
  14003. /**
  14004. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14005. */
  14006. static readonly FLIP_TILE: number;
  14007. /**
  14008. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14009. */
  14010. static readonly ROTATE_TILE: number;
  14011. /**
  14012. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14013. */
  14014. static readonly FLIP_ROW: number;
  14015. /**
  14016. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14017. */
  14018. static readonly ROTATE_ROW: number;
  14019. /**
  14020. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14021. */
  14022. static readonly FLIP_N_ROTATE_TILE: number;
  14023. /**
  14024. * Mesh pattern setting : rotate pattern and rotate
  14025. */
  14026. static readonly FLIP_N_ROTATE_ROW: number;
  14027. /**
  14028. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14029. */
  14030. static readonly CENTER: number;
  14031. /**
  14032. * Mesh tile positioning : part tiles on left
  14033. */
  14034. static readonly LEFT: number;
  14035. /**
  14036. * Mesh tile positioning : part tiles on right
  14037. */
  14038. static readonly RIGHT: number;
  14039. /**
  14040. * Mesh tile positioning : part tiles on top
  14041. */
  14042. static readonly TOP: number;
  14043. /**
  14044. * Mesh tile positioning : part tiles on bottom
  14045. */
  14046. static readonly BOTTOM: number;
  14047. /**
  14048. * Gets the default side orientation.
  14049. * @param orientation the orientation to value to attempt to get
  14050. * @returns the default orientation
  14051. * @hidden
  14052. */
  14053. static _GetDefaultSideOrientation(orientation?: number): number;
  14054. private _internalMeshDataInfo;
  14055. /**
  14056. * An event triggered before rendering the mesh
  14057. */
  14058. readonly onBeforeRenderObservable: Observable<Mesh>;
  14059. /**
  14060. * An event triggered before binding the mesh
  14061. */
  14062. readonly onBeforeBindObservable: Observable<Mesh>;
  14063. /**
  14064. * An event triggered after rendering the mesh
  14065. */
  14066. readonly onAfterRenderObservable: Observable<Mesh>;
  14067. /**
  14068. * An event triggered before drawing the mesh
  14069. */
  14070. readonly onBeforeDrawObservable: Observable<Mesh>;
  14071. private _onBeforeDrawObserver;
  14072. /**
  14073. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14074. */
  14075. onBeforeDraw: () => void;
  14076. /**
  14077. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14078. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14079. */
  14080. delayLoadState: number;
  14081. /**
  14082. * Gets the list of instances created from this mesh
  14083. * it is not supposed to be modified manually.
  14084. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14085. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14086. */
  14087. instances: InstancedMesh[];
  14088. /**
  14089. * Gets the file containing delay loading data for this mesh
  14090. */
  14091. delayLoadingFile: string;
  14092. /** @hidden */
  14093. _binaryInfo: any;
  14094. /**
  14095. * User defined function used to change how LOD level selection is done
  14096. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14097. */
  14098. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14099. /**
  14100. * Gets or sets the morph target manager
  14101. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14102. */
  14103. morphTargetManager: Nullable<MorphTargetManager>;
  14104. /** @hidden */
  14105. _creationDataStorage: Nullable<_CreationDataStorage>;
  14106. /** @hidden */
  14107. _geometry: Nullable<Geometry>;
  14108. /** @hidden */
  14109. _delayInfo: Array<string>;
  14110. /** @hidden */
  14111. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14112. /** @hidden */
  14113. _instanceDataStorage: _InstanceDataStorage;
  14114. private _effectiveMaterial;
  14115. /** @hidden */
  14116. _shouldGenerateFlatShading: boolean;
  14117. /** @hidden */
  14118. _originalBuilderSideOrientation: number;
  14119. /**
  14120. * Use this property to change the original side orientation defined at construction time
  14121. */
  14122. overrideMaterialSideOrientation: Nullable<number>;
  14123. /**
  14124. * Gets the source mesh (the one used to clone this one from)
  14125. */
  14126. readonly source: Nullable<Mesh>;
  14127. /**
  14128. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14129. */
  14130. isUnIndexed: boolean;
  14131. /**
  14132. * @constructor
  14133. * @param name The value used by scene.getMeshByName() to do a lookup.
  14134. * @param scene The scene to add this mesh to.
  14135. * @param parent The parent of this mesh, if it has one
  14136. * @param source An optional Mesh from which geometry is shared, cloned.
  14137. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14138. * When false, achieved by calling a clone(), also passing False.
  14139. * This will make creation of children, recursive.
  14140. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14141. */
  14142. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14143. /**
  14144. * Gets the class name
  14145. * @returns the string "Mesh".
  14146. */
  14147. getClassName(): string;
  14148. /** @hidden */
  14149. readonly _isMesh: boolean;
  14150. /**
  14151. * Returns a description of this mesh
  14152. * @param fullDetails define if full details about this mesh must be used
  14153. * @returns a descriptive string representing this mesh
  14154. */
  14155. toString(fullDetails?: boolean): string;
  14156. /** @hidden */
  14157. _unBindEffect(): void;
  14158. /**
  14159. * Gets a boolean indicating if this mesh has LOD
  14160. */
  14161. readonly hasLODLevels: boolean;
  14162. /**
  14163. * Gets the list of MeshLODLevel associated with the current mesh
  14164. * @returns an array of MeshLODLevel
  14165. */
  14166. getLODLevels(): MeshLODLevel[];
  14167. private _sortLODLevels;
  14168. /**
  14169. * Add a mesh as LOD level triggered at the given distance.
  14170. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14171. * @param distance The distance from the center of the object to show this level
  14172. * @param mesh The mesh to be added as LOD level (can be null)
  14173. * @return This mesh (for chaining)
  14174. */
  14175. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14176. /**
  14177. * Returns the LOD level mesh at the passed distance or null if not found.
  14178. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14179. * @param distance The distance from the center of the object to show this level
  14180. * @returns a Mesh or `null`
  14181. */
  14182. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14183. /**
  14184. * Remove a mesh from the LOD array
  14185. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14186. * @param mesh defines the mesh to be removed
  14187. * @return This mesh (for chaining)
  14188. */
  14189. removeLODLevel(mesh: Mesh): Mesh;
  14190. /**
  14191. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14192. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14193. * @param camera defines the camera to use to compute distance
  14194. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14195. * @return This mesh (for chaining)
  14196. */
  14197. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14198. /**
  14199. * Gets the mesh internal Geometry object
  14200. */
  14201. readonly geometry: Nullable<Geometry>;
  14202. /**
  14203. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14204. * @returns the total number of vertices
  14205. */
  14206. getTotalVertices(): number;
  14207. /**
  14208. * Returns the content of an associated vertex buffer
  14209. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14210. * - VertexBuffer.PositionKind
  14211. * - VertexBuffer.UVKind
  14212. * - VertexBuffer.UV2Kind
  14213. * - VertexBuffer.UV3Kind
  14214. * - VertexBuffer.UV4Kind
  14215. * - VertexBuffer.UV5Kind
  14216. * - VertexBuffer.UV6Kind
  14217. * - VertexBuffer.ColorKind
  14218. * - VertexBuffer.MatricesIndicesKind
  14219. * - VertexBuffer.MatricesIndicesExtraKind
  14220. * - VertexBuffer.MatricesWeightsKind
  14221. * - VertexBuffer.MatricesWeightsExtraKind
  14222. * @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
  14223. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14224. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14225. */
  14226. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14227. /**
  14228. * Returns the mesh VertexBuffer object from the requested `kind`
  14229. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14230. * - VertexBuffer.PositionKind
  14231. * - VertexBuffer.NormalKind
  14232. * - VertexBuffer.UVKind
  14233. * - VertexBuffer.UV2Kind
  14234. * - VertexBuffer.UV3Kind
  14235. * - VertexBuffer.UV4Kind
  14236. * - VertexBuffer.UV5Kind
  14237. * - VertexBuffer.UV6Kind
  14238. * - VertexBuffer.ColorKind
  14239. * - VertexBuffer.MatricesIndicesKind
  14240. * - VertexBuffer.MatricesIndicesExtraKind
  14241. * - VertexBuffer.MatricesWeightsKind
  14242. * - VertexBuffer.MatricesWeightsExtraKind
  14243. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14244. */
  14245. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14246. /**
  14247. * Tests if a specific vertex buffer is associated with this mesh
  14248. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14249. * - VertexBuffer.PositionKind
  14250. * - VertexBuffer.NormalKind
  14251. * - VertexBuffer.UVKind
  14252. * - VertexBuffer.UV2Kind
  14253. * - VertexBuffer.UV3Kind
  14254. * - VertexBuffer.UV4Kind
  14255. * - VertexBuffer.UV5Kind
  14256. * - VertexBuffer.UV6Kind
  14257. * - VertexBuffer.ColorKind
  14258. * - VertexBuffer.MatricesIndicesKind
  14259. * - VertexBuffer.MatricesIndicesExtraKind
  14260. * - VertexBuffer.MatricesWeightsKind
  14261. * - VertexBuffer.MatricesWeightsExtraKind
  14262. * @returns a boolean
  14263. */
  14264. isVerticesDataPresent(kind: string): boolean;
  14265. /**
  14266. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14267. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14268. * - VertexBuffer.PositionKind
  14269. * - VertexBuffer.UVKind
  14270. * - VertexBuffer.UV2Kind
  14271. * - VertexBuffer.UV3Kind
  14272. * - VertexBuffer.UV4Kind
  14273. * - VertexBuffer.UV5Kind
  14274. * - VertexBuffer.UV6Kind
  14275. * - VertexBuffer.ColorKind
  14276. * - VertexBuffer.MatricesIndicesKind
  14277. * - VertexBuffer.MatricesIndicesExtraKind
  14278. * - VertexBuffer.MatricesWeightsKind
  14279. * - VertexBuffer.MatricesWeightsExtraKind
  14280. * @returns a boolean
  14281. */
  14282. isVertexBufferUpdatable(kind: string): boolean;
  14283. /**
  14284. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14285. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14286. * - VertexBuffer.PositionKind
  14287. * - VertexBuffer.NormalKind
  14288. * - VertexBuffer.UVKind
  14289. * - VertexBuffer.UV2Kind
  14290. * - VertexBuffer.UV3Kind
  14291. * - VertexBuffer.UV4Kind
  14292. * - VertexBuffer.UV5Kind
  14293. * - VertexBuffer.UV6Kind
  14294. * - VertexBuffer.ColorKind
  14295. * - VertexBuffer.MatricesIndicesKind
  14296. * - VertexBuffer.MatricesIndicesExtraKind
  14297. * - VertexBuffer.MatricesWeightsKind
  14298. * - VertexBuffer.MatricesWeightsExtraKind
  14299. * @returns an array of strings
  14300. */
  14301. getVerticesDataKinds(): string[];
  14302. /**
  14303. * Returns a positive integer : the total number of indices in this mesh geometry.
  14304. * @returns the numner of indices or zero if the mesh has no geometry.
  14305. */
  14306. getTotalIndices(): number;
  14307. /**
  14308. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14309. * @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.
  14310. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14311. * @returns the indices array or an empty array if the mesh has no geometry
  14312. */
  14313. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14314. readonly isBlocked: boolean;
  14315. /**
  14316. * Determine if the current mesh is ready to be rendered
  14317. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14318. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14319. * @returns true if all associated assets are ready (material, textures, shaders)
  14320. */
  14321. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14322. /**
  14323. * 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.
  14324. */
  14325. readonly areNormalsFrozen: boolean;
  14326. /**
  14327. * 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.
  14328. * @returns the current mesh
  14329. */
  14330. freezeNormals(): Mesh;
  14331. /**
  14332. * 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
  14333. * @returns the current mesh
  14334. */
  14335. unfreezeNormals(): Mesh;
  14336. /**
  14337. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14338. */
  14339. overridenInstanceCount: number;
  14340. /** @hidden */
  14341. _preActivate(): Mesh;
  14342. /** @hidden */
  14343. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14344. /** @hidden */
  14345. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14346. /**
  14347. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14348. * This means the mesh underlying bounding box and sphere are recomputed.
  14349. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14350. * @returns the current mesh
  14351. */
  14352. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14353. /** @hidden */
  14354. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14355. /**
  14356. * This function will subdivide the mesh into multiple submeshes
  14357. * @param count defines the expected number of submeshes
  14358. */
  14359. subdivide(count: number): void;
  14360. /**
  14361. * Copy a FloatArray into a specific associated vertex buffer
  14362. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14363. * - VertexBuffer.PositionKind
  14364. * - VertexBuffer.UVKind
  14365. * - VertexBuffer.UV2Kind
  14366. * - VertexBuffer.UV3Kind
  14367. * - VertexBuffer.UV4Kind
  14368. * - VertexBuffer.UV5Kind
  14369. * - VertexBuffer.UV6Kind
  14370. * - VertexBuffer.ColorKind
  14371. * - VertexBuffer.MatricesIndicesKind
  14372. * - VertexBuffer.MatricesIndicesExtraKind
  14373. * - VertexBuffer.MatricesWeightsKind
  14374. * - VertexBuffer.MatricesWeightsExtraKind
  14375. * @param data defines the data source
  14376. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14377. * @param stride defines the data stride size (can be null)
  14378. * @returns the current mesh
  14379. */
  14380. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14381. /**
  14382. * Flags an associated vertex buffer as updatable
  14383. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14384. * - VertexBuffer.PositionKind
  14385. * - VertexBuffer.UVKind
  14386. * - VertexBuffer.UV2Kind
  14387. * - VertexBuffer.UV3Kind
  14388. * - VertexBuffer.UV4Kind
  14389. * - VertexBuffer.UV5Kind
  14390. * - VertexBuffer.UV6Kind
  14391. * - VertexBuffer.ColorKind
  14392. * - VertexBuffer.MatricesIndicesKind
  14393. * - VertexBuffer.MatricesIndicesExtraKind
  14394. * - VertexBuffer.MatricesWeightsKind
  14395. * - VertexBuffer.MatricesWeightsExtraKind
  14396. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14397. */
  14398. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14399. /**
  14400. * Sets the mesh global Vertex Buffer
  14401. * @param buffer defines the buffer to use
  14402. * @returns the current mesh
  14403. */
  14404. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14405. /**
  14406. * Update a specific associated vertex buffer
  14407. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14408. * - VertexBuffer.PositionKind
  14409. * - VertexBuffer.UVKind
  14410. * - VertexBuffer.UV2Kind
  14411. * - VertexBuffer.UV3Kind
  14412. * - VertexBuffer.UV4Kind
  14413. * - VertexBuffer.UV5Kind
  14414. * - VertexBuffer.UV6Kind
  14415. * - VertexBuffer.ColorKind
  14416. * - VertexBuffer.MatricesIndicesKind
  14417. * - VertexBuffer.MatricesIndicesExtraKind
  14418. * - VertexBuffer.MatricesWeightsKind
  14419. * - VertexBuffer.MatricesWeightsExtraKind
  14420. * @param data defines the data source
  14421. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14422. * @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)
  14423. * @returns the current mesh
  14424. */
  14425. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14426. /**
  14427. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14428. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14429. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14430. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14431. * @returns the current mesh
  14432. */
  14433. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14434. /**
  14435. * Creates a un-shared specific occurence of the geometry for the mesh.
  14436. * @returns the current mesh
  14437. */
  14438. makeGeometryUnique(): Mesh;
  14439. /**
  14440. * Set the index buffer of this mesh
  14441. * @param indices defines the source data
  14442. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14443. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14444. * @returns the current mesh
  14445. */
  14446. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14447. /**
  14448. * Update the current index buffer
  14449. * @param indices defines the source data
  14450. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14451. * @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)
  14452. * @returns the current mesh
  14453. */
  14454. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14455. /**
  14456. * Invert the geometry to move from a right handed system to a left handed one.
  14457. * @returns the current mesh
  14458. */
  14459. toLeftHanded(): Mesh;
  14460. /** @hidden */
  14461. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14462. /** @hidden */
  14463. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14464. /**
  14465. * Registers for this mesh a javascript function called just before the rendering process
  14466. * @param func defines the function to call before rendering this mesh
  14467. * @returns the current mesh
  14468. */
  14469. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14470. /**
  14471. * Disposes a previously registered javascript function called before the rendering
  14472. * @param func defines the function to remove
  14473. * @returns the current mesh
  14474. */
  14475. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14476. /**
  14477. * Registers for this mesh a javascript function called just after the rendering is complete
  14478. * @param func defines the function to call after rendering this mesh
  14479. * @returns the current mesh
  14480. */
  14481. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14482. /**
  14483. * Disposes a previously registered javascript function called after the rendering.
  14484. * @param func defines the function to remove
  14485. * @returns the current mesh
  14486. */
  14487. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14488. /** @hidden */
  14489. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14490. /** @hidden */
  14491. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14492. /** @hidden */
  14493. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14494. /** @hidden */
  14495. _rebuild(): void;
  14496. /** @hidden */
  14497. _freeze(): void;
  14498. /** @hidden */
  14499. _unFreeze(): void;
  14500. /**
  14501. * 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
  14502. * @param subMesh defines the subMesh to render
  14503. * @param enableAlphaMode defines if alpha mode can be changed
  14504. * @returns the current mesh
  14505. */
  14506. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14507. private _onBeforeDraw;
  14508. /**
  14509. * Renormalize the mesh and patch it up if there are no weights
  14510. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14511. * However in the case of zero weights then we set just a single influence to 1.
  14512. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14513. */
  14514. cleanMatrixWeights(): void;
  14515. private normalizeSkinFourWeights;
  14516. private normalizeSkinWeightsAndExtra;
  14517. /**
  14518. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14519. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14520. * the user know there was an issue with importing the mesh
  14521. * @returns a validation object with skinned, valid and report string
  14522. */
  14523. validateSkinning(): {
  14524. skinned: boolean;
  14525. valid: boolean;
  14526. report: string;
  14527. };
  14528. /** @hidden */
  14529. _checkDelayState(): Mesh;
  14530. private _queueLoad;
  14531. /**
  14532. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14533. * A mesh is in the frustum if its bounding box intersects the frustum
  14534. * @param frustumPlanes defines the frustum to test
  14535. * @returns true if the mesh is in the frustum planes
  14536. */
  14537. isInFrustum(frustumPlanes: Plane[]): boolean;
  14538. /**
  14539. * Sets the mesh material by the material or multiMaterial `id` property
  14540. * @param id is a string identifying the material or the multiMaterial
  14541. * @returns the current mesh
  14542. */
  14543. setMaterialByID(id: string): Mesh;
  14544. /**
  14545. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14546. * @returns an array of IAnimatable
  14547. */
  14548. getAnimatables(): IAnimatable[];
  14549. /**
  14550. * Modifies the mesh geometry according to the passed transformation matrix.
  14551. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14552. * The mesh normals are modified using the same transformation.
  14553. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14554. * @param transform defines the transform matrix to use
  14555. * @see http://doc.babylonjs.com/resources/baking_transformations
  14556. * @returns the current mesh
  14557. */
  14558. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14559. /**
  14560. * Modifies the mesh geometry according to its own current World Matrix.
  14561. * The mesh World Matrix is then reset.
  14562. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14563. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14564. * @see http://doc.babylonjs.com/resources/baking_transformations
  14565. * @returns the current mesh
  14566. */
  14567. bakeCurrentTransformIntoVertices(): Mesh;
  14568. /** @hidden */
  14569. readonly _positions: Nullable<Vector3[]>;
  14570. /** @hidden */
  14571. _resetPointsArrayCache(): Mesh;
  14572. /** @hidden */
  14573. _generatePointsArray(): boolean;
  14574. /**
  14575. * Returns a new Mesh object generated from the current mesh properties.
  14576. * This method must not get confused with createInstance()
  14577. * @param name is a string, the name given to the new mesh
  14578. * @param newParent can be any Node object (default `null`)
  14579. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14580. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14581. * @returns a new mesh
  14582. */
  14583. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14584. /**
  14585. * Releases resources associated with this mesh.
  14586. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14587. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14588. */
  14589. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14590. /**
  14591. * Modifies the mesh geometry according to a displacement map.
  14592. * 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.
  14593. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14594. * @param url is a string, the URL from the image file is to be downloaded.
  14595. * @param minHeight is the lower limit of the displacement.
  14596. * @param maxHeight is the upper limit of the displacement.
  14597. * @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.
  14598. * @param uvOffset is an optional vector2 used to offset UV.
  14599. * @param uvScale is an optional vector2 used to scale UV.
  14600. * @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.
  14601. * @returns the Mesh.
  14602. */
  14603. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14604. /**
  14605. * Modifies the mesh geometry according to a displacementMap buffer.
  14606. * 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.
  14607. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14608. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14609. * @param heightMapWidth is the width of the buffer image.
  14610. * @param heightMapHeight is the height of the buffer image.
  14611. * @param minHeight is the lower limit of the displacement.
  14612. * @param maxHeight is the upper limit of the displacement.
  14613. * @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.
  14614. * @param uvOffset is an optional vector2 used to offset UV.
  14615. * @param uvScale is an optional vector2 used to scale UV.
  14616. * @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.
  14617. * @returns the Mesh.
  14618. */
  14619. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14620. /**
  14621. * Modify the mesh to get a flat shading rendering.
  14622. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14623. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14624. * @returns current mesh
  14625. */
  14626. convertToFlatShadedMesh(): Mesh;
  14627. /**
  14628. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14629. * In other words, more vertices, no more indices and a single bigger VBO.
  14630. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14631. * @returns current mesh
  14632. */
  14633. convertToUnIndexedMesh(): Mesh;
  14634. /**
  14635. * Inverses facet orientations.
  14636. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14637. * @param flipNormals will also inverts the normals
  14638. * @returns current mesh
  14639. */
  14640. flipFaces(flipNormals?: boolean): Mesh;
  14641. /**
  14642. * Increase the number of facets and hence vertices in a mesh
  14643. * Vertex normals are interpolated from existing vertex normals
  14644. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14645. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14646. */
  14647. increaseVertices(numberPerEdge: number): void;
  14648. /**
  14649. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14650. * This will undo any application of covertToFlatShadedMesh
  14651. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14652. */
  14653. forceSharedVertices(): void;
  14654. /** @hidden */
  14655. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14656. /** @hidden */
  14657. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14658. /**
  14659. * Creates a new InstancedMesh object from the mesh model.
  14660. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14661. * @param name defines the name of the new instance
  14662. * @returns a new InstancedMesh
  14663. */
  14664. createInstance(name: string): InstancedMesh;
  14665. /**
  14666. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14667. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14668. * @returns the current mesh
  14669. */
  14670. synchronizeInstances(): Mesh;
  14671. /**
  14672. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14673. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14674. * This should be used together with the simplification to avoid disappearing triangles.
  14675. * @param successCallback an optional success callback to be called after the optimization finished.
  14676. * @returns the current mesh
  14677. */
  14678. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14679. /**
  14680. * Serialize current mesh
  14681. * @param serializationObject defines the object which will receive the serialization data
  14682. */
  14683. serialize(serializationObject: any): void;
  14684. /** @hidden */
  14685. _syncGeometryWithMorphTargetManager(): void;
  14686. /** @hidden */
  14687. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14688. /**
  14689. * Returns a new Mesh object parsed from the source provided.
  14690. * @param parsedMesh is the source
  14691. * @param scene defines the hosting scene
  14692. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14693. * @returns a new Mesh
  14694. */
  14695. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14696. /**
  14697. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14698. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14699. * @param name defines the name of the mesh to create
  14700. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14701. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14702. * @param closePath creates a seam between the first and the last points of each path of the path array
  14703. * @param offset is taken in account only if the `pathArray` is containing a single path
  14704. * @param scene defines the hosting scene
  14705. * @param updatable defines if the mesh must be flagged as updatable
  14706. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14707. * @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)
  14708. * @returns a new Mesh
  14709. */
  14710. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14711. /**
  14712. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14713. * @param name defines the name of the mesh to create
  14714. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14715. * @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
  14716. * @param scene defines the hosting scene
  14717. * @param updatable defines if the mesh must be flagged as updatable
  14718. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14719. * @returns a new Mesh
  14720. */
  14721. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14722. /**
  14723. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14724. * @param name defines the name of the mesh to create
  14725. * @param size sets the size (float) of each box side (default 1)
  14726. * @param scene defines the hosting scene
  14727. * @param updatable defines if the mesh must be flagged as updatable
  14728. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14729. * @returns a new Mesh
  14730. */
  14731. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14732. /**
  14733. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14734. * @param name defines the name of the mesh to create
  14735. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14736. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14737. * @param scene defines the hosting scene
  14738. * @param updatable defines if the mesh must be flagged as updatable
  14739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14740. * @returns a new Mesh
  14741. */
  14742. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14743. /**
  14744. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14745. * @param name defines the name of the mesh to create
  14746. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14747. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14748. * @param scene defines the hosting scene
  14749. * @returns a new Mesh
  14750. */
  14751. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14752. /**
  14753. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14754. * @param name defines the name of the mesh to create
  14755. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14756. * @param diameterTop set the top cap diameter (floats, default 1)
  14757. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14758. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14759. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14760. * @param scene defines the hosting scene
  14761. * @param updatable defines if the mesh must be flagged as updatable
  14762. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14763. * @returns a new Mesh
  14764. */
  14765. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14766. /**
  14767. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14768. * @param name defines the name of the mesh to create
  14769. * @param diameter sets the diameter size (float) of the torus (default 1)
  14770. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14771. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14772. * @param scene defines the hosting scene
  14773. * @param updatable defines if the mesh must be flagged as updatable
  14774. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14775. * @returns a new Mesh
  14776. */
  14777. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14778. /**
  14779. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14780. * @param name defines the name of the mesh to create
  14781. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14782. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14783. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14784. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14785. * @param p the number of windings on X axis (positive integers, default 2)
  14786. * @param q the number of windings on Y axis (positive integers, default 3)
  14787. * @param scene defines the hosting scene
  14788. * @param updatable defines if the mesh must be flagged as updatable
  14789. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14790. * @returns a new Mesh
  14791. */
  14792. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14793. /**
  14794. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14795. * @param name defines the name of the mesh to create
  14796. * @param points is an array successive Vector3
  14797. * @param scene defines the hosting scene
  14798. * @param updatable defines if the mesh must be flagged as updatable
  14799. * @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).
  14800. * @returns a new Mesh
  14801. */
  14802. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14803. /**
  14804. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14805. * @param name defines the name of the mesh to create
  14806. * @param points is an array successive Vector3
  14807. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14808. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14809. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14810. * @param scene defines the hosting scene
  14811. * @param updatable defines if the mesh must be flagged as updatable
  14812. * @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)
  14813. * @returns a new Mesh
  14814. */
  14815. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14816. /**
  14817. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14818. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14819. * 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.
  14820. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14821. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14822. * Remember you can only change the shape positions, not their number when updating a polygon.
  14823. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14824. * @param name defines the name of the mesh to create
  14825. * @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
  14826. * @param scene defines the hosting scene
  14827. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14828. * @param updatable defines if the mesh must be flagged as updatable
  14829. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14830. * @param earcutInjection can be used to inject your own earcut reference
  14831. * @returns a new Mesh
  14832. */
  14833. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14834. /**
  14835. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  14836. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  14837. * @param name defines the name of the mesh to create
  14838. * @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
  14839. * @param depth defines the height of extrusion
  14840. * @param scene defines the hosting scene
  14841. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14842. * @param updatable defines if the mesh must be flagged as updatable
  14843. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14844. * @param earcutInjection can be used to inject your own earcut reference
  14845. * @returns a new Mesh
  14846. */
  14847. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14848. /**
  14849. * Creates an extruded shape mesh.
  14850. * 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
  14851. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14852. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14853. * @param name defines the name of the mesh to create
  14854. * @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
  14855. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14856. * @param scale is the value to scale the shape
  14857. * @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
  14858. * @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
  14859. * @param scene defines the hosting scene
  14860. * @param updatable defines if the mesh must be flagged as updatable
  14861. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14862. * @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)
  14863. * @returns a new Mesh
  14864. */
  14865. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14866. /**
  14867. * Creates an custom extruded shape mesh.
  14868. * The custom extrusion is a parametric shape.
  14869. * It has no predefined shape. Its final shape will depend on the input parameters.
  14870. * Please consider using the same method from the MeshBuilder class instead
  14871. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14872. * @param name defines the name of the mesh to create
  14873. * @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
  14874. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14875. * @param scaleFunction is a custom Javascript function called on each path point
  14876. * @param rotationFunction is a custom Javascript function called on each path point
  14877. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  14878. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  14879. * @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
  14880. * @param scene defines the hosting scene
  14881. * @param updatable defines if the mesh must be flagged as updatable
  14882. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14883. * @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)
  14884. * @returns a new Mesh
  14885. */
  14886. 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;
  14887. /**
  14888. * Creates lathe mesh.
  14889. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  14890. * Please consider using the same method from the MeshBuilder class instead
  14891. * @param name defines the name of the mesh to create
  14892. * @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
  14893. * @param radius is the radius value of the lathe
  14894. * @param tessellation is the side number of the lathe.
  14895. * @param scene defines the hosting scene
  14896. * @param updatable defines if the mesh must be flagged as updatable
  14897. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14898. * @returns a new Mesh
  14899. */
  14900. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14901. /**
  14902. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  14903. * @param name defines the name of the mesh to create
  14904. * @param size sets the size (float) of both sides of the plane at once (default 1)
  14905. * @param scene defines the hosting scene
  14906. * @param updatable defines if the mesh must be flagged as updatable
  14907. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14908. * @returns a new Mesh
  14909. */
  14910. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14911. /**
  14912. * Creates a ground mesh.
  14913. * Please consider using the same method from the MeshBuilder class instead
  14914. * @param name defines the name of the mesh to create
  14915. * @param width set the width of the ground
  14916. * @param height set the height of the ground
  14917. * @param subdivisions sets the number of subdivisions per side
  14918. * @param scene defines the hosting scene
  14919. * @param updatable defines if the mesh must be flagged as updatable
  14920. * @returns a new Mesh
  14921. */
  14922. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  14923. /**
  14924. * Creates a tiled ground mesh.
  14925. * Please consider using the same method from the MeshBuilder class instead
  14926. * @param name defines the name of the mesh to create
  14927. * @param xmin set the ground minimum X coordinate
  14928. * @param zmin set the ground minimum Y coordinate
  14929. * @param xmax set the ground maximum X coordinate
  14930. * @param zmax set the ground maximum Z coordinate
  14931. * @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
  14932. * @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
  14933. * @param scene defines the hosting scene
  14934. * @param updatable defines if the mesh must be flagged as updatable
  14935. * @returns a new Mesh
  14936. */
  14937. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  14938. w: number;
  14939. h: number;
  14940. }, precision: {
  14941. w: number;
  14942. h: number;
  14943. }, scene: Scene, updatable?: boolean): Mesh;
  14944. /**
  14945. * Creates a ground mesh from a height map.
  14946. * Please consider using the same method from the MeshBuilder class instead
  14947. * @see http://doc.babylonjs.com/babylon101/height_map
  14948. * @param name defines the name of the mesh to create
  14949. * @param url sets the URL of the height map image resource
  14950. * @param width set the ground width size
  14951. * @param height set the ground height size
  14952. * @param subdivisions sets the number of subdivision per side
  14953. * @param minHeight is the minimum altitude on the ground
  14954. * @param maxHeight is the maximum altitude on the ground
  14955. * @param scene defines the hosting scene
  14956. * @param updatable defines if the mesh must be flagged as updatable
  14957. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  14958. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  14959. * @returns a new Mesh
  14960. */
  14961. 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;
  14962. /**
  14963. * Creates a tube mesh.
  14964. * The tube is a parametric shape.
  14965. * It has no predefined shape. Its final shape will depend on the input parameters.
  14966. * Please consider using the same method from the MeshBuilder class instead
  14967. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14968. * @param name defines the name of the mesh to create
  14969. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  14970. * @param radius sets the tube radius size
  14971. * @param tessellation is the number of sides on the tubular surface
  14972. * @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
  14973. * @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
  14974. * @param scene defines the hosting scene
  14975. * @param updatable defines if the mesh must be flagged as updatable
  14976. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14977. * @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)
  14978. * @returns a new Mesh
  14979. */
  14980. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  14981. (i: number, distance: number): number;
  14982. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14983. /**
  14984. * Creates a polyhedron mesh.
  14985. * Please consider using the same method from the MeshBuilder class instead.
  14986. * * 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
  14987. * * The parameter `size` (positive float, default 1) sets the polygon size
  14988. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  14989. * * 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`
  14990. * * 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
  14991. * * 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)`)
  14992. * * 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
  14993. * * 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
  14994. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14995. * * 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
  14996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14997. * @param name defines the name of the mesh to create
  14998. * @param options defines the options used to create the mesh
  14999. * @param scene defines the hosting scene
  15000. * @returns a new Mesh
  15001. */
  15002. static CreatePolyhedron(name: string, options: {
  15003. type?: number;
  15004. size?: number;
  15005. sizeX?: number;
  15006. sizeY?: number;
  15007. sizeZ?: number;
  15008. custom?: any;
  15009. faceUV?: Vector4[];
  15010. faceColors?: Color4[];
  15011. updatable?: boolean;
  15012. sideOrientation?: number;
  15013. }, scene: Scene): Mesh;
  15014. /**
  15015. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15016. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15017. * * 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`)
  15018. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15019. * * 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
  15020. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15021. * * 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
  15022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15023. * @param name defines the name of the mesh
  15024. * @param options defines the options used to create the mesh
  15025. * @param scene defines the hosting scene
  15026. * @returns a new Mesh
  15027. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15028. */
  15029. static CreateIcoSphere(name: string, options: {
  15030. radius?: number;
  15031. flat?: boolean;
  15032. subdivisions?: number;
  15033. sideOrientation?: number;
  15034. updatable?: boolean;
  15035. }, scene: Scene): Mesh;
  15036. /**
  15037. * Creates a decal mesh.
  15038. * Please consider using the same method from the MeshBuilder class instead.
  15039. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15040. * @param name defines the name of the mesh
  15041. * @param sourceMesh defines the mesh receiving the decal
  15042. * @param position sets the position of the decal in world coordinates
  15043. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15044. * @param size sets the decal scaling
  15045. * @param angle sets the angle to rotate the decal
  15046. * @returns a new Mesh
  15047. */
  15048. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15049. /**
  15050. * Prepare internal position array for software CPU skinning
  15051. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15052. */
  15053. setPositionsForCPUSkinning(): Float32Array;
  15054. /**
  15055. * Prepare internal normal array for software CPU skinning
  15056. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15057. */
  15058. setNormalsForCPUSkinning(): Float32Array;
  15059. /**
  15060. * Updates the vertex buffer by applying transformation from the bones
  15061. * @param skeleton defines the skeleton to apply to current mesh
  15062. * @returns the current mesh
  15063. */
  15064. applySkeleton(skeleton: Skeleton): Mesh;
  15065. /**
  15066. * 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
  15067. * @param meshes defines the list of meshes to scan
  15068. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15069. */
  15070. static MinMax(meshes: AbstractMesh[]): {
  15071. min: Vector3;
  15072. max: Vector3;
  15073. };
  15074. /**
  15075. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15076. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15077. * @returns a vector3
  15078. */
  15079. static Center(meshesOrMinMaxVector: {
  15080. min: Vector3;
  15081. max: Vector3;
  15082. } | AbstractMesh[]): Vector3;
  15083. /**
  15084. * Merge the array of meshes into a single mesh for performance reasons.
  15085. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15086. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15087. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15088. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15089. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15090. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15091. * @returns a new mesh
  15092. */
  15093. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15094. /** @hidden */
  15095. addInstance(instance: InstancedMesh): void;
  15096. /** @hidden */
  15097. removeInstance(instance: InstancedMesh): void;
  15098. }
  15099. }
  15100. declare module BABYLON {
  15101. /**
  15102. * Interface used to define Action
  15103. */
  15104. export interface IAction {
  15105. /**
  15106. * Trigger for the action
  15107. */
  15108. trigger: number;
  15109. /** Options of the trigger */
  15110. triggerOptions: any;
  15111. /**
  15112. * Gets the trigger parameters
  15113. * @returns the trigger parameters
  15114. */
  15115. getTriggerParameter(): any;
  15116. /**
  15117. * Internal only - executes current action event
  15118. * @hidden
  15119. */
  15120. _executeCurrent(evt?: ActionEvent): void;
  15121. /**
  15122. * Serialize placeholder for child classes
  15123. * @param parent of child
  15124. * @returns the serialized object
  15125. */
  15126. serialize(parent: any): any;
  15127. /**
  15128. * Internal only
  15129. * @hidden
  15130. */
  15131. _prepare(): void;
  15132. /**
  15133. * Internal only - manager for action
  15134. * @hidden
  15135. */
  15136. _actionManager: AbstractActionManager;
  15137. /**
  15138. * Adds action to chain of actions, may be a DoNothingAction
  15139. * @param action defines the next action to execute
  15140. * @returns The action passed in
  15141. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15142. */
  15143. then(action: IAction): IAction;
  15144. }
  15145. /**
  15146. * The action to be carried out following a trigger
  15147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15148. */
  15149. export class Action implements IAction {
  15150. /** the trigger, with or without parameters, for the action */
  15151. triggerOptions: any;
  15152. /**
  15153. * Trigger for the action
  15154. */
  15155. trigger: number;
  15156. /**
  15157. * Internal only - manager for action
  15158. * @hidden
  15159. */
  15160. _actionManager: ActionManager;
  15161. private _nextActiveAction;
  15162. private _child;
  15163. private _condition?;
  15164. private _triggerParameter;
  15165. /**
  15166. * An event triggered prior to action being executed.
  15167. */
  15168. onBeforeExecuteObservable: Observable<Action>;
  15169. /**
  15170. * Creates a new Action
  15171. * @param triggerOptions the trigger, with or without parameters, for the action
  15172. * @param condition an optional determinant of action
  15173. */
  15174. constructor(
  15175. /** the trigger, with or without parameters, for the action */
  15176. triggerOptions: any, condition?: Condition);
  15177. /**
  15178. * Internal only
  15179. * @hidden
  15180. */
  15181. _prepare(): void;
  15182. /**
  15183. * Gets the trigger parameters
  15184. * @returns the trigger parameters
  15185. */
  15186. getTriggerParameter(): any;
  15187. /**
  15188. * Internal only - executes current action event
  15189. * @hidden
  15190. */
  15191. _executeCurrent(evt?: ActionEvent): void;
  15192. /**
  15193. * Execute placeholder for child classes
  15194. * @param evt optional action event
  15195. */
  15196. execute(evt?: ActionEvent): void;
  15197. /**
  15198. * Skips to next active action
  15199. */
  15200. skipToNextActiveAction(): void;
  15201. /**
  15202. * Adds action to chain of actions, may be a DoNothingAction
  15203. * @param action defines the next action to execute
  15204. * @returns The action passed in
  15205. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15206. */
  15207. then(action: Action): Action;
  15208. /**
  15209. * Internal only
  15210. * @hidden
  15211. */
  15212. _getProperty(propertyPath: string): string;
  15213. /**
  15214. * Internal only
  15215. * @hidden
  15216. */
  15217. _getEffectiveTarget(target: any, propertyPath: string): any;
  15218. /**
  15219. * Serialize placeholder for child classes
  15220. * @param parent of child
  15221. * @returns the serialized object
  15222. */
  15223. serialize(parent: any): any;
  15224. /**
  15225. * Internal only called by serialize
  15226. * @hidden
  15227. */
  15228. protected _serialize(serializedAction: any, parent?: any): any;
  15229. /**
  15230. * Internal only
  15231. * @hidden
  15232. */
  15233. static _SerializeValueAsString: (value: any) => string;
  15234. /**
  15235. * Internal only
  15236. * @hidden
  15237. */
  15238. static _GetTargetProperty: (target: Scene | Node) => {
  15239. name: string;
  15240. targetType: string;
  15241. value: string;
  15242. };
  15243. }
  15244. }
  15245. declare module BABYLON {
  15246. /**
  15247. * A Condition applied to an Action
  15248. */
  15249. export class Condition {
  15250. /**
  15251. * Internal only - manager for action
  15252. * @hidden
  15253. */
  15254. _actionManager: ActionManager;
  15255. /**
  15256. * Internal only
  15257. * @hidden
  15258. */
  15259. _evaluationId: number;
  15260. /**
  15261. * Internal only
  15262. * @hidden
  15263. */
  15264. _currentResult: boolean;
  15265. /**
  15266. * Creates a new Condition
  15267. * @param actionManager the manager of the action the condition is applied to
  15268. */
  15269. constructor(actionManager: ActionManager);
  15270. /**
  15271. * Check if the current condition is valid
  15272. * @returns a boolean
  15273. */
  15274. isValid(): boolean;
  15275. /**
  15276. * Internal only
  15277. * @hidden
  15278. */
  15279. _getProperty(propertyPath: string): string;
  15280. /**
  15281. * Internal only
  15282. * @hidden
  15283. */
  15284. _getEffectiveTarget(target: any, propertyPath: string): any;
  15285. /**
  15286. * Serialize placeholder for child classes
  15287. * @returns the serialized object
  15288. */
  15289. serialize(): any;
  15290. /**
  15291. * Internal only
  15292. * @hidden
  15293. */
  15294. protected _serialize(serializedCondition: any): any;
  15295. }
  15296. /**
  15297. * Defines specific conditional operators as extensions of Condition
  15298. */
  15299. export class ValueCondition extends Condition {
  15300. /** path to specify the property of the target the conditional operator uses */
  15301. propertyPath: string;
  15302. /** the value compared by the conditional operator against the current value of the property */
  15303. value: any;
  15304. /** the conditional operator, default ValueCondition.IsEqual */
  15305. operator: number;
  15306. /**
  15307. * Internal only
  15308. * @hidden
  15309. */
  15310. private static _IsEqual;
  15311. /**
  15312. * Internal only
  15313. * @hidden
  15314. */
  15315. private static _IsDifferent;
  15316. /**
  15317. * Internal only
  15318. * @hidden
  15319. */
  15320. private static _IsGreater;
  15321. /**
  15322. * Internal only
  15323. * @hidden
  15324. */
  15325. private static _IsLesser;
  15326. /**
  15327. * returns the number for IsEqual
  15328. */
  15329. static readonly IsEqual: number;
  15330. /**
  15331. * Returns the number for IsDifferent
  15332. */
  15333. static readonly IsDifferent: number;
  15334. /**
  15335. * Returns the number for IsGreater
  15336. */
  15337. static readonly IsGreater: number;
  15338. /**
  15339. * Returns the number for IsLesser
  15340. */
  15341. static readonly IsLesser: number;
  15342. /**
  15343. * Internal only The action manager for the condition
  15344. * @hidden
  15345. */
  15346. _actionManager: ActionManager;
  15347. /**
  15348. * Internal only
  15349. * @hidden
  15350. */
  15351. private _target;
  15352. /**
  15353. * Internal only
  15354. * @hidden
  15355. */
  15356. private _effectiveTarget;
  15357. /**
  15358. * Internal only
  15359. * @hidden
  15360. */
  15361. private _property;
  15362. /**
  15363. * Creates a new ValueCondition
  15364. * @param actionManager manager for the action the condition applies to
  15365. * @param target for the action
  15366. * @param propertyPath path to specify the property of the target the conditional operator uses
  15367. * @param value the value compared by the conditional operator against the current value of the property
  15368. * @param operator the conditional operator, default ValueCondition.IsEqual
  15369. */
  15370. constructor(actionManager: ActionManager, target: any,
  15371. /** path to specify the property of the target the conditional operator uses */
  15372. propertyPath: string,
  15373. /** the value compared by the conditional operator against the current value of the property */
  15374. value: any,
  15375. /** the conditional operator, default ValueCondition.IsEqual */
  15376. operator?: number);
  15377. /**
  15378. * Compares the given value with the property value for the specified conditional operator
  15379. * @returns the result of the comparison
  15380. */
  15381. isValid(): boolean;
  15382. /**
  15383. * Serialize the ValueCondition into a JSON compatible object
  15384. * @returns serialization object
  15385. */
  15386. serialize(): any;
  15387. /**
  15388. * Gets the name of the conditional operator for the ValueCondition
  15389. * @param operator the conditional operator
  15390. * @returns the name
  15391. */
  15392. static GetOperatorName(operator: number): string;
  15393. }
  15394. /**
  15395. * Defines a predicate condition as an extension of Condition
  15396. */
  15397. export class PredicateCondition extends Condition {
  15398. /** defines the predicate function used to validate the condition */
  15399. predicate: () => boolean;
  15400. /**
  15401. * Internal only - manager for action
  15402. * @hidden
  15403. */
  15404. _actionManager: ActionManager;
  15405. /**
  15406. * Creates a new PredicateCondition
  15407. * @param actionManager manager for the action the condition applies to
  15408. * @param predicate defines the predicate function used to validate the condition
  15409. */
  15410. constructor(actionManager: ActionManager,
  15411. /** defines the predicate function used to validate the condition */
  15412. predicate: () => boolean);
  15413. /**
  15414. * @returns the validity of the predicate condition
  15415. */
  15416. isValid(): boolean;
  15417. }
  15418. /**
  15419. * Defines a state condition as an extension of Condition
  15420. */
  15421. export class StateCondition extends Condition {
  15422. /** Value to compare with target state */
  15423. value: string;
  15424. /**
  15425. * Internal only - manager for action
  15426. * @hidden
  15427. */
  15428. _actionManager: ActionManager;
  15429. /**
  15430. * Internal only
  15431. * @hidden
  15432. */
  15433. private _target;
  15434. /**
  15435. * Creates a new StateCondition
  15436. * @param actionManager manager for the action the condition applies to
  15437. * @param target of the condition
  15438. * @param value to compare with target state
  15439. */
  15440. constructor(actionManager: ActionManager, target: any,
  15441. /** Value to compare with target state */
  15442. value: string);
  15443. /**
  15444. * Gets a boolean indicating if the current condition is met
  15445. * @returns the validity of the state
  15446. */
  15447. isValid(): boolean;
  15448. /**
  15449. * Serialize the StateCondition into a JSON compatible object
  15450. * @returns serialization object
  15451. */
  15452. serialize(): any;
  15453. }
  15454. }
  15455. declare module BABYLON {
  15456. /**
  15457. * This defines an action responsible to toggle a boolean once triggered.
  15458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15459. */
  15460. export class SwitchBooleanAction extends Action {
  15461. /**
  15462. * The path to the boolean property in the target object
  15463. */
  15464. propertyPath: string;
  15465. private _target;
  15466. private _effectiveTarget;
  15467. private _property;
  15468. /**
  15469. * Instantiate the action
  15470. * @param triggerOptions defines the trigger options
  15471. * @param target defines the object containing the boolean
  15472. * @param propertyPath defines the path to the boolean property in the target object
  15473. * @param condition defines the trigger related conditions
  15474. */
  15475. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15476. /** @hidden */
  15477. _prepare(): void;
  15478. /**
  15479. * Execute the action toggle the boolean value.
  15480. */
  15481. execute(): void;
  15482. /**
  15483. * Serializes the actions and its related information.
  15484. * @param parent defines the object to serialize in
  15485. * @returns the serialized object
  15486. */
  15487. serialize(parent: any): any;
  15488. }
  15489. /**
  15490. * This defines an action responsible to set a the state field of the target
  15491. * to a desired value once triggered.
  15492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15493. */
  15494. export class SetStateAction extends Action {
  15495. /**
  15496. * The value to store in the state field.
  15497. */
  15498. value: string;
  15499. private _target;
  15500. /**
  15501. * Instantiate the action
  15502. * @param triggerOptions defines the trigger options
  15503. * @param target defines the object containing the state property
  15504. * @param value defines the value to store in the state field
  15505. * @param condition defines the trigger related conditions
  15506. */
  15507. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15508. /**
  15509. * Execute the action and store the value on the target state property.
  15510. */
  15511. execute(): void;
  15512. /**
  15513. * Serializes the actions and its related information.
  15514. * @param parent defines the object to serialize in
  15515. * @returns the serialized object
  15516. */
  15517. serialize(parent: any): any;
  15518. }
  15519. /**
  15520. * This defines an action responsible to set a property of the target
  15521. * to a desired value once triggered.
  15522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15523. */
  15524. export class SetValueAction extends Action {
  15525. /**
  15526. * The path of the property to set in the target.
  15527. */
  15528. propertyPath: string;
  15529. /**
  15530. * The value to set in the property
  15531. */
  15532. value: any;
  15533. private _target;
  15534. private _effectiveTarget;
  15535. private _property;
  15536. /**
  15537. * Instantiate the action
  15538. * @param triggerOptions defines the trigger options
  15539. * @param target defines the object containing the property
  15540. * @param propertyPath defines the path of the property to set in the target
  15541. * @param value defines the value to set in the property
  15542. * @param condition defines the trigger related conditions
  15543. */
  15544. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15545. /** @hidden */
  15546. _prepare(): void;
  15547. /**
  15548. * Execute the action and set the targetted property to the desired value.
  15549. */
  15550. execute(): void;
  15551. /**
  15552. * Serializes the actions and its related information.
  15553. * @param parent defines the object to serialize in
  15554. * @returns the serialized object
  15555. */
  15556. serialize(parent: any): any;
  15557. }
  15558. /**
  15559. * This defines an action responsible to increment the target value
  15560. * to a desired value once triggered.
  15561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15562. */
  15563. export class IncrementValueAction extends Action {
  15564. /**
  15565. * The path of the property to increment in the target.
  15566. */
  15567. propertyPath: string;
  15568. /**
  15569. * The value we should increment the property by.
  15570. */
  15571. value: any;
  15572. private _target;
  15573. private _effectiveTarget;
  15574. private _property;
  15575. /**
  15576. * Instantiate the action
  15577. * @param triggerOptions defines the trigger options
  15578. * @param target defines the object containing the property
  15579. * @param propertyPath defines the path of the property to increment in the target
  15580. * @param value defines the value value we should increment the property by
  15581. * @param condition defines the trigger related conditions
  15582. */
  15583. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15584. /** @hidden */
  15585. _prepare(): void;
  15586. /**
  15587. * Execute the action and increment the target of the value amount.
  15588. */
  15589. execute(): void;
  15590. /**
  15591. * Serializes the actions and its related information.
  15592. * @param parent defines the object to serialize in
  15593. * @returns the serialized object
  15594. */
  15595. serialize(parent: any): any;
  15596. }
  15597. /**
  15598. * This defines an action responsible to start an animation once triggered.
  15599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15600. */
  15601. export class PlayAnimationAction extends Action {
  15602. /**
  15603. * Where the animation should start (animation frame)
  15604. */
  15605. from: number;
  15606. /**
  15607. * Where the animation should stop (animation frame)
  15608. */
  15609. to: number;
  15610. /**
  15611. * Define if the animation should loop or stop after the first play.
  15612. */
  15613. loop?: boolean;
  15614. private _target;
  15615. /**
  15616. * Instantiate the action
  15617. * @param triggerOptions defines the trigger options
  15618. * @param target defines the target animation or animation name
  15619. * @param from defines from where the animation should start (animation frame)
  15620. * @param end defines where the animation should stop (animation frame)
  15621. * @param loop defines if the animation should loop or stop after the first play
  15622. * @param condition defines the trigger related conditions
  15623. */
  15624. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15625. /** @hidden */
  15626. _prepare(): void;
  15627. /**
  15628. * Execute the action and play the animation.
  15629. */
  15630. execute(): void;
  15631. /**
  15632. * Serializes the actions and its related information.
  15633. * @param parent defines the object to serialize in
  15634. * @returns the serialized object
  15635. */
  15636. serialize(parent: any): any;
  15637. }
  15638. /**
  15639. * This defines an action responsible to stop an animation once triggered.
  15640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15641. */
  15642. export class StopAnimationAction extends Action {
  15643. private _target;
  15644. /**
  15645. * Instantiate the action
  15646. * @param triggerOptions defines the trigger options
  15647. * @param target defines the target animation or animation name
  15648. * @param condition defines the trigger related conditions
  15649. */
  15650. constructor(triggerOptions: any, target: any, condition?: Condition);
  15651. /** @hidden */
  15652. _prepare(): void;
  15653. /**
  15654. * Execute the action and stop the animation.
  15655. */
  15656. execute(): void;
  15657. /**
  15658. * Serializes the actions and its related information.
  15659. * @param parent defines the object to serialize in
  15660. * @returns the serialized object
  15661. */
  15662. serialize(parent: any): any;
  15663. }
  15664. /**
  15665. * This defines an action responsible that does nothing once triggered.
  15666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15667. */
  15668. export class DoNothingAction extends Action {
  15669. /**
  15670. * Instantiate the action
  15671. * @param triggerOptions defines the trigger options
  15672. * @param condition defines the trigger related conditions
  15673. */
  15674. constructor(triggerOptions?: any, condition?: Condition);
  15675. /**
  15676. * Execute the action and do nothing.
  15677. */
  15678. execute(): void;
  15679. /**
  15680. * Serializes the actions and its related information.
  15681. * @param parent defines the object to serialize in
  15682. * @returns the serialized object
  15683. */
  15684. serialize(parent: any): any;
  15685. }
  15686. /**
  15687. * This defines an action responsible to trigger several actions once triggered.
  15688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15689. */
  15690. export class CombineAction extends Action {
  15691. /**
  15692. * The list of aggregated animations to run.
  15693. */
  15694. children: Action[];
  15695. /**
  15696. * Instantiate the action
  15697. * @param triggerOptions defines the trigger options
  15698. * @param children defines the list of aggregated animations to run
  15699. * @param condition defines the trigger related conditions
  15700. */
  15701. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15702. /** @hidden */
  15703. _prepare(): void;
  15704. /**
  15705. * Execute the action and executes all the aggregated actions.
  15706. */
  15707. execute(evt: ActionEvent): void;
  15708. /**
  15709. * Serializes the actions and its related information.
  15710. * @param parent defines the object to serialize in
  15711. * @returns the serialized object
  15712. */
  15713. serialize(parent: any): any;
  15714. }
  15715. /**
  15716. * This defines an action responsible to run code (external event) once triggered.
  15717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15718. */
  15719. export class ExecuteCodeAction extends Action {
  15720. /**
  15721. * The callback function to run.
  15722. */
  15723. func: (evt: ActionEvent) => void;
  15724. /**
  15725. * Instantiate the action
  15726. * @param triggerOptions defines the trigger options
  15727. * @param func defines the callback function to run
  15728. * @param condition defines the trigger related conditions
  15729. */
  15730. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15731. /**
  15732. * Execute the action and run the attached code.
  15733. */
  15734. execute(evt: ActionEvent): void;
  15735. }
  15736. /**
  15737. * This defines an action responsible to set the parent property of the target once triggered.
  15738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15739. */
  15740. export class SetParentAction extends Action {
  15741. private _parent;
  15742. private _target;
  15743. /**
  15744. * Instantiate the action
  15745. * @param triggerOptions defines the trigger options
  15746. * @param target defines the target containing the parent property
  15747. * @param parent defines from where the animation should start (animation frame)
  15748. * @param condition defines the trigger related conditions
  15749. */
  15750. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15751. /** @hidden */
  15752. _prepare(): void;
  15753. /**
  15754. * Execute the action and set the parent property.
  15755. */
  15756. execute(): void;
  15757. /**
  15758. * Serializes the actions and its related information.
  15759. * @param parent defines the object to serialize in
  15760. * @returns the serialized object
  15761. */
  15762. serialize(parent: any): any;
  15763. }
  15764. }
  15765. declare module BABYLON {
  15766. /**
  15767. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15768. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15770. */
  15771. export class ActionManager extends AbstractActionManager {
  15772. /**
  15773. * Nothing
  15774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15775. */
  15776. static readonly NothingTrigger: number;
  15777. /**
  15778. * On pick
  15779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15780. */
  15781. static readonly OnPickTrigger: number;
  15782. /**
  15783. * On left pick
  15784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15785. */
  15786. static readonly OnLeftPickTrigger: number;
  15787. /**
  15788. * On right pick
  15789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15790. */
  15791. static readonly OnRightPickTrigger: number;
  15792. /**
  15793. * On center pick
  15794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15795. */
  15796. static readonly OnCenterPickTrigger: number;
  15797. /**
  15798. * On pick down
  15799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15800. */
  15801. static readonly OnPickDownTrigger: number;
  15802. /**
  15803. * On double pick
  15804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15805. */
  15806. static readonly OnDoublePickTrigger: number;
  15807. /**
  15808. * On pick up
  15809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15810. */
  15811. static readonly OnPickUpTrigger: number;
  15812. /**
  15813. * On pick out.
  15814. * This trigger will only be raised if you also declared a OnPickDown
  15815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15816. */
  15817. static readonly OnPickOutTrigger: number;
  15818. /**
  15819. * On long press
  15820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15821. */
  15822. static readonly OnLongPressTrigger: number;
  15823. /**
  15824. * On pointer over
  15825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15826. */
  15827. static readonly OnPointerOverTrigger: number;
  15828. /**
  15829. * On pointer out
  15830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15831. */
  15832. static readonly OnPointerOutTrigger: number;
  15833. /**
  15834. * On every frame
  15835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15836. */
  15837. static readonly OnEveryFrameTrigger: number;
  15838. /**
  15839. * On intersection enter
  15840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15841. */
  15842. static readonly OnIntersectionEnterTrigger: number;
  15843. /**
  15844. * On intersection exit
  15845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15846. */
  15847. static readonly OnIntersectionExitTrigger: number;
  15848. /**
  15849. * On key down
  15850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15851. */
  15852. static readonly OnKeyDownTrigger: number;
  15853. /**
  15854. * On key up
  15855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15856. */
  15857. static readonly OnKeyUpTrigger: number;
  15858. private _scene;
  15859. /**
  15860. * Creates a new action manager
  15861. * @param scene defines the hosting scene
  15862. */
  15863. constructor(scene: Scene);
  15864. /**
  15865. * Releases all associated resources
  15866. */
  15867. dispose(): void;
  15868. /**
  15869. * Gets hosting scene
  15870. * @returns the hosting scene
  15871. */
  15872. getScene(): Scene;
  15873. /**
  15874. * Does this action manager handles actions of any of the given triggers
  15875. * @param triggers defines the triggers to be tested
  15876. * @return a boolean indicating whether one (or more) of the triggers is handled
  15877. */
  15878. hasSpecificTriggers(triggers: number[]): boolean;
  15879. /**
  15880. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  15881. * speed.
  15882. * @param triggerA defines the trigger to be tested
  15883. * @param triggerB defines the trigger to be tested
  15884. * @return a boolean indicating whether one (or more) of the triggers is handled
  15885. */
  15886. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  15887. /**
  15888. * Does this action manager handles actions of a given trigger
  15889. * @param trigger defines the trigger to be tested
  15890. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  15891. * @return whether the trigger is handled
  15892. */
  15893. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  15894. /**
  15895. * Does this action manager has pointer triggers
  15896. */
  15897. readonly hasPointerTriggers: boolean;
  15898. /**
  15899. * Does this action manager has pick triggers
  15900. */
  15901. readonly hasPickTriggers: boolean;
  15902. /**
  15903. * Registers an action to this action manager
  15904. * @param action defines the action to be registered
  15905. * @return the action amended (prepared) after registration
  15906. */
  15907. registerAction(action: IAction): Nullable<IAction>;
  15908. /**
  15909. * Unregisters an action to this action manager
  15910. * @param action defines the action to be unregistered
  15911. * @return a boolean indicating whether the action has been unregistered
  15912. */
  15913. unregisterAction(action: IAction): Boolean;
  15914. /**
  15915. * Process a specific trigger
  15916. * @param trigger defines the trigger to process
  15917. * @param evt defines the event details to be processed
  15918. */
  15919. processTrigger(trigger: number, evt?: IActionEvent): void;
  15920. /** @hidden */
  15921. _getEffectiveTarget(target: any, propertyPath: string): any;
  15922. /** @hidden */
  15923. _getProperty(propertyPath: string): string;
  15924. /**
  15925. * Serialize this manager to a JSON object
  15926. * @param name defines the property name to store this manager
  15927. * @returns a JSON representation of this manager
  15928. */
  15929. serialize(name: string): any;
  15930. /**
  15931. * Creates a new ActionManager from a JSON data
  15932. * @param parsedActions defines the JSON data to read from
  15933. * @param object defines the hosting mesh
  15934. * @param scene defines the hosting scene
  15935. */
  15936. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  15937. /**
  15938. * Get a trigger name by index
  15939. * @param trigger defines the trigger index
  15940. * @returns a trigger name
  15941. */
  15942. static GetTriggerName(trigger: number): string;
  15943. }
  15944. }
  15945. declare module BABYLON {
  15946. /**
  15947. * Class representing a ray with position and direction
  15948. */
  15949. export class Ray {
  15950. /** origin point */
  15951. origin: Vector3;
  15952. /** direction */
  15953. direction: Vector3;
  15954. /** length of the ray */
  15955. length: number;
  15956. private static readonly TmpVector3;
  15957. private _tmpRay;
  15958. /**
  15959. * Creates a new ray
  15960. * @param origin origin point
  15961. * @param direction direction
  15962. * @param length length of the ray
  15963. */
  15964. constructor(
  15965. /** origin point */
  15966. origin: Vector3,
  15967. /** direction */
  15968. direction: Vector3,
  15969. /** length of the ray */
  15970. length?: number);
  15971. /**
  15972. * Checks if the ray intersects a box
  15973. * @param minimum bound of the box
  15974. * @param maximum bound of the box
  15975. * @param intersectionTreshold extra extend to be added to the box in all direction
  15976. * @returns if the box was hit
  15977. */
  15978. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  15979. /**
  15980. * Checks if the ray intersects a box
  15981. * @param box the bounding box to check
  15982. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  15983. * @returns if the box was hit
  15984. */
  15985. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  15986. /**
  15987. * If the ray hits a sphere
  15988. * @param sphere the bounding sphere to check
  15989. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  15990. * @returns true if it hits the sphere
  15991. */
  15992. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  15993. /**
  15994. * If the ray hits a triange
  15995. * @param vertex0 triangle vertex
  15996. * @param vertex1 triangle vertex
  15997. * @param vertex2 triangle vertex
  15998. * @returns intersection information if hit
  15999. */
  16000. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16001. /**
  16002. * Checks if ray intersects a plane
  16003. * @param plane the plane to check
  16004. * @returns the distance away it was hit
  16005. */
  16006. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16007. /**
  16008. * Calculate the intercept of a ray on a given axis
  16009. * @param axis to check 'x' | 'y' | 'z'
  16010. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  16011. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  16012. */
  16013. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  16014. /**
  16015. * Checks if ray intersects a mesh
  16016. * @param mesh the mesh to check
  16017. * @param fastCheck if only the bounding box should checked
  16018. * @returns picking info of the intersecton
  16019. */
  16020. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16021. /**
  16022. * Checks if ray intersects a mesh
  16023. * @param meshes the meshes to check
  16024. * @param fastCheck if only the bounding box should checked
  16025. * @param results array to store result in
  16026. * @returns Array of picking infos
  16027. */
  16028. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16029. private _comparePickingInfo;
  16030. private static smallnum;
  16031. private static rayl;
  16032. /**
  16033. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16034. * @param sega the first point of the segment to test the intersection against
  16035. * @param segb the second point of the segment to test the intersection against
  16036. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16037. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16038. */
  16039. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16040. /**
  16041. * Update the ray from viewport position
  16042. * @param x position
  16043. * @param y y position
  16044. * @param viewportWidth viewport width
  16045. * @param viewportHeight viewport height
  16046. * @param world world matrix
  16047. * @param view view matrix
  16048. * @param projection projection matrix
  16049. * @returns this ray updated
  16050. */
  16051. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16052. /**
  16053. * Creates a ray with origin and direction of 0,0,0
  16054. * @returns the new ray
  16055. */
  16056. static Zero(): Ray;
  16057. /**
  16058. * Creates a new ray from screen space and viewport
  16059. * @param x position
  16060. * @param y y position
  16061. * @param viewportWidth viewport width
  16062. * @param viewportHeight viewport height
  16063. * @param world world matrix
  16064. * @param view view matrix
  16065. * @param projection projection matrix
  16066. * @returns new ray
  16067. */
  16068. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16069. /**
  16070. * 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
  16071. * transformed to the given world matrix.
  16072. * @param origin The origin point
  16073. * @param end The end point
  16074. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16075. * @returns the new ray
  16076. */
  16077. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16078. /**
  16079. * Transforms a ray by a matrix
  16080. * @param ray ray to transform
  16081. * @param matrix matrix to apply
  16082. * @returns the resulting new ray
  16083. */
  16084. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16085. /**
  16086. * Transforms a ray by a matrix
  16087. * @param ray ray to transform
  16088. * @param matrix matrix to apply
  16089. * @param result ray to store result in
  16090. */
  16091. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16092. /**
  16093. * Unproject a ray from screen space to object space
  16094. * @param sourceX defines the screen space x coordinate to use
  16095. * @param sourceY defines the screen space y coordinate to use
  16096. * @param viewportWidth defines the current width of the viewport
  16097. * @param viewportHeight defines the current height of the viewport
  16098. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16099. * @param view defines the view matrix to use
  16100. * @param projection defines the projection matrix to use
  16101. */
  16102. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16103. }
  16104. /**
  16105. * Type used to define predicate used to select faces when a mesh intersection is detected
  16106. */
  16107. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16108. interface Scene {
  16109. /** @hidden */
  16110. _tempPickingRay: Nullable<Ray>;
  16111. /** @hidden */
  16112. _cachedRayForTransform: Ray;
  16113. /** @hidden */
  16114. _pickWithRayInverseMatrix: Matrix;
  16115. /** @hidden */
  16116. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16117. /** @hidden */
  16118. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16119. }
  16120. }
  16121. declare module BABYLON {
  16122. interface Scene {
  16123. /** @hidden */
  16124. _pointerOverSprite: Nullable<Sprite>;
  16125. /** @hidden */
  16126. _pickedDownSprite: Nullable<Sprite>;
  16127. /** @hidden */
  16128. _tempSpritePickingRay: Nullable<Ray>;
  16129. /**
  16130. * All of the sprite managers added to this scene
  16131. * @see http://doc.babylonjs.com/babylon101/sprites
  16132. */
  16133. spriteManagers: Array<ISpriteManager>;
  16134. /**
  16135. * An event triggered when sprites rendering is about to start
  16136. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16137. */
  16138. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16139. /**
  16140. * An event triggered when sprites rendering is done
  16141. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16142. */
  16143. onAfterSpritesRenderingObservable: Observable<Scene>;
  16144. /** @hidden */
  16145. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16146. /** Launch a ray to try to pick a sprite in the scene
  16147. * @param x position on screen
  16148. * @param y position on screen
  16149. * @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
  16150. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16151. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16152. * @returns a PickingInfo
  16153. */
  16154. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16155. /** Use the given ray to pick a sprite in the scene
  16156. * @param ray The ray (in world space) to use to pick meshes
  16157. * @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
  16158. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16159. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16160. * @returns a PickingInfo
  16161. */
  16162. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16163. /**
  16164. * Force the sprite under the pointer
  16165. * @param sprite defines the sprite to use
  16166. */
  16167. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16168. /**
  16169. * Gets the sprite under the pointer
  16170. * @returns a Sprite or null if no sprite is under the pointer
  16171. */
  16172. getPointerOverSprite(): Nullable<Sprite>;
  16173. }
  16174. /**
  16175. * Defines the sprite scene component responsible to manage sprites
  16176. * in a given scene.
  16177. */
  16178. export class SpriteSceneComponent implements ISceneComponent {
  16179. /**
  16180. * The component name helpfull to identify the component in the list of scene components.
  16181. */
  16182. readonly name: string;
  16183. /**
  16184. * The scene the component belongs to.
  16185. */
  16186. scene: Scene;
  16187. /** @hidden */
  16188. private _spritePredicate;
  16189. /**
  16190. * Creates a new instance of the component for the given scene
  16191. * @param scene Defines the scene to register the component in
  16192. */
  16193. constructor(scene: Scene);
  16194. /**
  16195. * Registers the component in a given scene
  16196. */
  16197. register(): void;
  16198. /**
  16199. * Rebuilds the elements related to this component in case of
  16200. * context lost for instance.
  16201. */
  16202. rebuild(): void;
  16203. /**
  16204. * Disposes the component and the associated ressources.
  16205. */
  16206. dispose(): void;
  16207. private _pickSpriteButKeepRay;
  16208. private _pointerMove;
  16209. private _pointerDown;
  16210. private _pointerUp;
  16211. }
  16212. }
  16213. declare module BABYLON {
  16214. /** @hidden */
  16215. export var fogFragmentDeclaration: {
  16216. name: string;
  16217. shader: string;
  16218. };
  16219. }
  16220. declare module BABYLON {
  16221. /** @hidden */
  16222. export var fogFragment: {
  16223. name: string;
  16224. shader: string;
  16225. };
  16226. }
  16227. declare module BABYLON {
  16228. /** @hidden */
  16229. export var spritesPixelShader: {
  16230. name: string;
  16231. shader: string;
  16232. };
  16233. }
  16234. declare module BABYLON {
  16235. /** @hidden */
  16236. export var fogVertexDeclaration: {
  16237. name: string;
  16238. shader: string;
  16239. };
  16240. }
  16241. declare module BABYLON {
  16242. /** @hidden */
  16243. export var spritesVertexShader: {
  16244. name: string;
  16245. shader: string;
  16246. };
  16247. }
  16248. declare module BABYLON {
  16249. /**
  16250. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16251. */
  16252. export interface ISpriteManager extends IDisposable {
  16253. /**
  16254. * Restricts the camera to viewing objects with the same layerMask.
  16255. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16256. */
  16257. layerMask: number;
  16258. /**
  16259. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16260. */
  16261. isPickable: boolean;
  16262. /**
  16263. * Specifies the rendering group id for this mesh (0 by default)
  16264. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16265. */
  16266. renderingGroupId: number;
  16267. /**
  16268. * Defines the list of sprites managed by the manager.
  16269. */
  16270. sprites: Array<Sprite>;
  16271. /**
  16272. * Tests the intersection of a sprite with a specific ray.
  16273. * @param ray The ray we are sending to test the collision
  16274. * @param camera The camera space we are sending rays in
  16275. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16276. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16277. * @returns picking info or null.
  16278. */
  16279. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16280. /**
  16281. * Renders the list of sprites on screen.
  16282. */
  16283. render(): void;
  16284. }
  16285. /**
  16286. * Class used to manage multiple sprites on the same spritesheet
  16287. * @see http://doc.babylonjs.com/babylon101/sprites
  16288. */
  16289. export class SpriteManager implements ISpriteManager {
  16290. /** defines the manager's name */
  16291. name: string;
  16292. /** Gets the list of sprites */
  16293. sprites: Sprite[];
  16294. /** Gets or sets the rendering group id (0 by default) */
  16295. renderingGroupId: number;
  16296. /** Gets or sets camera layer mask */
  16297. layerMask: number;
  16298. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16299. fogEnabled: boolean;
  16300. /** Gets or sets a boolean indicating if the sprites are pickable */
  16301. isPickable: boolean;
  16302. /** Defines the default width of a cell in the spritesheet */
  16303. cellWidth: number;
  16304. /** Defines the default height of a cell in the spritesheet */
  16305. cellHeight: number;
  16306. /**
  16307. * An event triggered when the manager is disposed.
  16308. */
  16309. onDisposeObservable: Observable<SpriteManager>;
  16310. private _onDisposeObserver;
  16311. /**
  16312. * Callback called when the manager is disposed
  16313. */
  16314. onDispose: () => void;
  16315. private _capacity;
  16316. private _spriteTexture;
  16317. private _epsilon;
  16318. private _scene;
  16319. private _vertexData;
  16320. private _buffer;
  16321. private _vertexBuffers;
  16322. private _indexBuffer;
  16323. private _effectBase;
  16324. private _effectFog;
  16325. /**
  16326. * Gets or sets the spritesheet texture
  16327. */
  16328. texture: Texture;
  16329. /**
  16330. * Creates a new sprite manager
  16331. * @param name defines the manager's name
  16332. * @param imgUrl defines the sprite sheet url
  16333. * @param capacity defines the maximum allowed number of sprites
  16334. * @param cellSize defines the size of a sprite cell
  16335. * @param scene defines the hosting scene
  16336. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16337. * @param samplingMode defines the smapling mode to use with spritesheet
  16338. */
  16339. constructor(
  16340. /** defines the manager's name */
  16341. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16342. private _appendSpriteVertex;
  16343. /**
  16344. * Intersects the sprites with a ray
  16345. * @param ray defines the ray to intersect with
  16346. * @param camera defines the current active camera
  16347. * @param predicate defines a predicate used to select candidate sprites
  16348. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16349. * @returns null if no hit or a PickingInfo
  16350. */
  16351. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16352. /**
  16353. * Render all child sprites
  16354. */
  16355. render(): void;
  16356. /**
  16357. * Release associated resources
  16358. */
  16359. dispose(): void;
  16360. }
  16361. }
  16362. declare module BABYLON {
  16363. /**
  16364. * Class used to represent a sprite
  16365. * @see http://doc.babylonjs.com/babylon101/sprites
  16366. */
  16367. export class Sprite {
  16368. /** defines the name */
  16369. name: string;
  16370. /** Gets or sets the current world position */
  16371. position: Vector3;
  16372. /** Gets or sets the main color */
  16373. color: Color4;
  16374. /** Gets or sets the width */
  16375. width: number;
  16376. /** Gets or sets the height */
  16377. height: number;
  16378. /** Gets or sets rotation angle */
  16379. angle: number;
  16380. /** Gets or sets the cell index in the sprite sheet */
  16381. cellIndex: number;
  16382. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16383. invertU: number;
  16384. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16385. invertV: number;
  16386. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16387. disposeWhenFinishedAnimating: boolean;
  16388. /** Gets the list of attached animations */
  16389. animations: Animation[];
  16390. /** Gets or sets a boolean indicating if the sprite can be picked */
  16391. isPickable: boolean;
  16392. /**
  16393. * Gets or sets the associated action manager
  16394. */
  16395. actionManager: Nullable<ActionManager>;
  16396. private _animationStarted;
  16397. private _loopAnimation;
  16398. private _fromIndex;
  16399. private _toIndex;
  16400. private _delay;
  16401. private _direction;
  16402. private _manager;
  16403. private _time;
  16404. private _onAnimationEnd;
  16405. /**
  16406. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16407. */
  16408. isVisible: boolean;
  16409. /**
  16410. * Gets or sets the sprite size
  16411. */
  16412. size: number;
  16413. /**
  16414. * Creates a new Sprite
  16415. * @param name defines the name
  16416. * @param manager defines the manager
  16417. */
  16418. constructor(
  16419. /** defines the name */
  16420. name: string, manager: ISpriteManager);
  16421. /**
  16422. * Starts an animation
  16423. * @param from defines the initial key
  16424. * @param to defines the end key
  16425. * @param loop defines if the animation must loop
  16426. * @param delay defines the start delay (in ms)
  16427. * @param onAnimationEnd defines a callback to call when animation ends
  16428. */
  16429. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16430. /** Stops current animation (if any) */
  16431. stopAnimation(): void;
  16432. /** @hidden */
  16433. _animate(deltaTime: number): void;
  16434. /** Release associated resources */
  16435. dispose(): void;
  16436. }
  16437. }
  16438. declare module BABYLON {
  16439. /**
  16440. * Information about the result of picking within a scene
  16441. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16442. */
  16443. export class PickingInfo {
  16444. /** @hidden */
  16445. _pickingUnavailable: boolean;
  16446. /**
  16447. * If the pick collided with an object
  16448. */
  16449. hit: boolean;
  16450. /**
  16451. * Distance away where the pick collided
  16452. */
  16453. distance: number;
  16454. /**
  16455. * The location of pick collision
  16456. */
  16457. pickedPoint: Nullable<Vector3>;
  16458. /**
  16459. * The mesh corresponding the the pick collision
  16460. */
  16461. pickedMesh: Nullable<AbstractMesh>;
  16462. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16463. bu: number;
  16464. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16465. bv: number;
  16466. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16467. faceId: number;
  16468. /** Id of the the submesh that was picked */
  16469. subMeshId: number;
  16470. /** If a sprite was picked, this will be the sprite the pick collided with */
  16471. pickedSprite: Nullable<Sprite>;
  16472. /**
  16473. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16474. */
  16475. originMesh: Nullable<AbstractMesh>;
  16476. /**
  16477. * The ray that was used to perform the picking.
  16478. */
  16479. ray: Nullable<Ray>;
  16480. /**
  16481. * Gets the normal correspodning to the face the pick collided with
  16482. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16483. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16484. * @returns The normal correspodning to the face the pick collided with
  16485. */
  16486. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16487. /**
  16488. * Gets the texture coordinates of where the pick occured
  16489. * @returns the vector containing the coordnates of the texture
  16490. */
  16491. getTextureCoordinates(): Nullable<Vector2>;
  16492. }
  16493. }
  16494. declare module BABYLON {
  16495. /**
  16496. * Gather the list of pointer event types as constants.
  16497. */
  16498. export class PointerEventTypes {
  16499. /**
  16500. * 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.
  16501. */
  16502. static readonly POINTERDOWN: number;
  16503. /**
  16504. * The pointerup event is fired when a pointer is no longer active.
  16505. */
  16506. static readonly POINTERUP: number;
  16507. /**
  16508. * The pointermove event is fired when a pointer changes coordinates.
  16509. */
  16510. static readonly POINTERMOVE: number;
  16511. /**
  16512. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16513. */
  16514. static readonly POINTERWHEEL: number;
  16515. /**
  16516. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16517. */
  16518. static readonly POINTERPICK: number;
  16519. /**
  16520. * The pointertap event is fired when a the object has been touched and released without drag.
  16521. */
  16522. static readonly POINTERTAP: number;
  16523. /**
  16524. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16525. */
  16526. static readonly POINTERDOUBLETAP: number;
  16527. }
  16528. /**
  16529. * Base class of pointer info types.
  16530. */
  16531. export class PointerInfoBase {
  16532. /**
  16533. * Defines the type of event (PointerEventTypes)
  16534. */
  16535. type: number;
  16536. /**
  16537. * Defines the related dom event
  16538. */
  16539. event: PointerEvent | MouseWheelEvent;
  16540. /**
  16541. * Instantiates the base class of pointers info.
  16542. * @param type Defines the type of event (PointerEventTypes)
  16543. * @param event Defines the related dom event
  16544. */
  16545. constructor(
  16546. /**
  16547. * Defines the type of event (PointerEventTypes)
  16548. */
  16549. type: number,
  16550. /**
  16551. * Defines the related dom event
  16552. */
  16553. event: PointerEvent | MouseWheelEvent);
  16554. }
  16555. /**
  16556. * This class is used to store pointer related info for the onPrePointerObservable event.
  16557. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16558. */
  16559. export class PointerInfoPre extends PointerInfoBase {
  16560. /**
  16561. * Ray from a pointer if availible (eg. 6dof controller)
  16562. */
  16563. ray: Nullable<Ray>;
  16564. /**
  16565. * Defines the local position of the pointer on the canvas.
  16566. */
  16567. localPosition: Vector2;
  16568. /**
  16569. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16570. */
  16571. skipOnPointerObservable: boolean;
  16572. /**
  16573. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16574. * @param type Defines the type of event (PointerEventTypes)
  16575. * @param event Defines the related dom event
  16576. * @param localX Defines the local x coordinates of the pointer when the event occured
  16577. * @param localY Defines the local y coordinates of the pointer when the event occured
  16578. */
  16579. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16580. }
  16581. /**
  16582. * This type contains all the data related to a pointer event in Babylon.js.
  16583. * 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.
  16584. */
  16585. export class PointerInfo extends PointerInfoBase {
  16586. /**
  16587. * Defines the picking info associated to the info (if any)\
  16588. */
  16589. pickInfo: Nullable<PickingInfo>;
  16590. /**
  16591. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16592. * @param type Defines the type of event (PointerEventTypes)
  16593. * @param event Defines the related dom event
  16594. * @param pickInfo Defines the picking info associated to the info (if any)\
  16595. */
  16596. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16597. /**
  16598. * Defines the picking info associated to the info (if any)\
  16599. */
  16600. pickInfo: Nullable<PickingInfo>);
  16601. }
  16602. /**
  16603. * Data relating to a touch event on the screen.
  16604. */
  16605. export interface PointerTouch {
  16606. /**
  16607. * X coordinate of touch.
  16608. */
  16609. x: number;
  16610. /**
  16611. * Y coordinate of touch.
  16612. */
  16613. y: number;
  16614. /**
  16615. * Id of touch. Unique for each finger.
  16616. */
  16617. pointerId: number;
  16618. /**
  16619. * Event type passed from DOM.
  16620. */
  16621. type: any;
  16622. }
  16623. }
  16624. declare module BABYLON {
  16625. /**
  16626. * Manage the mouse inputs to control the movement of a free camera.
  16627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16628. */
  16629. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16630. /**
  16631. * Define if touch is enabled in the mouse input
  16632. */
  16633. touchEnabled: boolean;
  16634. /**
  16635. * Defines the camera the input is attached to.
  16636. */
  16637. camera: FreeCamera;
  16638. /**
  16639. * Defines the buttons associated with the input to handle camera move.
  16640. */
  16641. buttons: number[];
  16642. /**
  16643. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16644. */
  16645. angularSensibility: number;
  16646. private _pointerInput;
  16647. private _onMouseMove;
  16648. private _observer;
  16649. private previousPosition;
  16650. /**
  16651. * Observable for when a pointer move event occurs containing the move offset
  16652. */
  16653. onPointerMovedObservable: Observable<{
  16654. offsetX: number;
  16655. offsetY: number;
  16656. }>;
  16657. /**
  16658. * @hidden
  16659. * If the camera should be rotated automatically based on pointer movement
  16660. */
  16661. _allowCameraRotation: boolean;
  16662. /**
  16663. * Manage the mouse inputs to control the movement of a free camera.
  16664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16665. * @param touchEnabled Defines if touch is enabled or not
  16666. */
  16667. constructor(
  16668. /**
  16669. * Define if touch is enabled in the mouse input
  16670. */
  16671. touchEnabled?: boolean);
  16672. /**
  16673. * Attach the input controls to a specific dom element to get the input from.
  16674. * @param element Defines the element the controls should be listened from
  16675. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16676. */
  16677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16678. /**
  16679. * Called on JS contextmenu event.
  16680. * Override this method to provide functionality.
  16681. */
  16682. protected onContextMenu(evt: PointerEvent): void;
  16683. /**
  16684. * Detach the current controls from the specified dom element.
  16685. * @param element Defines the element to stop listening the inputs from
  16686. */
  16687. detachControl(element: Nullable<HTMLElement>): void;
  16688. /**
  16689. * Gets the class name of the current intput.
  16690. * @returns the class name
  16691. */
  16692. getClassName(): string;
  16693. /**
  16694. * Get the friendly name associated with the input class.
  16695. * @returns the input friendly name
  16696. */
  16697. getSimpleName(): string;
  16698. }
  16699. }
  16700. declare module BABYLON {
  16701. /**
  16702. * Manage the touch inputs to control the movement of a free camera.
  16703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16704. */
  16705. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16706. /**
  16707. * Defines the camera the input is attached to.
  16708. */
  16709. camera: FreeCamera;
  16710. /**
  16711. * Defines the touch sensibility for rotation.
  16712. * The higher the faster.
  16713. */
  16714. touchAngularSensibility: number;
  16715. /**
  16716. * Defines the touch sensibility for move.
  16717. * The higher the faster.
  16718. */
  16719. touchMoveSensibility: number;
  16720. private _offsetX;
  16721. private _offsetY;
  16722. private _pointerPressed;
  16723. private _pointerInput;
  16724. private _observer;
  16725. private _onLostFocus;
  16726. /**
  16727. * Attach the input controls to a specific dom element to get the input from.
  16728. * @param element Defines the element the controls should be listened from
  16729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16730. */
  16731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16732. /**
  16733. * Detach the current controls from the specified dom element.
  16734. * @param element Defines the element to stop listening the inputs from
  16735. */
  16736. detachControl(element: Nullable<HTMLElement>): void;
  16737. /**
  16738. * Update the current camera state depending on the inputs that have been used this frame.
  16739. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16740. */
  16741. checkInputs(): void;
  16742. /**
  16743. * Gets the class name of the current intput.
  16744. * @returns the class name
  16745. */
  16746. getClassName(): string;
  16747. /**
  16748. * Get the friendly name associated with the input class.
  16749. * @returns the input friendly name
  16750. */
  16751. getSimpleName(): string;
  16752. }
  16753. }
  16754. declare module BABYLON {
  16755. /**
  16756. * Default Inputs manager for the FreeCamera.
  16757. * It groups all the default supported inputs for ease of use.
  16758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16759. */
  16760. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16761. /**
  16762. * @hidden
  16763. */
  16764. _mouseInput: Nullable<FreeCameraMouseInput>;
  16765. /**
  16766. * Instantiates a new FreeCameraInputsManager.
  16767. * @param camera Defines the camera the inputs belong to
  16768. */
  16769. constructor(camera: FreeCamera);
  16770. /**
  16771. * Add keyboard input support to the input manager.
  16772. * @returns the current input manager
  16773. */
  16774. addKeyboard(): FreeCameraInputsManager;
  16775. /**
  16776. * Add mouse input support to the input manager.
  16777. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  16778. * @returns the current input manager
  16779. */
  16780. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  16781. /**
  16782. * Removes the mouse input support from the manager
  16783. * @returns the current input manager
  16784. */
  16785. removeMouse(): FreeCameraInputsManager;
  16786. /**
  16787. * Add touch input support to the input manager.
  16788. * @returns the current input manager
  16789. */
  16790. addTouch(): FreeCameraInputsManager;
  16791. /**
  16792. * Remove all attached input methods from a camera
  16793. */
  16794. clear(): void;
  16795. }
  16796. }
  16797. declare module BABYLON {
  16798. /**
  16799. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16800. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  16801. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16802. */
  16803. export class FreeCamera extends TargetCamera {
  16804. /**
  16805. * Define the collision ellipsoid of the camera.
  16806. * This is helpful to simulate a camera body like the player body around the camera
  16807. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  16808. */
  16809. ellipsoid: Vector3;
  16810. /**
  16811. * Define an offset for the position of the ellipsoid around the camera.
  16812. * This can be helpful to determine the center of the body near the gravity center of the body
  16813. * instead of its head.
  16814. */
  16815. ellipsoidOffset: Vector3;
  16816. /**
  16817. * Enable or disable collisions of the camera with the rest of the scene objects.
  16818. */
  16819. checkCollisions: boolean;
  16820. /**
  16821. * Enable or disable gravity on the camera.
  16822. */
  16823. applyGravity: boolean;
  16824. /**
  16825. * Define the input manager associated to the camera.
  16826. */
  16827. inputs: FreeCameraInputsManager;
  16828. /**
  16829. * Gets the input sensibility for a mouse input. (default is 2000.0)
  16830. * Higher values reduce sensitivity.
  16831. */
  16832. /**
  16833. * Sets the input sensibility for a mouse input. (default is 2000.0)
  16834. * Higher values reduce sensitivity.
  16835. */
  16836. angularSensibility: number;
  16837. /**
  16838. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  16839. */
  16840. keysUp: number[];
  16841. /**
  16842. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  16843. */
  16844. keysDown: number[];
  16845. /**
  16846. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  16847. */
  16848. keysLeft: number[];
  16849. /**
  16850. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  16851. */
  16852. keysRight: number[];
  16853. /**
  16854. * Event raised when the camera collide with a mesh in the scene.
  16855. */
  16856. onCollide: (collidedMesh: AbstractMesh) => void;
  16857. private _collider;
  16858. private _needMoveForGravity;
  16859. private _oldPosition;
  16860. private _diffPosition;
  16861. private _newPosition;
  16862. /** @hidden */
  16863. _localDirection: Vector3;
  16864. /** @hidden */
  16865. _transformedDirection: Vector3;
  16866. /**
  16867. * Instantiates a Free Camera.
  16868. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16869. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  16870. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16871. * @param name Define the name of the camera in the scene
  16872. * @param position Define the start position of the camera in the scene
  16873. * @param scene Define the scene the camera belongs to
  16874. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  16875. */
  16876. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  16877. /**
  16878. * Attached controls to the current camera.
  16879. * @param element Defines the element the controls should be listened from
  16880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16881. */
  16882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16883. /**
  16884. * Detach the current controls from the camera.
  16885. * The camera will stop reacting to inputs.
  16886. * @param element Defines the element to stop listening the inputs from
  16887. */
  16888. detachControl(element: HTMLElement): void;
  16889. private _collisionMask;
  16890. /**
  16891. * Define a collision mask to limit the list of object the camera can collide with
  16892. */
  16893. collisionMask: number;
  16894. /** @hidden */
  16895. _collideWithWorld(displacement: Vector3): void;
  16896. private _onCollisionPositionChange;
  16897. /** @hidden */
  16898. _checkInputs(): void;
  16899. /** @hidden */
  16900. _decideIfNeedsToMove(): boolean;
  16901. /** @hidden */
  16902. _updatePosition(): void;
  16903. /**
  16904. * Destroy the camera and release the current resources hold by it.
  16905. */
  16906. dispose(): void;
  16907. /**
  16908. * Gets the current object class name.
  16909. * @return the class name
  16910. */
  16911. getClassName(): string;
  16912. }
  16913. }
  16914. declare module BABYLON {
  16915. /**
  16916. * Represents a gamepad control stick position
  16917. */
  16918. export class StickValues {
  16919. /**
  16920. * The x component of the control stick
  16921. */
  16922. x: number;
  16923. /**
  16924. * The y component of the control stick
  16925. */
  16926. y: number;
  16927. /**
  16928. * Initializes the gamepad x and y control stick values
  16929. * @param x The x component of the gamepad control stick value
  16930. * @param y The y component of the gamepad control stick value
  16931. */
  16932. constructor(
  16933. /**
  16934. * The x component of the control stick
  16935. */
  16936. x: number,
  16937. /**
  16938. * The y component of the control stick
  16939. */
  16940. y: number);
  16941. }
  16942. /**
  16943. * An interface which manages callbacks for gamepad button changes
  16944. */
  16945. export interface GamepadButtonChanges {
  16946. /**
  16947. * Called when a gamepad has been changed
  16948. */
  16949. changed: boolean;
  16950. /**
  16951. * Called when a gamepad press event has been triggered
  16952. */
  16953. pressChanged: boolean;
  16954. /**
  16955. * Called when a touch event has been triggered
  16956. */
  16957. touchChanged: boolean;
  16958. /**
  16959. * Called when a value has changed
  16960. */
  16961. valueChanged: boolean;
  16962. }
  16963. /**
  16964. * Represents a gamepad
  16965. */
  16966. export class Gamepad {
  16967. /**
  16968. * The id of the gamepad
  16969. */
  16970. id: string;
  16971. /**
  16972. * The index of the gamepad
  16973. */
  16974. index: number;
  16975. /**
  16976. * The browser gamepad
  16977. */
  16978. browserGamepad: any;
  16979. /**
  16980. * Specifies what type of gamepad this represents
  16981. */
  16982. type: number;
  16983. private _leftStick;
  16984. private _rightStick;
  16985. /** @hidden */
  16986. _isConnected: boolean;
  16987. private _leftStickAxisX;
  16988. private _leftStickAxisY;
  16989. private _rightStickAxisX;
  16990. private _rightStickAxisY;
  16991. /**
  16992. * Triggered when the left control stick has been changed
  16993. */
  16994. private _onleftstickchanged;
  16995. /**
  16996. * Triggered when the right control stick has been changed
  16997. */
  16998. private _onrightstickchanged;
  16999. /**
  17000. * Represents a gamepad controller
  17001. */
  17002. static GAMEPAD: number;
  17003. /**
  17004. * Represents a generic controller
  17005. */
  17006. static GENERIC: number;
  17007. /**
  17008. * Represents an XBox controller
  17009. */
  17010. static XBOX: number;
  17011. /**
  17012. * Represents a pose-enabled controller
  17013. */
  17014. static POSE_ENABLED: number;
  17015. /**
  17016. * Specifies whether the left control stick should be Y-inverted
  17017. */
  17018. protected _invertLeftStickY: boolean;
  17019. /**
  17020. * Specifies if the gamepad has been connected
  17021. */
  17022. readonly isConnected: boolean;
  17023. /**
  17024. * Initializes the gamepad
  17025. * @param id The id of the gamepad
  17026. * @param index The index of the gamepad
  17027. * @param browserGamepad The browser gamepad
  17028. * @param leftStickX The x component of the left joystick
  17029. * @param leftStickY The y component of the left joystick
  17030. * @param rightStickX The x component of the right joystick
  17031. * @param rightStickY The y component of the right joystick
  17032. */
  17033. constructor(
  17034. /**
  17035. * The id of the gamepad
  17036. */
  17037. id: string,
  17038. /**
  17039. * The index of the gamepad
  17040. */
  17041. index: number,
  17042. /**
  17043. * The browser gamepad
  17044. */
  17045. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17046. /**
  17047. * Callback triggered when the left joystick has changed
  17048. * @param callback
  17049. */
  17050. onleftstickchanged(callback: (values: StickValues) => void): void;
  17051. /**
  17052. * Callback triggered when the right joystick has changed
  17053. * @param callback
  17054. */
  17055. onrightstickchanged(callback: (values: StickValues) => void): void;
  17056. /**
  17057. * Gets the left joystick
  17058. */
  17059. /**
  17060. * Sets the left joystick values
  17061. */
  17062. leftStick: StickValues;
  17063. /**
  17064. * Gets the right joystick
  17065. */
  17066. /**
  17067. * Sets the right joystick value
  17068. */
  17069. rightStick: StickValues;
  17070. /**
  17071. * Updates the gamepad joystick positions
  17072. */
  17073. update(): void;
  17074. /**
  17075. * Disposes the gamepad
  17076. */
  17077. dispose(): void;
  17078. }
  17079. /**
  17080. * Represents a generic gamepad
  17081. */
  17082. export class GenericPad extends Gamepad {
  17083. private _buttons;
  17084. private _onbuttondown;
  17085. private _onbuttonup;
  17086. /**
  17087. * Observable triggered when a button has been pressed
  17088. */
  17089. onButtonDownObservable: Observable<number>;
  17090. /**
  17091. * Observable triggered when a button has been released
  17092. */
  17093. onButtonUpObservable: Observable<number>;
  17094. /**
  17095. * Callback triggered when a button has been pressed
  17096. * @param callback Called when a button has been pressed
  17097. */
  17098. onbuttondown(callback: (buttonPressed: number) => void): void;
  17099. /**
  17100. * Callback triggered when a button has been released
  17101. * @param callback Called when a button has been released
  17102. */
  17103. onbuttonup(callback: (buttonReleased: number) => void): void;
  17104. /**
  17105. * Initializes the generic gamepad
  17106. * @param id The id of the generic gamepad
  17107. * @param index The index of the generic gamepad
  17108. * @param browserGamepad The browser gamepad
  17109. */
  17110. constructor(id: string, index: number, browserGamepad: any);
  17111. private _setButtonValue;
  17112. /**
  17113. * Updates the generic gamepad
  17114. */
  17115. update(): void;
  17116. /**
  17117. * Disposes the generic gamepad
  17118. */
  17119. dispose(): void;
  17120. }
  17121. }
  17122. declare module BABYLON {
  17123. /**
  17124. * Defines the types of pose enabled controllers that are supported
  17125. */
  17126. export enum PoseEnabledControllerType {
  17127. /**
  17128. * HTC Vive
  17129. */
  17130. VIVE = 0,
  17131. /**
  17132. * Oculus Rift
  17133. */
  17134. OCULUS = 1,
  17135. /**
  17136. * Windows mixed reality
  17137. */
  17138. WINDOWS = 2,
  17139. /**
  17140. * Samsung gear VR
  17141. */
  17142. GEAR_VR = 3,
  17143. /**
  17144. * Google Daydream
  17145. */
  17146. DAYDREAM = 4,
  17147. /**
  17148. * Generic
  17149. */
  17150. GENERIC = 5
  17151. }
  17152. /**
  17153. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17154. */
  17155. export interface MutableGamepadButton {
  17156. /**
  17157. * Value of the button/trigger
  17158. */
  17159. value: number;
  17160. /**
  17161. * If the button/trigger is currently touched
  17162. */
  17163. touched: boolean;
  17164. /**
  17165. * If the button/trigger is currently pressed
  17166. */
  17167. pressed: boolean;
  17168. }
  17169. /**
  17170. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17171. * @hidden
  17172. */
  17173. export interface ExtendedGamepadButton extends GamepadButton {
  17174. /**
  17175. * If the button/trigger is currently pressed
  17176. */
  17177. readonly pressed: boolean;
  17178. /**
  17179. * If the button/trigger is currently touched
  17180. */
  17181. readonly touched: boolean;
  17182. /**
  17183. * Value of the button/trigger
  17184. */
  17185. readonly value: number;
  17186. }
  17187. /** @hidden */
  17188. export interface _GamePadFactory {
  17189. /**
  17190. * Returns wether or not the current gamepad can be created for this type of controller.
  17191. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17192. * @returns true if it can be created, otherwise false
  17193. */
  17194. canCreate(gamepadInfo: any): boolean;
  17195. /**
  17196. * Creates a new instance of the Gamepad.
  17197. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17198. * @returns the new gamepad instance
  17199. */
  17200. create(gamepadInfo: any): Gamepad;
  17201. }
  17202. /**
  17203. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17204. */
  17205. export class PoseEnabledControllerHelper {
  17206. /** @hidden */
  17207. static _ControllerFactories: _GamePadFactory[];
  17208. /** @hidden */
  17209. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17210. /**
  17211. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17212. * @param vrGamepad the gamepad to initialized
  17213. * @returns a vr controller of the type the gamepad identified as
  17214. */
  17215. static InitiateController(vrGamepad: any): Gamepad;
  17216. }
  17217. /**
  17218. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17219. */
  17220. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17221. /**
  17222. * If the controller is used in a webXR session
  17223. */
  17224. isXR: boolean;
  17225. private _deviceRoomPosition;
  17226. private _deviceRoomRotationQuaternion;
  17227. /**
  17228. * The device position in babylon space
  17229. */
  17230. devicePosition: Vector3;
  17231. /**
  17232. * The device rotation in babylon space
  17233. */
  17234. deviceRotationQuaternion: Quaternion;
  17235. /**
  17236. * The scale factor of the device in babylon space
  17237. */
  17238. deviceScaleFactor: number;
  17239. /**
  17240. * (Likely devicePosition should be used instead) The device position in its room space
  17241. */
  17242. position: Vector3;
  17243. /**
  17244. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17245. */
  17246. rotationQuaternion: Quaternion;
  17247. /**
  17248. * The type of controller (Eg. Windows mixed reality)
  17249. */
  17250. controllerType: PoseEnabledControllerType;
  17251. protected _calculatedPosition: Vector3;
  17252. private _calculatedRotation;
  17253. /**
  17254. * The raw pose from the device
  17255. */
  17256. rawPose: DevicePose;
  17257. private _trackPosition;
  17258. private _maxRotationDistFromHeadset;
  17259. private _draggedRoomRotation;
  17260. /**
  17261. * @hidden
  17262. */
  17263. _disableTrackPosition(fixedPosition: Vector3): void;
  17264. /**
  17265. * Internal, the mesh attached to the controller
  17266. * @hidden
  17267. */
  17268. _mesh: Nullable<AbstractMesh>;
  17269. private _poseControlledCamera;
  17270. private _leftHandSystemQuaternion;
  17271. /**
  17272. * Internal, matrix used to convert room space to babylon space
  17273. * @hidden
  17274. */
  17275. _deviceToWorld: Matrix;
  17276. /**
  17277. * Node to be used when casting a ray from the controller
  17278. * @hidden
  17279. */
  17280. _pointingPoseNode: Nullable<TransformNode>;
  17281. /**
  17282. * Name of the child mesh that can be used to cast a ray from the controller
  17283. */
  17284. static readonly POINTING_POSE: string;
  17285. /**
  17286. * Creates a new PoseEnabledController from a gamepad
  17287. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17288. */
  17289. constructor(browserGamepad: any);
  17290. private _workingMatrix;
  17291. /**
  17292. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17293. */
  17294. update(): void;
  17295. /**
  17296. * Updates only the pose device and mesh without doing any button event checking
  17297. */
  17298. protected _updatePoseAndMesh(): void;
  17299. /**
  17300. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17301. * @param poseData raw pose fromthe device
  17302. */
  17303. updateFromDevice(poseData: DevicePose): void;
  17304. /**
  17305. * @hidden
  17306. */
  17307. _meshAttachedObservable: Observable<AbstractMesh>;
  17308. /**
  17309. * Attaches a mesh to the controller
  17310. * @param mesh the mesh to be attached
  17311. */
  17312. attachToMesh(mesh: AbstractMesh): void;
  17313. /**
  17314. * Attaches the controllers mesh to a camera
  17315. * @param camera the camera the mesh should be attached to
  17316. */
  17317. attachToPoseControlledCamera(camera: TargetCamera): void;
  17318. /**
  17319. * Disposes of the controller
  17320. */
  17321. dispose(): void;
  17322. /**
  17323. * The mesh that is attached to the controller
  17324. */
  17325. readonly mesh: Nullable<AbstractMesh>;
  17326. /**
  17327. * Gets the ray of the controller in the direction the controller is pointing
  17328. * @param length the length the resulting ray should be
  17329. * @returns a ray in the direction the controller is pointing
  17330. */
  17331. getForwardRay(length?: number): Ray;
  17332. }
  17333. }
  17334. declare module BABYLON {
  17335. /**
  17336. * Defines the WebVRController object that represents controllers tracked in 3D space
  17337. */
  17338. export abstract class WebVRController extends PoseEnabledController {
  17339. /**
  17340. * Internal, the default controller model for the controller
  17341. */
  17342. protected _defaultModel: AbstractMesh;
  17343. /**
  17344. * Fired when the trigger state has changed
  17345. */
  17346. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17347. /**
  17348. * Fired when the main button state has changed
  17349. */
  17350. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17351. /**
  17352. * Fired when the secondary button state has changed
  17353. */
  17354. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17355. /**
  17356. * Fired when the pad state has changed
  17357. */
  17358. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17359. /**
  17360. * Fired when controllers stick values have changed
  17361. */
  17362. onPadValuesChangedObservable: Observable<StickValues>;
  17363. /**
  17364. * Array of button availible on the controller
  17365. */
  17366. protected _buttons: Array<MutableGamepadButton>;
  17367. private _onButtonStateChange;
  17368. /**
  17369. * Fired when a controller button's state has changed
  17370. * @param callback the callback containing the button that was modified
  17371. */
  17372. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17373. /**
  17374. * X and Y axis corresponding to the controllers joystick
  17375. */
  17376. pad: StickValues;
  17377. /**
  17378. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17379. */
  17380. hand: string;
  17381. /**
  17382. * The default controller model for the controller
  17383. */
  17384. readonly defaultModel: AbstractMesh;
  17385. /**
  17386. * Creates a new WebVRController from a gamepad
  17387. * @param vrGamepad the gamepad that the WebVRController should be created from
  17388. */
  17389. constructor(vrGamepad: any);
  17390. /**
  17391. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17392. */
  17393. update(): void;
  17394. /**
  17395. * Function to be called when a button is modified
  17396. */
  17397. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17398. /**
  17399. * Loads a mesh and attaches it to the controller
  17400. * @param scene the scene the mesh should be added to
  17401. * @param meshLoaded callback for when the mesh has been loaded
  17402. */
  17403. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17404. private _setButtonValue;
  17405. private _changes;
  17406. private _checkChanges;
  17407. /**
  17408. * Disposes of th webVRCOntroller
  17409. */
  17410. dispose(): void;
  17411. }
  17412. }
  17413. declare module BABYLON {
  17414. /**
  17415. * The HemisphericLight simulates the ambient environment light,
  17416. * so the passed direction is the light reflection direction, not the incoming direction.
  17417. */
  17418. export class HemisphericLight extends Light {
  17419. /**
  17420. * The groundColor is the light in the opposite direction to the one specified during creation.
  17421. * 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.
  17422. */
  17423. groundColor: Color3;
  17424. /**
  17425. * The light reflection direction, not the incoming direction.
  17426. */
  17427. direction: Vector3;
  17428. /**
  17429. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17430. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17431. * The HemisphericLight can't cast shadows.
  17432. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17433. * @param name The friendly name of the light
  17434. * @param direction The direction of the light reflection
  17435. * @param scene The scene the light belongs to
  17436. */
  17437. constructor(name: string, direction: Vector3, scene: Scene);
  17438. protected _buildUniformLayout(): void;
  17439. /**
  17440. * Returns the string "HemisphericLight".
  17441. * @return The class name
  17442. */
  17443. getClassName(): string;
  17444. /**
  17445. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17446. * Returns the updated direction.
  17447. * @param target The target the direction should point to
  17448. * @return The computed direction
  17449. */
  17450. setDirectionToTarget(target: Vector3): Vector3;
  17451. /**
  17452. * Returns the shadow generator associated to the light.
  17453. * @returns Always null for hemispheric lights because it does not support shadows.
  17454. */
  17455. getShadowGenerator(): Nullable<IShadowGenerator>;
  17456. /**
  17457. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17458. * @param effect The effect to update
  17459. * @param lightIndex The index of the light in the effect to update
  17460. * @returns The hemispheric light
  17461. */
  17462. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17463. /**
  17464. * Computes the world matrix of the node
  17465. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17466. * @param useWasUpdatedFlag defines a reserved property
  17467. * @returns the world matrix
  17468. */
  17469. computeWorldMatrix(): Matrix;
  17470. /**
  17471. * Returns the integer 3.
  17472. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17473. */
  17474. getTypeID(): number;
  17475. /**
  17476. * Prepares the list of defines specific to the light type.
  17477. * @param defines the list of defines
  17478. * @param lightIndex defines the index of the light for the effect
  17479. */
  17480. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17481. }
  17482. }
  17483. declare module BABYLON {
  17484. /** @hidden */
  17485. export var vrMultiviewToSingleviewPixelShader: {
  17486. name: string;
  17487. shader: string;
  17488. };
  17489. }
  17490. declare module BABYLON {
  17491. /**
  17492. * Renders to multiple views with a single draw call
  17493. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17494. */
  17495. export class MultiviewRenderTarget extends RenderTargetTexture {
  17496. /**
  17497. * Creates a multiview render target
  17498. * @param scene scene used with the render target
  17499. * @param size the size of the render target (used for each view)
  17500. */
  17501. constructor(scene: Scene, size?: number | {
  17502. width: number;
  17503. height: number;
  17504. } | {
  17505. ratio: number;
  17506. });
  17507. /**
  17508. * @hidden
  17509. * @param faceIndex the face index, if its a cube texture
  17510. */
  17511. _bindFrameBuffer(faceIndex?: number): void;
  17512. /**
  17513. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17514. * @returns the view count
  17515. */
  17516. getViewCount(): number;
  17517. }
  17518. }
  17519. declare module BABYLON {
  17520. interface Engine {
  17521. /**
  17522. * Creates a new multiview render target
  17523. * @param width defines the width of the texture
  17524. * @param height defines the height of the texture
  17525. * @returns the created multiview texture
  17526. */
  17527. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17528. /**
  17529. * Binds a multiview framebuffer to be drawn to
  17530. * @param multiviewTexture texture to bind
  17531. */
  17532. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17533. }
  17534. interface Camera {
  17535. /**
  17536. * @hidden
  17537. * 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)
  17538. */
  17539. _useMultiviewToSingleView: boolean;
  17540. /**
  17541. * @hidden
  17542. * 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)
  17543. */
  17544. _multiviewTexture: Nullable<RenderTargetTexture>;
  17545. /**
  17546. * @hidden
  17547. * ensures the multiview texture of the camera exists and has the specified width/height
  17548. * @param width height to set on the multiview texture
  17549. * @param height width to set on the multiview texture
  17550. */
  17551. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17552. }
  17553. interface Scene {
  17554. /** @hidden */
  17555. _transformMatrixR: Matrix;
  17556. /** @hidden */
  17557. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17558. /** @hidden */
  17559. _createMultiviewUbo(): void;
  17560. /** @hidden */
  17561. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17562. /** @hidden */
  17563. _renderMultiviewToSingleView(camera: Camera): void;
  17564. }
  17565. }
  17566. declare module BABYLON {
  17567. /**
  17568. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17569. * This will not be used for webXR as it supports displaying texture arrays directly
  17570. */
  17571. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17572. /**
  17573. * Initializes a VRMultiviewToSingleview
  17574. * @param name name of the post process
  17575. * @param camera camera to be applied to
  17576. * @param scaleFactor scaling factor to the size of the output texture
  17577. */
  17578. constructor(name: string, camera: Camera, scaleFactor: number);
  17579. }
  17580. }
  17581. declare module BABYLON {
  17582. interface Engine {
  17583. /** @hidden */
  17584. _vrDisplay: any;
  17585. /** @hidden */
  17586. _vrSupported: boolean;
  17587. /** @hidden */
  17588. _oldSize: Size;
  17589. /** @hidden */
  17590. _oldHardwareScaleFactor: number;
  17591. /** @hidden */
  17592. _vrExclusivePointerMode: boolean;
  17593. /** @hidden */
  17594. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17595. /** @hidden */
  17596. _onVRDisplayPointerRestricted: () => void;
  17597. /** @hidden */
  17598. _onVRDisplayPointerUnrestricted: () => void;
  17599. /** @hidden */
  17600. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17601. /** @hidden */
  17602. _onVrDisplayDisconnect: Nullable<() => void>;
  17603. /** @hidden */
  17604. _onVrDisplayPresentChange: Nullable<() => void>;
  17605. /**
  17606. * Observable signaled when VR display mode changes
  17607. */
  17608. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17609. /**
  17610. * Observable signaled when VR request present is complete
  17611. */
  17612. onVRRequestPresentComplete: Observable<boolean>;
  17613. /**
  17614. * Observable signaled when VR request present starts
  17615. */
  17616. onVRRequestPresentStart: Observable<Engine>;
  17617. /**
  17618. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17619. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17620. */
  17621. isInVRExclusivePointerMode: boolean;
  17622. /**
  17623. * Gets a boolean indicating if a webVR device was detected
  17624. * @returns true if a webVR device was detected
  17625. */
  17626. isVRDevicePresent(): boolean;
  17627. /**
  17628. * Gets the current webVR device
  17629. * @returns the current webVR device (or null)
  17630. */
  17631. getVRDevice(): any;
  17632. /**
  17633. * Initializes a webVR display and starts listening to display change events
  17634. * The onVRDisplayChangedObservable will be notified upon these changes
  17635. * @returns A promise containing a VRDisplay and if vr is supported
  17636. */
  17637. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17638. /** @hidden */
  17639. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17640. /**
  17641. * Call this function to switch to webVR mode
  17642. * Will do nothing if webVR is not supported or if there is no webVR device
  17643. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17644. */
  17645. enableVR(): void;
  17646. /** @hidden */
  17647. _onVRFullScreenTriggered(): void;
  17648. }
  17649. }
  17650. declare module BABYLON {
  17651. /**
  17652. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17653. * IMPORTANT!! The data is right-hand data.
  17654. * @export
  17655. * @interface DevicePose
  17656. */
  17657. export interface DevicePose {
  17658. /**
  17659. * The position of the device, values in array are [x,y,z].
  17660. */
  17661. readonly position: Nullable<Float32Array>;
  17662. /**
  17663. * The linearVelocity of the device, values in array are [x,y,z].
  17664. */
  17665. readonly linearVelocity: Nullable<Float32Array>;
  17666. /**
  17667. * The linearAcceleration of the device, values in array are [x,y,z].
  17668. */
  17669. readonly linearAcceleration: Nullable<Float32Array>;
  17670. /**
  17671. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17672. */
  17673. readonly orientation: Nullable<Float32Array>;
  17674. /**
  17675. * The angularVelocity of the device, values in array are [x,y,z].
  17676. */
  17677. readonly angularVelocity: Nullable<Float32Array>;
  17678. /**
  17679. * The angularAcceleration of the device, values in array are [x,y,z].
  17680. */
  17681. readonly angularAcceleration: Nullable<Float32Array>;
  17682. }
  17683. /**
  17684. * Interface representing a pose controlled object in Babylon.
  17685. * A pose controlled object has both regular pose values as well as pose values
  17686. * from an external device such as a VR head mounted display
  17687. */
  17688. export interface PoseControlled {
  17689. /**
  17690. * The position of the object in babylon space.
  17691. */
  17692. position: Vector3;
  17693. /**
  17694. * The rotation quaternion of the object in babylon space.
  17695. */
  17696. rotationQuaternion: Quaternion;
  17697. /**
  17698. * The position of the device in babylon space.
  17699. */
  17700. devicePosition?: Vector3;
  17701. /**
  17702. * The rotation quaternion of the device in babylon space.
  17703. */
  17704. deviceRotationQuaternion: Quaternion;
  17705. /**
  17706. * The raw pose coming from the device.
  17707. */
  17708. rawPose: Nullable<DevicePose>;
  17709. /**
  17710. * The scale of the device to be used when translating from device space to babylon space.
  17711. */
  17712. deviceScaleFactor: number;
  17713. /**
  17714. * Updates the poseControlled values based on the input device pose.
  17715. * @param poseData the pose data to update the object with
  17716. */
  17717. updateFromDevice(poseData: DevicePose): void;
  17718. }
  17719. /**
  17720. * Set of options to customize the webVRCamera
  17721. */
  17722. export interface WebVROptions {
  17723. /**
  17724. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  17725. */
  17726. trackPosition?: boolean;
  17727. /**
  17728. * Sets the scale of the vrDevice in babylon space. (default: 1)
  17729. */
  17730. positionScale?: number;
  17731. /**
  17732. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  17733. */
  17734. displayName?: string;
  17735. /**
  17736. * Should the native controller meshes be initialized. (default: true)
  17737. */
  17738. controllerMeshes?: boolean;
  17739. /**
  17740. * Creating a default HemiLight only on controllers. (default: true)
  17741. */
  17742. defaultLightingOnControllers?: boolean;
  17743. /**
  17744. * If you don't want to use the default VR button of the helper. (default: false)
  17745. */
  17746. useCustomVRButton?: boolean;
  17747. /**
  17748. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  17749. */
  17750. customVRButton?: HTMLButtonElement;
  17751. /**
  17752. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  17753. */
  17754. rayLength?: number;
  17755. /**
  17756. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  17757. */
  17758. defaultHeight?: number;
  17759. /**
  17760. * If multiview should be used if availible (default: false)
  17761. */
  17762. useMultiview?: boolean;
  17763. }
  17764. /**
  17765. * This represents a WebVR camera.
  17766. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17767. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17768. */
  17769. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  17770. private webVROptions;
  17771. /**
  17772. * @hidden
  17773. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17774. */
  17775. _vrDevice: any;
  17776. /**
  17777. * The rawPose of the vrDevice.
  17778. */
  17779. rawPose: Nullable<DevicePose>;
  17780. private _onVREnabled;
  17781. private _specsVersion;
  17782. private _attached;
  17783. private _frameData;
  17784. protected _descendants: Array<Node>;
  17785. private _deviceRoomPosition;
  17786. /** @hidden */
  17787. _deviceRoomRotationQuaternion: Quaternion;
  17788. private _standingMatrix;
  17789. /**
  17790. * Represents device position in babylon space.
  17791. */
  17792. devicePosition: Vector3;
  17793. /**
  17794. * Represents device rotation in babylon space.
  17795. */
  17796. deviceRotationQuaternion: Quaternion;
  17797. /**
  17798. * The scale of the device to be used when translating from device space to babylon space.
  17799. */
  17800. deviceScaleFactor: number;
  17801. private _deviceToWorld;
  17802. private _worldToDevice;
  17803. /**
  17804. * References to the webVR controllers for the vrDevice.
  17805. */
  17806. controllers: Array<WebVRController>;
  17807. /**
  17808. * Emits an event when a controller is attached.
  17809. */
  17810. onControllersAttachedObservable: Observable<WebVRController[]>;
  17811. /**
  17812. * Emits an event when a controller's mesh has been loaded;
  17813. */
  17814. onControllerMeshLoadedObservable: Observable<WebVRController>;
  17815. /**
  17816. * Emits an event when the HMD's pose has been updated.
  17817. */
  17818. onPoseUpdatedFromDeviceObservable: Observable<any>;
  17819. private _poseSet;
  17820. /**
  17821. * If the rig cameras be used as parent instead of this camera.
  17822. */
  17823. rigParenting: boolean;
  17824. private _lightOnControllers;
  17825. private _defaultHeight?;
  17826. /**
  17827. * Instantiates a WebVRFreeCamera.
  17828. * @param name The name of the WebVRFreeCamera
  17829. * @param position The starting anchor position for the camera
  17830. * @param scene The scene the camera belongs to
  17831. * @param webVROptions a set of customizable options for the webVRCamera
  17832. */
  17833. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  17834. /**
  17835. * Gets the device distance from the ground in meters.
  17836. * @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.
  17837. */
  17838. deviceDistanceToRoomGround(): number;
  17839. /**
  17840. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17841. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17842. */
  17843. useStandingMatrix(callback?: (bool: boolean) => void): void;
  17844. /**
  17845. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17846. * @returns A promise with a boolean set to if the standing matrix is supported.
  17847. */
  17848. useStandingMatrixAsync(): Promise<boolean>;
  17849. /**
  17850. * Disposes the camera
  17851. */
  17852. dispose(): void;
  17853. /**
  17854. * Gets a vrController by name.
  17855. * @param name The name of the controller to retreive
  17856. * @returns the controller matching the name specified or null if not found
  17857. */
  17858. getControllerByName(name: string): Nullable<WebVRController>;
  17859. private _leftController;
  17860. /**
  17861. * The controller corresponding to the users left hand.
  17862. */
  17863. readonly leftController: Nullable<WebVRController>;
  17864. private _rightController;
  17865. /**
  17866. * The controller corresponding to the users right hand.
  17867. */
  17868. readonly rightController: Nullable<WebVRController>;
  17869. /**
  17870. * Casts a ray forward from the vrCamera's gaze.
  17871. * @param length Length of the ray (default: 100)
  17872. * @returns the ray corresponding to the gaze
  17873. */
  17874. getForwardRay(length?: number): Ray;
  17875. /**
  17876. * @hidden
  17877. * Updates the camera based on device's frame data
  17878. */
  17879. _checkInputs(): void;
  17880. /**
  17881. * Updates the poseControlled values based on the input device pose.
  17882. * @param poseData Pose coming from the device
  17883. */
  17884. updateFromDevice(poseData: DevicePose): void;
  17885. private _htmlElementAttached;
  17886. private _detachIfAttached;
  17887. /**
  17888. * WebVR's attach control will start broadcasting frames to the device.
  17889. * Note that in certain browsers (chrome for example) this function must be called
  17890. * within a user-interaction callback. Example:
  17891. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17892. *
  17893. * @param element html element to attach the vrDevice to
  17894. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17895. */
  17896. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17897. /**
  17898. * Detaches the camera from the html element and disables VR
  17899. *
  17900. * @param element html element to detach from
  17901. */
  17902. detachControl(element: HTMLElement): void;
  17903. /**
  17904. * @returns the name of this class
  17905. */
  17906. getClassName(): string;
  17907. /**
  17908. * Calls resetPose on the vrDisplay
  17909. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17910. */
  17911. resetToCurrentRotation(): void;
  17912. /**
  17913. * @hidden
  17914. * Updates the rig cameras (left and right eye)
  17915. */
  17916. _updateRigCameras(): void;
  17917. private _workingVector;
  17918. private _oneVector;
  17919. private _workingMatrix;
  17920. private updateCacheCalled;
  17921. private _correctPositionIfNotTrackPosition;
  17922. /**
  17923. * @hidden
  17924. * Updates the cached values of the camera
  17925. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17926. */
  17927. _updateCache(ignoreParentClass?: boolean): void;
  17928. /**
  17929. * @hidden
  17930. * Get current device position in babylon world
  17931. */
  17932. _computeDevicePosition(): void;
  17933. /**
  17934. * Updates the current device position and rotation in the babylon world
  17935. */
  17936. update(): void;
  17937. /**
  17938. * @hidden
  17939. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17940. * @returns an identity matrix
  17941. */
  17942. _getViewMatrix(): Matrix;
  17943. private _tmpMatrix;
  17944. /**
  17945. * This function is called by the two RIG cameras.
  17946. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17947. * @hidden
  17948. */
  17949. _getWebVRViewMatrix(): Matrix;
  17950. /** @hidden */
  17951. _getWebVRProjectionMatrix(): Matrix;
  17952. private _onGamepadConnectedObserver;
  17953. private _onGamepadDisconnectedObserver;
  17954. private _updateCacheWhenTrackingDisabledObserver;
  17955. /**
  17956. * Initializes the controllers and their meshes
  17957. */
  17958. initControllers(): void;
  17959. }
  17960. }
  17961. declare module BABYLON {
  17962. /**
  17963. * Size options for a post process
  17964. */
  17965. export type PostProcessOptions = {
  17966. width: number;
  17967. height: number;
  17968. };
  17969. /**
  17970. * PostProcess can be used to apply a shader to a texture after it has been rendered
  17971. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  17972. */
  17973. export class PostProcess {
  17974. /** Name of the PostProcess. */
  17975. name: string;
  17976. /**
  17977. * Gets or sets the unique id of the post process
  17978. */
  17979. uniqueId: number;
  17980. /**
  17981. * Width of the texture to apply the post process on
  17982. */
  17983. width: number;
  17984. /**
  17985. * Height of the texture to apply the post process on
  17986. */
  17987. height: number;
  17988. /**
  17989. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  17990. * @hidden
  17991. */
  17992. _outputTexture: Nullable<InternalTexture>;
  17993. /**
  17994. * Sampling mode used by the shader
  17995. * See https://doc.babylonjs.com/classes/3.1/texture
  17996. */
  17997. renderTargetSamplingMode: number;
  17998. /**
  17999. * Clear color to use when screen clearing
  18000. */
  18001. clearColor: Color4;
  18002. /**
  18003. * If the buffer needs to be cleared before applying the post process. (default: true)
  18004. * Should be set to false if shader will overwrite all previous pixels.
  18005. */
  18006. autoClear: boolean;
  18007. /**
  18008. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18009. */
  18010. alphaMode: number;
  18011. /**
  18012. * Sets the setAlphaBlendConstants of the babylon engine
  18013. */
  18014. alphaConstants: Color4;
  18015. /**
  18016. * Animations to be used for the post processing
  18017. */
  18018. animations: Animation[];
  18019. /**
  18020. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18021. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18022. */
  18023. enablePixelPerfectMode: boolean;
  18024. /**
  18025. * Force the postprocess to be applied without taking in account viewport
  18026. */
  18027. forceFullscreenViewport: boolean;
  18028. /**
  18029. * List of inspectable custom properties (used by the Inspector)
  18030. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18031. */
  18032. inspectableCustomProperties: IInspectable[];
  18033. /**
  18034. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18035. *
  18036. * | Value | Type | Description |
  18037. * | ----- | ----------------------------------- | ----------- |
  18038. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18039. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18040. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18041. *
  18042. */
  18043. scaleMode: number;
  18044. /**
  18045. * Force textures to be a power of two (default: false)
  18046. */
  18047. alwaysForcePOT: boolean;
  18048. private _samples;
  18049. /**
  18050. * Number of sample textures (default: 1)
  18051. */
  18052. samples: number;
  18053. /**
  18054. * Modify the scale of the post process to be the same as the viewport (default: false)
  18055. */
  18056. adaptScaleToCurrentViewport: boolean;
  18057. private _camera;
  18058. private _scene;
  18059. private _engine;
  18060. private _options;
  18061. private _reusable;
  18062. private _textureType;
  18063. /**
  18064. * Smart array of input and output textures for the post process.
  18065. * @hidden
  18066. */
  18067. _textures: SmartArray<InternalTexture>;
  18068. /**
  18069. * The index in _textures that corresponds to the output texture.
  18070. * @hidden
  18071. */
  18072. _currentRenderTextureInd: number;
  18073. private _effect;
  18074. private _samplers;
  18075. private _fragmentUrl;
  18076. private _vertexUrl;
  18077. private _parameters;
  18078. private _scaleRatio;
  18079. protected _indexParameters: any;
  18080. private _shareOutputWithPostProcess;
  18081. private _texelSize;
  18082. private _forcedOutputTexture;
  18083. /**
  18084. * Returns the fragment url or shader name used in the post process.
  18085. * @returns the fragment url or name in the shader store.
  18086. */
  18087. getEffectName(): string;
  18088. /**
  18089. * An event triggered when the postprocess is activated.
  18090. */
  18091. onActivateObservable: Observable<Camera>;
  18092. private _onActivateObserver;
  18093. /**
  18094. * A function that is added to the onActivateObservable
  18095. */
  18096. onActivate: Nullable<(camera: Camera) => void>;
  18097. /**
  18098. * An event triggered when the postprocess changes its size.
  18099. */
  18100. onSizeChangedObservable: Observable<PostProcess>;
  18101. private _onSizeChangedObserver;
  18102. /**
  18103. * A function that is added to the onSizeChangedObservable
  18104. */
  18105. onSizeChanged: (postProcess: PostProcess) => void;
  18106. /**
  18107. * An event triggered when the postprocess applies its effect.
  18108. */
  18109. onApplyObservable: Observable<Effect>;
  18110. private _onApplyObserver;
  18111. /**
  18112. * A function that is added to the onApplyObservable
  18113. */
  18114. onApply: (effect: Effect) => void;
  18115. /**
  18116. * An event triggered before rendering the postprocess
  18117. */
  18118. onBeforeRenderObservable: Observable<Effect>;
  18119. private _onBeforeRenderObserver;
  18120. /**
  18121. * A function that is added to the onBeforeRenderObservable
  18122. */
  18123. onBeforeRender: (effect: Effect) => void;
  18124. /**
  18125. * An event triggered after rendering the postprocess
  18126. */
  18127. onAfterRenderObservable: Observable<Effect>;
  18128. private _onAfterRenderObserver;
  18129. /**
  18130. * A function that is added to the onAfterRenderObservable
  18131. */
  18132. onAfterRender: (efect: Effect) => void;
  18133. /**
  18134. * 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
  18135. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18136. */
  18137. inputTexture: InternalTexture;
  18138. /**
  18139. * Gets the camera which post process is applied to.
  18140. * @returns The camera the post process is applied to.
  18141. */
  18142. getCamera(): Camera;
  18143. /**
  18144. * Gets the texel size of the postprocess.
  18145. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18146. */
  18147. readonly texelSize: Vector2;
  18148. /**
  18149. * Creates a new instance PostProcess
  18150. * @param name The name of the PostProcess.
  18151. * @param fragmentUrl The url of the fragment shader to be used.
  18152. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18153. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18154. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18155. * @param camera The camera to apply the render pass to.
  18156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18157. * @param engine The engine which the post process will be applied. (default: current engine)
  18158. * @param reusable If the post process can be reused on the same frame. (default: false)
  18159. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18160. * @param textureType Type of textures used when performing the post process. (default: 0)
  18161. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18162. * @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
  18163. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18164. */
  18165. constructor(
  18166. /** Name of the PostProcess. */
  18167. 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);
  18168. /**
  18169. * Gets a string idenfifying the name of the class
  18170. * @returns "PostProcess" string
  18171. */
  18172. getClassName(): string;
  18173. /**
  18174. * Gets the engine which this post process belongs to.
  18175. * @returns The engine the post process was enabled with.
  18176. */
  18177. getEngine(): Engine;
  18178. /**
  18179. * The effect that is created when initializing the post process.
  18180. * @returns The created effect corresponding the the postprocess.
  18181. */
  18182. getEffect(): Effect;
  18183. /**
  18184. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18185. * @param postProcess The post process to share the output with.
  18186. * @returns This post process.
  18187. */
  18188. shareOutputWith(postProcess: PostProcess): PostProcess;
  18189. /**
  18190. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18191. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18192. */
  18193. useOwnOutput(): void;
  18194. /**
  18195. * Updates the effect with the current post process compile time values and recompiles the shader.
  18196. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18197. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18198. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18199. * @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
  18200. * @param onCompiled Called when the shader has been compiled.
  18201. * @param onError Called if there is an error when compiling a shader.
  18202. */
  18203. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18204. /**
  18205. * The post process is reusable if it can be used multiple times within one frame.
  18206. * @returns If the post process is reusable
  18207. */
  18208. isReusable(): boolean;
  18209. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18210. markTextureDirty(): void;
  18211. /**
  18212. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18213. * 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.
  18214. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18215. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18216. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18217. * @returns The target texture that was bound to be written to.
  18218. */
  18219. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18220. /**
  18221. * If the post process is supported.
  18222. */
  18223. readonly isSupported: boolean;
  18224. /**
  18225. * The aspect ratio of the output texture.
  18226. */
  18227. readonly aspectRatio: number;
  18228. /**
  18229. * Get a value indicating if the post-process is ready to be used
  18230. * @returns true if the post-process is ready (shader is compiled)
  18231. */
  18232. isReady(): boolean;
  18233. /**
  18234. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18235. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18236. */
  18237. apply(): Nullable<Effect>;
  18238. private _disposeTextures;
  18239. /**
  18240. * Disposes the post process.
  18241. * @param camera The camera to dispose the post process on.
  18242. */
  18243. dispose(camera?: Camera): void;
  18244. }
  18245. }
  18246. declare module BABYLON {
  18247. /** @hidden */
  18248. export var kernelBlurVaryingDeclaration: {
  18249. name: string;
  18250. shader: string;
  18251. };
  18252. }
  18253. declare module BABYLON {
  18254. /** @hidden */
  18255. export var kernelBlurFragment: {
  18256. name: string;
  18257. shader: string;
  18258. };
  18259. }
  18260. declare module BABYLON {
  18261. /** @hidden */
  18262. export var kernelBlurFragment2: {
  18263. name: string;
  18264. shader: string;
  18265. };
  18266. }
  18267. declare module BABYLON {
  18268. /** @hidden */
  18269. export var kernelBlurPixelShader: {
  18270. name: string;
  18271. shader: string;
  18272. };
  18273. }
  18274. declare module BABYLON {
  18275. /** @hidden */
  18276. export var kernelBlurVertex: {
  18277. name: string;
  18278. shader: string;
  18279. };
  18280. }
  18281. declare module BABYLON {
  18282. /** @hidden */
  18283. export var kernelBlurVertexShader: {
  18284. name: string;
  18285. shader: string;
  18286. };
  18287. }
  18288. declare module BABYLON {
  18289. /**
  18290. * The Blur Post Process which blurs an image based on a kernel and direction.
  18291. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18292. */
  18293. export class BlurPostProcess extends PostProcess {
  18294. /** The direction in which to blur the image. */
  18295. direction: Vector2;
  18296. private blockCompilation;
  18297. protected _kernel: number;
  18298. protected _idealKernel: number;
  18299. protected _packedFloat: boolean;
  18300. private _staticDefines;
  18301. /**
  18302. * Sets the length in pixels of the blur sample region
  18303. */
  18304. /**
  18305. * Gets the length in pixels of the blur sample region
  18306. */
  18307. kernel: number;
  18308. /**
  18309. * Sets wether or not the blur needs to unpack/repack floats
  18310. */
  18311. /**
  18312. * Gets wether or not the blur is unpacking/repacking floats
  18313. */
  18314. packedFloat: boolean;
  18315. /**
  18316. * Creates a new instance BlurPostProcess
  18317. * @param name The name of the effect.
  18318. * @param direction The direction in which to blur the image.
  18319. * @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.
  18320. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18321. * @param camera The camera to apply the render pass to.
  18322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18323. * @param engine The engine which the post process will be applied. (default: current engine)
  18324. * @param reusable If the post process can be reused on the same frame. (default: false)
  18325. * @param textureType Type of textures used when performing the post process. (default: 0)
  18326. * @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)
  18327. */
  18328. constructor(name: string,
  18329. /** The direction in which to blur the image. */
  18330. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18331. /**
  18332. * Updates the effect with the current post process compile time values and recompiles the shader.
  18333. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18334. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18335. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18336. * @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
  18337. * @param onCompiled Called when the shader has been compiled.
  18338. * @param onError Called if there is an error when compiling a shader.
  18339. */
  18340. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18341. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18342. /**
  18343. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18344. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18345. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18346. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18347. * The gaps between physical kernels are compensated for in the weighting of the samples
  18348. * @param idealKernel Ideal blur kernel.
  18349. * @return Nearest best kernel.
  18350. */
  18351. protected _nearestBestKernel(idealKernel: number): number;
  18352. /**
  18353. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18354. * @param x The point on the Gaussian distribution to sample.
  18355. * @return the value of the Gaussian function at x.
  18356. */
  18357. protected _gaussianWeight(x: number): number;
  18358. /**
  18359. * Generates a string that can be used as a floating point number in GLSL.
  18360. * @param x Value to print.
  18361. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18362. * @return GLSL float string.
  18363. */
  18364. protected _glslFloat(x: number, decimalFigures?: number): string;
  18365. }
  18366. }
  18367. declare module BABYLON {
  18368. /**
  18369. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18370. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18371. * You can then easily use it as a reflectionTexture on a flat surface.
  18372. * In case the surface is not a plane, please consider relying on reflection probes.
  18373. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18374. */
  18375. export class MirrorTexture extends RenderTargetTexture {
  18376. private scene;
  18377. /**
  18378. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18379. * 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.
  18380. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18381. */
  18382. mirrorPlane: Plane;
  18383. /**
  18384. * Define the blur ratio used to blur the reflection if needed.
  18385. */
  18386. blurRatio: number;
  18387. /**
  18388. * Define the adaptive blur kernel used to blur the reflection if needed.
  18389. * This will autocompute the closest best match for the `blurKernel`
  18390. */
  18391. adaptiveBlurKernel: number;
  18392. /**
  18393. * Define the blur kernel used to blur the reflection if needed.
  18394. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18395. */
  18396. blurKernel: number;
  18397. /**
  18398. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18399. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18400. */
  18401. blurKernelX: number;
  18402. /**
  18403. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18404. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18405. */
  18406. blurKernelY: number;
  18407. private _autoComputeBlurKernel;
  18408. protected _onRatioRescale(): void;
  18409. private _updateGammaSpace;
  18410. private _imageProcessingConfigChangeObserver;
  18411. private _transformMatrix;
  18412. private _mirrorMatrix;
  18413. private _savedViewMatrix;
  18414. private _blurX;
  18415. private _blurY;
  18416. private _adaptiveBlurKernel;
  18417. private _blurKernelX;
  18418. private _blurKernelY;
  18419. private _blurRatio;
  18420. /**
  18421. * Instantiates a Mirror Texture.
  18422. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18423. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18424. * You can then easily use it as a reflectionTexture on a flat surface.
  18425. * In case the surface is not a plane, please consider relying on reflection probes.
  18426. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18427. * @param name
  18428. * @param size
  18429. * @param scene
  18430. * @param generateMipMaps
  18431. * @param type
  18432. * @param samplingMode
  18433. * @param generateDepthBuffer
  18434. */
  18435. constructor(name: string, size: number | {
  18436. width: number;
  18437. height: number;
  18438. } | {
  18439. ratio: number;
  18440. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18441. private _preparePostProcesses;
  18442. /**
  18443. * Clone the mirror texture.
  18444. * @returns the cloned texture
  18445. */
  18446. clone(): MirrorTexture;
  18447. /**
  18448. * Serialize the texture to a JSON representation you could use in Parse later on
  18449. * @returns the serialized JSON representation
  18450. */
  18451. serialize(): any;
  18452. /**
  18453. * Dispose the texture and release its associated resources.
  18454. */
  18455. dispose(): void;
  18456. }
  18457. }
  18458. declare module BABYLON {
  18459. /**
  18460. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18461. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18462. */
  18463. export class Texture extends BaseTexture {
  18464. /** @hidden */
  18465. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18466. /** @hidden */
  18467. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18468. /** @hidden */
  18469. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18470. /** nearest is mag = nearest and min = nearest and mip = linear */
  18471. static readonly NEAREST_SAMPLINGMODE: number;
  18472. /** nearest is mag = nearest and min = nearest and mip = linear */
  18473. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18474. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18475. static readonly BILINEAR_SAMPLINGMODE: number;
  18476. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18477. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18478. /** Trilinear is mag = linear and min = linear and mip = linear */
  18479. static readonly TRILINEAR_SAMPLINGMODE: number;
  18480. /** Trilinear is mag = linear and min = linear and mip = linear */
  18481. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18482. /** mag = nearest and min = nearest and mip = nearest */
  18483. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18484. /** mag = nearest and min = linear and mip = nearest */
  18485. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18486. /** mag = nearest and min = linear and mip = linear */
  18487. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18488. /** mag = nearest and min = linear and mip = none */
  18489. static readonly NEAREST_LINEAR: number;
  18490. /** mag = nearest and min = nearest and mip = none */
  18491. static readonly NEAREST_NEAREST: number;
  18492. /** mag = linear and min = nearest and mip = nearest */
  18493. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18494. /** mag = linear and min = nearest and mip = linear */
  18495. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18496. /** mag = linear and min = linear and mip = none */
  18497. static readonly LINEAR_LINEAR: number;
  18498. /** mag = linear and min = nearest and mip = none */
  18499. static readonly LINEAR_NEAREST: number;
  18500. /** Explicit coordinates mode */
  18501. static readonly EXPLICIT_MODE: number;
  18502. /** Spherical coordinates mode */
  18503. static readonly SPHERICAL_MODE: number;
  18504. /** Planar coordinates mode */
  18505. static readonly PLANAR_MODE: number;
  18506. /** Cubic coordinates mode */
  18507. static readonly CUBIC_MODE: number;
  18508. /** Projection coordinates mode */
  18509. static readonly PROJECTION_MODE: number;
  18510. /** Inverse Cubic coordinates mode */
  18511. static readonly SKYBOX_MODE: number;
  18512. /** Inverse Cubic coordinates mode */
  18513. static readonly INVCUBIC_MODE: number;
  18514. /** Equirectangular coordinates mode */
  18515. static readonly EQUIRECTANGULAR_MODE: number;
  18516. /** Equirectangular Fixed coordinates mode */
  18517. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18518. /** Equirectangular Fixed Mirrored coordinates mode */
  18519. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18520. /** Texture is not repeating outside of 0..1 UVs */
  18521. static readonly CLAMP_ADDRESSMODE: number;
  18522. /** Texture is repeating outside of 0..1 UVs */
  18523. static readonly WRAP_ADDRESSMODE: number;
  18524. /** Texture is repeating and mirrored */
  18525. static readonly MIRROR_ADDRESSMODE: number;
  18526. /**
  18527. * 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
  18528. */
  18529. static UseSerializedUrlIfAny: boolean;
  18530. /**
  18531. * Define the url of the texture.
  18532. */
  18533. url: Nullable<string>;
  18534. /**
  18535. * Define an offset on the texture to offset the u coordinates of the UVs
  18536. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18537. */
  18538. uOffset: number;
  18539. /**
  18540. * Define an offset on the texture to offset the v coordinates of the UVs
  18541. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18542. */
  18543. vOffset: number;
  18544. /**
  18545. * Define an offset on the texture to scale the u coordinates of the UVs
  18546. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18547. */
  18548. uScale: number;
  18549. /**
  18550. * Define an offset on the texture to scale the v coordinates of the UVs
  18551. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18552. */
  18553. vScale: number;
  18554. /**
  18555. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18556. * @see http://doc.babylonjs.com/how_to/more_materials
  18557. */
  18558. uAng: number;
  18559. /**
  18560. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18561. * @see http://doc.babylonjs.com/how_to/more_materials
  18562. */
  18563. vAng: number;
  18564. /**
  18565. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18566. * @see http://doc.babylonjs.com/how_to/more_materials
  18567. */
  18568. wAng: number;
  18569. /**
  18570. * Defines the center of rotation (U)
  18571. */
  18572. uRotationCenter: number;
  18573. /**
  18574. * Defines the center of rotation (V)
  18575. */
  18576. vRotationCenter: number;
  18577. /**
  18578. * Defines the center of rotation (W)
  18579. */
  18580. wRotationCenter: number;
  18581. /**
  18582. * Are mip maps generated for this texture or not.
  18583. */
  18584. readonly noMipmap: boolean;
  18585. /**
  18586. * List of inspectable custom properties (used by the Inspector)
  18587. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18588. */
  18589. inspectableCustomProperties: Nullable<IInspectable[]>;
  18590. private _noMipmap;
  18591. /** @hidden */
  18592. _invertY: boolean;
  18593. private _rowGenerationMatrix;
  18594. private _cachedTextureMatrix;
  18595. private _projectionModeMatrix;
  18596. private _t0;
  18597. private _t1;
  18598. private _t2;
  18599. private _cachedUOffset;
  18600. private _cachedVOffset;
  18601. private _cachedUScale;
  18602. private _cachedVScale;
  18603. private _cachedUAng;
  18604. private _cachedVAng;
  18605. private _cachedWAng;
  18606. private _cachedProjectionMatrixId;
  18607. private _cachedCoordinatesMode;
  18608. /** @hidden */
  18609. protected _initialSamplingMode: number;
  18610. /** @hidden */
  18611. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18612. private _deleteBuffer;
  18613. protected _format: Nullable<number>;
  18614. private _delayedOnLoad;
  18615. private _delayedOnError;
  18616. /**
  18617. * Observable triggered once the texture has been loaded.
  18618. */
  18619. onLoadObservable: Observable<Texture>;
  18620. protected _isBlocking: boolean;
  18621. /**
  18622. * Is the texture preventing material to render while loading.
  18623. * If false, a default texture will be used instead of the loading one during the preparation step.
  18624. */
  18625. isBlocking: boolean;
  18626. /**
  18627. * Get the current sampling mode associated with the texture.
  18628. */
  18629. readonly samplingMode: number;
  18630. /**
  18631. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18632. */
  18633. readonly invertY: boolean;
  18634. /**
  18635. * Instantiates a new texture.
  18636. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18637. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18638. * @param url define the url of the picture to load as a texture
  18639. * @param scene define the scene or engine the texture will belong to
  18640. * @param noMipmap define if the texture will require mip maps or not
  18641. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18642. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18643. * @param onLoad define a callback triggered when the texture has been loaded
  18644. * @param onError define a callback triggered when an error occurred during the loading session
  18645. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18646. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18647. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18648. */
  18649. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18650. /**
  18651. * Update the url (and optional buffer) of this texture if url was null during construction.
  18652. * @param url the url of the texture
  18653. * @param buffer the buffer of the texture (defaults to null)
  18654. * @param onLoad callback called when the texture is loaded (defaults to null)
  18655. */
  18656. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18657. /**
  18658. * Finish the loading sequence of a texture flagged as delayed load.
  18659. * @hidden
  18660. */
  18661. delayLoad(): void;
  18662. private _prepareRowForTextureGeneration;
  18663. /**
  18664. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18665. * @returns the transform matrix of the texture.
  18666. */
  18667. getTextureMatrix(): Matrix;
  18668. /**
  18669. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18670. * @returns The reflection texture transform
  18671. */
  18672. getReflectionTextureMatrix(): Matrix;
  18673. /**
  18674. * Clones the texture.
  18675. * @returns the cloned texture
  18676. */
  18677. clone(): Texture;
  18678. /**
  18679. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18680. * @returns The JSON representation of the texture
  18681. */
  18682. serialize(): any;
  18683. /**
  18684. * Get the current class name of the texture useful for serialization or dynamic coding.
  18685. * @returns "Texture"
  18686. */
  18687. getClassName(): string;
  18688. /**
  18689. * Dispose the texture and release its associated resources.
  18690. */
  18691. dispose(): void;
  18692. /**
  18693. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18694. * @param parsedTexture Define the JSON representation of the texture
  18695. * @param scene Define the scene the parsed texture should be instantiated in
  18696. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18697. * @returns The parsed texture if successful
  18698. */
  18699. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18700. /**
  18701. * Creates a texture from its base 64 representation.
  18702. * @param data Define the base64 payload without the data: prefix
  18703. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18704. * @param scene Define the scene the texture should belong to
  18705. * @param noMipmap Forces the texture to not create mip map information if true
  18706. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18707. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18708. * @param onLoad define a callback triggered when the texture has been loaded
  18709. * @param onError define a callback triggered when an error occurred during the loading session
  18710. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18711. * @returns the created texture
  18712. */
  18713. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18714. /**
  18715. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18716. * @param data Define the base64 payload without the data: prefix
  18717. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18718. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18719. * @param scene Define the scene the texture should belong to
  18720. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18721. * @param noMipmap Forces the texture to not create mip map information if true
  18722. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18723. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18724. * @param onLoad define a callback triggered when the texture has been loaded
  18725. * @param onError define a callback triggered when an error occurred during the loading session
  18726. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18727. * @returns the created texture
  18728. */
  18729. 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;
  18730. }
  18731. }
  18732. declare module BABYLON {
  18733. /**
  18734. * PostProcessManager is used to manage one or more post processes or post process pipelines
  18735. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18736. */
  18737. export class PostProcessManager {
  18738. private _scene;
  18739. private _indexBuffer;
  18740. private _vertexBuffers;
  18741. /**
  18742. * Creates a new instance PostProcess
  18743. * @param scene The scene that the post process is associated with.
  18744. */
  18745. constructor(scene: Scene);
  18746. private _prepareBuffers;
  18747. private _buildIndexBuffer;
  18748. /**
  18749. * Rebuilds the vertex buffers of the manager.
  18750. * @hidden
  18751. */
  18752. _rebuild(): void;
  18753. /**
  18754. * Prepares a frame to be run through a post process.
  18755. * @param sourceTexture The input texture to the post procesess. (default: null)
  18756. * @param postProcesses An array of post processes to be run. (default: null)
  18757. * @returns True if the post processes were able to be run.
  18758. * @hidden
  18759. */
  18760. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  18761. /**
  18762. * Manually render a set of post processes to a texture.
  18763. * @param postProcesses An array of post processes to be run.
  18764. * @param targetTexture The target texture to render to.
  18765. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  18766. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  18767. * @param lodLevel defines which lod of the texture to render to
  18768. */
  18769. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  18770. /**
  18771. * Finalize the result of the output of the postprocesses.
  18772. * @param doNotPresent If true the result will not be displayed to the screen.
  18773. * @param targetTexture The target texture to render to.
  18774. * @param faceIndex The index of the face to bind the target texture to.
  18775. * @param postProcesses The array of post processes to render.
  18776. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  18777. * @hidden
  18778. */
  18779. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  18780. /**
  18781. * Disposes of the post process manager.
  18782. */
  18783. dispose(): void;
  18784. }
  18785. }
  18786. declare module BABYLON {
  18787. interface AbstractScene {
  18788. /**
  18789. * The list of procedural textures added to the scene
  18790. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18791. */
  18792. proceduralTextures: Array<ProceduralTexture>;
  18793. }
  18794. /**
  18795. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  18796. * in a given scene.
  18797. */
  18798. export class ProceduralTextureSceneComponent implements ISceneComponent {
  18799. /**
  18800. * The component name helpfull to identify the component in the list of scene components.
  18801. */
  18802. readonly name: string;
  18803. /**
  18804. * The scene the component belongs to.
  18805. */
  18806. scene: Scene;
  18807. /**
  18808. * Creates a new instance of the component for the given scene
  18809. * @param scene Defines the scene to register the component in
  18810. */
  18811. constructor(scene: Scene);
  18812. /**
  18813. * Registers the component in a given scene
  18814. */
  18815. register(): void;
  18816. /**
  18817. * Rebuilds the elements related to this component in case of
  18818. * context lost for instance.
  18819. */
  18820. rebuild(): void;
  18821. /**
  18822. * Disposes the component and the associated ressources.
  18823. */
  18824. dispose(): void;
  18825. private _beforeClear;
  18826. }
  18827. }
  18828. declare module BABYLON {
  18829. interface Engine {
  18830. /**
  18831. * Creates a new render target cube texture
  18832. * @param size defines the size of the texture
  18833. * @param options defines the options used to create the texture
  18834. * @returns a new render target cube texture stored in an InternalTexture
  18835. */
  18836. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  18837. }
  18838. }
  18839. declare module BABYLON {
  18840. /** @hidden */
  18841. export var proceduralVertexShader: {
  18842. name: string;
  18843. shader: string;
  18844. };
  18845. }
  18846. declare module BABYLON {
  18847. /**
  18848. * 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.
  18849. * This is the base class of any Procedural texture and contains most of the shareable code.
  18850. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18851. */
  18852. export class ProceduralTexture extends Texture {
  18853. isCube: boolean;
  18854. /**
  18855. * Define if the texture is enabled or not (disabled texture will not render)
  18856. */
  18857. isEnabled: boolean;
  18858. /**
  18859. * Define if the texture must be cleared before rendering (default is true)
  18860. */
  18861. autoClear: boolean;
  18862. /**
  18863. * Callback called when the texture is generated
  18864. */
  18865. onGenerated: () => void;
  18866. /**
  18867. * Event raised when the texture is generated
  18868. */
  18869. onGeneratedObservable: Observable<ProceduralTexture>;
  18870. /** @hidden */
  18871. _generateMipMaps: boolean;
  18872. /** @hidden **/
  18873. _effect: Effect;
  18874. /** @hidden */
  18875. _textures: {
  18876. [key: string]: Texture;
  18877. };
  18878. private _size;
  18879. private _currentRefreshId;
  18880. private _refreshRate;
  18881. private _vertexBuffers;
  18882. private _indexBuffer;
  18883. private _uniforms;
  18884. private _samplers;
  18885. private _fragment;
  18886. private _floats;
  18887. private _ints;
  18888. private _floatsArrays;
  18889. private _colors3;
  18890. private _colors4;
  18891. private _vectors2;
  18892. private _vectors3;
  18893. private _matrices;
  18894. private _fallbackTexture;
  18895. private _fallbackTextureUsed;
  18896. private _engine;
  18897. private _cachedDefines;
  18898. private _contentUpdateId;
  18899. private _contentData;
  18900. /**
  18901. * Instantiates a new procedural texture.
  18902. * 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.
  18903. * This is the base class of any Procedural texture and contains most of the shareable code.
  18904. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18905. * @param name Define the name of the texture
  18906. * @param size Define the size of the texture to create
  18907. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  18908. * @param scene Define the scene the texture belongs to
  18909. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  18910. * @param generateMipMaps Define if the texture should creates mip maps or not
  18911. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  18912. */
  18913. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  18914. /**
  18915. * The effect that is created when initializing the post process.
  18916. * @returns The created effect corresponding the the postprocess.
  18917. */
  18918. getEffect(): Effect;
  18919. /**
  18920. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  18921. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  18922. */
  18923. getContent(): Nullable<ArrayBufferView>;
  18924. private _createIndexBuffer;
  18925. /** @hidden */
  18926. _rebuild(): void;
  18927. /**
  18928. * Resets the texture in order to recreate its associated resources.
  18929. * This can be called in case of context loss
  18930. */
  18931. reset(): void;
  18932. protected _getDefines(): string;
  18933. /**
  18934. * Is the texture ready to be used ? (rendered at least once)
  18935. * @returns true if ready, otherwise, false.
  18936. */
  18937. isReady(): boolean;
  18938. /**
  18939. * Resets the refresh counter of the texture and start bak from scratch.
  18940. * Could be useful to regenerate the texture if it is setup to render only once.
  18941. */
  18942. resetRefreshCounter(): void;
  18943. /**
  18944. * Set the fragment shader to use in order to render the texture.
  18945. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  18946. */
  18947. setFragment(fragment: any): void;
  18948. /**
  18949. * Define the refresh rate of the texture or the rendering frequency.
  18950. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18951. */
  18952. refreshRate: number;
  18953. /** @hidden */
  18954. _shouldRender(): boolean;
  18955. /**
  18956. * Get the size the texture is rendering at.
  18957. * @returns the size (texture is always squared)
  18958. */
  18959. getRenderSize(): number;
  18960. /**
  18961. * Resize the texture to new value.
  18962. * @param size Define the new size the texture should have
  18963. * @param generateMipMaps Define whether the new texture should create mip maps
  18964. */
  18965. resize(size: number, generateMipMaps: boolean): void;
  18966. private _checkUniform;
  18967. /**
  18968. * Set a texture in the shader program used to render.
  18969. * @param name Define the name of the uniform samplers as defined in the shader
  18970. * @param texture Define the texture to bind to this sampler
  18971. * @return the texture itself allowing "fluent" like uniform updates
  18972. */
  18973. setTexture(name: string, texture: Texture): ProceduralTexture;
  18974. /**
  18975. * Set a float in the shader.
  18976. * @param name Define the name of the uniform as defined in the shader
  18977. * @param value Define the value to give to the uniform
  18978. * @return the texture itself allowing "fluent" like uniform updates
  18979. */
  18980. setFloat(name: string, value: number): ProceduralTexture;
  18981. /**
  18982. * Set a int in the shader.
  18983. * @param name Define the name of the uniform as defined in the shader
  18984. * @param value Define the value to give to the uniform
  18985. * @return the texture itself allowing "fluent" like uniform updates
  18986. */
  18987. setInt(name: string, value: number): ProceduralTexture;
  18988. /**
  18989. * Set an array of floats in the shader.
  18990. * @param name Define the name of the uniform as defined in the shader
  18991. * @param value Define the value to give to the uniform
  18992. * @return the texture itself allowing "fluent" like uniform updates
  18993. */
  18994. setFloats(name: string, value: number[]): ProceduralTexture;
  18995. /**
  18996. * Set a vec3 in the shader from a Color3.
  18997. * @param name Define the name of the uniform as defined in the shader
  18998. * @param value Define the value to give to the uniform
  18999. * @return the texture itself allowing "fluent" like uniform updates
  19000. */
  19001. setColor3(name: string, value: Color3): ProceduralTexture;
  19002. /**
  19003. * Set a vec4 in the shader from a Color4.
  19004. * @param name Define the name of the uniform as defined in the shader
  19005. * @param value Define the value to give to the uniform
  19006. * @return the texture itself allowing "fluent" like uniform updates
  19007. */
  19008. setColor4(name: string, value: Color4): ProceduralTexture;
  19009. /**
  19010. * Set a vec2 in the shader from a Vector2.
  19011. * @param name Define the name of the uniform as defined in the shader
  19012. * @param value Define the value to give to the uniform
  19013. * @return the texture itself allowing "fluent" like uniform updates
  19014. */
  19015. setVector2(name: string, value: Vector2): ProceduralTexture;
  19016. /**
  19017. * Set a vec3 in the shader from a Vector3.
  19018. * @param name Define the name of the uniform as defined in the shader
  19019. * @param value Define the value to give to the uniform
  19020. * @return the texture itself allowing "fluent" like uniform updates
  19021. */
  19022. setVector3(name: string, value: Vector3): ProceduralTexture;
  19023. /**
  19024. * Set a mat4 in the shader from a MAtrix.
  19025. * @param name Define the name of the uniform as defined in the shader
  19026. * @param value Define the value to give to the uniform
  19027. * @return the texture itself allowing "fluent" like uniform updates
  19028. */
  19029. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19030. /**
  19031. * Render the texture to its associated render target.
  19032. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19033. */
  19034. render(useCameraPostProcess?: boolean): void;
  19035. /**
  19036. * Clone the texture.
  19037. * @returns the cloned texture
  19038. */
  19039. clone(): ProceduralTexture;
  19040. /**
  19041. * Dispose the texture and release its asoociated resources.
  19042. */
  19043. dispose(): void;
  19044. }
  19045. }
  19046. declare module BABYLON {
  19047. /**
  19048. * This represents the base class for particle system in Babylon.
  19049. * 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.
  19050. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19051. * @example https://doc.babylonjs.com/babylon101/particles
  19052. */
  19053. export class BaseParticleSystem {
  19054. /**
  19055. * Source color is added to the destination color without alpha affecting the result
  19056. */
  19057. static BLENDMODE_ONEONE: number;
  19058. /**
  19059. * Blend current color and particle color using particle’s alpha
  19060. */
  19061. static BLENDMODE_STANDARD: number;
  19062. /**
  19063. * Add current color and particle color multiplied by particle’s alpha
  19064. */
  19065. static BLENDMODE_ADD: number;
  19066. /**
  19067. * Multiply current color with particle color
  19068. */
  19069. static BLENDMODE_MULTIPLY: number;
  19070. /**
  19071. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19072. */
  19073. static BLENDMODE_MULTIPLYADD: number;
  19074. /**
  19075. * List of animations used by the particle system.
  19076. */
  19077. animations: Animation[];
  19078. /**
  19079. * The id of the Particle system.
  19080. */
  19081. id: string;
  19082. /**
  19083. * The friendly name of the Particle system.
  19084. */
  19085. name: string;
  19086. /**
  19087. * The rendering group used by the Particle system to chose when to render.
  19088. */
  19089. renderingGroupId: number;
  19090. /**
  19091. * The emitter represents the Mesh or position we are attaching the particle system to.
  19092. */
  19093. emitter: Nullable<AbstractMesh | Vector3>;
  19094. /**
  19095. * The maximum number of particles to emit per frame
  19096. */
  19097. emitRate: number;
  19098. /**
  19099. * If you want to launch only a few particles at once, that can be done, as well.
  19100. */
  19101. manualEmitCount: number;
  19102. /**
  19103. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19104. */
  19105. updateSpeed: number;
  19106. /**
  19107. * The amount of time the particle system is running (depends of the overall update speed).
  19108. */
  19109. targetStopDuration: number;
  19110. /**
  19111. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19112. */
  19113. disposeOnStop: boolean;
  19114. /**
  19115. * Minimum power of emitting particles.
  19116. */
  19117. minEmitPower: number;
  19118. /**
  19119. * Maximum power of emitting particles.
  19120. */
  19121. maxEmitPower: number;
  19122. /**
  19123. * Minimum life time of emitting particles.
  19124. */
  19125. minLifeTime: number;
  19126. /**
  19127. * Maximum life time of emitting particles.
  19128. */
  19129. maxLifeTime: number;
  19130. /**
  19131. * Minimum Size of emitting particles.
  19132. */
  19133. minSize: number;
  19134. /**
  19135. * Maximum Size of emitting particles.
  19136. */
  19137. maxSize: number;
  19138. /**
  19139. * Minimum scale of emitting particles on X axis.
  19140. */
  19141. minScaleX: number;
  19142. /**
  19143. * Maximum scale of emitting particles on X axis.
  19144. */
  19145. maxScaleX: number;
  19146. /**
  19147. * Minimum scale of emitting particles on Y axis.
  19148. */
  19149. minScaleY: number;
  19150. /**
  19151. * Maximum scale of emitting particles on Y axis.
  19152. */
  19153. maxScaleY: number;
  19154. /**
  19155. * Gets or sets the minimal initial rotation in radians.
  19156. */
  19157. minInitialRotation: number;
  19158. /**
  19159. * Gets or sets the maximal initial rotation in radians.
  19160. */
  19161. maxInitialRotation: number;
  19162. /**
  19163. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19164. */
  19165. minAngularSpeed: number;
  19166. /**
  19167. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19168. */
  19169. maxAngularSpeed: number;
  19170. /**
  19171. * The texture used to render each particle. (this can be a spritesheet)
  19172. */
  19173. particleTexture: Nullable<Texture>;
  19174. /**
  19175. * The layer mask we are rendering the particles through.
  19176. */
  19177. layerMask: number;
  19178. /**
  19179. * This can help using your own shader to render the particle system.
  19180. * The according effect will be created
  19181. */
  19182. customShader: any;
  19183. /**
  19184. * By default particle system starts as soon as they are created. This prevents the
  19185. * automatic start to happen and let you decide when to start emitting particles.
  19186. */
  19187. preventAutoStart: boolean;
  19188. private _noiseTexture;
  19189. /**
  19190. * Gets or sets a texture used to add random noise to particle positions
  19191. */
  19192. noiseTexture: Nullable<ProceduralTexture>;
  19193. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19194. noiseStrength: Vector3;
  19195. /**
  19196. * Callback triggered when the particle animation is ending.
  19197. */
  19198. onAnimationEnd: Nullable<() => void>;
  19199. /**
  19200. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19201. */
  19202. blendMode: number;
  19203. /**
  19204. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19205. * to override the particles.
  19206. */
  19207. forceDepthWrite: boolean;
  19208. /** 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 */
  19209. preWarmCycles: number;
  19210. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19211. preWarmStepOffset: number;
  19212. /**
  19213. * 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)
  19214. */
  19215. spriteCellChangeSpeed: number;
  19216. /**
  19217. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19218. */
  19219. startSpriteCellID: number;
  19220. /**
  19221. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19222. */
  19223. endSpriteCellID: number;
  19224. /**
  19225. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19226. */
  19227. spriteCellWidth: number;
  19228. /**
  19229. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19230. */
  19231. spriteCellHeight: number;
  19232. /**
  19233. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19234. */
  19235. spriteRandomStartCell: boolean;
  19236. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19237. translationPivot: Vector2;
  19238. /** @hidden */
  19239. protected _isAnimationSheetEnabled: boolean;
  19240. /**
  19241. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19242. */
  19243. beginAnimationOnStart: boolean;
  19244. /**
  19245. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19246. */
  19247. beginAnimationFrom: number;
  19248. /**
  19249. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19250. */
  19251. beginAnimationTo: number;
  19252. /**
  19253. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19254. */
  19255. beginAnimationLoop: boolean;
  19256. /**
  19257. * Gets or sets a world offset applied to all particles
  19258. */
  19259. worldOffset: Vector3;
  19260. /**
  19261. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19262. */
  19263. isAnimationSheetEnabled: boolean;
  19264. /**
  19265. * Get hosting scene
  19266. * @returns the scene
  19267. */
  19268. getScene(): Scene;
  19269. /**
  19270. * You can use gravity if you want to give an orientation to your particles.
  19271. */
  19272. gravity: Vector3;
  19273. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19274. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19275. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19276. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19277. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19278. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19279. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19280. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19281. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19282. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19283. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19284. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19285. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19286. /**
  19287. * Defines the delay in milliseconds before starting the system (0 by default)
  19288. */
  19289. startDelay: number;
  19290. /**
  19291. * Gets the current list of drag gradients.
  19292. * You must use addDragGradient and removeDragGradient to udpate this list
  19293. * @returns the list of drag gradients
  19294. */
  19295. getDragGradients(): Nullable<Array<FactorGradient>>;
  19296. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19297. limitVelocityDamping: number;
  19298. /**
  19299. * Gets the current list of limit velocity gradients.
  19300. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19301. * @returns the list of limit velocity gradients
  19302. */
  19303. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19304. /**
  19305. * Gets the current list of color gradients.
  19306. * You must use addColorGradient and removeColorGradient to udpate this list
  19307. * @returns the list of color gradients
  19308. */
  19309. getColorGradients(): Nullable<Array<ColorGradient>>;
  19310. /**
  19311. * Gets the current list of size gradients.
  19312. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19313. * @returns the list of size gradients
  19314. */
  19315. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19316. /**
  19317. * Gets the current list of color remap gradients.
  19318. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19319. * @returns the list of color remap gradients
  19320. */
  19321. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19322. /**
  19323. * Gets the current list of alpha remap gradients.
  19324. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19325. * @returns the list of alpha remap gradients
  19326. */
  19327. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19328. /**
  19329. * Gets the current list of life time gradients.
  19330. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19331. * @returns the list of life time gradients
  19332. */
  19333. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19334. /**
  19335. * Gets the current list of angular speed gradients.
  19336. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19337. * @returns the list of angular speed gradients
  19338. */
  19339. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19340. /**
  19341. * Gets the current list of velocity gradients.
  19342. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19343. * @returns the list of velocity gradients
  19344. */
  19345. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19346. /**
  19347. * Gets the current list of start size gradients.
  19348. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19349. * @returns the list of start size gradients
  19350. */
  19351. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19352. /**
  19353. * Gets the current list of emit rate gradients.
  19354. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19355. * @returns the list of emit rate gradients
  19356. */
  19357. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19358. /**
  19359. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19360. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19361. */
  19362. direction1: Vector3;
  19363. /**
  19364. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19365. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19366. */
  19367. direction2: Vector3;
  19368. /**
  19369. * 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.
  19370. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19371. */
  19372. minEmitBox: Vector3;
  19373. /**
  19374. * 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.
  19375. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19376. */
  19377. maxEmitBox: Vector3;
  19378. /**
  19379. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19380. */
  19381. color1: Color4;
  19382. /**
  19383. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19384. */
  19385. color2: Color4;
  19386. /**
  19387. * Color the particle will have at the end of its lifetime
  19388. */
  19389. colorDead: Color4;
  19390. /**
  19391. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19392. */
  19393. textureMask: Color4;
  19394. /**
  19395. * The particle emitter type defines the emitter used by the particle system.
  19396. * It can be for example box, sphere, or cone...
  19397. */
  19398. particleEmitterType: IParticleEmitterType;
  19399. /** @hidden */
  19400. _isSubEmitter: boolean;
  19401. /**
  19402. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19403. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19404. */
  19405. billboardMode: number;
  19406. protected _isBillboardBased: boolean;
  19407. /**
  19408. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19409. */
  19410. isBillboardBased: boolean;
  19411. /**
  19412. * The scene the particle system belongs to.
  19413. */
  19414. protected _scene: Scene;
  19415. /**
  19416. * Local cache of defines for image processing.
  19417. */
  19418. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19419. /**
  19420. * Default configuration related to image processing available in the standard Material.
  19421. */
  19422. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19423. /**
  19424. * Gets the image processing configuration used either in this material.
  19425. */
  19426. /**
  19427. * Sets the Default image processing configuration used either in the this material.
  19428. *
  19429. * If sets to null, the scene one is in use.
  19430. */
  19431. imageProcessingConfiguration: ImageProcessingConfiguration;
  19432. /**
  19433. * Attaches a new image processing configuration to the Standard Material.
  19434. * @param configuration
  19435. */
  19436. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19437. /** @hidden */
  19438. protected _reset(): void;
  19439. /** @hidden */
  19440. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19441. /**
  19442. * Instantiates a particle system.
  19443. * 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.
  19444. * @param name The name of the particle system
  19445. */
  19446. constructor(name: string);
  19447. /**
  19448. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19449. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19450. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19451. * @returns the emitter
  19452. */
  19453. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19454. /**
  19455. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19456. * @param radius The radius of the hemisphere to emit from
  19457. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19458. * @returns the emitter
  19459. */
  19460. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19461. /**
  19462. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19463. * @param radius The radius of the sphere to emit from
  19464. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19465. * @returns the emitter
  19466. */
  19467. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19468. /**
  19469. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19470. * @param radius The radius of the sphere to emit from
  19471. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19472. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19473. * @returns the emitter
  19474. */
  19475. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19476. /**
  19477. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19478. * @param radius The radius of the emission cylinder
  19479. * @param height The height of the emission cylinder
  19480. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19481. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19482. * @returns the emitter
  19483. */
  19484. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19485. /**
  19486. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19487. * @param radius The radius of the cylinder to emit from
  19488. * @param height The height of the emission cylinder
  19489. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19490. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19491. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19492. * @returns the emitter
  19493. */
  19494. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19495. /**
  19496. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19497. * @param radius The radius of the cone to emit from
  19498. * @param angle The base angle of the cone
  19499. * @returns the emitter
  19500. */
  19501. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19502. /**
  19503. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19504. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19505. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19506. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19507. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19508. * @returns the emitter
  19509. */
  19510. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19511. }
  19512. }
  19513. declare module BABYLON {
  19514. /**
  19515. * Type of sub emitter
  19516. */
  19517. export enum SubEmitterType {
  19518. /**
  19519. * Attached to the particle over it's lifetime
  19520. */
  19521. ATTACHED = 0,
  19522. /**
  19523. * Created when the particle dies
  19524. */
  19525. END = 1
  19526. }
  19527. /**
  19528. * Sub emitter class used to emit particles from an existing particle
  19529. */
  19530. export class SubEmitter {
  19531. /**
  19532. * the particle system to be used by the sub emitter
  19533. */
  19534. particleSystem: ParticleSystem;
  19535. /**
  19536. * Type of the submitter (Default: END)
  19537. */
  19538. type: SubEmitterType;
  19539. /**
  19540. * 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)
  19541. * Note: This only is supported when using an emitter of type Mesh
  19542. */
  19543. inheritDirection: boolean;
  19544. /**
  19545. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19546. */
  19547. inheritedVelocityAmount: number;
  19548. /**
  19549. * Creates a sub emitter
  19550. * @param particleSystem the particle system to be used by the sub emitter
  19551. */
  19552. constructor(
  19553. /**
  19554. * the particle system to be used by the sub emitter
  19555. */
  19556. particleSystem: ParticleSystem);
  19557. /**
  19558. * Clones the sub emitter
  19559. * @returns the cloned sub emitter
  19560. */
  19561. clone(): SubEmitter;
  19562. /**
  19563. * Serialize current object to a JSON object
  19564. * @returns the serialized object
  19565. */
  19566. serialize(): any;
  19567. /** @hidden */
  19568. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19569. /**
  19570. * Creates a new SubEmitter from a serialized JSON version
  19571. * @param serializationObject defines the JSON object to read from
  19572. * @param scene defines the hosting scene
  19573. * @param rootUrl defines the rootUrl for data loading
  19574. * @returns a new SubEmitter
  19575. */
  19576. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19577. /** Release associated resources */
  19578. dispose(): void;
  19579. }
  19580. }
  19581. declare module BABYLON {
  19582. /** @hidden */
  19583. export var imageProcessingDeclaration: {
  19584. name: string;
  19585. shader: string;
  19586. };
  19587. }
  19588. declare module BABYLON {
  19589. /** @hidden */
  19590. export var imageProcessingFunctions: {
  19591. name: string;
  19592. shader: string;
  19593. };
  19594. }
  19595. declare module BABYLON {
  19596. /** @hidden */
  19597. export var particlesPixelShader: {
  19598. name: string;
  19599. shader: string;
  19600. };
  19601. }
  19602. declare module BABYLON {
  19603. /** @hidden */
  19604. export var particlesVertexShader: {
  19605. name: string;
  19606. shader: string;
  19607. };
  19608. }
  19609. declare module BABYLON {
  19610. /**
  19611. * This represents a particle system in Babylon.
  19612. * 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.
  19613. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19614. * @example https://doc.babylonjs.com/babylon101/particles
  19615. */
  19616. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19617. /**
  19618. * Billboard mode will only apply to Y axis
  19619. */
  19620. static readonly BILLBOARDMODE_Y: number;
  19621. /**
  19622. * Billboard mode will apply to all axes
  19623. */
  19624. static readonly BILLBOARDMODE_ALL: number;
  19625. /**
  19626. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  19627. */
  19628. static readonly BILLBOARDMODE_STRETCHED: number;
  19629. /**
  19630. * This function can be defined to provide custom update for active particles.
  19631. * This function will be called instead of regular update (age, position, color, etc.).
  19632. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19633. */
  19634. updateFunction: (particles: Particle[]) => void;
  19635. private _emitterWorldMatrix;
  19636. /**
  19637. * This function can be defined to specify initial direction for every new particle.
  19638. * It by default use the emitterType defined function
  19639. */
  19640. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19641. /**
  19642. * This function can be defined to specify initial position for every new particle.
  19643. * It by default use the emitterType defined function
  19644. */
  19645. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19646. /**
  19647. * @hidden
  19648. */
  19649. _inheritedVelocityOffset: Vector3;
  19650. /**
  19651. * An event triggered when the system is disposed
  19652. */
  19653. onDisposeObservable: Observable<ParticleSystem>;
  19654. private _onDisposeObserver;
  19655. /**
  19656. * Sets a callback that will be triggered when the system is disposed
  19657. */
  19658. onDispose: () => void;
  19659. private _particles;
  19660. private _epsilon;
  19661. private _capacity;
  19662. private _stockParticles;
  19663. private _newPartsExcess;
  19664. private _vertexData;
  19665. private _vertexBuffer;
  19666. private _vertexBuffers;
  19667. private _spriteBuffer;
  19668. private _indexBuffer;
  19669. private _effect;
  19670. private _customEffect;
  19671. private _cachedDefines;
  19672. private _scaledColorStep;
  19673. private _colorDiff;
  19674. private _scaledDirection;
  19675. private _scaledGravity;
  19676. private _currentRenderId;
  19677. private _alive;
  19678. private _useInstancing;
  19679. private _started;
  19680. private _stopped;
  19681. private _actualFrame;
  19682. private _scaledUpdateSpeed;
  19683. private _vertexBufferSize;
  19684. /** @hidden */
  19685. _currentEmitRateGradient: Nullable<FactorGradient>;
  19686. /** @hidden */
  19687. _currentEmitRate1: number;
  19688. /** @hidden */
  19689. _currentEmitRate2: number;
  19690. /** @hidden */
  19691. _currentStartSizeGradient: Nullable<FactorGradient>;
  19692. /** @hidden */
  19693. _currentStartSize1: number;
  19694. /** @hidden */
  19695. _currentStartSize2: number;
  19696. private readonly _rawTextureWidth;
  19697. private _rampGradientsTexture;
  19698. private _useRampGradients;
  19699. /** Gets or sets a boolean indicating that ramp gradients must be used
  19700. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19701. */
  19702. useRampGradients: boolean;
  19703. /**
  19704. * 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.
  19705. * 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: [])
  19706. */
  19707. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  19708. private _subEmitters;
  19709. /**
  19710. * @hidden
  19711. * If the particle systems emitter should be disposed when the particle system is disposed
  19712. */
  19713. _disposeEmitterOnDispose: boolean;
  19714. /**
  19715. * The current active Sub-systems, this property is used by the root particle system only.
  19716. */
  19717. activeSubSystems: Array<ParticleSystem>;
  19718. private _rootParticleSystem;
  19719. /**
  19720. * Gets the current list of active particles
  19721. */
  19722. readonly particles: Particle[];
  19723. /**
  19724. * Returns the string "ParticleSystem"
  19725. * @returns a string containing the class name
  19726. */
  19727. getClassName(): string;
  19728. /**
  19729. * Instantiates a particle system.
  19730. * 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.
  19731. * @param name The name of the particle system
  19732. * @param capacity The max number of particles alive at the same time
  19733. * @param scene The scene the particle system belongs to
  19734. * @param customEffect a custom effect used to change the way particles are rendered by default
  19735. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19736. * @param epsilon Offset used to render the particles
  19737. */
  19738. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19739. private _addFactorGradient;
  19740. private _removeFactorGradient;
  19741. /**
  19742. * Adds a new life time gradient
  19743. * @param gradient defines the gradient to use (between 0 and 1)
  19744. * @param factor defines the life time factor to affect to the specified gradient
  19745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19746. * @returns the current particle system
  19747. */
  19748. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19749. /**
  19750. * Remove a specific life time gradient
  19751. * @param gradient defines the gradient to remove
  19752. * @returns the current particle system
  19753. */
  19754. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19755. /**
  19756. * Adds a new size gradient
  19757. * @param gradient defines the gradient to use (between 0 and 1)
  19758. * @param factor defines the size factor to affect to the specified gradient
  19759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19760. * @returns the current particle system
  19761. */
  19762. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19763. /**
  19764. * Remove a specific size gradient
  19765. * @param gradient defines the gradient to remove
  19766. * @returns the current particle system
  19767. */
  19768. removeSizeGradient(gradient: number): IParticleSystem;
  19769. /**
  19770. * Adds a new color remap gradient
  19771. * @param gradient defines the gradient to use (between 0 and 1)
  19772. * @param min defines the color remap minimal range
  19773. * @param max defines the color remap maximal range
  19774. * @returns the current particle system
  19775. */
  19776. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19777. /**
  19778. * Remove a specific color remap gradient
  19779. * @param gradient defines the gradient to remove
  19780. * @returns the current particle system
  19781. */
  19782. removeColorRemapGradient(gradient: number): IParticleSystem;
  19783. /**
  19784. * Adds a new alpha remap gradient
  19785. * @param gradient defines the gradient to use (between 0 and 1)
  19786. * @param min defines the alpha remap minimal range
  19787. * @param max defines the alpha remap maximal range
  19788. * @returns the current particle system
  19789. */
  19790. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19791. /**
  19792. * Remove a specific alpha remap gradient
  19793. * @param gradient defines the gradient to remove
  19794. * @returns the current particle system
  19795. */
  19796. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  19797. /**
  19798. * Adds a new angular speed gradient
  19799. * @param gradient defines the gradient to use (between 0 and 1)
  19800. * @param factor defines the angular speed to affect to the specified gradient
  19801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19802. * @returns the current particle system
  19803. */
  19804. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19805. /**
  19806. * Remove a specific angular speed gradient
  19807. * @param gradient defines the gradient to remove
  19808. * @returns the current particle system
  19809. */
  19810. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19811. /**
  19812. * Adds a new velocity gradient
  19813. * @param gradient defines the gradient to use (between 0 and 1)
  19814. * @param factor defines the velocity to affect to the specified gradient
  19815. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19816. * @returns the current particle system
  19817. */
  19818. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19819. /**
  19820. * Remove a specific velocity gradient
  19821. * @param gradient defines the gradient to remove
  19822. * @returns the current particle system
  19823. */
  19824. removeVelocityGradient(gradient: number): IParticleSystem;
  19825. /**
  19826. * Adds a new limit velocity gradient
  19827. * @param gradient defines the gradient to use (between 0 and 1)
  19828. * @param factor defines the limit velocity value to affect to the specified gradient
  19829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19830. * @returns the current particle system
  19831. */
  19832. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19833. /**
  19834. * Remove a specific limit velocity gradient
  19835. * @param gradient defines the gradient to remove
  19836. * @returns the current particle system
  19837. */
  19838. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19839. /**
  19840. * Adds a new drag gradient
  19841. * @param gradient defines the gradient to use (between 0 and 1)
  19842. * @param factor defines the drag value to affect to the specified gradient
  19843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19844. * @returns the current particle system
  19845. */
  19846. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19847. /**
  19848. * Remove a specific drag gradient
  19849. * @param gradient defines the gradient to remove
  19850. * @returns the current particle system
  19851. */
  19852. removeDragGradient(gradient: number): IParticleSystem;
  19853. /**
  19854. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19855. * @param gradient defines the gradient to use (between 0 and 1)
  19856. * @param factor defines the emit rate value to affect to the specified gradient
  19857. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19858. * @returns the current particle system
  19859. */
  19860. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19861. /**
  19862. * Remove a specific emit rate gradient
  19863. * @param gradient defines the gradient to remove
  19864. * @returns the current particle system
  19865. */
  19866. removeEmitRateGradient(gradient: number): IParticleSystem;
  19867. /**
  19868. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19869. * @param gradient defines the gradient to use (between 0 and 1)
  19870. * @param factor defines the start size value to affect to the specified gradient
  19871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19872. * @returns the current particle system
  19873. */
  19874. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19875. /**
  19876. * Remove a specific start size gradient
  19877. * @param gradient defines the gradient to remove
  19878. * @returns the current particle system
  19879. */
  19880. removeStartSizeGradient(gradient: number): IParticleSystem;
  19881. private _createRampGradientTexture;
  19882. /**
  19883. * Gets the current list of ramp gradients.
  19884. * You must use addRampGradient and removeRampGradient to udpate this list
  19885. * @returns the list of ramp gradients
  19886. */
  19887. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19888. /**
  19889. * Adds a new ramp gradient used to remap particle colors
  19890. * @param gradient defines the gradient to use (between 0 and 1)
  19891. * @param color defines the color to affect to the specified gradient
  19892. * @returns the current particle system
  19893. */
  19894. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  19895. /**
  19896. * Remove a specific ramp gradient
  19897. * @param gradient defines the gradient to remove
  19898. * @returns the current particle system
  19899. */
  19900. removeRampGradient(gradient: number): ParticleSystem;
  19901. /**
  19902. * Adds a new color gradient
  19903. * @param gradient defines the gradient to use (between 0 and 1)
  19904. * @param color1 defines the color to affect to the specified gradient
  19905. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19906. * @returns this particle system
  19907. */
  19908. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19909. /**
  19910. * Remove a specific color gradient
  19911. * @param gradient defines the gradient to remove
  19912. * @returns this particle system
  19913. */
  19914. removeColorGradient(gradient: number): IParticleSystem;
  19915. private _fetchR;
  19916. protected _reset(): void;
  19917. private _resetEffect;
  19918. private _createVertexBuffers;
  19919. private _createIndexBuffer;
  19920. /**
  19921. * Gets the maximum number of particles active at the same time.
  19922. * @returns The max number of active particles.
  19923. */
  19924. getCapacity(): number;
  19925. /**
  19926. * Gets whether there are still active particles in the system.
  19927. * @returns True if it is alive, otherwise false.
  19928. */
  19929. isAlive(): boolean;
  19930. /**
  19931. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19932. * @returns True if it has been started, otherwise false.
  19933. */
  19934. isStarted(): boolean;
  19935. private _prepareSubEmitterInternalArray;
  19936. /**
  19937. * Starts the particle system and begins to emit
  19938. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  19939. */
  19940. start(delay?: number): void;
  19941. /**
  19942. * Stops the particle system.
  19943. * @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.
  19944. */
  19945. stop(stopSubEmitters?: boolean): void;
  19946. /**
  19947. * Remove all active particles
  19948. */
  19949. reset(): void;
  19950. /**
  19951. * @hidden (for internal use only)
  19952. */
  19953. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19954. /**
  19955. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19956. * Its lifetime will start back at 0.
  19957. */
  19958. recycleParticle: (particle: Particle) => void;
  19959. private _stopSubEmitters;
  19960. private _createParticle;
  19961. private _removeFromRoot;
  19962. private _emitFromParticle;
  19963. private _update;
  19964. /** @hidden */
  19965. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  19966. /** @hidden */
  19967. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  19968. /** @hidden */
  19969. private _getEffect;
  19970. /**
  19971. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19972. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  19973. */
  19974. animate(preWarmOnly?: boolean): void;
  19975. private _appendParticleVertices;
  19976. /**
  19977. * Rebuilds the particle system.
  19978. */
  19979. rebuild(): void;
  19980. /**
  19981. * Is this system ready to be used/rendered
  19982. * @return true if the system is ready
  19983. */
  19984. isReady(): boolean;
  19985. private _render;
  19986. /**
  19987. * Renders the particle system in its current state.
  19988. * @returns the current number of particles
  19989. */
  19990. render(): number;
  19991. /**
  19992. * Disposes the particle system and free the associated resources
  19993. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19994. */
  19995. dispose(disposeTexture?: boolean): void;
  19996. /**
  19997. * Clones the particle system.
  19998. * @param name The name of the cloned object
  19999. * @param newEmitter The new emitter to use
  20000. * @returns the cloned particle system
  20001. */
  20002. clone(name: string, newEmitter: any): ParticleSystem;
  20003. /**
  20004. * Serializes the particle system to a JSON object.
  20005. * @returns the JSON object
  20006. */
  20007. serialize(): any;
  20008. /** @hidden */
  20009. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20010. /** @hidden */
  20011. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20012. /**
  20013. * Parses a JSON object to create a particle system.
  20014. * @param parsedParticleSystem The JSON object to parse
  20015. * @param scene The scene to create the particle system in
  20016. * @param rootUrl The root url to use to load external dependencies like texture
  20017. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20018. * @returns the Parsed particle system
  20019. */
  20020. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20021. }
  20022. }
  20023. declare module BABYLON {
  20024. /**
  20025. * A particle represents one of the element emitted by a particle system.
  20026. * This is mainly define by its coordinates, direction, velocity and age.
  20027. */
  20028. export class Particle {
  20029. /**
  20030. * The particle system the particle belongs to.
  20031. */
  20032. particleSystem: ParticleSystem;
  20033. private static _Count;
  20034. /**
  20035. * Unique ID of the particle
  20036. */
  20037. id: number;
  20038. /**
  20039. * The world position of the particle in the scene.
  20040. */
  20041. position: Vector3;
  20042. /**
  20043. * The world direction of the particle in the scene.
  20044. */
  20045. direction: Vector3;
  20046. /**
  20047. * The color of the particle.
  20048. */
  20049. color: Color4;
  20050. /**
  20051. * The color change of the particle per step.
  20052. */
  20053. colorStep: Color4;
  20054. /**
  20055. * Defines how long will the life of the particle be.
  20056. */
  20057. lifeTime: number;
  20058. /**
  20059. * The current age of the particle.
  20060. */
  20061. age: number;
  20062. /**
  20063. * The current size of the particle.
  20064. */
  20065. size: number;
  20066. /**
  20067. * The current scale of the particle.
  20068. */
  20069. scale: Vector2;
  20070. /**
  20071. * The current angle of the particle.
  20072. */
  20073. angle: number;
  20074. /**
  20075. * Defines how fast is the angle changing.
  20076. */
  20077. angularSpeed: number;
  20078. /**
  20079. * Defines the cell index used by the particle to be rendered from a sprite.
  20080. */
  20081. cellIndex: number;
  20082. /**
  20083. * The information required to support color remapping
  20084. */
  20085. remapData: Vector4;
  20086. /** @hidden */
  20087. _randomCellOffset?: number;
  20088. /** @hidden */
  20089. _initialDirection: Nullable<Vector3>;
  20090. /** @hidden */
  20091. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20092. /** @hidden */
  20093. _initialStartSpriteCellID: number;
  20094. /** @hidden */
  20095. _initialEndSpriteCellID: number;
  20096. /** @hidden */
  20097. _currentColorGradient: Nullable<ColorGradient>;
  20098. /** @hidden */
  20099. _currentColor1: Color4;
  20100. /** @hidden */
  20101. _currentColor2: Color4;
  20102. /** @hidden */
  20103. _currentSizeGradient: Nullable<FactorGradient>;
  20104. /** @hidden */
  20105. _currentSize1: number;
  20106. /** @hidden */
  20107. _currentSize2: number;
  20108. /** @hidden */
  20109. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20110. /** @hidden */
  20111. _currentAngularSpeed1: number;
  20112. /** @hidden */
  20113. _currentAngularSpeed2: number;
  20114. /** @hidden */
  20115. _currentVelocityGradient: Nullable<FactorGradient>;
  20116. /** @hidden */
  20117. _currentVelocity1: number;
  20118. /** @hidden */
  20119. _currentVelocity2: number;
  20120. /** @hidden */
  20121. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20122. /** @hidden */
  20123. _currentLimitVelocity1: number;
  20124. /** @hidden */
  20125. _currentLimitVelocity2: number;
  20126. /** @hidden */
  20127. _currentDragGradient: Nullable<FactorGradient>;
  20128. /** @hidden */
  20129. _currentDrag1: number;
  20130. /** @hidden */
  20131. _currentDrag2: number;
  20132. /** @hidden */
  20133. _randomNoiseCoordinates1: Vector3;
  20134. /** @hidden */
  20135. _randomNoiseCoordinates2: Vector3;
  20136. /**
  20137. * Creates a new instance Particle
  20138. * @param particleSystem the particle system the particle belongs to
  20139. */
  20140. constructor(
  20141. /**
  20142. * The particle system the particle belongs to.
  20143. */
  20144. particleSystem: ParticleSystem);
  20145. private updateCellInfoFromSystem;
  20146. /**
  20147. * Defines how the sprite cell index is updated for the particle
  20148. */
  20149. updateCellIndex(): void;
  20150. /** @hidden */
  20151. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20152. /** @hidden */
  20153. _inheritParticleInfoToSubEmitters(): void;
  20154. /** @hidden */
  20155. _reset(): void;
  20156. /**
  20157. * Copy the properties of particle to another one.
  20158. * @param other the particle to copy the information to.
  20159. */
  20160. copyTo(other: Particle): void;
  20161. }
  20162. }
  20163. declare module BABYLON {
  20164. /**
  20165. * Particle emitter represents a volume emitting particles.
  20166. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20167. */
  20168. export interface IParticleEmitterType {
  20169. /**
  20170. * Called by the particle System when the direction is computed for the created particle.
  20171. * @param worldMatrix is the world matrix of the particle system
  20172. * @param directionToUpdate is the direction vector to update with the result
  20173. * @param particle is the particle we are computed the direction for
  20174. */
  20175. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20176. /**
  20177. * Called by the particle System when the position is computed for the created particle.
  20178. * @param worldMatrix is the world matrix of the particle system
  20179. * @param positionToUpdate is the position vector to update with the result
  20180. * @param particle is the particle we are computed the position for
  20181. */
  20182. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20183. /**
  20184. * Clones the current emitter and returns a copy of it
  20185. * @returns the new emitter
  20186. */
  20187. clone(): IParticleEmitterType;
  20188. /**
  20189. * Called by the GPUParticleSystem to setup the update shader
  20190. * @param effect defines the update shader
  20191. */
  20192. applyToShader(effect: Effect): void;
  20193. /**
  20194. * Returns a string to use to update the GPU particles update shader
  20195. * @returns the effect defines string
  20196. */
  20197. getEffectDefines(): string;
  20198. /**
  20199. * Returns a string representing the class name
  20200. * @returns a string containing the class name
  20201. */
  20202. getClassName(): string;
  20203. /**
  20204. * Serializes the particle system to a JSON object.
  20205. * @returns the JSON object
  20206. */
  20207. serialize(): any;
  20208. /**
  20209. * Parse properties from a JSON object
  20210. * @param serializationObject defines the JSON object
  20211. */
  20212. parse(serializationObject: any): void;
  20213. }
  20214. }
  20215. declare module BABYLON {
  20216. /**
  20217. * Particle emitter emitting particles from the inside of a box.
  20218. * It emits the particles randomly between 2 given directions.
  20219. */
  20220. export class BoxParticleEmitter implements IParticleEmitterType {
  20221. /**
  20222. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20223. */
  20224. direction1: Vector3;
  20225. /**
  20226. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20227. */
  20228. direction2: Vector3;
  20229. /**
  20230. * 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.
  20231. */
  20232. minEmitBox: Vector3;
  20233. /**
  20234. * 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.
  20235. */
  20236. maxEmitBox: Vector3;
  20237. /**
  20238. * Creates a new instance BoxParticleEmitter
  20239. */
  20240. constructor();
  20241. /**
  20242. * Called by the particle System when the direction is computed for the created particle.
  20243. * @param worldMatrix is the world matrix of the particle system
  20244. * @param directionToUpdate is the direction vector to update with the result
  20245. * @param particle is the particle we are computed the direction for
  20246. */
  20247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20248. /**
  20249. * Called by the particle System when the position is computed for the created particle.
  20250. * @param worldMatrix is the world matrix of the particle system
  20251. * @param positionToUpdate is the position vector to update with the result
  20252. * @param particle is the particle we are computed the position for
  20253. */
  20254. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20255. /**
  20256. * Clones the current emitter and returns a copy of it
  20257. * @returns the new emitter
  20258. */
  20259. clone(): BoxParticleEmitter;
  20260. /**
  20261. * Called by the GPUParticleSystem to setup the update shader
  20262. * @param effect defines the update shader
  20263. */
  20264. applyToShader(effect: Effect): void;
  20265. /**
  20266. * Returns a string to use to update the GPU particles update shader
  20267. * @returns a string containng the defines string
  20268. */
  20269. getEffectDefines(): string;
  20270. /**
  20271. * Returns the string "BoxParticleEmitter"
  20272. * @returns a string containing the class name
  20273. */
  20274. getClassName(): string;
  20275. /**
  20276. * Serializes the particle system to a JSON object.
  20277. * @returns the JSON object
  20278. */
  20279. serialize(): any;
  20280. /**
  20281. * Parse properties from a JSON object
  20282. * @param serializationObject defines the JSON object
  20283. */
  20284. parse(serializationObject: any): void;
  20285. }
  20286. }
  20287. declare module BABYLON {
  20288. /**
  20289. * Particle emitter emitting particles from the inside of a cone.
  20290. * It emits the particles alongside the cone volume from the base to the particle.
  20291. * The emission direction might be randomized.
  20292. */
  20293. export class ConeParticleEmitter implements IParticleEmitterType {
  20294. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20295. directionRandomizer: number;
  20296. private _radius;
  20297. private _angle;
  20298. private _height;
  20299. /**
  20300. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20301. */
  20302. radiusRange: number;
  20303. /**
  20304. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20305. */
  20306. heightRange: number;
  20307. /**
  20308. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20309. */
  20310. emitFromSpawnPointOnly: boolean;
  20311. /**
  20312. * Gets or sets the radius of the emission cone
  20313. */
  20314. radius: number;
  20315. /**
  20316. * Gets or sets the angle of the emission cone
  20317. */
  20318. angle: number;
  20319. private _buildHeight;
  20320. /**
  20321. * Creates a new instance ConeParticleEmitter
  20322. * @param radius the radius of the emission cone (1 by default)
  20323. * @param angle the cone base angle (PI by default)
  20324. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20325. */
  20326. constructor(radius?: number, angle?: number,
  20327. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20328. directionRandomizer?: number);
  20329. /**
  20330. * Called by the particle System when the direction is computed for the created particle.
  20331. * @param worldMatrix is the world matrix of the particle system
  20332. * @param directionToUpdate is the direction vector to update with the result
  20333. * @param particle is the particle we are computed the direction for
  20334. */
  20335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20336. /**
  20337. * Called by the particle System when the position is computed for the created particle.
  20338. * @param worldMatrix is the world matrix of the particle system
  20339. * @param positionToUpdate is the position vector to update with the result
  20340. * @param particle is the particle we are computed the position for
  20341. */
  20342. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20343. /**
  20344. * Clones the current emitter and returns a copy of it
  20345. * @returns the new emitter
  20346. */
  20347. clone(): ConeParticleEmitter;
  20348. /**
  20349. * Called by the GPUParticleSystem to setup the update shader
  20350. * @param effect defines the update shader
  20351. */
  20352. applyToShader(effect: Effect): void;
  20353. /**
  20354. * Returns a string to use to update the GPU particles update shader
  20355. * @returns a string containng the defines string
  20356. */
  20357. getEffectDefines(): string;
  20358. /**
  20359. * Returns the string "ConeParticleEmitter"
  20360. * @returns a string containing the class name
  20361. */
  20362. getClassName(): string;
  20363. /**
  20364. * Serializes the particle system to a JSON object.
  20365. * @returns the JSON object
  20366. */
  20367. serialize(): any;
  20368. /**
  20369. * Parse properties from a JSON object
  20370. * @param serializationObject defines the JSON object
  20371. */
  20372. parse(serializationObject: any): void;
  20373. }
  20374. }
  20375. declare module BABYLON {
  20376. /**
  20377. * Particle emitter emitting particles from the inside of a cylinder.
  20378. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20379. */
  20380. export class CylinderParticleEmitter implements IParticleEmitterType {
  20381. /**
  20382. * The radius of the emission cylinder.
  20383. */
  20384. radius: number;
  20385. /**
  20386. * The height of the emission cylinder.
  20387. */
  20388. height: number;
  20389. /**
  20390. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20391. */
  20392. radiusRange: number;
  20393. /**
  20394. * How much to randomize the particle direction [0-1].
  20395. */
  20396. directionRandomizer: number;
  20397. /**
  20398. * Creates a new instance CylinderParticleEmitter
  20399. * @param radius the radius of the emission cylinder (1 by default)
  20400. * @param height the height of the emission cylinder (1 by default)
  20401. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20402. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20403. */
  20404. constructor(
  20405. /**
  20406. * The radius of the emission cylinder.
  20407. */
  20408. radius?: number,
  20409. /**
  20410. * The height of the emission cylinder.
  20411. */
  20412. height?: number,
  20413. /**
  20414. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20415. */
  20416. radiusRange?: number,
  20417. /**
  20418. * How much to randomize the particle direction [0-1].
  20419. */
  20420. directionRandomizer?: number);
  20421. /**
  20422. * Called by the particle System when the direction is computed for the created particle.
  20423. * @param worldMatrix is the world matrix of the particle system
  20424. * @param directionToUpdate is the direction vector to update with the result
  20425. * @param particle is the particle we are computed the direction for
  20426. */
  20427. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20428. /**
  20429. * Called by the particle System when the position is computed for the created particle.
  20430. * @param worldMatrix is the world matrix of the particle system
  20431. * @param positionToUpdate is the position vector to update with the result
  20432. * @param particle is the particle we are computed the position for
  20433. */
  20434. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20435. /**
  20436. * Clones the current emitter and returns a copy of it
  20437. * @returns the new emitter
  20438. */
  20439. clone(): CylinderParticleEmitter;
  20440. /**
  20441. * Called by the GPUParticleSystem to setup the update shader
  20442. * @param effect defines the update shader
  20443. */
  20444. applyToShader(effect: Effect): void;
  20445. /**
  20446. * Returns a string to use to update the GPU particles update shader
  20447. * @returns a string containng the defines string
  20448. */
  20449. getEffectDefines(): string;
  20450. /**
  20451. * Returns the string "CylinderParticleEmitter"
  20452. * @returns a string containing the class name
  20453. */
  20454. getClassName(): string;
  20455. /**
  20456. * Serializes the particle system to a JSON object.
  20457. * @returns the JSON object
  20458. */
  20459. serialize(): any;
  20460. /**
  20461. * Parse properties from a JSON object
  20462. * @param serializationObject defines the JSON object
  20463. */
  20464. parse(serializationObject: any): void;
  20465. }
  20466. /**
  20467. * Particle emitter emitting particles from the inside of a cylinder.
  20468. * It emits the particles randomly between two vectors.
  20469. */
  20470. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20471. /**
  20472. * The min limit of the emission direction.
  20473. */
  20474. direction1: Vector3;
  20475. /**
  20476. * The max limit of the emission direction.
  20477. */
  20478. direction2: Vector3;
  20479. /**
  20480. * Creates a new instance CylinderDirectedParticleEmitter
  20481. * @param radius the radius of the emission cylinder (1 by default)
  20482. * @param height the height of the emission cylinder (1 by default)
  20483. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20484. * @param direction1 the min limit of the emission direction (up vector by default)
  20485. * @param direction2 the max limit of the emission direction (up vector by default)
  20486. */
  20487. constructor(radius?: number, height?: number, radiusRange?: number,
  20488. /**
  20489. * The min limit of the emission direction.
  20490. */
  20491. direction1?: Vector3,
  20492. /**
  20493. * The max limit of the emission direction.
  20494. */
  20495. direction2?: Vector3);
  20496. /**
  20497. * Called by the particle System when the direction is computed for the created particle.
  20498. * @param worldMatrix is the world matrix of the particle system
  20499. * @param directionToUpdate is the direction vector to update with the result
  20500. * @param particle is the particle we are computed the direction for
  20501. */
  20502. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20503. /**
  20504. * Clones the current emitter and returns a copy of it
  20505. * @returns the new emitter
  20506. */
  20507. clone(): CylinderDirectedParticleEmitter;
  20508. /**
  20509. * Called by the GPUParticleSystem to setup the update shader
  20510. * @param effect defines the update shader
  20511. */
  20512. applyToShader(effect: Effect): void;
  20513. /**
  20514. * Returns a string to use to update the GPU particles update shader
  20515. * @returns a string containng the defines string
  20516. */
  20517. getEffectDefines(): string;
  20518. /**
  20519. * Returns the string "CylinderDirectedParticleEmitter"
  20520. * @returns a string containing the class name
  20521. */
  20522. getClassName(): string;
  20523. /**
  20524. * Serializes the particle system to a JSON object.
  20525. * @returns the JSON object
  20526. */
  20527. serialize(): any;
  20528. /**
  20529. * Parse properties from a JSON object
  20530. * @param serializationObject defines the JSON object
  20531. */
  20532. parse(serializationObject: any): void;
  20533. }
  20534. }
  20535. declare module BABYLON {
  20536. /**
  20537. * Particle emitter emitting particles from the inside of a hemisphere.
  20538. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20539. */
  20540. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20541. /**
  20542. * The radius of the emission hemisphere.
  20543. */
  20544. radius: number;
  20545. /**
  20546. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20547. */
  20548. radiusRange: number;
  20549. /**
  20550. * How much to randomize the particle direction [0-1].
  20551. */
  20552. directionRandomizer: number;
  20553. /**
  20554. * Creates a new instance HemisphericParticleEmitter
  20555. * @param radius the radius of the emission hemisphere (1 by default)
  20556. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20557. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20558. */
  20559. constructor(
  20560. /**
  20561. * The radius of the emission hemisphere.
  20562. */
  20563. radius?: number,
  20564. /**
  20565. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20566. */
  20567. radiusRange?: number,
  20568. /**
  20569. * How much to randomize the particle direction [0-1].
  20570. */
  20571. directionRandomizer?: number);
  20572. /**
  20573. * Called by the particle System when the direction is computed for the created particle.
  20574. * @param worldMatrix is the world matrix of the particle system
  20575. * @param directionToUpdate is the direction vector to update with the result
  20576. * @param particle is the particle we are computed the direction for
  20577. */
  20578. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20579. /**
  20580. * Called by the particle System when the position is computed for the created particle.
  20581. * @param worldMatrix is the world matrix of the particle system
  20582. * @param positionToUpdate is the position vector to update with the result
  20583. * @param particle is the particle we are computed the position for
  20584. */
  20585. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20586. /**
  20587. * Clones the current emitter and returns a copy of it
  20588. * @returns the new emitter
  20589. */
  20590. clone(): HemisphericParticleEmitter;
  20591. /**
  20592. * Called by the GPUParticleSystem to setup the update shader
  20593. * @param effect defines the update shader
  20594. */
  20595. applyToShader(effect: Effect): void;
  20596. /**
  20597. * Returns a string to use to update the GPU particles update shader
  20598. * @returns a string containng the defines string
  20599. */
  20600. getEffectDefines(): string;
  20601. /**
  20602. * Returns the string "HemisphericParticleEmitter"
  20603. * @returns a string containing the class name
  20604. */
  20605. getClassName(): string;
  20606. /**
  20607. * Serializes the particle system to a JSON object.
  20608. * @returns the JSON object
  20609. */
  20610. serialize(): any;
  20611. /**
  20612. * Parse properties from a JSON object
  20613. * @param serializationObject defines the JSON object
  20614. */
  20615. parse(serializationObject: any): void;
  20616. }
  20617. }
  20618. declare module BABYLON {
  20619. /**
  20620. * Particle emitter emitting particles from a point.
  20621. * It emits the particles randomly between 2 given directions.
  20622. */
  20623. export class PointParticleEmitter implements IParticleEmitterType {
  20624. /**
  20625. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20626. */
  20627. direction1: Vector3;
  20628. /**
  20629. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20630. */
  20631. direction2: Vector3;
  20632. /**
  20633. * Creates a new instance PointParticleEmitter
  20634. */
  20635. constructor();
  20636. /**
  20637. * Called by the particle System when the direction is computed for the created particle.
  20638. * @param worldMatrix is the world matrix of the particle system
  20639. * @param directionToUpdate is the direction vector to update with the result
  20640. * @param particle is the particle we are computed the direction for
  20641. */
  20642. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20643. /**
  20644. * Called by the particle System when the position is computed for the created particle.
  20645. * @param worldMatrix is the world matrix of the particle system
  20646. * @param positionToUpdate is the position vector to update with the result
  20647. * @param particle is the particle we are computed the position for
  20648. */
  20649. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20650. /**
  20651. * Clones the current emitter and returns a copy of it
  20652. * @returns the new emitter
  20653. */
  20654. clone(): PointParticleEmitter;
  20655. /**
  20656. * Called by the GPUParticleSystem to setup the update shader
  20657. * @param effect defines the update shader
  20658. */
  20659. applyToShader(effect: Effect): void;
  20660. /**
  20661. * Returns a string to use to update the GPU particles update shader
  20662. * @returns a string containng the defines string
  20663. */
  20664. getEffectDefines(): string;
  20665. /**
  20666. * Returns the string "PointParticleEmitter"
  20667. * @returns a string containing the class name
  20668. */
  20669. getClassName(): string;
  20670. /**
  20671. * Serializes the particle system to a JSON object.
  20672. * @returns the JSON object
  20673. */
  20674. serialize(): any;
  20675. /**
  20676. * Parse properties from a JSON object
  20677. * @param serializationObject defines the JSON object
  20678. */
  20679. parse(serializationObject: any): void;
  20680. }
  20681. }
  20682. declare module BABYLON {
  20683. /**
  20684. * Particle emitter emitting particles from the inside of a sphere.
  20685. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  20686. */
  20687. export class SphereParticleEmitter implements IParticleEmitterType {
  20688. /**
  20689. * The radius of the emission sphere.
  20690. */
  20691. radius: number;
  20692. /**
  20693. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20694. */
  20695. radiusRange: number;
  20696. /**
  20697. * How much to randomize the particle direction [0-1].
  20698. */
  20699. directionRandomizer: number;
  20700. /**
  20701. * Creates a new instance SphereParticleEmitter
  20702. * @param radius the radius of the emission sphere (1 by default)
  20703. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20704. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20705. */
  20706. constructor(
  20707. /**
  20708. * The radius of the emission sphere.
  20709. */
  20710. radius?: number,
  20711. /**
  20712. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20713. */
  20714. radiusRange?: number,
  20715. /**
  20716. * How much to randomize the particle direction [0-1].
  20717. */
  20718. directionRandomizer?: number);
  20719. /**
  20720. * Called by the particle System when the direction is computed for the created particle.
  20721. * @param worldMatrix is the world matrix of the particle system
  20722. * @param directionToUpdate is the direction vector to update with the result
  20723. * @param particle is the particle we are computed the direction for
  20724. */
  20725. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20726. /**
  20727. * Called by the particle System when the position is computed for the created particle.
  20728. * @param worldMatrix is the world matrix of the particle system
  20729. * @param positionToUpdate is the position vector to update with the result
  20730. * @param particle is the particle we are computed the position for
  20731. */
  20732. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20733. /**
  20734. * Clones the current emitter and returns a copy of it
  20735. * @returns the new emitter
  20736. */
  20737. clone(): SphereParticleEmitter;
  20738. /**
  20739. * Called by the GPUParticleSystem to setup the update shader
  20740. * @param effect defines the update shader
  20741. */
  20742. applyToShader(effect: Effect): void;
  20743. /**
  20744. * Returns a string to use to update the GPU particles update shader
  20745. * @returns a string containng the defines string
  20746. */
  20747. getEffectDefines(): string;
  20748. /**
  20749. * Returns the string "SphereParticleEmitter"
  20750. * @returns a string containing the class name
  20751. */
  20752. getClassName(): string;
  20753. /**
  20754. * Serializes the particle system to a JSON object.
  20755. * @returns the JSON object
  20756. */
  20757. serialize(): any;
  20758. /**
  20759. * Parse properties from a JSON object
  20760. * @param serializationObject defines the JSON object
  20761. */
  20762. parse(serializationObject: any): void;
  20763. }
  20764. /**
  20765. * Particle emitter emitting particles from the inside of a sphere.
  20766. * It emits the particles randomly between two vectors.
  20767. */
  20768. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  20769. /**
  20770. * The min limit of the emission direction.
  20771. */
  20772. direction1: Vector3;
  20773. /**
  20774. * The max limit of the emission direction.
  20775. */
  20776. direction2: Vector3;
  20777. /**
  20778. * Creates a new instance SphereDirectedParticleEmitter
  20779. * @param radius the radius of the emission sphere (1 by default)
  20780. * @param direction1 the min limit of the emission direction (up vector by default)
  20781. * @param direction2 the max limit of the emission direction (up vector by default)
  20782. */
  20783. constructor(radius?: number,
  20784. /**
  20785. * The min limit of the emission direction.
  20786. */
  20787. direction1?: Vector3,
  20788. /**
  20789. * The max limit of the emission direction.
  20790. */
  20791. direction2?: Vector3);
  20792. /**
  20793. * Called by the particle System when the direction is computed for the created particle.
  20794. * @param worldMatrix is the world matrix of the particle system
  20795. * @param directionToUpdate is the direction vector to update with the result
  20796. * @param particle is the particle we are computed the direction for
  20797. */
  20798. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20799. /**
  20800. * Clones the current emitter and returns a copy of it
  20801. * @returns the new emitter
  20802. */
  20803. clone(): SphereDirectedParticleEmitter;
  20804. /**
  20805. * Called by the GPUParticleSystem to setup the update shader
  20806. * @param effect defines the update shader
  20807. */
  20808. applyToShader(effect: Effect): void;
  20809. /**
  20810. * Returns a string to use to update the GPU particles update shader
  20811. * @returns a string containng the defines string
  20812. */
  20813. getEffectDefines(): string;
  20814. /**
  20815. * Returns the string "SphereDirectedParticleEmitter"
  20816. * @returns a string containing the class name
  20817. */
  20818. getClassName(): string;
  20819. /**
  20820. * Serializes the particle system to a JSON object.
  20821. * @returns the JSON object
  20822. */
  20823. serialize(): any;
  20824. /**
  20825. * Parse properties from a JSON object
  20826. * @param serializationObject defines the JSON object
  20827. */
  20828. parse(serializationObject: any): void;
  20829. }
  20830. }
  20831. declare module BABYLON {
  20832. /**
  20833. * Interface representing a particle system in Babylon.js.
  20834. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  20835. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  20836. */
  20837. export interface IParticleSystem {
  20838. /**
  20839. * List of animations used by the particle system.
  20840. */
  20841. animations: Animation[];
  20842. /**
  20843. * The id of the Particle system.
  20844. */
  20845. id: string;
  20846. /**
  20847. * The name of the Particle system.
  20848. */
  20849. name: string;
  20850. /**
  20851. * The emitter represents the Mesh or position we are attaching the particle system to.
  20852. */
  20853. emitter: Nullable<AbstractMesh | Vector3>;
  20854. /**
  20855. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  20856. */
  20857. isBillboardBased: boolean;
  20858. /**
  20859. * The rendering group used by the Particle system to chose when to render.
  20860. */
  20861. renderingGroupId: number;
  20862. /**
  20863. * The layer mask we are rendering the particles through.
  20864. */
  20865. layerMask: number;
  20866. /**
  20867. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20868. */
  20869. updateSpeed: number;
  20870. /**
  20871. * The amount of time the particle system is running (depends of the overall update speed).
  20872. */
  20873. targetStopDuration: number;
  20874. /**
  20875. * The texture used to render each particle. (this can be a spritesheet)
  20876. */
  20877. particleTexture: Nullable<Texture>;
  20878. /**
  20879. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  20880. */
  20881. blendMode: number;
  20882. /**
  20883. * Minimum life time of emitting particles.
  20884. */
  20885. minLifeTime: number;
  20886. /**
  20887. * Maximum life time of emitting particles.
  20888. */
  20889. maxLifeTime: number;
  20890. /**
  20891. * Minimum Size of emitting particles.
  20892. */
  20893. minSize: number;
  20894. /**
  20895. * Maximum Size of emitting particles.
  20896. */
  20897. maxSize: number;
  20898. /**
  20899. * Minimum scale of emitting particles on X axis.
  20900. */
  20901. minScaleX: number;
  20902. /**
  20903. * Maximum scale of emitting particles on X axis.
  20904. */
  20905. maxScaleX: number;
  20906. /**
  20907. * Minimum scale of emitting particles on Y axis.
  20908. */
  20909. minScaleY: number;
  20910. /**
  20911. * Maximum scale of emitting particles on Y axis.
  20912. */
  20913. maxScaleY: number;
  20914. /**
  20915. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20916. */
  20917. color1: Color4;
  20918. /**
  20919. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20920. */
  20921. color2: Color4;
  20922. /**
  20923. * Color the particle will have at the end of its lifetime.
  20924. */
  20925. colorDead: Color4;
  20926. /**
  20927. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  20928. */
  20929. emitRate: number;
  20930. /**
  20931. * You can use gravity if you want to give an orientation to your particles.
  20932. */
  20933. gravity: Vector3;
  20934. /**
  20935. * Minimum power of emitting particles.
  20936. */
  20937. minEmitPower: number;
  20938. /**
  20939. * Maximum power of emitting particles.
  20940. */
  20941. maxEmitPower: number;
  20942. /**
  20943. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  20944. */
  20945. minAngularSpeed: number;
  20946. /**
  20947. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  20948. */
  20949. maxAngularSpeed: number;
  20950. /**
  20951. * Gets or sets the minimal initial rotation in radians.
  20952. */
  20953. minInitialRotation: number;
  20954. /**
  20955. * Gets or sets the maximal initial rotation in radians.
  20956. */
  20957. maxInitialRotation: number;
  20958. /**
  20959. * The particle emitter type defines the emitter used by the particle system.
  20960. * It can be for example box, sphere, or cone...
  20961. */
  20962. particleEmitterType: Nullable<IParticleEmitterType>;
  20963. /**
  20964. * Defines the delay in milliseconds before starting the system (0 by default)
  20965. */
  20966. startDelay: number;
  20967. /**
  20968. * 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
  20969. */
  20970. preWarmCycles: number;
  20971. /**
  20972. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  20973. */
  20974. preWarmStepOffset: number;
  20975. /**
  20976. * 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)
  20977. */
  20978. spriteCellChangeSpeed: number;
  20979. /**
  20980. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  20981. */
  20982. startSpriteCellID: number;
  20983. /**
  20984. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  20985. */
  20986. endSpriteCellID: number;
  20987. /**
  20988. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  20989. */
  20990. spriteCellWidth: number;
  20991. /**
  20992. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  20993. */
  20994. spriteCellHeight: number;
  20995. /**
  20996. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  20997. */
  20998. spriteRandomStartCell: boolean;
  20999. /**
  21000. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21001. */
  21002. isAnimationSheetEnabled: boolean;
  21003. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21004. translationPivot: Vector2;
  21005. /**
  21006. * Gets or sets a texture used to add random noise to particle positions
  21007. */
  21008. noiseTexture: Nullable<BaseTexture>;
  21009. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21010. noiseStrength: Vector3;
  21011. /**
  21012. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21013. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21014. */
  21015. billboardMode: number;
  21016. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21017. limitVelocityDamping: number;
  21018. /**
  21019. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21020. */
  21021. beginAnimationOnStart: boolean;
  21022. /**
  21023. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21024. */
  21025. beginAnimationFrom: number;
  21026. /**
  21027. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21028. */
  21029. beginAnimationTo: number;
  21030. /**
  21031. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21032. */
  21033. beginAnimationLoop: boolean;
  21034. /**
  21035. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21036. */
  21037. disposeOnStop: boolean;
  21038. /**
  21039. * Gets the maximum number of particles active at the same time.
  21040. * @returns The max number of active particles.
  21041. */
  21042. getCapacity(): number;
  21043. /**
  21044. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21045. * @returns True if it has been started, otherwise false.
  21046. */
  21047. isStarted(): boolean;
  21048. /**
  21049. * Animates the particle system for this frame.
  21050. */
  21051. animate(): void;
  21052. /**
  21053. * Renders the particle system in its current state.
  21054. * @returns the current number of particles
  21055. */
  21056. render(): number;
  21057. /**
  21058. * Dispose the particle system and frees its associated resources.
  21059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21060. */
  21061. dispose(disposeTexture?: boolean): void;
  21062. /**
  21063. * Clones the particle system.
  21064. * @param name The name of the cloned object
  21065. * @param newEmitter The new emitter to use
  21066. * @returns the cloned particle system
  21067. */
  21068. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21069. /**
  21070. * Serializes the particle system to a JSON object.
  21071. * @returns the JSON object
  21072. */
  21073. serialize(): any;
  21074. /**
  21075. * Rebuild the particle system
  21076. */
  21077. rebuild(): void;
  21078. /**
  21079. * Starts the particle system and begins to emit
  21080. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21081. */
  21082. start(delay?: number): void;
  21083. /**
  21084. * Stops the particle system.
  21085. */
  21086. stop(): void;
  21087. /**
  21088. * Remove all active particles
  21089. */
  21090. reset(): void;
  21091. /**
  21092. * Is this system ready to be used/rendered
  21093. * @return true if the system is ready
  21094. */
  21095. isReady(): boolean;
  21096. /**
  21097. * Adds a new color gradient
  21098. * @param gradient defines the gradient to use (between 0 and 1)
  21099. * @param color1 defines the color to affect to the specified gradient
  21100. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21101. * @returns the current particle system
  21102. */
  21103. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21104. /**
  21105. * Remove a specific color gradient
  21106. * @param gradient defines the gradient to remove
  21107. * @returns the current particle system
  21108. */
  21109. removeColorGradient(gradient: number): IParticleSystem;
  21110. /**
  21111. * Adds a new size gradient
  21112. * @param gradient defines the gradient to use (between 0 and 1)
  21113. * @param factor defines the size factor to affect to the specified gradient
  21114. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21115. * @returns the current particle system
  21116. */
  21117. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21118. /**
  21119. * Remove a specific size gradient
  21120. * @param gradient defines the gradient to remove
  21121. * @returns the current particle system
  21122. */
  21123. removeSizeGradient(gradient: number): IParticleSystem;
  21124. /**
  21125. * Gets the current list of color gradients.
  21126. * You must use addColorGradient and removeColorGradient to udpate this list
  21127. * @returns the list of color gradients
  21128. */
  21129. getColorGradients(): Nullable<Array<ColorGradient>>;
  21130. /**
  21131. * Gets the current list of size gradients.
  21132. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21133. * @returns the list of size gradients
  21134. */
  21135. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21136. /**
  21137. * Gets the current list of angular speed gradients.
  21138. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21139. * @returns the list of angular speed gradients
  21140. */
  21141. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21142. /**
  21143. * Adds a new angular speed gradient
  21144. * @param gradient defines the gradient to use (between 0 and 1)
  21145. * @param factor defines the angular speed to affect to the specified gradient
  21146. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21147. * @returns the current particle system
  21148. */
  21149. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21150. /**
  21151. * Remove a specific angular speed gradient
  21152. * @param gradient defines the gradient to remove
  21153. * @returns the current particle system
  21154. */
  21155. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21156. /**
  21157. * Gets the current list of velocity gradients.
  21158. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21159. * @returns the list of velocity gradients
  21160. */
  21161. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21162. /**
  21163. * Adds a new velocity gradient
  21164. * @param gradient defines the gradient to use (between 0 and 1)
  21165. * @param factor defines the velocity to affect to the specified gradient
  21166. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21167. * @returns the current particle system
  21168. */
  21169. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21170. /**
  21171. * Remove a specific velocity gradient
  21172. * @param gradient defines the gradient to remove
  21173. * @returns the current particle system
  21174. */
  21175. removeVelocityGradient(gradient: number): IParticleSystem;
  21176. /**
  21177. * Gets the current list of limit velocity gradients.
  21178. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21179. * @returns the list of limit velocity gradients
  21180. */
  21181. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21182. /**
  21183. * Adds a new limit velocity gradient
  21184. * @param gradient defines the gradient to use (between 0 and 1)
  21185. * @param factor defines the limit velocity to affect to the specified gradient
  21186. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21187. * @returns the current particle system
  21188. */
  21189. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21190. /**
  21191. * Remove a specific limit velocity gradient
  21192. * @param gradient defines the gradient to remove
  21193. * @returns the current particle system
  21194. */
  21195. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21196. /**
  21197. * Adds a new drag gradient
  21198. * @param gradient defines the gradient to use (between 0 and 1)
  21199. * @param factor defines the drag to affect to the specified gradient
  21200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21201. * @returns the current particle system
  21202. */
  21203. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21204. /**
  21205. * Remove a specific drag gradient
  21206. * @param gradient defines the gradient to remove
  21207. * @returns the current particle system
  21208. */
  21209. removeDragGradient(gradient: number): IParticleSystem;
  21210. /**
  21211. * Gets the current list of drag gradients.
  21212. * You must use addDragGradient and removeDragGradient to udpate this list
  21213. * @returns the list of drag gradients
  21214. */
  21215. getDragGradients(): Nullable<Array<FactorGradient>>;
  21216. /**
  21217. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21218. * @param gradient defines the gradient to use (between 0 and 1)
  21219. * @param factor defines the emit rate to affect to the specified gradient
  21220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21221. * @returns the current particle system
  21222. */
  21223. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21224. /**
  21225. * Remove a specific emit rate gradient
  21226. * @param gradient defines the gradient to remove
  21227. * @returns the current particle system
  21228. */
  21229. removeEmitRateGradient(gradient: number): IParticleSystem;
  21230. /**
  21231. * Gets the current list of emit rate gradients.
  21232. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21233. * @returns the list of emit rate gradients
  21234. */
  21235. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21236. /**
  21237. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21238. * @param gradient defines the gradient to use (between 0 and 1)
  21239. * @param factor defines the start size to affect to the specified gradient
  21240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21241. * @returns the current particle system
  21242. */
  21243. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21244. /**
  21245. * Remove a specific start size gradient
  21246. * @param gradient defines the gradient to remove
  21247. * @returns the current particle system
  21248. */
  21249. removeStartSizeGradient(gradient: number): IParticleSystem;
  21250. /**
  21251. * Gets the current list of start size gradients.
  21252. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21253. * @returns the list of start size gradients
  21254. */
  21255. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21256. /**
  21257. * Adds a new life time gradient
  21258. * @param gradient defines the gradient to use (between 0 and 1)
  21259. * @param factor defines the life time factor to affect to the specified gradient
  21260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21261. * @returns the current particle system
  21262. */
  21263. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21264. /**
  21265. * Remove a specific life time gradient
  21266. * @param gradient defines the gradient to remove
  21267. * @returns the current particle system
  21268. */
  21269. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21270. /**
  21271. * Gets the current list of life time gradients.
  21272. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21273. * @returns the list of life time gradients
  21274. */
  21275. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21276. /**
  21277. * Gets the current list of color gradients.
  21278. * You must use addColorGradient and removeColorGradient to udpate this list
  21279. * @returns the list of color gradients
  21280. */
  21281. getColorGradients(): Nullable<Array<ColorGradient>>;
  21282. /**
  21283. * Adds a new ramp gradient used to remap particle colors
  21284. * @param gradient defines the gradient to use (between 0 and 1)
  21285. * @param color defines the color to affect to the specified gradient
  21286. * @returns the current particle system
  21287. */
  21288. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21289. /**
  21290. * Gets the current list of ramp gradients.
  21291. * You must use addRampGradient and removeRampGradient to udpate this list
  21292. * @returns the list of ramp gradients
  21293. */
  21294. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21295. /** Gets or sets a boolean indicating that ramp gradients must be used
  21296. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21297. */
  21298. useRampGradients: boolean;
  21299. /**
  21300. * Adds a new color remap gradient
  21301. * @param gradient defines the gradient to use (between 0 and 1)
  21302. * @param min defines the color remap minimal range
  21303. * @param max defines the color remap maximal range
  21304. * @returns the current particle system
  21305. */
  21306. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21307. /**
  21308. * Gets the current list of color remap gradients.
  21309. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21310. * @returns the list of color remap gradients
  21311. */
  21312. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21313. /**
  21314. * Adds a new alpha remap gradient
  21315. * @param gradient defines the gradient to use (between 0 and 1)
  21316. * @param min defines the alpha remap minimal range
  21317. * @param max defines the alpha remap maximal range
  21318. * @returns the current particle system
  21319. */
  21320. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21321. /**
  21322. * Gets the current list of alpha remap gradients.
  21323. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21324. * @returns the list of alpha remap gradients
  21325. */
  21326. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21327. /**
  21328. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21329. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21330. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21331. * @returns the emitter
  21332. */
  21333. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21334. /**
  21335. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21336. * @param radius The radius of the hemisphere to emit from
  21337. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21338. * @returns the emitter
  21339. */
  21340. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21341. /**
  21342. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21343. * @param radius The radius of the sphere to emit from
  21344. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21345. * @returns the emitter
  21346. */
  21347. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21348. /**
  21349. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21350. * @param radius The radius of the sphere to emit from
  21351. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21352. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21353. * @returns the emitter
  21354. */
  21355. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21356. /**
  21357. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21358. * @param radius The radius of the emission cylinder
  21359. * @param height The height of the emission cylinder
  21360. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21361. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21362. * @returns the emitter
  21363. */
  21364. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21365. /**
  21366. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21367. * @param radius The radius of the cylinder to emit from
  21368. * @param height The height of the emission cylinder
  21369. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21370. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21371. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21372. * @returns the emitter
  21373. */
  21374. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21375. /**
  21376. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21377. * @param radius The radius of the cone to emit from
  21378. * @param angle The base angle of the cone
  21379. * @returns the emitter
  21380. */
  21381. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21382. /**
  21383. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21384. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21385. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21386. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21387. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21388. * @returns the emitter
  21389. */
  21390. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21391. /**
  21392. * Get hosting scene
  21393. * @returns the scene
  21394. */
  21395. getScene(): Scene;
  21396. }
  21397. }
  21398. declare module BABYLON {
  21399. /** @hidden */
  21400. export var linePixelShader: {
  21401. name: string;
  21402. shader: string;
  21403. };
  21404. }
  21405. declare module BABYLON {
  21406. /** @hidden */
  21407. export var lineVertexShader: {
  21408. name: string;
  21409. shader: string;
  21410. };
  21411. }
  21412. declare module BABYLON {
  21413. interface AbstractMesh {
  21414. /**
  21415. * Gets the edgesRenderer associated with the mesh
  21416. */
  21417. edgesRenderer: Nullable<EdgesRenderer>;
  21418. }
  21419. interface LinesMesh {
  21420. /**
  21421. * Enables the edge rendering mode on the mesh.
  21422. * This mode makes the mesh edges visible
  21423. * @param epsilon defines the maximal distance between two angles to detect a face
  21424. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21425. * @returns the currentAbstractMesh
  21426. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21427. */
  21428. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21429. }
  21430. interface InstancedLinesMesh {
  21431. /**
  21432. * Enables the edge rendering mode on the mesh.
  21433. * This mode makes the mesh edges visible
  21434. * @param epsilon defines the maximal distance between two angles to detect a face
  21435. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21436. * @returns the current InstancedLinesMesh
  21437. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21438. */
  21439. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21440. }
  21441. /**
  21442. * Defines the minimum contract an Edges renderer should follow.
  21443. */
  21444. export interface IEdgesRenderer extends IDisposable {
  21445. /**
  21446. * Gets or sets a boolean indicating if the edgesRenderer is active
  21447. */
  21448. isEnabled: boolean;
  21449. /**
  21450. * Renders the edges of the attached mesh,
  21451. */
  21452. render(): void;
  21453. /**
  21454. * Checks wether or not the edges renderer is ready to render.
  21455. * @return true if ready, otherwise false.
  21456. */
  21457. isReady(): boolean;
  21458. }
  21459. /**
  21460. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21461. */
  21462. export class EdgesRenderer implements IEdgesRenderer {
  21463. /**
  21464. * Define the size of the edges with an orthographic camera
  21465. */
  21466. edgesWidthScalerForOrthographic: number;
  21467. /**
  21468. * Define the size of the edges with a perspective camera
  21469. */
  21470. edgesWidthScalerForPerspective: number;
  21471. protected _source: AbstractMesh;
  21472. protected _linesPositions: number[];
  21473. protected _linesNormals: number[];
  21474. protected _linesIndices: number[];
  21475. protected _epsilon: number;
  21476. protected _indicesCount: number;
  21477. protected _lineShader: ShaderMaterial;
  21478. protected _ib: DataBuffer;
  21479. protected _buffers: {
  21480. [key: string]: Nullable<VertexBuffer>;
  21481. };
  21482. protected _checkVerticesInsteadOfIndices: boolean;
  21483. private _meshRebuildObserver;
  21484. private _meshDisposeObserver;
  21485. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21486. isEnabled: boolean;
  21487. /**
  21488. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21489. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21490. * @param source Mesh used to create edges
  21491. * @param epsilon sum of angles in adjacency to check for edge
  21492. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21493. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21494. */
  21495. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21496. protected _prepareRessources(): void;
  21497. /** @hidden */
  21498. _rebuild(): void;
  21499. /**
  21500. * Releases the required resources for the edges renderer
  21501. */
  21502. dispose(): void;
  21503. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21504. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21505. /**
  21506. * Checks if the pair of p0 and p1 is en edge
  21507. * @param faceIndex
  21508. * @param edge
  21509. * @param faceNormals
  21510. * @param p0
  21511. * @param p1
  21512. * @private
  21513. */
  21514. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21515. /**
  21516. * push line into the position, normal and index buffer
  21517. * @protected
  21518. */
  21519. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21520. /**
  21521. * Generates lines edges from adjacencjes
  21522. * @private
  21523. */
  21524. _generateEdgesLines(): void;
  21525. /**
  21526. * Checks wether or not the edges renderer is ready to render.
  21527. * @return true if ready, otherwise false.
  21528. */
  21529. isReady(): boolean;
  21530. /**
  21531. * Renders the edges of the attached mesh,
  21532. */
  21533. render(): void;
  21534. }
  21535. /**
  21536. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21537. */
  21538. export class LineEdgesRenderer extends EdgesRenderer {
  21539. /**
  21540. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21541. * @param source LineMesh used to generate edges
  21542. * @param epsilon not important (specified angle for edge detection)
  21543. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21544. */
  21545. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21546. /**
  21547. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21548. */
  21549. _generateEdgesLines(): void;
  21550. }
  21551. }
  21552. declare module BABYLON {
  21553. /**
  21554. * This represents the object necessary to create a rendering group.
  21555. * This is exclusively used and created by the rendering manager.
  21556. * To modify the behavior, you use the available helpers in your scene or meshes.
  21557. * @hidden
  21558. */
  21559. export class RenderingGroup {
  21560. index: number;
  21561. private static _zeroVector;
  21562. private _scene;
  21563. private _opaqueSubMeshes;
  21564. private _transparentSubMeshes;
  21565. private _alphaTestSubMeshes;
  21566. private _depthOnlySubMeshes;
  21567. private _particleSystems;
  21568. private _spriteManagers;
  21569. private _opaqueSortCompareFn;
  21570. private _alphaTestSortCompareFn;
  21571. private _transparentSortCompareFn;
  21572. private _renderOpaque;
  21573. private _renderAlphaTest;
  21574. private _renderTransparent;
  21575. /** @hidden */
  21576. _edgesRenderers: SmartArray<IEdgesRenderer>;
  21577. onBeforeTransparentRendering: () => void;
  21578. /**
  21579. * Set the opaque sort comparison function.
  21580. * If null the sub meshes will be render in the order they were created
  21581. */
  21582. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21583. /**
  21584. * Set the alpha test sort comparison function.
  21585. * If null the sub meshes will be render in the order they were created
  21586. */
  21587. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21588. /**
  21589. * Set the transparent sort comparison function.
  21590. * If null the sub meshes will be render in the order they were created
  21591. */
  21592. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21593. /**
  21594. * Creates a new rendering group.
  21595. * @param index The rendering group index
  21596. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  21597. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  21598. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  21599. */
  21600. 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>);
  21601. /**
  21602. * Render all the sub meshes contained in the group.
  21603. * @param customRenderFunction Used to override the default render behaviour of the group.
  21604. * @returns true if rendered some submeshes.
  21605. */
  21606. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  21607. /**
  21608. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  21609. * @param subMeshes The submeshes to render
  21610. */
  21611. private renderOpaqueSorted;
  21612. /**
  21613. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  21614. * @param subMeshes The submeshes to render
  21615. */
  21616. private renderAlphaTestSorted;
  21617. /**
  21618. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  21619. * @param subMeshes The submeshes to render
  21620. */
  21621. private renderTransparentSorted;
  21622. /**
  21623. * Renders the submeshes in a specified order.
  21624. * @param subMeshes The submeshes to sort before render
  21625. * @param sortCompareFn The comparison function use to sort
  21626. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  21627. * @param transparent Specifies to activate blending if true
  21628. */
  21629. private static renderSorted;
  21630. /**
  21631. * Renders the submeshes in the order they were dispatched (no sort applied).
  21632. * @param subMeshes The submeshes to render
  21633. */
  21634. private static renderUnsorted;
  21635. /**
  21636. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21637. * are rendered back to front if in the same alpha index.
  21638. *
  21639. * @param a The first submesh
  21640. * @param b The second submesh
  21641. * @returns The result of the comparison
  21642. */
  21643. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  21644. /**
  21645. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21646. * are rendered back to front.
  21647. *
  21648. * @param a The first submesh
  21649. * @param b The second submesh
  21650. * @returns The result of the comparison
  21651. */
  21652. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  21653. /**
  21654. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21655. * are rendered front to back (prevent overdraw).
  21656. *
  21657. * @param a The first submesh
  21658. * @param b The second submesh
  21659. * @returns The result of the comparison
  21660. */
  21661. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  21662. /**
  21663. * Resets the different lists of submeshes to prepare a new frame.
  21664. */
  21665. prepare(): void;
  21666. dispose(): void;
  21667. /**
  21668. * Inserts the submesh in its correct queue depending on its material.
  21669. * @param subMesh The submesh to dispatch
  21670. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21671. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21672. */
  21673. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21674. dispatchSprites(spriteManager: ISpriteManager): void;
  21675. dispatchParticles(particleSystem: IParticleSystem): void;
  21676. private _renderParticles;
  21677. private _renderSprites;
  21678. }
  21679. }
  21680. declare module BABYLON {
  21681. /**
  21682. * Interface describing the different options available in the rendering manager
  21683. * regarding Auto Clear between groups.
  21684. */
  21685. export interface IRenderingManagerAutoClearSetup {
  21686. /**
  21687. * Defines whether or not autoclear is enable.
  21688. */
  21689. autoClear: boolean;
  21690. /**
  21691. * Defines whether or not to autoclear the depth buffer.
  21692. */
  21693. depth: boolean;
  21694. /**
  21695. * Defines whether or not to autoclear the stencil buffer.
  21696. */
  21697. stencil: boolean;
  21698. }
  21699. /**
  21700. * This class is used by the onRenderingGroupObservable
  21701. */
  21702. export class RenderingGroupInfo {
  21703. /**
  21704. * The Scene that being rendered
  21705. */
  21706. scene: Scene;
  21707. /**
  21708. * The camera currently used for the rendering pass
  21709. */
  21710. camera: Nullable<Camera>;
  21711. /**
  21712. * The ID of the renderingGroup being processed
  21713. */
  21714. renderingGroupId: number;
  21715. }
  21716. /**
  21717. * This is the manager responsible of all the rendering for meshes sprites and particles.
  21718. * It is enable to manage the different groups as well as the different necessary sort functions.
  21719. * This should not be used directly aside of the few static configurations
  21720. */
  21721. export class RenderingManager {
  21722. /**
  21723. * The max id used for rendering groups (not included)
  21724. */
  21725. static MAX_RENDERINGGROUPS: number;
  21726. /**
  21727. * The min id used for rendering groups (included)
  21728. */
  21729. static MIN_RENDERINGGROUPS: number;
  21730. /**
  21731. * Used to globally prevent autoclearing scenes.
  21732. */
  21733. static AUTOCLEAR: boolean;
  21734. /**
  21735. * @hidden
  21736. */
  21737. _useSceneAutoClearSetup: boolean;
  21738. private _scene;
  21739. private _renderingGroups;
  21740. private _depthStencilBufferAlreadyCleaned;
  21741. private _autoClearDepthStencil;
  21742. private _customOpaqueSortCompareFn;
  21743. private _customAlphaTestSortCompareFn;
  21744. private _customTransparentSortCompareFn;
  21745. private _renderingGroupInfo;
  21746. /**
  21747. * Instantiates a new rendering group for a particular scene
  21748. * @param scene Defines the scene the groups belongs to
  21749. */
  21750. constructor(scene: Scene);
  21751. private _clearDepthStencilBuffer;
  21752. /**
  21753. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  21754. * @hidden
  21755. */
  21756. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  21757. /**
  21758. * Resets the different information of the group to prepare a new frame
  21759. * @hidden
  21760. */
  21761. reset(): void;
  21762. /**
  21763. * Dispose and release the group and its associated resources.
  21764. * @hidden
  21765. */
  21766. dispose(): void;
  21767. /**
  21768. * Clear the info related to rendering groups preventing retention points during dispose.
  21769. */
  21770. freeRenderingGroups(): void;
  21771. private _prepareRenderingGroup;
  21772. /**
  21773. * Add a sprite manager to the rendering manager in order to render it this frame.
  21774. * @param spriteManager Define the sprite manager to render
  21775. */
  21776. dispatchSprites(spriteManager: ISpriteManager): void;
  21777. /**
  21778. * Add a particle system to the rendering manager in order to render it this frame.
  21779. * @param particleSystem Define the particle system to render
  21780. */
  21781. dispatchParticles(particleSystem: IParticleSystem): void;
  21782. /**
  21783. * Add a submesh to the manager in order to render it this frame
  21784. * @param subMesh The submesh to dispatch
  21785. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21786. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21787. */
  21788. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21789. /**
  21790. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21791. * This allowed control for front to back rendering or reversly depending of the special needs.
  21792. *
  21793. * @param renderingGroupId The rendering group id corresponding to its index
  21794. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21795. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21796. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21797. */
  21798. 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;
  21799. /**
  21800. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21801. *
  21802. * @param renderingGroupId The rendering group id corresponding to its index
  21803. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21804. * @param depth Automatically clears depth between groups if true and autoClear is true.
  21805. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  21806. */
  21807. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  21808. /**
  21809. * Gets the current auto clear configuration for one rendering group of the rendering
  21810. * manager.
  21811. * @param index the rendering group index to get the information for
  21812. * @returns The auto clear setup for the requested rendering group
  21813. */
  21814. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  21815. }
  21816. }
  21817. declare module BABYLON {
  21818. /**
  21819. * This Helps creating a texture that will be created from a camera in your scene.
  21820. * It is basically a dynamic texture that could be used to create special effects for instance.
  21821. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21822. */
  21823. export class RenderTargetTexture extends Texture {
  21824. isCube: boolean;
  21825. /**
  21826. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21827. */
  21828. static readonly REFRESHRATE_RENDER_ONCE: number;
  21829. /**
  21830. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21831. */
  21832. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21833. /**
  21834. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21835. * the central point of your effect and can save a lot of performances.
  21836. */
  21837. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21838. /**
  21839. * Use this predicate to dynamically define the list of mesh you want to render.
  21840. * If set, the renderList property will be overwritten.
  21841. */
  21842. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21843. private _renderList;
  21844. /**
  21845. * Use this list to define the list of mesh you want to render.
  21846. */
  21847. renderList: Nullable<Array<AbstractMesh>>;
  21848. private _hookArray;
  21849. /**
  21850. * Define if particles should be rendered in your texture.
  21851. */
  21852. renderParticles: boolean;
  21853. /**
  21854. * Define if sprites should be rendered in your texture.
  21855. */
  21856. renderSprites: boolean;
  21857. /**
  21858. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21859. */
  21860. coordinatesMode: number;
  21861. /**
  21862. * Define the camera used to render the texture.
  21863. */
  21864. activeCamera: Nullable<Camera>;
  21865. /**
  21866. * Override the render function of the texture with your own one.
  21867. */
  21868. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21869. /**
  21870. * Define if camera post processes should be use while rendering the texture.
  21871. */
  21872. useCameraPostProcesses: boolean;
  21873. /**
  21874. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21875. */
  21876. ignoreCameraViewport: boolean;
  21877. private _postProcessManager;
  21878. private _postProcesses;
  21879. private _resizeObserver;
  21880. /**
  21881. * An event triggered when the texture is unbind.
  21882. */
  21883. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21884. /**
  21885. * An event triggered when the texture is unbind.
  21886. */
  21887. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21888. private _onAfterUnbindObserver;
  21889. /**
  21890. * Set a after unbind callback in the texture.
  21891. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21892. */
  21893. onAfterUnbind: () => void;
  21894. /**
  21895. * An event triggered before rendering the texture
  21896. */
  21897. onBeforeRenderObservable: Observable<number>;
  21898. private _onBeforeRenderObserver;
  21899. /**
  21900. * Set a before render callback in the texture.
  21901. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21902. */
  21903. onBeforeRender: (faceIndex: number) => void;
  21904. /**
  21905. * An event triggered after rendering the texture
  21906. */
  21907. onAfterRenderObservable: Observable<number>;
  21908. private _onAfterRenderObserver;
  21909. /**
  21910. * Set a after render callback in the texture.
  21911. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21912. */
  21913. onAfterRender: (faceIndex: number) => void;
  21914. /**
  21915. * An event triggered after the texture clear
  21916. */
  21917. onClearObservable: Observable<Engine>;
  21918. private _onClearObserver;
  21919. /**
  21920. * Set a clear callback in the texture.
  21921. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21922. */
  21923. onClear: (Engine: Engine) => void;
  21924. /**
  21925. * Define the clear color of the Render Target if it should be different from the scene.
  21926. */
  21927. clearColor: Color4;
  21928. protected _size: number | {
  21929. width: number;
  21930. height: number;
  21931. };
  21932. protected _initialSizeParameter: number | {
  21933. width: number;
  21934. height: number;
  21935. } | {
  21936. ratio: number;
  21937. };
  21938. protected _sizeRatio: Nullable<number>;
  21939. /** @hidden */
  21940. _generateMipMaps: boolean;
  21941. protected _renderingManager: RenderingManager;
  21942. /** @hidden */
  21943. _waitingRenderList: string[];
  21944. protected _doNotChangeAspectRatio: boolean;
  21945. protected _currentRefreshId: number;
  21946. protected _refreshRate: number;
  21947. protected _textureMatrix: Matrix;
  21948. protected _samples: number;
  21949. protected _renderTargetOptions: RenderTargetCreationOptions;
  21950. /**
  21951. * Gets render target creation options that were used.
  21952. */
  21953. readonly renderTargetOptions: RenderTargetCreationOptions;
  21954. protected _engine: Engine;
  21955. protected _onRatioRescale(): void;
  21956. /**
  21957. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21958. * It must define where the camera used to render the texture is set
  21959. */
  21960. boundingBoxPosition: Vector3;
  21961. private _boundingBoxSize;
  21962. /**
  21963. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21964. * When defined, the cubemap will switch to local mode
  21965. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21966. * @example https://www.babylonjs-playground.com/#RNASML
  21967. */
  21968. boundingBoxSize: Vector3;
  21969. /**
  21970. * In case the RTT has been created with a depth texture, get the associated
  21971. * depth texture.
  21972. * Otherwise, return null.
  21973. */
  21974. depthStencilTexture: Nullable<InternalTexture>;
  21975. /**
  21976. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21977. * or used a shadow, depth texture...
  21978. * @param name The friendly name of the texture
  21979. * @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)
  21980. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21981. * @param generateMipMaps True if mip maps need to be generated after render.
  21982. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21983. * @param type The type of the buffer in the RTT (int, half float, float...)
  21984. * @param isCube True if a cube texture needs to be created
  21985. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21986. * @param generateDepthBuffer True to generate a depth buffer
  21987. * @param generateStencilBuffer True to generate a stencil buffer
  21988. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21989. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21990. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21991. */
  21992. constructor(name: string, size: number | {
  21993. width: number;
  21994. height: number;
  21995. } | {
  21996. ratio: number;
  21997. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21998. /**
  21999. * Creates a depth stencil texture.
  22000. * This is only available in WebGL 2 or with the depth texture extension available.
  22001. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22002. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22003. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22004. */
  22005. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22006. private _processSizeParameter;
  22007. /**
  22008. * Define the number of samples to use in case of MSAA.
  22009. * It defaults to one meaning no MSAA has been enabled.
  22010. */
  22011. samples: number;
  22012. /**
  22013. * Resets the refresh counter of the texture and start bak from scratch.
  22014. * Could be useful to regenerate the texture if it is setup to render only once.
  22015. */
  22016. resetRefreshCounter(): void;
  22017. /**
  22018. * Define the refresh rate of the texture or the rendering frequency.
  22019. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22020. */
  22021. refreshRate: number;
  22022. /**
  22023. * Adds a post process to the render target rendering passes.
  22024. * @param postProcess define the post process to add
  22025. */
  22026. addPostProcess(postProcess: PostProcess): void;
  22027. /**
  22028. * Clear all the post processes attached to the render target
  22029. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22030. */
  22031. clearPostProcesses(dispose?: boolean): void;
  22032. /**
  22033. * Remove one of the post process from the list of attached post processes to the texture
  22034. * @param postProcess define the post process to remove from the list
  22035. */
  22036. removePostProcess(postProcess: PostProcess): void;
  22037. /** @hidden */
  22038. _shouldRender(): boolean;
  22039. /**
  22040. * Gets the actual render size of the texture.
  22041. * @returns the width of the render size
  22042. */
  22043. getRenderSize(): number;
  22044. /**
  22045. * Gets the actual render width of the texture.
  22046. * @returns the width of the render size
  22047. */
  22048. getRenderWidth(): number;
  22049. /**
  22050. * Gets the actual render height of the texture.
  22051. * @returns the height of the render size
  22052. */
  22053. getRenderHeight(): number;
  22054. /**
  22055. * Get if the texture can be rescaled or not.
  22056. */
  22057. readonly canRescale: boolean;
  22058. /**
  22059. * Resize the texture using a ratio.
  22060. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22061. */
  22062. scale(ratio: number): void;
  22063. /**
  22064. * Get the texture reflection matrix used to rotate/transform the reflection.
  22065. * @returns the reflection matrix
  22066. */
  22067. getReflectionTextureMatrix(): Matrix;
  22068. /**
  22069. * Resize the texture to a new desired size.
  22070. * Be carrefull as it will recreate all the data in the new texture.
  22071. * @param size Define the new size. It can be:
  22072. * - a number for squared texture,
  22073. * - an object containing { width: number, height: number }
  22074. * - or an object containing a ratio { ratio: number }
  22075. */
  22076. resize(size: number | {
  22077. width: number;
  22078. height: number;
  22079. } | {
  22080. ratio: number;
  22081. }): void;
  22082. /**
  22083. * Renders all the objects from the render list into the texture.
  22084. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22085. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22086. */
  22087. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22088. private _bestReflectionRenderTargetDimension;
  22089. /**
  22090. * @hidden
  22091. * @param faceIndex face index to bind to if this is a cubetexture
  22092. */
  22093. _bindFrameBuffer(faceIndex?: number): void;
  22094. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22095. private renderToTarget;
  22096. /**
  22097. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22098. * This allowed control for front to back rendering or reversly depending of the special needs.
  22099. *
  22100. * @param renderingGroupId The rendering group id corresponding to its index
  22101. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22102. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22103. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22104. */
  22105. 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;
  22106. /**
  22107. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22108. *
  22109. * @param renderingGroupId The rendering group id corresponding to its index
  22110. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22111. */
  22112. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22113. /**
  22114. * Clones the texture.
  22115. * @returns the cloned texture
  22116. */
  22117. clone(): RenderTargetTexture;
  22118. /**
  22119. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22120. * @returns The JSON representation of the texture
  22121. */
  22122. serialize(): any;
  22123. /**
  22124. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22125. */
  22126. disposeFramebufferObjects(): void;
  22127. /**
  22128. * Dispose the texture and release its associated resources.
  22129. */
  22130. dispose(): void;
  22131. /** @hidden */
  22132. _rebuild(): void;
  22133. /**
  22134. * Clear the info related to rendering groups preventing retention point in material dispose.
  22135. */
  22136. freeRenderingGroups(): void;
  22137. /**
  22138. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22139. * @returns the view count
  22140. */
  22141. getViewCount(): number;
  22142. }
  22143. }
  22144. declare module BABYLON {
  22145. /**
  22146. * Base class for the main features of a material in Babylon.js
  22147. */
  22148. export class Material implements IAnimatable {
  22149. /**
  22150. * Returns the triangle fill mode
  22151. */
  22152. static readonly TriangleFillMode: number;
  22153. /**
  22154. * Returns the wireframe mode
  22155. */
  22156. static readonly WireFrameFillMode: number;
  22157. /**
  22158. * Returns the point fill mode
  22159. */
  22160. static readonly PointFillMode: number;
  22161. /**
  22162. * Returns the point list draw mode
  22163. */
  22164. static readonly PointListDrawMode: number;
  22165. /**
  22166. * Returns the line list draw mode
  22167. */
  22168. static readonly LineListDrawMode: number;
  22169. /**
  22170. * Returns the line loop draw mode
  22171. */
  22172. static readonly LineLoopDrawMode: number;
  22173. /**
  22174. * Returns the line strip draw mode
  22175. */
  22176. static readonly LineStripDrawMode: number;
  22177. /**
  22178. * Returns the triangle strip draw mode
  22179. */
  22180. static readonly TriangleStripDrawMode: number;
  22181. /**
  22182. * Returns the triangle fan draw mode
  22183. */
  22184. static readonly TriangleFanDrawMode: number;
  22185. /**
  22186. * Stores the clock-wise side orientation
  22187. */
  22188. static readonly ClockWiseSideOrientation: number;
  22189. /**
  22190. * Stores the counter clock-wise side orientation
  22191. */
  22192. static readonly CounterClockWiseSideOrientation: number;
  22193. /**
  22194. * The dirty texture flag value
  22195. */
  22196. static readonly TextureDirtyFlag: number;
  22197. /**
  22198. * The dirty light flag value
  22199. */
  22200. static readonly LightDirtyFlag: number;
  22201. /**
  22202. * The dirty fresnel flag value
  22203. */
  22204. static readonly FresnelDirtyFlag: number;
  22205. /**
  22206. * The dirty attribute flag value
  22207. */
  22208. static readonly AttributesDirtyFlag: number;
  22209. /**
  22210. * The dirty misc flag value
  22211. */
  22212. static readonly MiscDirtyFlag: number;
  22213. /**
  22214. * The all dirty flag value
  22215. */
  22216. static readonly AllDirtyFlag: number;
  22217. /**
  22218. * The ID of the material
  22219. */
  22220. id: string;
  22221. /**
  22222. * Gets or sets the unique id of the material
  22223. */
  22224. uniqueId: number;
  22225. /**
  22226. * The name of the material
  22227. */
  22228. name: string;
  22229. /**
  22230. * Gets or sets user defined metadata
  22231. */
  22232. metadata: any;
  22233. /**
  22234. * For internal use only. Please do not use.
  22235. */
  22236. reservedDataStore: any;
  22237. /**
  22238. * Specifies if the ready state should be checked on each call
  22239. */
  22240. checkReadyOnEveryCall: boolean;
  22241. /**
  22242. * Specifies if the ready state should be checked once
  22243. */
  22244. checkReadyOnlyOnce: boolean;
  22245. /**
  22246. * The state of the material
  22247. */
  22248. state: string;
  22249. /**
  22250. * The alpha value of the material
  22251. */
  22252. protected _alpha: number;
  22253. /**
  22254. * List of inspectable custom properties (used by the Inspector)
  22255. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22256. */
  22257. inspectableCustomProperties: IInspectable[];
  22258. /**
  22259. * Sets the alpha value of the material
  22260. */
  22261. /**
  22262. * Gets the alpha value of the material
  22263. */
  22264. alpha: number;
  22265. /**
  22266. * Specifies if back face culling is enabled
  22267. */
  22268. protected _backFaceCulling: boolean;
  22269. /**
  22270. * Sets the back-face culling state
  22271. */
  22272. /**
  22273. * Gets the back-face culling state
  22274. */
  22275. backFaceCulling: boolean;
  22276. /**
  22277. * Stores the value for side orientation
  22278. */
  22279. sideOrientation: number;
  22280. /**
  22281. * Callback triggered when the material is compiled
  22282. */
  22283. onCompiled: Nullable<(effect: Effect) => void>;
  22284. /**
  22285. * Callback triggered when an error occurs
  22286. */
  22287. onError: Nullable<(effect: Effect, errors: string) => void>;
  22288. /**
  22289. * Callback triggered to get the render target textures
  22290. */
  22291. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22292. /**
  22293. * Gets a boolean indicating that current material needs to register RTT
  22294. */
  22295. readonly hasRenderTargetTextures: boolean;
  22296. /**
  22297. * Specifies if the material should be serialized
  22298. */
  22299. doNotSerialize: boolean;
  22300. /**
  22301. * @hidden
  22302. */
  22303. _storeEffectOnSubMeshes: boolean;
  22304. /**
  22305. * Stores the animations for the material
  22306. */
  22307. animations: Nullable<Array<Animation>>;
  22308. /**
  22309. * An event triggered when the material is disposed
  22310. */
  22311. onDisposeObservable: Observable<Material>;
  22312. /**
  22313. * An observer which watches for dispose events
  22314. */
  22315. private _onDisposeObserver;
  22316. private _onUnBindObservable;
  22317. /**
  22318. * Called during a dispose event
  22319. */
  22320. onDispose: () => void;
  22321. private _onBindObservable;
  22322. /**
  22323. * An event triggered when the material is bound
  22324. */
  22325. readonly onBindObservable: Observable<AbstractMesh>;
  22326. /**
  22327. * An observer which watches for bind events
  22328. */
  22329. private _onBindObserver;
  22330. /**
  22331. * Called during a bind event
  22332. */
  22333. onBind: (Mesh: AbstractMesh) => void;
  22334. /**
  22335. * An event triggered when the material is unbound
  22336. */
  22337. readonly onUnBindObservable: Observable<Material>;
  22338. /**
  22339. * Stores the value of the alpha mode
  22340. */
  22341. private _alphaMode;
  22342. /**
  22343. * Sets the value of the alpha mode.
  22344. *
  22345. * | Value | Type | Description |
  22346. * | --- | --- | --- |
  22347. * | 0 | ALPHA_DISABLE | |
  22348. * | 1 | ALPHA_ADD | |
  22349. * | 2 | ALPHA_COMBINE | |
  22350. * | 3 | ALPHA_SUBTRACT | |
  22351. * | 4 | ALPHA_MULTIPLY | |
  22352. * | 5 | ALPHA_MAXIMIZED | |
  22353. * | 6 | ALPHA_ONEONE | |
  22354. * | 7 | ALPHA_PREMULTIPLIED | |
  22355. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22356. * | 9 | ALPHA_INTERPOLATE | |
  22357. * | 10 | ALPHA_SCREENMODE | |
  22358. *
  22359. */
  22360. /**
  22361. * Gets the value of the alpha mode
  22362. */
  22363. alphaMode: number;
  22364. /**
  22365. * Stores the state of the need depth pre-pass value
  22366. */
  22367. private _needDepthPrePass;
  22368. /**
  22369. * Sets the need depth pre-pass value
  22370. */
  22371. /**
  22372. * Gets the depth pre-pass value
  22373. */
  22374. needDepthPrePass: boolean;
  22375. /**
  22376. * Specifies if depth writing should be disabled
  22377. */
  22378. disableDepthWrite: boolean;
  22379. /**
  22380. * Specifies if depth writing should be forced
  22381. */
  22382. forceDepthWrite: boolean;
  22383. /**
  22384. * Specifies if there should be a separate pass for culling
  22385. */
  22386. separateCullingPass: boolean;
  22387. /**
  22388. * Stores the state specifing if fog should be enabled
  22389. */
  22390. private _fogEnabled;
  22391. /**
  22392. * Sets the state for enabling fog
  22393. */
  22394. /**
  22395. * Gets the value of the fog enabled state
  22396. */
  22397. fogEnabled: boolean;
  22398. /**
  22399. * Stores the size of points
  22400. */
  22401. pointSize: number;
  22402. /**
  22403. * Stores the z offset value
  22404. */
  22405. zOffset: number;
  22406. /**
  22407. * Gets a value specifying if wireframe mode is enabled
  22408. */
  22409. /**
  22410. * Sets the state of wireframe mode
  22411. */
  22412. wireframe: boolean;
  22413. /**
  22414. * Gets the value specifying if point clouds are enabled
  22415. */
  22416. /**
  22417. * Sets the state of point cloud mode
  22418. */
  22419. pointsCloud: boolean;
  22420. /**
  22421. * Gets the material fill mode
  22422. */
  22423. /**
  22424. * Sets the material fill mode
  22425. */
  22426. fillMode: number;
  22427. /**
  22428. * @hidden
  22429. * Stores the effects for the material
  22430. */
  22431. _effect: Nullable<Effect>;
  22432. /**
  22433. * @hidden
  22434. * Specifies if the material was previously ready
  22435. */
  22436. _wasPreviouslyReady: boolean;
  22437. /**
  22438. * Specifies if uniform buffers should be used
  22439. */
  22440. private _useUBO;
  22441. /**
  22442. * Stores a reference to the scene
  22443. */
  22444. private _scene;
  22445. /**
  22446. * Stores the fill mode state
  22447. */
  22448. private _fillMode;
  22449. /**
  22450. * Specifies if the depth write state should be cached
  22451. */
  22452. private _cachedDepthWriteState;
  22453. /**
  22454. * Stores the uniform buffer
  22455. */
  22456. protected _uniformBuffer: UniformBuffer;
  22457. /** @hidden */
  22458. _indexInSceneMaterialArray: number;
  22459. /** @hidden */
  22460. meshMap: Nullable<{
  22461. [id: string]: AbstractMesh | undefined;
  22462. }>;
  22463. /**
  22464. * Creates a material instance
  22465. * @param name defines the name of the material
  22466. * @param scene defines the scene to reference
  22467. * @param doNotAdd specifies if the material should be added to the scene
  22468. */
  22469. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22470. /**
  22471. * Returns a string representation of the current material
  22472. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22473. * @returns a string with material information
  22474. */
  22475. toString(fullDetails?: boolean): string;
  22476. /**
  22477. * Gets the class name of the material
  22478. * @returns a string with the class name of the material
  22479. */
  22480. getClassName(): string;
  22481. /**
  22482. * Specifies if updates for the material been locked
  22483. */
  22484. readonly isFrozen: boolean;
  22485. /**
  22486. * Locks updates for the material
  22487. */
  22488. freeze(): void;
  22489. /**
  22490. * Unlocks updates for the material
  22491. */
  22492. unfreeze(): void;
  22493. /**
  22494. * Specifies if the material is ready to be used
  22495. * @param mesh defines the mesh to check
  22496. * @param useInstances specifies if instances should be used
  22497. * @returns a boolean indicating if the material is ready to be used
  22498. */
  22499. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22500. /**
  22501. * Specifies that the submesh is ready to be used
  22502. * @param mesh defines the mesh to check
  22503. * @param subMesh defines which submesh to check
  22504. * @param useInstances specifies that instances should be used
  22505. * @returns a boolean indicating that the submesh is ready or not
  22506. */
  22507. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22508. /**
  22509. * Returns the material effect
  22510. * @returns the effect associated with the material
  22511. */
  22512. getEffect(): Nullable<Effect>;
  22513. /**
  22514. * Returns the current scene
  22515. * @returns a Scene
  22516. */
  22517. getScene(): Scene;
  22518. /**
  22519. * Specifies if the material will require alpha blending
  22520. * @returns a boolean specifying if alpha blending is needed
  22521. */
  22522. needAlphaBlending(): boolean;
  22523. /**
  22524. * Specifies if the mesh will require alpha blending
  22525. * @param mesh defines the mesh to check
  22526. * @returns a boolean specifying if alpha blending is needed for the mesh
  22527. */
  22528. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22529. /**
  22530. * Specifies if this material should be rendered in alpha test mode
  22531. * @returns a boolean specifying if an alpha test is needed.
  22532. */
  22533. needAlphaTesting(): boolean;
  22534. /**
  22535. * Gets the texture used for the alpha test
  22536. * @returns the texture to use for alpha testing
  22537. */
  22538. getAlphaTestTexture(): Nullable<BaseTexture>;
  22539. /**
  22540. * Marks the material to indicate that it needs to be re-calculated
  22541. */
  22542. markDirty(): void;
  22543. /** @hidden */
  22544. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22545. /**
  22546. * Binds the material to the mesh
  22547. * @param world defines the world transformation matrix
  22548. * @param mesh defines the mesh to bind the material to
  22549. */
  22550. bind(world: Matrix, mesh?: Mesh): void;
  22551. /**
  22552. * Binds the submesh to the material
  22553. * @param world defines the world transformation matrix
  22554. * @param mesh defines the mesh containing the submesh
  22555. * @param subMesh defines the submesh to bind the material to
  22556. */
  22557. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22558. /**
  22559. * Binds the world matrix to the material
  22560. * @param world defines the world transformation matrix
  22561. */
  22562. bindOnlyWorldMatrix(world: Matrix): void;
  22563. /**
  22564. * Binds the scene's uniform buffer to the effect.
  22565. * @param effect defines the effect to bind to the scene uniform buffer
  22566. * @param sceneUbo defines the uniform buffer storing scene data
  22567. */
  22568. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22569. /**
  22570. * Binds the view matrix to the effect
  22571. * @param effect defines the effect to bind the view matrix to
  22572. */
  22573. bindView(effect: Effect): void;
  22574. /**
  22575. * Binds the view projection matrix to the effect
  22576. * @param effect defines the effect to bind the view projection matrix to
  22577. */
  22578. bindViewProjection(effect: Effect): void;
  22579. /**
  22580. * Specifies if material alpha testing should be turned on for the mesh
  22581. * @param mesh defines the mesh to check
  22582. */
  22583. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22584. /**
  22585. * Processes to execute after binding the material to a mesh
  22586. * @param mesh defines the rendered mesh
  22587. */
  22588. protected _afterBind(mesh?: Mesh): void;
  22589. /**
  22590. * Unbinds the material from the mesh
  22591. */
  22592. unbind(): void;
  22593. /**
  22594. * Gets the active textures from the material
  22595. * @returns an array of textures
  22596. */
  22597. getActiveTextures(): BaseTexture[];
  22598. /**
  22599. * Specifies if the material uses a texture
  22600. * @param texture defines the texture to check against the material
  22601. * @returns a boolean specifying if the material uses the texture
  22602. */
  22603. hasTexture(texture: BaseTexture): boolean;
  22604. /**
  22605. * Makes a duplicate of the material, and gives it a new name
  22606. * @param name defines the new name for the duplicated material
  22607. * @returns the cloned material
  22608. */
  22609. clone(name: string): Nullable<Material>;
  22610. /**
  22611. * Gets the meshes bound to the material
  22612. * @returns an array of meshes bound to the material
  22613. */
  22614. getBindedMeshes(): AbstractMesh[];
  22615. /**
  22616. * Force shader compilation
  22617. * @param mesh defines the mesh associated with this material
  22618. * @param onCompiled defines a function to execute once the material is compiled
  22619. * @param options defines the options to configure the compilation
  22620. */
  22621. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22622. clipPlane: boolean;
  22623. }>): void;
  22624. /**
  22625. * Force shader compilation
  22626. * @param mesh defines the mesh that will use this material
  22627. * @param options defines additional options for compiling the shaders
  22628. * @returns a promise that resolves when the compilation completes
  22629. */
  22630. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22631. clipPlane: boolean;
  22632. }>): Promise<void>;
  22633. private static readonly _AllDirtyCallBack;
  22634. private static readonly _ImageProcessingDirtyCallBack;
  22635. private static readonly _TextureDirtyCallBack;
  22636. private static readonly _FresnelDirtyCallBack;
  22637. private static readonly _MiscDirtyCallBack;
  22638. private static readonly _LightsDirtyCallBack;
  22639. private static readonly _AttributeDirtyCallBack;
  22640. private static _FresnelAndMiscDirtyCallBack;
  22641. private static _TextureAndMiscDirtyCallBack;
  22642. private static readonly _DirtyCallbackArray;
  22643. private static readonly _RunDirtyCallBacks;
  22644. /**
  22645. * Marks a define in the material to indicate that it needs to be re-computed
  22646. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22647. */
  22648. markAsDirty(flag: number): void;
  22649. /**
  22650. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22651. * @param func defines a function which checks material defines against the submeshes
  22652. */
  22653. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22654. /**
  22655. * Indicates that we need to re-calculated for all submeshes
  22656. */
  22657. protected _markAllSubMeshesAsAllDirty(): void;
  22658. /**
  22659. * Indicates that image processing needs to be re-calculated for all submeshes
  22660. */
  22661. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22662. /**
  22663. * Indicates that textures need to be re-calculated for all submeshes
  22664. */
  22665. protected _markAllSubMeshesAsTexturesDirty(): void;
  22666. /**
  22667. * Indicates that fresnel needs to be re-calculated for all submeshes
  22668. */
  22669. protected _markAllSubMeshesAsFresnelDirty(): void;
  22670. /**
  22671. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22672. */
  22673. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22674. /**
  22675. * Indicates that lights need to be re-calculated for all submeshes
  22676. */
  22677. protected _markAllSubMeshesAsLightsDirty(): void;
  22678. /**
  22679. * Indicates that attributes need to be re-calculated for all submeshes
  22680. */
  22681. protected _markAllSubMeshesAsAttributesDirty(): void;
  22682. /**
  22683. * Indicates that misc needs to be re-calculated for all submeshes
  22684. */
  22685. protected _markAllSubMeshesAsMiscDirty(): void;
  22686. /**
  22687. * Indicates that textures and misc need to be re-calculated for all submeshes
  22688. */
  22689. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22690. /**
  22691. * Disposes the material
  22692. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22693. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22694. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22695. */
  22696. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22697. /** @hidden */
  22698. private releaseVertexArrayObject;
  22699. /**
  22700. * Serializes this material
  22701. * @returns the serialized material object
  22702. */
  22703. serialize(): any;
  22704. /**
  22705. * Creates a material from parsed material data
  22706. * @param parsedMaterial defines parsed material data
  22707. * @param scene defines the hosting scene
  22708. * @param rootUrl defines the root URL to use to load textures
  22709. * @returns a new material
  22710. */
  22711. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22712. }
  22713. }
  22714. declare module BABYLON {
  22715. /**
  22716. * Base class for submeshes
  22717. */
  22718. export class BaseSubMesh {
  22719. /** @hidden */
  22720. _materialDefines: Nullable<MaterialDefines>;
  22721. /** @hidden */
  22722. _materialEffect: Nullable<Effect>;
  22723. /**
  22724. * Gets associated effect
  22725. */
  22726. readonly effect: Nullable<Effect>;
  22727. /**
  22728. * Sets associated effect (effect used to render this submesh)
  22729. * @param effect defines the effect to associate with
  22730. * @param defines defines the set of defines used to compile this effect
  22731. */
  22732. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22733. }
  22734. /**
  22735. * Defines a subdivision inside a mesh
  22736. */
  22737. export class SubMesh extends BaseSubMesh implements ICullable {
  22738. /** the material index to use */
  22739. materialIndex: number;
  22740. /** vertex index start */
  22741. verticesStart: number;
  22742. /** vertices count */
  22743. verticesCount: number;
  22744. /** index start */
  22745. indexStart: number;
  22746. /** indices count */
  22747. indexCount: number;
  22748. /** @hidden */
  22749. _linesIndexCount: number;
  22750. private _mesh;
  22751. private _renderingMesh;
  22752. private _boundingInfo;
  22753. private _linesIndexBuffer;
  22754. /** @hidden */
  22755. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22756. /** @hidden */
  22757. _trianglePlanes: Plane[];
  22758. /** @hidden */
  22759. _lastColliderTransformMatrix: Nullable<Matrix>;
  22760. /** @hidden */
  22761. _renderId: number;
  22762. /** @hidden */
  22763. _alphaIndex: number;
  22764. /** @hidden */
  22765. _distanceToCamera: number;
  22766. /** @hidden */
  22767. _id: number;
  22768. private _currentMaterial;
  22769. /**
  22770. * Add a new submesh to a mesh
  22771. * @param materialIndex defines the material index to use
  22772. * @param verticesStart defines vertex index start
  22773. * @param verticesCount defines vertices count
  22774. * @param indexStart defines index start
  22775. * @param indexCount defines indices count
  22776. * @param mesh defines the parent mesh
  22777. * @param renderingMesh defines an optional rendering mesh
  22778. * @param createBoundingBox defines if bounding box should be created for this submesh
  22779. * @returns the new submesh
  22780. */
  22781. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22782. /**
  22783. * Creates a new submesh
  22784. * @param materialIndex defines the material index to use
  22785. * @param verticesStart defines vertex index start
  22786. * @param verticesCount defines vertices count
  22787. * @param indexStart defines index start
  22788. * @param indexCount defines indices count
  22789. * @param mesh defines the parent mesh
  22790. * @param renderingMesh defines an optional rendering mesh
  22791. * @param createBoundingBox defines if bounding box should be created for this submesh
  22792. */
  22793. constructor(
  22794. /** the material index to use */
  22795. materialIndex: number,
  22796. /** vertex index start */
  22797. verticesStart: number,
  22798. /** vertices count */
  22799. verticesCount: number,
  22800. /** index start */
  22801. indexStart: number,
  22802. /** indices count */
  22803. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22804. /**
  22805. * Returns true if this submesh covers the entire parent mesh
  22806. * @ignorenaming
  22807. */
  22808. readonly IsGlobal: boolean;
  22809. /**
  22810. * Returns the submesh BoudingInfo object
  22811. * @returns current bounding info (or mesh's one if the submesh is global)
  22812. */
  22813. getBoundingInfo(): BoundingInfo;
  22814. /**
  22815. * Sets the submesh BoundingInfo
  22816. * @param boundingInfo defines the new bounding info to use
  22817. * @returns the SubMesh
  22818. */
  22819. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22820. /**
  22821. * Returns the mesh of the current submesh
  22822. * @return the parent mesh
  22823. */
  22824. getMesh(): AbstractMesh;
  22825. /**
  22826. * Returns the rendering mesh of the submesh
  22827. * @returns the rendering mesh (could be different from parent mesh)
  22828. */
  22829. getRenderingMesh(): Mesh;
  22830. /**
  22831. * Returns the submesh material
  22832. * @returns null or the current material
  22833. */
  22834. getMaterial(): Nullable<Material>;
  22835. /**
  22836. * Sets a new updated BoundingInfo object to the submesh
  22837. * @param data defines an optional position array to use to determine the bounding info
  22838. * @returns the SubMesh
  22839. */
  22840. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22841. /** @hidden */
  22842. _checkCollision(collider: Collider): boolean;
  22843. /**
  22844. * Updates the submesh BoundingInfo
  22845. * @param world defines the world matrix to use to update the bounding info
  22846. * @returns the submesh
  22847. */
  22848. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22849. /**
  22850. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22851. * @param frustumPlanes defines the frustum planes
  22852. * @returns true if the submesh is intersecting with the frustum
  22853. */
  22854. isInFrustum(frustumPlanes: Plane[]): boolean;
  22855. /**
  22856. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22857. * @param frustumPlanes defines the frustum planes
  22858. * @returns true if the submesh is inside the frustum
  22859. */
  22860. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22861. /**
  22862. * Renders the submesh
  22863. * @param enableAlphaMode defines if alpha needs to be used
  22864. * @returns the submesh
  22865. */
  22866. render(enableAlphaMode: boolean): SubMesh;
  22867. /**
  22868. * @hidden
  22869. */
  22870. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22871. /**
  22872. * Checks if the submesh intersects with a ray
  22873. * @param ray defines the ray to test
  22874. * @returns true is the passed ray intersects the submesh bounding box
  22875. */
  22876. canIntersects(ray: Ray): boolean;
  22877. /**
  22878. * Intersects current submesh with a ray
  22879. * @param ray defines the ray to test
  22880. * @param positions defines mesh's positions array
  22881. * @param indices defines mesh's indices array
  22882. * @param fastCheck defines if only bounding info should be used
  22883. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22884. * @returns intersection info or null if no intersection
  22885. */
  22886. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22887. /** @hidden */
  22888. private _intersectLines;
  22889. /** @hidden */
  22890. private _intersectUnIndexedLines;
  22891. /** @hidden */
  22892. private _intersectTriangles;
  22893. /** @hidden */
  22894. private _intersectUnIndexedTriangles;
  22895. /** @hidden */
  22896. _rebuild(): void;
  22897. /**
  22898. * Creates a new submesh from the passed mesh
  22899. * @param newMesh defines the new hosting mesh
  22900. * @param newRenderingMesh defines an optional rendering mesh
  22901. * @returns the new submesh
  22902. */
  22903. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22904. /**
  22905. * Release associated resources
  22906. */
  22907. dispose(): void;
  22908. /**
  22909. * Gets the class name
  22910. * @returns the string "SubMesh".
  22911. */
  22912. getClassName(): string;
  22913. /**
  22914. * Creates a new submesh from indices data
  22915. * @param materialIndex the index of the main mesh material
  22916. * @param startIndex the index where to start the copy in the mesh indices array
  22917. * @param indexCount the number of indices to copy then from the startIndex
  22918. * @param mesh the main mesh to create the submesh from
  22919. * @param renderingMesh the optional rendering mesh
  22920. * @returns a new submesh
  22921. */
  22922. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22923. }
  22924. }
  22925. declare module BABYLON {
  22926. /**
  22927. * Class used to store geometry data (vertex buffers + index buffer)
  22928. */
  22929. export class Geometry implements IGetSetVerticesData {
  22930. /**
  22931. * Gets or sets the ID of the geometry
  22932. */
  22933. id: string;
  22934. /**
  22935. * Gets or sets the unique ID of the geometry
  22936. */
  22937. uniqueId: number;
  22938. /**
  22939. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22940. */
  22941. delayLoadState: number;
  22942. /**
  22943. * Gets the file containing the data to load when running in delay load state
  22944. */
  22945. delayLoadingFile: Nullable<string>;
  22946. /**
  22947. * Callback called when the geometry is updated
  22948. */
  22949. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22950. private _scene;
  22951. private _engine;
  22952. private _meshes;
  22953. private _totalVertices;
  22954. /** @hidden */
  22955. _indices: IndicesArray;
  22956. /** @hidden */
  22957. _vertexBuffers: {
  22958. [key: string]: VertexBuffer;
  22959. };
  22960. private _isDisposed;
  22961. private _extend;
  22962. private _boundingBias;
  22963. /** @hidden */
  22964. _delayInfo: Array<string>;
  22965. private _indexBuffer;
  22966. private _indexBufferIsUpdatable;
  22967. /** @hidden */
  22968. _boundingInfo: Nullable<BoundingInfo>;
  22969. /** @hidden */
  22970. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22971. /** @hidden */
  22972. _softwareSkinningFrameId: number;
  22973. private _vertexArrayObjects;
  22974. private _updatable;
  22975. /** @hidden */
  22976. _positions: Nullable<Vector3[]>;
  22977. /**
  22978. * 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
  22979. */
  22980. /**
  22981. * 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
  22982. */
  22983. boundingBias: Vector2;
  22984. /**
  22985. * Static function used to attach a new empty geometry to a mesh
  22986. * @param mesh defines the mesh to attach the geometry to
  22987. * @returns the new Geometry
  22988. */
  22989. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22990. /**
  22991. * Creates a new geometry
  22992. * @param id defines the unique ID
  22993. * @param scene defines the hosting scene
  22994. * @param vertexData defines the VertexData used to get geometry data
  22995. * @param updatable defines if geometry must be updatable (false by default)
  22996. * @param mesh defines the mesh that will be associated with the geometry
  22997. */
  22998. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22999. /**
  23000. * Gets the current extend of the geometry
  23001. */
  23002. readonly extend: {
  23003. minimum: Vector3;
  23004. maximum: Vector3;
  23005. };
  23006. /**
  23007. * Gets the hosting scene
  23008. * @returns the hosting Scene
  23009. */
  23010. getScene(): Scene;
  23011. /**
  23012. * Gets the hosting engine
  23013. * @returns the hosting Engine
  23014. */
  23015. getEngine(): Engine;
  23016. /**
  23017. * Defines if the geometry is ready to use
  23018. * @returns true if the geometry is ready to be used
  23019. */
  23020. isReady(): boolean;
  23021. /**
  23022. * Gets a value indicating that the geometry should not be serialized
  23023. */
  23024. readonly doNotSerialize: boolean;
  23025. /** @hidden */
  23026. _rebuild(): void;
  23027. /**
  23028. * Affects all geometry data in one call
  23029. * @param vertexData defines the geometry data
  23030. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23031. */
  23032. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23033. /**
  23034. * Set specific vertex data
  23035. * @param kind defines the data kind (Position, normal, etc...)
  23036. * @param data defines the vertex data to use
  23037. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23038. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23039. */
  23040. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23041. /**
  23042. * Removes a specific vertex data
  23043. * @param kind defines the data kind (Position, normal, etc...)
  23044. */
  23045. removeVerticesData(kind: string): void;
  23046. /**
  23047. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23048. * @param buffer defines the vertex buffer to use
  23049. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23050. */
  23051. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23052. /**
  23053. * Update a specific vertex buffer
  23054. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23055. * It will do nothing if the buffer is not updatable
  23056. * @param kind defines the data kind (Position, normal, etc...)
  23057. * @param data defines the data to use
  23058. * @param offset defines the offset in the target buffer where to store the data
  23059. * @param useBytes set to true if the offset is in bytes
  23060. */
  23061. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23062. /**
  23063. * Update a specific vertex buffer
  23064. * This function will create a new buffer if the current one is not updatable
  23065. * @param kind defines the data kind (Position, normal, etc...)
  23066. * @param data defines the data to use
  23067. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23068. */
  23069. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23070. private _updateBoundingInfo;
  23071. /** @hidden */
  23072. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23073. /**
  23074. * Gets total number of vertices
  23075. * @returns the total number of vertices
  23076. */
  23077. getTotalVertices(): number;
  23078. /**
  23079. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23080. * @param kind defines the data kind (Position, normal, etc...)
  23081. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23082. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23083. * @returns a float array containing vertex data
  23084. */
  23085. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23086. /**
  23087. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23088. * @param kind defines the data kind (Position, normal, etc...)
  23089. * @returns true if the vertex buffer with the specified kind is updatable
  23090. */
  23091. isVertexBufferUpdatable(kind: string): boolean;
  23092. /**
  23093. * Gets a specific vertex buffer
  23094. * @param kind defines the data kind (Position, normal, etc...)
  23095. * @returns a VertexBuffer
  23096. */
  23097. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23098. /**
  23099. * Returns all vertex buffers
  23100. * @return an object holding all vertex buffers indexed by kind
  23101. */
  23102. getVertexBuffers(): Nullable<{
  23103. [key: string]: VertexBuffer;
  23104. }>;
  23105. /**
  23106. * Gets a boolean indicating if specific vertex buffer is present
  23107. * @param kind defines the data kind (Position, normal, etc...)
  23108. * @returns true if data is present
  23109. */
  23110. isVerticesDataPresent(kind: string): boolean;
  23111. /**
  23112. * Gets a list of all attached data kinds (Position, normal, etc...)
  23113. * @returns a list of string containing all kinds
  23114. */
  23115. getVerticesDataKinds(): string[];
  23116. /**
  23117. * Update index buffer
  23118. * @param indices defines the indices to store in the index buffer
  23119. * @param offset defines the offset in the target buffer where to store the data
  23120. * @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)
  23121. */
  23122. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23123. /**
  23124. * Creates a new index buffer
  23125. * @param indices defines the indices to store in the index buffer
  23126. * @param totalVertices defines the total number of vertices (could be null)
  23127. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23128. */
  23129. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23130. /**
  23131. * Return the total number of indices
  23132. * @returns the total number of indices
  23133. */
  23134. getTotalIndices(): number;
  23135. /**
  23136. * Gets the index buffer array
  23137. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23138. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23139. * @returns the index buffer array
  23140. */
  23141. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23142. /**
  23143. * Gets the index buffer
  23144. * @return the index buffer
  23145. */
  23146. getIndexBuffer(): Nullable<DataBuffer>;
  23147. /** @hidden */
  23148. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23149. /**
  23150. * Release the associated resources for a specific mesh
  23151. * @param mesh defines the source mesh
  23152. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23153. */
  23154. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23155. /**
  23156. * Apply current geometry to a given mesh
  23157. * @param mesh defines the mesh to apply geometry to
  23158. */
  23159. applyToMesh(mesh: Mesh): void;
  23160. private _updateExtend;
  23161. private _applyToMesh;
  23162. private notifyUpdate;
  23163. /**
  23164. * Load the geometry if it was flagged as delay loaded
  23165. * @param scene defines the hosting scene
  23166. * @param onLoaded defines a callback called when the geometry is loaded
  23167. */
  23168. load(scene: Scene, onLoaded?: () => void): void;
  23169. private _queueLoad;
  23170. /**
  23171. * Invert the geometry to move from a right handed system to a left handed one.
  23172. */
  23173. toLeftHanded(): void;
  23174. /** @hidden */
  23175. _resetPointsArrayCache(): void;
  23176. /** @hidden */
  23177. _generatePointsArray(): boolean;
  23178. /**
  23179. * Gets a value indicating if the geometry is disposed
  23180. * @returns true if the geometry was disposed
  23181. */
  23182. isDisposed(): boolean;
  23183. private _disposeVertexArrayObjects;
  23184. /**
  23185. * Free all associated resources
  23186. */
  23187. dispose(): void;
  23188. /**
  23189. * Clone the current geometry into a new geometry
  23190. * @param id defines the unique ID of the new geometry
  23191. * @returns a new geometry object
  23192. */
  23193. copy(id: string): Geometry;
  23194. /**
  23195. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23196. * @return a JSON representation of the current geometry data (without the vertices data)
  23197. */
  23198. serialize(): any;
  23199. private toNumberArray;
  23200. /**
  23201. * Serialize all vertices data into a JSON oject
  23202. * @returns a JSON representation of the current geometry data
  23203. */
  23204. serializeVerticeData(): any;
  23205. /**
  23206. * Extracts a clone of a mesh geometry
  23207. * @param mesh defines the source mesh
  23208. * @param id defines the unique ID of the new geometry object
  23209. * @returns the new geometry object
  23210. */
  23211. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23212. /**
  23213. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23214. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23215. * Be aware Math.random() could cause collisions, but:
  23216. * "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"
  23217. * @returns a string containing a new GUID
  23218. */
  23219. static RandomId(): string;
  23220. /** @hidden */
  23221. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23222. private static _CleanMatricesWeights;
  23223. /**
  23224. * Create a new geometry from persisted data (Using .babylon file format)
  23225. * @param parsedVertexData defines the persisted data
  23226. * @param scene defines the hosting scene
  23227. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23228. * @returns the new geometry object
  23229. */
  23230. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23231. }
  23232. }
  23233. declare module BABYLON {
  23234. /**
  23235. * Define an interface for all classes that will get and set the data on vertices
  23236. */
  23237. export interface IGetSetVerticesData {
  23238. /**
  23239. * Gets a boolean indicating if specific vertex data is present
  23240. * @param kind defines the vertex data kind to use
  23241. * @returns true is data kind is present
  23242. */
  23243. isVerticesDataPresent(kind: string): boolean;
  23244. /**
  23245. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23246. * @param kind defines the data kind (Position, normal, etc...)
  23247. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23248. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23249. * @returns a float array containing vertex data
  23250. */
  23251. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23252. /**
  23253. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23254. * @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.
  23255. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23256. * @returns the indices array or an empty array if the mesh has no geometry
  23257. */
  23258. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23259. /**
  23260. * Set specific vertex data
  23261. * @param kind defines the data kind (Position, normal, etc...)
  23262. * @param data defines the vertex data to use
  23263. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23264. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23265. */
  23266. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23267. /**
  23268. * Update a specific associated vertex buffer
  23269. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23270. * - VertexBuffer.PositionKind
  23271. * - VertexBuffer.UVKind
  23272. * - VertexBuffer.UV2Kind
  23273. * - VertexBuffer.UV3Kind
  23274. * - VertexBuffer.UV4Kind
  23275. * - VertexBuffer.UV5Kind
  23276. * - VertexBuffer.UV6Kind
  23277. * - VertexBuffer.ColorKind
  23278. * - VertexBuffer.MatricesIndicesKind
  23279. * - VertexBuffer.MatricesIndicesExtraKind
  23280. * - VertexBuffer.MatricesWeightsKind
  23281. * - VertexBuffer.MatricesWeightsExtraKind
  23282. * @param data defines the data source
  23283. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23284. * @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)
  23285. */
  23286. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23287. /**
  23288. * Creates a new index buffer
  23289. * @param indices defines the indices to store in the index buffer
  23290. * @param totalVertices defines the total number of vertices (could be null)
  23291. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23292. */
  23293. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23294. }
  23295. /**
  23296. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23297. */
  23298. export class VertexData {
  23299. /**
  23300. * Mesh side orientation : usually the external or front surface
  23301. */
  23302. static readonly FRONTSIDE: number;
  23303. /**
  23304. * Mesh side orientation : usually the internal or back surface
  23305. */
  23306. static readonly BACKSIDE: number;
  23307. /**
  23308. * Mesh side orientation : both internal and external or front and back surfaces
  23309. */
  23310. static readonly DOUBLESIDE: number;
  23311. /**
  23312. * Mesh side orientation : by default, `FRONTSIDE`
  23313. */
  23314. static readonly DEFAULTSIDE: number;
  23315. /**
  23316. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23317. */
  23318. positions: Nullable<FloatArray>;
  23319. /**
  23320. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23321. */
  23322. normals: Nullable<FloatArray>;
  23323. /**
  23324. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23325. */
  23326. tangents: Nullable<FloatArray>;
  23327. /**
  23328. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23329. */
  23330. uvs: Nullable<FloatArray>;
  23331. /**
  23332. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23333. */
  23334. uvs2: Nullable<FloatArray>;
  23335. /**
  23336. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23337. */
  23338. uvs3: Nullable<FloatArray>;
  23339. /**
  23340. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23341. */
  23342. uvs4: Nullable<FloatArray>;
  23343. /**
  23344. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23345. */
  23346. uvs5: Nullable<FloatArray>;
  23347. /**
  23348. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23349. */
  23350. uvs6: Nullable<FloatArray>;
  23351. /**
  23352. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23353. */
  23354. colors: Nullable<FloatArray>;
  23355. /**
  23356. * 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).
  23357. */
  23358. matricesIndices: Nullable<FloatArray>;
  23359. /**
  23360. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23361. */
  23362. matricesWeights: Nullable<FloatArray>;
  23363. /**
  23364. * An array extending the number of possible indices
  23365. */
  23366. matricesIndicesExtra: Nullable<FloatArray>;
  23367. /**
  23368. * An array extending the number of possible weights when the number of indices is extended
  23369. */
  23370. matricesWeightsExtra: Nullable<FloatArray>;
  23371. /**
  23372. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23373. */
  23374. indices: Nullable<IndicesArray>;
  23375. /**
  23376. * Uses the passed data array to set the set the values for the specified kind of data
  23377. * @param data a linear array of floating numbers
  23378. * @param kind the type of data that is being set, eg positions, colors etc
  23379. */
  23380. set(data: FloatArray, kind: string): void;
  23381. /**
  23382. * Associates the vertexData to the passed Mesh.
  23383. * Sets it as updatable or not (default `false`)
  23384. * @param mesh the mesh the vertexData is applied to
  23385. * @param updatable when used and having the value true allows new data to update the vertexData
  23386. * @returns the VertexData
  23387. */
  23388. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23389. /**
  23390. * Associates the vertexData to the passed Geometry.
  23391. * Sets it as updatable or not (default `false`)
  23392. * @param geometry the geometry the vertexData is applied to
  23393. * @param updatable when used and having the value true allows new data to update the vertexData
  23394. * @returns VertexData
  23395. */
  23396. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23397. /**
  23398. * Updates the associated mesh
  23399. * @param mesh the mesh to be updated
  23400. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23401. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  23402. * @returns VertexData
  23403. */
  23404. updateMesh(mesh: Mesh): VertexData;
  23405. /**
  23406. * Updates the associated geometry
  23407. * @param geometry the geometry to be updated
  23408. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23409. * @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
  23410. * @returns VertexData.
  23411. */
  23412. updateGeometry(geometry: Geometry): VertexData;
  23413. private _applyTo;
  23414. private _update;
  23415. /**
  23416. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23417. * @param matrix the transforming matrix
  23418. * @returns the VertexData
  23419. */
  23420. transform(matrix: Matrix): VertexData;
  23421. /**
  23422. * Merges the passed VertexData into the current one
  23423. * @param other the VertexData to be merged into the current one
  23424. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23425. * @returns the modified VertexData
  23426. */
  23427. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23428. private _mergeElement;
  23429. private _validate;
  23430. /**
  23431. * Serializes the VertexData
  23432. * @returns a serialized object
  23433. */
  23434. serialize(): any;
  23435. /**
  23436. * Extracts the vertexData from a mesh
  23437. * @param mesh the mesh from which to extract the VertexData
  23438. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23439. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23440. * @returns the object VertexData associated to the passed mesh
  23441. */
  23442. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23443. /**
  23444. * Extracts the vertexData from the geometry
  23445. * @param geometry the geometry from which to extract the VertexData
  23446. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23447. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23448. * @returns the object VertexData associated to the passed mesh
  23449. */
  23450. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23451. private static _ExtractFrom;
  23452. /**
  23453. * Creates the VertexData for a Ribbon
  23454. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23455. * * pathArray array of paths, each of which an array of successive Vector3
  23456. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23457. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23458. * * 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
  23459. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23460. * * 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)
  23461. * * 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)
  23462. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23463. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23464. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23465. * @returns the VertexData of the ribbon
  23466. */
  23467. static CreateRibbon(options: {
  23468. pathArray: Vector3[][];
  23469. closeArray?: boolean;
  23470. closePath?: boolean;
  23471. offset?: number;
  23472. sideOrientation?: number;
  23473. frontUVs?: Vector4;
  23474. backUVs?: Vector4;
  23475. invertUV?: boolean;
  23476. uvs?: Vector2[];
  23477. colors?: Color4[];
  23478. }): VertexData;
  23479. /**
  23480. * Creates the VertexData for a box
  23481. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23482. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23483. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23484. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23485. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23486. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23487. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23488. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23489. * * 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)
  23490. * * 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)
  23491. * @returns the VertexData of the box
  23492. */
  23493. static CreateBox(options: {
  23494. size?: number;
  23495. width?: number;
  23496. height?: number;
  23497. depth?: number;
  23498. faceUV?: Vector4[];
  23499. faceColors?: Color4[];
  23500. sideOrientation?: number;
  23501. frontUVs?: Vector4;
  23502. backUVs?: Vector4;
  23503. }): VertexData;
  23504. /**
  23505. * Creates the VertexData for a tiled box
  23506. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23507. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23508. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23509. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23510. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23511. * @returns the VertexData of the box
  23512. */
  23513. static CreateTiledBox(options: {
  23514. pattern?: number;
  23515. width?: number;
  23516. height?: number;
  23517. depth?: number;
  23518. tileSize?: number;
  23519. tileWidth?: number;
  23520. tileHeight?: number;
  23521. alignHorizontal?: number;
  23522. alignVertical?: number;
  23523. faceUV?: Vector4[];
  23524. faceColors?: Color4[];
  23525. sideOrientation?: number;
  23526. }): VertexData;
  23527. /**
  23528. * Creates the VertexData for a tiled plane
  23529. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23530. * * pattern a limited pattern arrangement depending on the number
  23531. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23532. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23533. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23534. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23535. * * 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)
  23536. * * 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)
  23537. * @returns the VertexData of the tiled plane
  23538. */
  23539. static CreateTiledPlane(options: {
  23540. pattern?: number;
  23541. tileSize?: number;
  23542. tileWidth?: number;
  23543. tileHeight?: number;
  23544. size?: number;
  23545. width?: number;
  23546. height?: number;
  23547. alignHorizontal?: number;
  23548. alignVertical?: number;
  23549. sideOrientation?: number;
  23550. frontUVs?: Vector4;
  23551. backUVs?: Vector4;
  23552. }): VertexData;
  23553. /**
  23554. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23555. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23556. * * segments sets the number of horizontal strips optional, default 32
  23557. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23558. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23559. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23560. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23561. * * 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
  23562. * * 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
  23563. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23564. * * 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)
  23565. * * 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)
  23566. * @returns the VertexData of the ellipsoid
  23567. */
  23568. static CreateSphere(options: {
  23569. segments?: number;
  23570. diameter?: number;
  23571. diameterX?: number;
  23572. diameterY?: number;
  23573. diameterZ?: number;
  23574. arc?: number;
  23575. slice?: number;
  23576. sideOrientation?: number;
  23577. frontUVs?: Vector4;
  23578. backUVs?: Vector4;
  23579. }): VertexData;
  23580. /**
  23581. * Creates the VertexData for a cylinder, cone or prism
  23582. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23583. * * height sets the height (y direction) of the cylinder, optional, default 2
  23584. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23585. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23586. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23587. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23588. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23589. * * 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
  23590. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23591. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23592. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23593. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23594. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23595. * * 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)
  23596. * * 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)
  23597. * @returns the VertexData of the cylinder, cone or prism
  23598. */
  23599. static CreateCylinder(options: {
  23600. height?: number;
  23601. diameterTop?: number;
  23602. diameterBottom?: number;
  23603. diameter?: number;
  23604. tessellation?: number;
  23605. subdivisions?: number;
  23606. arc?: number;
  23607. faceColors?: Color4[];
  23608. faceUV?: Vector4[];
  23609. hasRings?: boolean;
  23610. enclose?: boolean;
  23611. sideOrientation?: number;
  23612. frontUVs?: Vector4;
  23613. backUVs?: Vector4;
  23614. }): VertexData;
  23615. /**
  23616. * Creates the VertexData for a torus
  23617. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23618. * * diameter the diameter of the torus, optional default 1
  23619. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23620. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23621. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23622. * * 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)
  23623. * * 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)
  23624. * @returns the VertexData of the torus
  23625. */
  23626. static CreateTorus(options: {
  23627. diameter?: number;
  23628. thickness?: number;
  23629. tessellation?: number;
  23630. sideOrientation?: number;
  23631. frontUVs?: Vector4;
  23632. backUVs?: Vector4;
  23633. }): VertexData;
  23634. /**
  23635. * Creates the VertexData of the LineSystem
  23636. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23637. * - lines an array of lines, each line being an array of successive Vector3
  23638. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23639. * @returns the VertexData of the LineSystem
  23640. */
  23641. static CreateLineSystem(options: {
  23642. lines: Vector3[][];
  23643. colors?: Nullable<Color4[][]>;
  23644. }): VertexData;
  23645. /**
  23646. * Create the VertexData for a DashedLines
  23647. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23648. * - points an array successive Vector3
  23649. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23650. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23651. * - dashNb the intended total number of dashes, optional, default 200
  23652. * @returns the VertexData for the DashedLines
  23653. */
  23654. static CreateDashedLines(options: {
  23655. points: Vector3[];
  23656. dashSize?: number;
  23657. gapSize?: number;
  23658. dashNb?: number;
  23659. }): VertexData;
  23660. /**
  23661. * Creates the VertexData for a Ground
  23662. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23663. * - width the width (x direction) of the ground, optional, default 1
  23664. * - height the height (z direction) of the ground, optional, default 1
  23665. * - subdivisions the number of subdivisions per side, optional, default 1
  23666. * @returns the VertexData of the Ground
  23667. */
  23668. static CreateGround(options: {
  23669. width?: number;
  23670. height?: number;
  23671. subdivisions?: number;
  23672. subdivisionsX?: number;
  23673. subdivisionsY?: number;
  23674. }): VertexData;
  23675. /**
  23676. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23677. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23678. * * xmin the ground minimum X coordinate, optional, default -1
  23679. * * zmin the ground minimum Z coordinate, optional, default -1
  23680. * * xmax the ground maximum X coordinate, optional, default 1
  23681. * * zmax the ground maximum Z coordinate, optional, default 1
  23682. * * 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}
  23683. * * 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}
  23684. * @returns the VertexData of the TiledGround
  23685. */
  23686. static CreateTiledGround(options: {
  23687. xmin: number;
  23688. zmin: number;
  23689. xmax: number;
  23690. zmax: number;
  23691. subdivisions?: {
  23692. w: number;
  23693. h: number;
  23694. };
  23695. precision?: {
  23696. w: number;
  23697. h: number;
  23698. };
  23699. }): VertexData;
  23700. /**
  23701. * Creates the VertexData of the Ground designed from a heightmap
  23702. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23703. * * width the width (x direction) of the ground
  23704. * * height the height (z direction) of the ground
  23705. * * subdivisions the number of subdivisions per side
  23706. * * minHeight the minimum altitude on the ground, optional, default 0
  23707. * * maxHeight the maximum altitude on the ground, optional default 1
  23708. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23709. * * buffer the array holding the image color data
  23710. * * bufferWidth the width of image
  23711. * * bufferHeight the height of image
  23712. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23713. * @returns the VertexData of the Ground designed from a heightmap
  23714. */
  23715. static CreateGroundFromHeightMap(options: {
  23716. width: number;
  23717. height: number;
  23718. subdivisions: number;
  23719. minHeight: number;
  23720. maxHeight: number;
  23721. colorFilter: Color3;
  23722. buffer: Uint8Array;
  23723. bufferWidth: number;
  23724. bufferHeight: number;
  23725. alphaFilter: number;
  23726. }): VertexData;
  23727. /**
  23728. * Creates the VertexData for a Plane
  23729. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23730. * * size sets the width and height of the plane to the value of size, optional default 1
  23731. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23732. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23733. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23734. * * 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)
  23735. * * 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)
  23736. * @returns the VertexData of the box
  23737. */
  23738. static CreatePlane(options: {
  23739. size?: number;
  23740. width?: number;
  23741. height?: number;
  23742. sideOrientation?: number;
  23743. frontUVs?: Vector4;
  23744. backUVs?: Vector4;
  23745. }): VertexData;
  23746. /**
  23747. * Creates the VertexData of the Disc or regular Polygon
  23748. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23749. * * radius the radius of the disc, optional default 0.5
  23750. * * tessellation the number of polygon sides, optional, default 64
  23751. * * 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
  23752. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23753. * * 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)
  23754. * * 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)
  23755. * @returns the VertexData of the box
  23756. */
  23757. static CreateDisc(options: {
  23758. radius?: number;
  23759. tessellation?: number;
  23760. arc?: number;
  23761. sideOrientation?: number;
  23762. frontUVs?: Vector4;
  23763. backUVs?: Vector4;
  23764. }): VertexData;
  23765. /**
  23766. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23767. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23768. * @param polygon a mesh built from polygonTriangulation.build()
  23769. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23770. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23771. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23772. * @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)
  23773. * @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)
  23774. * @returns the VertexData of the Polygon
  23775. */
  23776. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23777. /**
  23778. * Creates the VertexData of the IcoSphere
  23779. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23780. * * radius the radius of the IcoSphere, optional default 1
  23781. * * radiusX allows stretching in the x direction, optional, default radius
  23782. * * radiusY allows stretching in the y direction, optional, default radius
  23783. * * radiusZ allows stretching in the z direction, optional, default radius
  23784. * * flat when true creates a flat shaded mesh, optional, default true
  23785. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23786. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23787. * * 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)
  23788. * * 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)
  23789. * @returns the VertexData of the IcoSphere
  23790. */
  23791. static CreateIcoSphere(options: {
  23792. radius?: number;
  23793. radiusX?: number;
  23794. radiusY?: number;
  23795. radiusZ?: number;
  23796. flat?: boolean;
  23797. subdivisions?: number;
  23798. sideOrientation?: number;
  23799. frontUVs?: Vector4;
  23800. backUVs?: Vector4;
  23801. }): VertexData;
  23802. /**
  23803. * Creates the VertexData for a Polyhedron
  23804. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23805. * * type provided types are:
  23806. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23807. * * 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)
  23808. * * size the size of the IcoSphere, optional default 1
  23809. * * sizeX allows stretching in the x direction, optional, default size
  23810. * * sizeY allows stretching in the y direction, optional, default size
  23811. * * sizeZ allows stretching in the z direction, optional, default size
  23812. * * 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
  23813. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23814. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23815. * * flat when true creates a flat shaded mesh, optional, default true
  23816. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23817. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23818. * * 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)
  23819. * * 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)
  23820. * @returns the VertexData of the Polyhedron
  23821. */
  23822. static CreatePolyhedron(options: {
  23823. type?: number;
  23824. size?: number;
  23825. sizeX?: number;
  23826. sizeY?: number;
  23827. sizeZ?: number;
  23828. custom?: any;
  23829. faceUV?: Vector4[];
  23830. faceColors?: Color4[];
  23831. flat?: boolean;
  23832. sideOrientation?: number;
  23833. frontUVs?: Vector4;
  23834. backUVs?: Vector4;
  23835. }): VertexData;
  23836. /**
  23837. * Creates the VertexData for a TorusKnot
  23838. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23839. * * radius the radius of the torus knot, optional, default 2
  23840. * * tube the thickness of the tube, optional, default 0.5
  23841. * * radialSegments the number of sides on each tube segments, optional, default 32
  23842. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23843. * * p the number of windings around the z axis, optional, default 2
  23844. * * q the number of windings around the x axis, optional, default 3
  23845. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23846. * * 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)
  23847. * * 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)
  23848. * @returns the VertexData of the Torus Knot
  23849. */
  23850. static CreateTorusKnot(options: {
  23851. radius?: number;
  23852. tube?: number;
  23853. radialSegments?: number;
  23854. tubularSegments?: number;
  23855. p?: number;
  23856. q?: number;
  23857. sideOrientation?: number;
  23858. frontUVs?: Vector4;
  23859. backUVs?: Vector4;
  23860. }): VertexData;
  23861. /**
  23862. * Compute normals for given positions and indices
  23863. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23864. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23865. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23866. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23867. * * facetNormals : optional array of facet normals (vector3)
  23868. * * facetPositions : optional array of facet positions (vector3)
  23869. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23870. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23871. * * bInfo : optional bounding info, required for facetPartitioning computation
  23872. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23873. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23874. * * useRightHandedSystem: optional boolean to for right handed system computation
  23875. * * depthSort : optional boolean to enable the facet depth sort computation
  23876. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23877. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23878. */
  23879. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23880. facetNormals?: any;
  23881. facetPositions?: any;
  23882. facetPartitioning?: any;
  23883. ratio?: number;
  23884. bInfo?: any;
  23885. bbSize?: Vector3;
  23886. subDiv?: any;
  23887. useRightHandedSystem?: boolean;
  23888. depthSort?: boolean;
  23889. distanceTo?: Vector3;
  23890. depthSortedFacets?: any;
  23891. }): void;
  23892. /** @hidden */
  23893. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23894. /**
  23895. * Applies VertexData created from the imported parameters to the geometry
  23896. * @param parsedVertexData the parsed data from an imported file
  23897. * @param geometry the geometry to apply the VertexData to
  23898. */
  23899. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23900. }
  23901. }
  23902. declare module BABYLON {
  23903. /**
  23904. * Class containing static functions to help procedurally build meshes
  23905. */
  23906. export class DiscBuilder {
  23907. /**
  23908. * Creates a plane polygonal mesh. By default, this is a disc
  23909. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23910. * * 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
  23911. * * 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
  23912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23913. * * 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
  23914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23915. * @param name defines the name of the mesh
  23916. * @param options defines the options used to create the mesh
  23917. * @param scene defines the hosting scene
  23918. * @returns the plane polygonal mesh
  23919. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23920. */
  23921. static CreateDisc(name: string, options: {
  23922. radius?: number;
  23923. tessellation?: number;
  23924. arc?: number;
  23925. updatable?: boolean;
  23926. sideOrientation?: number;
  23927. frontUVs?: Vector4;
  23928. backUVs?: Vector4;
  23929. }, scene?: Nullable<Scene>): Mesh;
  23930. }
  23931. }
  23932. declare module BABYLON {
  23933. /**
  23934. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23935. *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.
  23936. * The SPS is also a particle system. It provides some methods to manage the particles.
  23937. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23938. *
  23939. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23940. */
  23941. export class SolidParticleSystem implements IDisposable {
  23942. /**
  23943. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23944. * Example : var p = SPS.particles[i];
  23945. */
  23946. particles: SolidParticle[];
  23947. /**
  23948. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23949. */
  23950. nbParticles: number;
  23951. /**
  23952. * If the particles must ever face the camera (default false). Useful for planar particles.
  23953. */
  23954. billboard: boolean;
  23955. /**
  23956. * Recompute normals when adding a shape
  23957. */
  23958. recomputeNormals: boolean;
  23959. /**
  23960. * This a counter ofr your own usage. It's not set by any SPS functions.
  23961. */
  23962. counter: number;
  23963. /**
  23964. * The SPS name. This name is also given to the underlying mesh.
  23965. */
  23966. name: string;
  23967. /**
  23968. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23969. */
  23970. mesh: Mesh;
  23971. /**
  23972. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23973. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23974. */
  23975. vars: any;
  23976. /**
  23977. * This array is populated when the SPS is set as 'pickable'.
  23978. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23979. * Each element of this array is an object `{idx: int, faceId: int}`.
  23980. * `idx` is the picked particle index in the `SPS.particles` array
  23981. * `faceId` is the picked face index counted within this particle.
  23982. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23983. */
  23984. pickedParticles: {
  23985. idx: number;
  23986. faceId: number;
  23987. }[];
  23988. /**
  23989. * This array is populated when `enableDepthSort` is set to true.
  23990. * Each element of this array is an instance of the class DepthSortedParticle.
  23991. */
  23992. depthSortedParticles: DepthSortedParticle[];
  23993. /**
  23994. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23995. * @hidden
  23996. */
  23997. _bSphereOnly: boolean;
  23998. /**
  23999. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24000. * @hidden
  24001. */
  24002. _bSphereRadiusFactor: number;
  24003. private _scene;
  24004. private _positions;
  24005. private _indices;
  24006. private _normals;
  24007. private _colors;
  24008. private _uvs;
  24009. private _indices32;
  24010. private _positions32;
  24011. private _normals32;
  24012. private _fixedNormal32;
  24013. private _colors32;
  24014. private _uvs32;
  24015. private _index;
  24016. private _updatable;
  24017. private _pickable;
  24018. private _isVisibilityBoxLocked;
  24019. private _alwaysVisible;
  24020. private _depthSort;
  24021. private _shapeCounter;
  24022. private _copy;
  24023. private _color;
  24024. private _computeParticleColor;
  24025. private _computeParticleTexture;
  24026. private _computeParticleRotation;
  24027. private _computeParticleVertex;
  24028. private _computeBoundingBox;
  24029. private _depthSortParticles;
  24030. private _camera;
  24031. private _mustUnrotateFixedNormals;
  24032. private _particlesIntersect;
  24033. private _needs32Bits;
  24034. /**
  24035. * Creates a SPS (Solid Particle System) object.
  24036. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24037. * @param scene (Scene) is the scene in which the SPS is added.
  24038. * @param options defines the options of the sps e.g.
  24039. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24040. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24041. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24042. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24043. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24044. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24045. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24046. */
  24047. constructor(name: string, scene: Scene, options?: {
  24048. updatable?: boolean;
  24049. isPickable?: boolean;
  24050. enableDepthSort?: boolean;
  24051. particleIntersection?: boolean;
  24052. boundingSphereOnly?: boolean;
  24053. bSphereRadiusFactor?: number;
  24054. });
  24055. /**
  24056. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24057. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24058. * @returns the created mesh
  24059. */
  24060. buildMesh(): Mesh;
  24061. /**
  24062. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24063. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24064. * Thus the particles generated from `digest()` have their property `position` set yet.
  24065. * @param mesh ( Mesh ) is the mesh to be digested
  24066. * @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
  24067. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24068. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24069. * @returns the current SPS
  24070. */
  24071. digest(mesh: Mesh, options?: {
  24072. facetNb?: number;
  24073. number?: number;
  24074. delta?: number;
  24075. }): SolidParticleSystem;
  24076. private _unrotateFixedNormals;
  24077. private _resetCopy;
  24078. private _meshBuilder;
  24079. private _posToShape;
  24080. private _uvsToShapeUV;
  24081. private _addParticle;
  24082. /**
  24083. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24084. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24085. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24086. * @param nb (positive integer) the number of particles to be created from this model
  24087. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24088. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24089. * @returns the number of shapes in the system
  24090. */
  24091. addShape(mesh: Mesh, nb: number, options?: {
  24092. positionFunction?: any;
  24093. vertexFunction?: any;
  24094. }): number;
  24095. private _rebuildParticle;
  24096. /**
  24097. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24098. * @returns the SPS.
  24099. */
  24100. rebuildMesh(): SolidParticleSystem;
  24101. /**
  24102. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24103. * This method calls `updateParticle()` for each particle of the SPS.
  24104. * For an animated SPS, it is usually called within the render loop.
  24105. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24106. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24107. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24108. * @returns the SPS.
  24109. */
  24110. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24111. /**
  24112. * Disposes the SPS.
  24113. */
  24114. dispose(): void;
  24115. /**
  24116. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24117. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24118. * @returns the SPS.
  24119. */
  24120. refreshVisibleSize(): SolidParticleSystem;
  24121. /**
  24122. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24123. * @param size the size (float) of the visibility box
  24124. * note : this doesn't lock the SPS mesh bounding box.
  24125. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24126. */
  24127. setVisibilityBox(size: number): void;
  24128. /**
  24129. * Gets whether the SPS as always visible or not
  24130. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24131. */
  24132. /**
  24133. * Sets the SPS as always visible or not
  24134. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24135. */
  24136. isAlwaysVisible: boolean;
  24137. /**
  24138. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24139. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24140. */
  24141. /**
  24142. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24143. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24144. */
  24145. isVisibilityBoxLocked: boolean;
  24146. /**
  24147. * Tells to `setParticles()` to compute the particle rotations or not.
  24148. * Default value : true. The SPS is faster when it's set to false.
  24149. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24150. */
  24151. /**
  24152. * Gets if `setParticles()` computes the particle rotations or not.
  24153. * Default value : true. The SPS is faster when it's set to false.
  24154. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24155. */
  24156. computeParticleRotation: boolean;
  24157. /**
  24158. * Tells to `setParticles()` to compute the particle colors or not.
  24159. * Default value : true. The SPS is faster when it's set to false.
  24160. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24161. */
  24162. /**
  24163. * Gets if `setParticles()` computes the particle colors or not.
  24164. * Default value : true. The SPS is faster when it's set to false.
  24165. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24166. */
  24167. computeParticleColor: boolean;
  24168. /**
  24169. * Gets if `setParticles()` computes the particle textures or not.
  24170. * Default value : true. The SPS is faster when it's set to false.
  24171. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24172. */
  24173. computeParticleTexture: boolean;
  24174. /**
  24175. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24176. * Default value : false. The SPS is faster when it's set to false.
  24177. * Note : the particle custom vertex positions aren't stored values.
  24178. */
  24179. /**
  24180. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24181. * Default value : false. The SPS is faster when it's set to false.
  24182. * Note : the particle custom vertex positions aren't stored values.
  24183. */
  24184. computeParticleVertex: boolean;
  24185. /**
  24186. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24187. */
  24188. /**
  24189. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24190. */
  24191. computeBoundingBox: boolean;
  24192. /**
  24193. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24194. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24195. * Default : `true`
  24196. */
  24197. /**
  24198. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24199. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24200. * Default : `true`
  24201. */
  24202. depthSortParticles: boolean;
  24203. /**
  24204. * This function does nothing. It may be overwritten to set all the particle first values.
  24205. * The SPS doesn't call this function, you may have to call it by your own.
  24206. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24207. */
  24208. initParticles(): void;
  24209. /**
  24210. * This function does nothing. It may be overwritten to recycle a particle.
  24211. * The SPS doesn't call this function, you may have to call it by your own.
  24212. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24213. * @param particle The particle to recycle
  24214. * @returns the recycled particle
  24215. */
  24216. recycleParticle(particle: SolidParticle): SolidParticle;
  24217. /**
  24218. * Updates a particle : this function should be overwritten by the user.
  24219. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24220. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24221. * @example : just set a particle position or velocity and recycle conditions
  24222. * @param particle The particle to update
  24223. * @returns the updated particle
  24224. */
  24225. updateParticle(particle: SolidParticle): SolidParticle;
  24226. /**
  24227. * Updates a vertex of a particle : it can be overwritten by the user.
  24228. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24229. * @param particle the current particle
  24230. * @param vertex the current index of the current particle
  24231. * @param pt the index of the current vertex in the particle shape
  24232. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24233. * @example : just set a vertex particle position
  24234. * @returns the updated vertex
  24235. */
  24236. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24237. /**
  24238. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24239. * This does nothing and may be overwritten by the user.
  24240. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24241. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24242. * @param update the boolean update value actually passed to setParticles()
  24243. */
  24244. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24245. /**
  24246. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24247. * This will be passed three parameters.
  24248. * This does nothing and may be overwritten by the user.
  24249. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24250. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24251. * @param update the boolean update value actually passed to setParticles()
  24252. */
  24253. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24254. }
  24255. }
  24256. declare module BABYLON {
  24257. /**
  24258. * Represents one particle of a solid particle system.
  24259. */
  24260. export class SolidParticle {
  24261. /**
  24262. * particle global index
  24263. */
  24264. idx: number;
  24265. /**
  24266. * The color of the particle
  24267. */
  24268. color: Nullable<Color4>;
  24269. /**
  24270. * The world space position of the particle.
  24271. */
  24272. position: Vector3;
  24273. /**
  24274. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24275. */
  24276. rotation: Vector3;
  24277. /**
  24278. * The world space rotation quaternion of the particle.
  24279. */
  24280. rotationQuaternion: Nullable<Quaternion>;
  24281. /**
  24282. * The scaling of the particle.
  24283. */
  24284. scaling: Vector3;
  24285. /**
  24286. * The uvs of the particle.
  24287. */
  24288. uvs: Vector4;
  24289. /**
  24290. * The current speed of the particle.
  24291. */
  24292. velocity: Vector3;
  24293. /**
  24294. * The pivot point in the particle local space.
  24295. */
  24296. pivot: Vector3;
  24297. /**
  24298. * Must the particle be translated from its pivot point in its local space ?
  24299. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24300. * Default : false
  24301. */
  24302. translateFromPivot: boolean;
  24303. /**
  24304. * Is the particle active or not ?
  24305. */
  24306. alive: boolean;
  24307. /**
  24308. * Is the particle visible or not ?
  24309. */
  24310. isVisible: boolean;
  24311. /**
  24312. * Index of this particle in the global "positions" array (Internal use)
  24313. * @hidden
  24314. */
  24315. _pos: number;
  24316. /**
  24317. * @hidden Index of this particle in the global "indices" array (Internal use)
  24318. */
  24319. _ind: number;
  24320. /**
  24321. * @hidden ModelShape of this particle (Internal use)
  24322. */
  24323. _model: ModelShape;
  24324. /**
  24325. * ModelShape id of this particle
  24326. */
  24327. shapeId: number;
  24328. /**
  24329. * Index of the particle in its shape id (Internal use)
  24330. */
  24331. idxInShape: number;
  24332. /**
  24333. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24334. */
  24335. _modelBoundingInfo: BoundingInfo;
  24336. /**
  24337. * @hidden Particle BoundingInfo object (Internal use)
  24338. */
  24339. _boundingInfo: BoundingInfo;
  24340. /**
  24341. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24342. */
  24343. _sps: SolidParticleSystem;
  24344. /**
  24345. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24346. */
  24347. _stillInvisible: boolean;
  24348. /**
  24349. * @hidden Last computed particle rotation matrix
  24350. */
  24351. _rotationMatrix: number[];
  24352. /**
  24353. * Parent particle Id, if any.
  24354. * Default null.
  24355. */
  24356. parentId: Nullable<number>;
  24357. /**
  24358. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24359. * The possible values are :
  24360. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24361. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24362. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24363. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24364. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24365. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24366. * */
  24367. cullingStrategy: number;
  24368. /**
  24369. * @hidden Internal global position in the SPS.
  24370. */
  24371. _globalPosition: Vector3;
  24372. /**
  24373. * Creates a Solid Particle object.
  24374. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24375. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24376. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24377. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24378. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24379. * @param shapeId (integer) is the model shape identifier in the SPS.
  24380. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24381. * @param sps defines the sps it is associated to
  24382. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24383. */
  24384. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24385. /**
  24386. * Legacy support, changed scale to scaling
  24387. */
  24388. /**
  24389. * Legacy support, changed scale to scaling
  24390. */
  24391. scale: Vector3;
  24392. /**
  24393. * Legacy support, changed quaternion to rotationQuaternion
  24394. */
  24395. /**
  24396. * Legacy support, changed quaternion to rotationQuaternion
  24397. */
  24398. quaternion: Nullable<Quaternion>;
  24399. /**
  24400. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24401. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24402. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24403. * @returns true if it intersects
  24404. */
  24405. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24406. /**
  24407. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24408. * A particle is in the frustum if its bounding box intersects the frustum
  24409. * @param frustumPlanes defines the frustum to test
  24410. * @returns true if the particle is in the frustum planes
  24411. */
  24412. isInFrustum(frustumPlanes: Plane[]): boolean;
  24413. /**
  24414. * get the rotation matrix of the particle
  24415. * @hidden
  24416. */
  24417. getRotationMatrix(m: Matrix): void;
  24418. }
  24419. /**
  24420. * Represents the shape of the model used by one particle of a solid particle system.
  24421. * SPS internal tool, don't use it manually.
  24422. */
  24423. export class ModelShape {
  24424. /**
  24425. * The shape id
  24426. * @hidden
  24427. */
  24428. shapeID: number;
  24429. /**
  24430. * flat array of model positions (internal use)
  24431. * @hidden
  24432. */
  24433. _shape: Vector3[];
  24434. /**
  24435. * flat array of model UVs (internal use)
  24436. * @hidden
  24437. */
  24438. _shapeUV: number[];
  24439. /**
  24440. * length of the shape in the model indices array (internal use)
  24441. * @hidden
  24442. */
  24443. _indicesLength: number;
  24444. /**
  24445. * Custom position function (internal use)
  24446. * @hidden
  24447. */
  24448. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24449. /**
  24450. * Custom vertex function (internal use)
  24451. * @hidden
  24452. */
  24453. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24454. /**
  24455. * 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.
  24456. * SPS internal tool, don't use it manually.
  24457. * @hidden
  24458. */
  24459. 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>);
  24460. }
  24461. /**
  24462. * Represents a Depth Sorted Particle in the solid particle system.
  24463. */
  24464. export class DepthSortedParticle {
  24465. /**
  24466. * Index of the particle in the "indices" array
  24467. */
  24468. ind: number;
  24469. /**
  24470. * Length of the particle shape in the "indices" array
  24471. */
  24472. indicesLength: number;
  24473. /**
  24474. * Squared distance from the particle to the camera
  24475. */
  24476. sqDistance: number;
  24477. }
  24478. }
  24479. declare module BABYLON {
  24480. /**
  24481. * @hidden
  24482. */
  24483. export class _MeshCollisionData {
  24484. _checkCollisions: boolean;
  24485. _collisionMask: number;
  24486. _collisionGroup: number;
  24487. _collider: Nullable<Collider>;
  24488. _oldPositionForCollisions: Vector3;
  24489. _diffPositionForCollisions: Vector3;
  24490. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24491. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24492. }
  24493. }
  24494. declare module BABYLON {
  24495. /** @hidden */
  24496. class _FacetDataStorage {
  24497. facetPositions: Vector3[];
  24498. facetNormals: Vector3[];
  24499. facetPartitioning: number[][];
  24500. facetNb: number;
  24501. partitioningSubdivisions: number;
  24502. partitioningBBoxRatio: number;
  24503. facetDataEnabled: boolean;
  24504. facetParameters: any;
  24505. bbSize: Vector3;
  24506. subDiv: {
  24507. max: number;
  24508. X: number;
  24509. Y: number;
  24510. Z: number;
  24511. };
  24512. facetDepthSort: boolean;
  24513. facetDepthSortEnabled: boolean;
  24514. depthSortedIndices: IndicesArray;
  24515. depthSortedFacets: {
  24516. ind: number;
  24517. sqDistance: number;
  24518. }[];
  24519. facetDepthSortFunction: (f1: {
  24520. ind: number;
  24521. sqDistance: number;
  24522. }, f2: {
  24523. ind: number;
  24524. sqDistance: number;
  24525. }) => number;
  24526. facetDepthSortFrom: Vector3;
  24527. facetDepthSortOrigin: Vector3;
  24528. invertedMatrix: Matrix;
  24529. }
  24530. /**
  24531. * @hidden
  24532. **/
  24533. class _InternalAbstractMeshDataInfo {
  24534. _hasVertexAlpha: boolean;
  24535. _useVertexColors: boolean;
  24536. _numBoneInfluencers: number;
  24537. _applyFog: boolean;
  24538. _receiveShadows: boolean;
  24539. _facetData: _FacetDataStorage;
  24540. _visibility: number;
  24541. _skeleton: Nullable<Skeleton>;
  24542. _layerMask: number;
  24543. _computeBonesUsingShaders: boolean;
  24544. _isActive: boolean;
  24545. _onlyForInstances: boolean;
  24546. _isActiveIntermediate: boolean;
  24547. _onlyForInstancesIntermediate: boolean;
  24548. }
  24549. /**
  24550. * Class used to store all common mesh properties
  24551. */
  24552. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24553. /** No occlusion */
  24554. static OCCLUSION_TYPE_NONE: number;
  24555. /** Occlusion set to optimisitic */
  24556. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24557. /** Occlusion set to strict */
  24558. static OCCLUSION_TYPE_STRICT: number;
  24559. /** Use an accurante occlusion algorithm */
  24560. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24561. /** Use a conservative occlusion algorithm */
  24562. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24563. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24564. * Test order :
  24565. * Is the bounding sphere outside the frustum ?
  24566. * If not, are the bounding box vertices outside the frustum ?
  24567. * It not, then the cullable object is in the frustum.
  24568. */
  24569. static readonly CULLINGSTRATEGY_STANDARD: number;
  24570. /** Culling strategy : Bounding Sphere Only.
  24571. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24572. * It's also less accurate than the standard because some not visible objects can still be selected.
  24573. * Test : is the bounding sphere outside the frustum ?
  24574. * If not, then the cullable object is in the frustum.
  24575. */
  24576. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24577. /** Culling strategy : Optimistic Inclusion.
  24578. * This in an inclusion test first, then the standard exclusion test.
  24579. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24580. * 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.
  24581. * Anyway, it's as accurate as the standard strategy.
  24582. * Test :
  24583. * Is the cullable object bounding sphere center in the frustum ?
  24584. * If not, apply the default culling strategy.
  24585. */
  24586. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24587. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24588. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24589. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24590. * 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.
  24591. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24592. * Test :
  24593. * Is the cullable object bounding sphere center in the frustum ?
  24594. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24595. */
  24596. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24597. /**
  24598. * No billboard
  24599. */
  24600. static readonly BILLBOARDMODE_NONE: number;
  24601. /** Billboard on X axis */
  24602. static readonly BILLBOARDMODE_X: number;
  24603. /** Billboard on Y axis */
  24604. static readonly BILLBOARDMODE_Y: number;
  24605. /** Billboard on Z axis */
  24606. static readonly BILLBOARDMODE_Z: number;
  24607. /** Billboard on all axes */
  24608. static readonly BILLBOARDMODE_ALL: number;
  24609. /** @hidden */
  24610. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24611. /**
  24612. * The culling strategy to use to check whether the mesh must be rendered or not.
  24613. * This value can be changed at any time and will be used on the next render mesh selection.
  24614. * The possible values are :
  24615. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24616. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24617. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24618. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24619. * Please read each static variable documentation to get details about the culling process.
  24620. * */
  24621. cullingStrategy: number;
  24622. /**
  24623. * Gets the number of facets in the mesh
  24624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24625. */
  24626. readonly facetNb: number;
  24627. /**
  24628. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24629. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24630. */
  24631. partitioningSubdivisions: number;
  24632. /**
  24633. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24634. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24635. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24636. */
  24637. partitioningBBoxRatio: number;
  24638. /**
  24639. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24640. * Works only for updatable meshes.
  24641. * Doesn't work with multi-materials
  24642. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24643. */
  24644. mustDepthSortFacets: boolean;
  24645. /**
  24646. * The location (Vector3) where the facet depth sort must be computed from.
  24647. * By default, the active camera position.
  24648. * Used only when facet depth sort is enabled
  24649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24650. */
  24651. facetDepthSortFrom: Vector3;
  24652. /**
  24653. * gets a boolean indicating if facetData is enabled
  24654. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24655. */
  24656. readonly isFacetDataEnabled: boolean;
  24657. /** @hidden */
  24658. _updateNonUniformScalingState(value: boolean): boolean;
  24659. /**
  24660. * An event triggered when this mesh collides with another one
  24661. */
  24662. onCollideObservable: Observable<AbstractMesh>;
  24663. /** Set a function to call when this mesh collides with another one */
  24664. onCollide: () => void;
  24665. /**
  24666. * An event triggered when the collision's position changes
  24667. */
  24668. onCollisionPositionChangeObservable: Observable<Vector3>;
  24669. /** Set a function to call when the collision's position changes */
  24670. onCollisionPositionChange: () => void;
  24671. /**
  24672. * An event triggered when material is changed
  24673. */
  24674. onMaterialChangedObservable: Observable<AbstractMesh>;
  24675. /**
  24676. * Gets or sets the orientation for POV movement & rotation
  24677. */
  24678. definedFacingForward: boolean;
  24679. /** @hidden */
  24680. _occlusionQuery: Nullable<WebGLQuery>;
  24681. /** @hidden */
  24682. _renderingGroup: Nullable<RenderingGroup>;
  24683. /**
  24684. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24685. */
  24686. /**
  24687. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24688. */
  24689. visibility: number;
  24690. /** Gets or sets the alpha index used to sort transparent meshes
  24691. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24692. */
  24693. alphaIndex: number;
  24694. /**
  24695. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24696. */
  24697. isVisible: boolean;
  24698. /**
  24699. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24700. */
  24701. isPickable: boolean;
  24702. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24703. showSubMeshesBoundingBox: boolean;
  24704. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24705. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24706. */
  24707. isBlocker: boolean;
  24708. /**
  24709. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24710. */
  24711. enablePointerMoveEvents: boolean;
  24712. /**
  24713. * Specifies the rendering group id for this mesh (0 by default)
  24714. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24715. */
  24716. renderingGroupId: number;
  24717. private _material;
  24718. /** Gets or sets current material */
  24719. material: Nullable<Material>;
  24720. /**
  24721. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24722. * @see http://doc.babylonjs.com/babylon101/shadows
  24723. */
  24724. receiveShadows: boolean;
  24725. /** Defines color to use when rendering outline */
  24726. outlineColor: Color3;
  24727. /** Define width to use when rendering outline */
  24728. outlineWidth: number;
  24729. /** Defines color to use when rendering overlay */
  24730. overlayColor: Color3;
  24731. /** Defines alpha to use when rendering overlay */
  24732. overlayAlpha: number;
  24733. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24734. hasVertexAlpha: boolean;
  24735. /** 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) */
  24736. useVertexColors: boolean;
  24737. /**
  24738. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24739. */
  24740. computeBonesUsingShaders: boolean;
  24741. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24742. numBoneInfluencers: number;
  24743. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24744. applyFog: boolean;
  24745. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24746. useOctreeForRenderingSelection: boolean;
  24747. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24748. useOctreeForPicking: boolean;
  24749. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24750. useOctreeForCollisions: boolean;
  24751. /**
  24752. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24753. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24754. */
  24755. layerMask: number;
  24756. /**
  24757. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24758. */
  24759. alwaysSelectAsActiveMesh: boolean;
  24760. /**
  24761. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24762. */
  24763. doNotSyncBoundingInfo: boolean;
  24764. /**
  24765. * Gets or sets the current action manager
  24766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24767. */
  24768. actionManager: Nullable<AbstractActionManager>;
  24769. private _meshCollisionData;
  24770. /**
  24771. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24772. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24773. */
  24774. ellipsoid: Vector3;
  24775. /**
  24776. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24777. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24778. */
  24779. ellipsoidOffset: Vector3;
  24780. /**
  24781. * Gets or sets a collision mask used to mask collisions (default is -1).
  24782. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24783. */
  24784. collisionMask: number;
  24785. /**
  24786. * Gets or sets the current collision group mask (-1 by default).
  24787. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24788. */
  24789. collisionGroup: number;
  24790. /**
  24791. * Defines edge width used when edgesRenderer is enabled
  24792. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24793. */
  24794. edgesWidth: number;
  24795. /**
  24796. * Defines edge color used when edgesRenderer is enabled
  24797. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24798. */
  24799. edgesColor: Color4;
  24800. /** @hidden */
  24801. _edgesRenderer: Nullable<IEdgesRenderer>;
  24802. /** @hidden */
  24803. _masterMesh: Nullable<AbstractMesh>;
  24804. /** @hidden */
  24805. _boundingInfo: Nullable<BoundingInfo>;
  24806. /** @hidden */
  24807. _renderId: number;
  24808. /**
  24809. * Gets or sets the list of subMeshes
  24810. * @see http://doc.babylonjs.com/how_to/multi_materials
  24811. */
  24812. subMeshes: SubMesh[];
  24813. /** @hidden */
  24814. _intersectionsInProgress: AbstractMesh[];
  24815. /** @hidden */
  24816. _unIndexed: boolean;
  24817. /** @hidden */
  24818. _lightSources: Light[];
  24819. /** Gets the list of lights affecting that mesh */
  24820. readonly lightSources: Light[];
  24821. /** @hidden */
  24822. readonly _positions: Nullable<Vector3[]>;
  24823. /** @hidden */
  24824. _waitingData: {
  24825. lods: Nullable<any>;
  24826. actions: Nullable<any>;
  24827. freezeWorldMatrix: Nullable<boolean>;
  24828. };
  24829. /** @hidden */
  24830. _bonesTransformMatrices: Nullable<Float32Array>;
  24831. /** @hidden */
  24832. _transformMatrixTexture: Nullable<RawTexture>;
  24833. /**
  24834. * Gets or sets a skeleton to apply skining transformations
  24835. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24836. */
  24837. skeleton: Nullable<Skeleton>;
  24838. /**
  24839. * An event triggered when the mesh is rebuilt.
  24840. */
  24841. onRebuildObservable: Observable<AbstractMesh>;
  24842. /**
  24843. * Creates a new AbstractMesh
  24844. * @param name defines the name of the mesh
  24845. * @param scene defines the hosting scene
  24846. */
  24847. constructor(name: string, scene?: Nullable<Scene>);
  24848. /**
  24849. * Returns the string "AbstractMesh"
  24850. * @returns "AbstractMesh"
  24851. */
  24852. getClassName(): string;
  24853. /**
  24854. * Gets a string representation of the current mesh
  24855. * @param fullDetails defines a boolean indicating if full details must be included
  24856. * @returns a string representation of the current mesh
  24857. */
  24858. toString(fullDetails?: boolean): string;
  24859. /**
  24860. * @hidden
  24861. */
  24862. protected _getEffectiveParent(): Nullable<Node>;
  24863. /** @hidden */
  24864. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24865. /** @hidden */
  24866. _rebuild(): void;
  24867. /** @hidden */
  24868. _resyncLightSources(): void;
  24869. /** @hidden */
  24870. _resyncLighSource(light: Light): void;
  24871. /** @hidden */
  24872. _unBindEffect(): void;
  24873. /** @hidden */
  24874. _removeLightSource(light: Light): void;
  24875. private _markSubMeshesAsDirty;
  24876. /** @hidden */
  24877. _markSubMeshesAsLightDirty(): void;
  24878. /** @hidden */
  24879. _markSubMeshesAsAttributesDirty(): void;
  24880. /** @hidden */
  24881. _markSubMeshesAsMiscDirty(): void;
  24882. /**
  24883. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24884. */
  24885. scaling: Vector3;
  24886. /**
  24887. * Returns true if the mesh is blocked. Implemented by child classes
  24888. */
  24889. readonly isBlocked: boolean;
  24890. /**
  24891. * Returns the mesh itself by default. Implemented by child classes
  24892. * @param camera defines the camera to use to pick the right LOD level
  24893. * @returns the currentAbstractMesh
  24894. */
  24895. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24896. /**
  24897. * Returns 0 by default. Implemented by child classes
  24898. * @returns an integer
  24899. */
  24900. getTotalVertices(): number;
  24901. /**
  24902. * Returns a positive integer : the total number of indices in this mesh geometry.
  24903. * @returns the numner of indices or zero if the mesh has no geometry.
  24904. */
  24905. getTotalIndices(): number;
  24906. /**
  24907. * Returns null by default. Implemented by child classes
  24908. * @returns null
  24909. */
  24910. getIndices(): Nullable<IndicesArray>;
  24911. /**
  24912. * Returns the array of the requested vertex data kind. Implemented by child classes
  24913. * @param kind defines the vertex data kind to use
  24914. * @returns null
  24915. */
  24916. getVerticesData(kind: string): Nullable<FloatArray>;
  24917. /**
  24918. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24919. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24920. * Note that a new underlying VertexBuffer object is created each call.
  24921. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24922. * @param kind defines vertex data kind:
  24923. * * VertexBuffer.PositionKind
  24924. * * VertexBuffer.UVKind
  24925. * * VertexBuffer.UV2Kind
  24926. * * VertexBuffer.UV3Kind
  24927. * * VertexBuffer.UV4Kind
  24928. * * VertexBuffer.UV5Kind
  24929. * * VertexBuffer.UV6Kind
  24930. * * VertexBuffer.ColorKind
  24931. * * VertexBuffer.MatricesIndicesKind
  24932. * * VertexBuffer.MatricesIndicesExtraKind
  24933. * * VertexBuffer.MatricesWeightsKind
  24934. * * VertexBuffer.MatricesWeightsExtraKind
  24935. * @param data defines the data source
  24936. * @param updatable defines if the data must be flagged as updatable (or static)
  24937. * @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
  24938. * @returns the current mesh
  24939. */
  24940. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24941. /**
  24942. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24943. * If the mesh has no geometry, it is simply returned as it is.
  24944. * @param kind defines vertex data kind:
  24945. * * VertexBuffer.PositionKind
  24946. * * VertexBuffer.UVKind
  24947. * * VertexBuffer.UV2Kind
  24948. * * VertexBuffer.UV3Kind
  24949. * * VertexBuffer.UV4Kind
  24950. * * VertexBuffer.UV5Kind
  24951. * * VertexBuffer.UV6Kind
  24952. * * VertexBuffer.ColorKind
  24953. * * VertexBuffer.MatricesIndicesKind
  24954. * * VertexBuffer.MatricesIndicesExtraKind
  24955. * * VertexBuffer.MatricesWeightsKind
  24956. * * VertexBuffer.MatricesWeightsExtraKind
  24957. * @param data defines the data source
  24958. * @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
  24959. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24960. * @returns the current mesh
  24961. */
  24962. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24963. /**
  24964. * Sets the mesh indices,
  24965. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24966. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24967. * @param totalVertices Defines the total number of vertices
  24968. * @returns the current mesh
  24969. */
  24970. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24971. /**
  24972. * Gets a boolean indicating if specific vertex data is present
  24973. * @param kind defines the vertex data kind to use
  24974. * @returns true is data kind is present
  24975. */
  24976. isVerticesDataPresent(kind: string): boolean;
  24977. /**
  24978. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  24979. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  24980. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  24981. * @returns a BoundingInfo
  24982. */
  24983. getBoundingInfo(): BoundingInfo;
  24984. /**
  24985. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24986. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24987. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24988. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  24989. * @returns the current mesh
  24990. */
  24991. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  24992. /**
  24993. * Overwrite the current bounding info
  24994. * @param boundingInfo defines the new bounding info
  24995. * @returns the current mesh
  24996. */
  24997. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24998. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24999. readonly useBones: boolean;
  25000. /** @hidden */
  25001. _preActivate(): void;
  25002. /** @hidden */
  25003. _preActivateForIntermediateRendering(renderId: number): void;
  25004. /** @hidden */
  25005. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25006. /** @hidden */
  25007. _postActivate(): void;
  25008. /** @hidden */
  25009. _freeze(): void;
  25010. /** @hidden */
  25011. _unFreeze(): void;
  25012. /**
  25013. * Gets the current world matrix
  25014. * @returns a Matrix
  25015. */
  25016. getWorldMatrix(): Matrix;
  25017. /** @hidden */
  25018. _getWorldMatrixDeterminant(): number;
  25019. /**
  25020. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25021. */
  25022. readonly isAnInstance: boolean;
  25023. /**
  25024. * Perform relative position change from the point of view of behind the front of the mesh.
  25025. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25026. * Supports definition of mesh facing forward or backward
  25027. * @param amountRight defines the distance on the right axis
  25028. * @param amountUp defines the distance on the up axis
  25029. * @param amountForward defines the distance on the forward axis
  25030. * @returns the current mesh
  25031. */
  25032. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25033. /**
  25034. * Calculate relative position change from the point of view of behind the front of the mesh.
  25035. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25036. * Supports definition of mesh facing forward or backward
  25037. * @param amountRight defines the distance on the right axis
  25038. * @param amountUp defines the distance on the up axis
  25039. * @param amountForward defines the distance on the forward axis
  25040. * @returns the new displacement vector
  25041. */
  25042. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25043. /**
  25044. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25045. * Supports definition of mesh facing forward or backward
  25046. * @param flipBack defines the flip
  25047. * @param twirlClockwise defines the twirl
  25048. * @param tiltRight defines the tilt
  25049. * @returns the current mesh
  25050. */
  25051. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25052. /**
  25053. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25054. * Supports definition of mesh facing forward or backward.
  25055. * @param flipBack defines the flip
  25056. * @param twirlClockwise defines the twirl
  25057. * @param tiltRight defines the tilt
  25058. * @returns the new rotation vector
  25059. */
  25060. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25061. /**
  25062. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25063. * This means the mesh underlying bounding box and sphere are recomputed.
  25064. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25065. * @returns the current mesh
  25066. */
  25067. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25068. /** @hidden */
  25069. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25070. /** @hidden */
  25071. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25072. /** @hidden */
  25073. _updateBoundingInfo(): AbstractMesh;
  25074. /** @hidden */
  25075. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25076. /** @hidden */
  25077. protected _afterComputeWorldMatrix(): void;
  25078. /** @hidden */
  25079. readonly _effectiveMesh: AbstractMesh;
  25080. /**
  25081. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25082. * A mesh is in the frustum if its bounding box intersects the frustum
  25083. * @param frustumPlanes defines the frustum to test
  25084. * @returns true if the mesh is in the frustum planes
  25085. */
  25086. isInFrustum(frustumPlanes: Plane[]): boolean;
  25087. /**
  25088. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25089. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25090. * @param frustumPlanes defines the frustum to test
  25091. * @returns true if the mesh is completely in the frustum planes
  25092. */
  25093. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25094. /**
  25095. * True if the mesh intersects another mesh or a SolidParticle object
  25096. * @param mesh defines a target mesh or SolidParticle to test
  25097. * @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)
  25098. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25099. * @returns true if there is an intersection
  25100. */
  25101. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25102. /**
  25103. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25104. * @param point defines the point to test
  25105. * @returns true if there is an intersection
  25106. */
  25107. intersectsPoint(point: Vector3): boolean;
  25108. /**
  25109. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25110. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25111. */
  25112. checkCollisions: boolean;
  25113. /**
  25114. * Gets Collider object used to compute collisions (not physics)
  25115. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25116. */
  25117. readonly collider: Nullable<Collider>;
  25118. /**
  25119. * Move the mesh using collision engine
  25120. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25121. * @param displacement defines the requested displacement vector
  25122. * @returns the current mesh
  25123. */
  25124. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25125. private _onCollisionPositionChange;
  25126. /** @hidden */
  25127. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25128. /** @hidden */
  25129. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25130. /** @hidden */
  25131. _checkCollision(collider: Collider): AbstractMesh;
  25132. /** @hidden */
  25133. _generatePointsArray(): boolean;
  25134. /**
  25135. * Checks if the passed Ray intersects with the mesh
  25136. * @param ray defines the ray to use
  25137. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25138. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25139. * @returns the picking info
  25140. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25141. */
  25142. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25143. /**
  25144. * Clones the current mesh
  25145. * @param name defines the mesh name
  25146. * @param newParent defines the new mesh parent
  25147. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25148. * @returns the new mesh
  25149. */
  25150. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25151. /**
  25152. * Disposes all the submeshes of the current meshnp
  25153. * @returns the current mesh
  25154. */
  25155. releaseSubMeshes(): AbstractMesh;
  25156. /**
  25157. * Releases resources associated with this abstract mesh.
  25158. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25159. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25160. */
  25161. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25162. /**
  25163. * Adds the passed mesh as a child to the current mesh
  25164. * @param mesh defines the child mesh
  25165. * @returns the current mesh
  25166. */
  25167. addChild(mesh: AbstractMesh): AbstractMesh;
  25168. /**
  25169. * Removes the passed mesh from the current mesh children list
  25170. * @param mesh defines the child mesh
  25171. * @returns the current mesh
  25172. */
  25173. removeChild(mesh: AbstractMesh): AbstractMesh;
  25174. /** @hidden */
  25175. private _initFacetData;
  25176. /**
  25177. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25178. * This method can be called within the render loop.
  25179. * 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
  25180. * @returns the current mesh
  25181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25182. */
  25183. updateFacetData(): AbstractMesh;
  25184. /**
  25185. * Returns the facetLocalNormals array.
  25186. * The normals are expressed in the mesh local spac
  25187. * @returns an array of Vector3
  25188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25189. */
  25190. getFacetLocalNormals(): Vector3[];
  25191. /**
  25192. * Returns the facetLocalPositions array.
  25193. * The facet positions are expressed in the mesh local space
  25194. * @returns an array of Vector3
  25195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25196. */
  25197. getFacetLocalPositions(): Vector3[];
  25198. /**
  25199. * Returns the facetLocalPartioning array
  25200. * @returns an array of array of numbers
  25201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25202. */
  25203. getFacetLocalPartitioning(): number[][];
  25204. /**
  25205. * Returns the i-th facet position in the world system.
  25206. * This method allocates a new Vector3 per call
  25207. * @param i defines the facet index
  25208. * @returns a new Vector3
  25209. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25210. */
  25211. getFacetPosition(i: number): Vector3;
  25212. /**
  25213. * Sets the reference Vector3 with the i-th facet position in the world system
  25214. * @param i defines the facet index
  25215. * @param ref defines the target vector
  25216. * @returns the current mesh
  25217. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25218. */
  25219. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25220. /**
  25221. * Returns the i-th facet normal in the world system.
  25222. * This method allocates a new Vector3 per call
  25223. * @param i defines the facet index
  25224. * @returns a new Vector3
  25225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25226. */
  25227. getFacetNormal(i: number): Vector3;
  25228. /**
  25229. * Sets the reference Vector3 with the i-th facet normal in the world system
  25230. * @param i defines the facet index
  25231. * @param ref defines the target vector
  25232. * @returns the current mesh
  25233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25234. */
  25235. getFacetNormalToRef(i: number, ref: Vector3): this;
  25236. /**
  25237. * 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)
  25238. * @param x defines x coordinate
  25239. * @param y defines y coordinate
  25240. * @param z defines z coordinate
  25241. * @returns the array of facet indexes
  25242. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25243. */
  25244. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25245. /**
  25246. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25247. * @param projected sets as the (x,y,z) world projection on the facet
  25248. * @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
  25249. * @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
  25250. * @param x defines x coordinate
  25251. * @param y defines y coordinate
  25252. * @param z defines z coordinate
  25253. * @returns the face index if found (or null instead)
  25254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25255. */
  25256. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25257. /**
  25258. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25259. * @param projected sets as the (x,y,z) local projection on the facet
  25260. * @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
  25261. * @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
  25262. * @param x defines x coordinate
  25263. * @param y defines y coordinate
  25264. * @param z defines z coordinate
  25265. * @returns the face index if found (or null instead)
  25266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25267. */
  25268. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25269. /**
  25270. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25271. * @returns the parameters
  25272. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25273. */
  25274. getFacetDataParameters(): any;
  25275. /**
  25276. * Disables the feature FacetData and frees the related memory
  25277. * @returns the current mesh
  25278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25279. */
  25280. disableFacetData(): AbstractMesh;
  25281. /**
  25282. * Updates the AbstractMesh indices array
  25283. * @param indices defines the data source
  25284. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25285. * @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)
  25286. * @returns the current mesh
  25287. */
  25288. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25289. /**
  25290. * Creates new normals data for the mesh
  25291. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25292. * @returns the current mesh
  25293. */
  25294. createNormals(updatable: boolean): AbstractMesh;
  25295. /**
  25296. * Align the mesh with a normal
  25297. * @param normal defines the normal to use
  25298. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25299. * @returns the current mesh
  25300. */
  25301. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25302. /** @hidden */
  25303. _checkOcclusionQuery(): boolean;
  25304. /**
  25305. * Disables the mesh edge rendering mode
  25306. * @returns the currentAbstractMesh
  25307. */
  25308. disableEdgesRendering(): AbstractMesh;
  25309. /**
  25310. * Enables the edge rendering mode on the mesh.
  25311. * This mode makes the mesh edges visible
  25312. * @param epsilon defines the maximal distance between two angles to detect a face
  25313. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25314. * @returns the currentAbstractMesh
  25315. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25316. */
  25317. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25318. }
  25319. }
  25320. declare module BABYLON {
  25321. /**
  25322. * Interface used to define ActionEvent
  25323. */
  25324. export interface IActionEvent {
  25325. /** The mesh or sprite that triggered the action */
  25326. source: any;
  25327. /** The X mouse cursor position at the time of the event */
  25328. pointerX: number;
  25329. /** The Y mouse cursor position at the time of the event */
  25330. pointerY: number;
  25331. /** The mesh that is currently pointed at (can be null) */
  25332. meshUnderPointer: Nullable<AbstractMesh>;
  25333. /** the original (browser) event that triggered the ActionEvent */
  25334. sourceEvent?: any;
  25335. /** additional data for the event */
  25336. additionalData?: any;
  25337. }
  25338. /**
  25339. * ActionEvent is the event being sent when an action is triggered.
  25340. */
  25341. export class ActionEvent implements IActionEvent {
  25342. /** The mesh or sprite that triggered the action */
  25343. source: any;
  25344. /** The X mouse cursor position at the time of the event */
  25345. pointerX: number;
  25346. /** The Y mouse cursor position at the time of the event */
  25347. pointerY: number;
  25348. /** The mesh that is currently pointed at (can be null) */
  25349. meshUnderPointer: Nullable<AbstractMesh>;
  25350. /** the original (browser) event that triggered the ActionEvent */
  25351. sourceEvent?: any;
  25352. /** additional data for the event */
  25353. additionalData?: any;
  25354. /**
  25355. * Creates a new ActionEvent
  25356. * @param source The mesh or sprite that triggered the action
  25357. * @param pointerX The X mouse cursor position at the time of the event
  25358. * @param pointerY The Y mouse cursor position at the time of the event
  25359. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25360. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25361. * @param additionalData additional data for the event
  25362. */
  25363. constructor(
  25364. /** The mesh or sprite that triggered the action */
  25365. source: any,
  25366. /** The X mouse cursor position at the time of the event */
  25367. pointerX: number,
  25368. /** The Y mouse cursor position at the time of the event */
  25369. pointerY: number,
  25370. /** The mesh that is currently pointed at (can be null) */
  25371. meshUnderPointer: Nullable<AbstractMesh>,
  25372. /** the original (browser) event that triggered the ActionEvent */
  25373. sourceEvent?: any,
  25374. /** additional data for the event */
  25375. additionalData?: any);
  25376. /**
  25377. * Helper function to auto-create an ActionEvent from a source mesh.
  25378. * @param source The source mesh that triggered the event
  25379. * @param evt The original (browser) event
  25380. * @param additionalData additional data for the event
  25381. * @returns the new ActionEvent
  25382. */
  25383. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25384. /**
  25385. * Helper function to auto-create an ActionEvent from a source sprite
  25386. * @param source The source sprite that triggered the event
  25387. * @param scene Scene associated with the sprite
  25388. * @param evt The original (browser) event
  25389. * @param additionalData additional data for the event
  25390. * @returns the new ActionEvent
  25391. */
  25392. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25393. /**
  25394. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25395. * @param scene the scene where the event occurred
  25396. * @param evt The original (browser) event
  25397. * @returns the new ActionEvent
  25398. */
  25399. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25400. /**
  25401. * Helper function to auto-create an ActionEvent from a primitive
  25402. * @param prim defines the target primitive
  25403. * @param pointerPos defines the pointer position
  25404. * @param evt The original (browser) event
  25405. * @param additionalData additional data for the event
  25406. * @returns the new ActionEvent
  25407. */
  25408. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25409. }
  25410. }
  25411. declare module BABYLON {
  25412. /**
  25413. * Abstract class used to decouple action Manager from scene and meshes.
  25414. * Do not instantiate.
  25415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25416. */
  25417. export abstract class AbstractActionManager implements IDisposable {
  25418. /** Gets the list of active triggers */
  25419. static Triggers: {
  25420. [key: string]: number;
  25421. };
  25422. /** Gets the cursor to use when hovering items */
  25423. hoverCursor: string;
  25424. /** Gets the list of actions */
  25425. actions: IAction[];
  25426. /**
  25427. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25428. */
  25429. isRecursive: boolean;
  25430. /**
  25431. * Releases all associated resources
  25432. */
  25433. abstract dispose(): void;
  25434. /**
  25435. * Does this action manager has pointer triggers
  25436. */
  25437. abstract readonly hasPointerTriggers: boolean;
  25438. /**
  25439. * Does this action manager has pick triggers
  25440. */
  25441. abstract readonly hasPickTriggers: boolean;
  25442. /**
  25443. * Process a specific trigger
  25444. * @param trigger defines the trigger to process
  25445. * @param evt defines the event details to be processed
  25446. */
  25447. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25448. /**
  25449. * Does this action manager handles actions of any of the given triggers
  25450. * @param triggers defines the triggers to be tested
  25451. * @return a boolean indicating whether one (or more) of the triggers is handled
  25452. */
  25453. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25454. /**
  25455. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25456. * speed.
  25457. * @param triggerA defines the trigger to be tested
  25458. * @param triggerB defines the trigger to be tested
  25459. * @return a boolean indicating whether one (or more) of the triggers is handled
  25460. */
  25461. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25462. /**
  25463. * Does this action manager handles actions of a given trigger
  25464. * @param trigger defines the trigger to be tested
  25465. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25466. * @return whether the trigger is handled
  25467. */
  25468. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25469. /**
  25470. * Serialize this manager to a JSON object
  25471. * @param name defines the property name to store this manager
  25472. * @returns a JSON representation of this manager
  25473. */
  25474. abstract serialize(name: string): any;
  25475. /**
  25476. * Registers an action to this action manager
  25477. * @param action defines the action to be registered
  25478. * @return the action amended (prepared) after registration
  25479. */
  25480. abstract registerAction(action: IAction): Nullable<IAction>;
  25481. /**
  25482. * Unregisters an action to this action manager
  25483. * @param action defines the action to be unregistered
  25484. * @return a boolean indicating whether the action has been unregistered
  25485. */
  25486. abstract unregisterAction(action: IAction): Boolean;
  25487. /**
  25488. * Does exist one action manager with at least one trigger
  25489. **/
  25490. static readonly HasTriggers: boolean;
  25491. /**
  25492. * Does exist one action manager with at least one pick trigger
  25493. **/
  25494. static readonly HasPickTriggers: boolean;
  25495. /**
  25496. * Does exist one action manager that handles actions of a given trigger
  25497. * @param trigger defines the trigger to be tested
  25498. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25499. **/
  25500. static HasSpecificTrigger(trigger: number): boolean;
  25501. }
  25502. }
  25503. declare module BABYLON {
  25504. /**
  25505. * Defines how a node can be built from a string name.
  25506. */
  25507. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25508. /**
  25509. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25510. */
  25511. export class Node implements IBehaviorAware<Node> {
  25512. /** @hidden */
  25513. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25514. private static _NodeConstructors;
  25515. /**
  25516. * Add a new node constructor
  25517. * @param type defines the type name of the node to construct
  25518. * @param constructorFunc defines the constructor function
  25519. */
  25520. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25521. /**
  25522. * Returns a node constructor based on type name
  25523. * @param type defines the type name
  25524. * @param name defines the new node name
  25525. * @param scene defines the hosting scene
  25526. * @param options defines optional options to transmit to constructors
  25527. * @returns the new constructor or null
  25528. */
  25529. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25530. /**
  25531. * Gets or sets the name of the node
  25532. */
  25533. name: string;
  25534. /**
  25535. * Gets or sets the id of the node
  25536. */
  25537. id: string;
  25538. /**
  25539. * Gets or sets the unique id of the node
  25540. */
  25541. uniqueId: number;
  25542. /**
  25543. * Gets or sets a string used to store user defined state for the node
  25544. */
  25545. state: string;
  25546. /**
  25547. * Gets or sets an object used to store user defined information for the node
  25548. */
  25549. metadata: any;
  25550. /**
  25551. * For internal use only. Please do not use.
  25552. */
  25553. reservedDataStore: any;
  25554. /**
  25555. * List of inspectable custom properties (used by the Inspector)
  25556. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25557. */
  25558. inspectableCustomProperties: IInspectable[];
  25559. /**
  25560. * Gets or sets a boolean used to define if the node must be serialized
  25561. */
  25562. doNotSerialize: boolean;
  25563. /** @hidden */
  25564. _isDisposed: boolean;
  25565. /**
  25566. * Gets a list of Animations associated with the node
  25567. */
  25568. animations: Animation[];
  25569. protected _ranges: {
  25570. [name: string]: Nullable<AnimationRange>;
  25571. };
  25572. /**
  25573. * Callback raised when the node is ready to be used
  25574. */
  25575. onReady: Nullable<(node: Node) => void>;
  25576. private _isEnabled;
  25577. private _isParentEnabled;
  25578. private _isReady;
  25579. /** @hidden */
  25580. _currentRenderId: number;
  25581. private _parentUpdateId;
  25582. /** @hidden */
  25583. _childUpdateId: number;
  25584. /** @hidden */
  25585. _waitingParentId: Nullable<string>;
  25586. /** @hidden */
  25587. _scene: Scene;
  25588. /** @hidden */
  25589. _cache: any;
  25590. private _parentNode;
  25591. private _children;
  25592. /** @hidden */
  25593. _worldMatrix: Matrix;
  25594. /** @hidden */
  25595. _worldMatrixDeterminant: number;
  25596. /** @hidden */
  25597. _worldMatrixDeterminantIsDirty: boolean;
  25598. /** @hidden */
  25599. private _sceneRootNodesIndex;
  25600. /**
  25601. * Gets a boolean indicating if the node has been disposed
  25602. * @returns true if the node was disposed
  25603. */
  25604. isDisposed(): boolean;
  25605. /**
  25606. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25607. * @see https://doc.babylonjs.com/how_to/parenting
  25608. */
  25609. parent: Nullable<Node>;
  25610. private addToSceneRootNodes;
  25611. private removeFromSceneRootNodes;
  25612. private _animationPropertiesOverride;
  25613. /**
  25614. * Gets or sets the animation properties override
  25615. */
  25616. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25617. /**
  25618. * Gets a string idenfifying the name of the class
  25619. * @returns "Node" string
  25620. */
  25621. getClassName(): string;
  25622. /** @hidden */
  25623. readonly _isNode: boolean;
  25624. /**
  25625. * An event triggered when the mesh is disposed
  25626. */
  25627. onDisposeObservable: Observable<Node>;
  25628. private _onDisposeObserver;
  25629. /**
  25630. * Sets a callback that will be raised when the node will be disposed
  25631. */
  25632. onDispose: () => void;
  25633. /**
  25634. * Creates a new Node
  25635. * @param name the name and id to be given to this node
  25636. * @param scene the scene this node will be added to
  25637. * @param addToRootNodes the node will be added to scene.rootNodes
  25638. */
  25639. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25640. /**
  25641. * Gets the scene of the node
  25642. * @returns a scene
  25643. */
  25644. getScene(): Scene;
  25645. /**
  25646. * Gets the engine of the node
  25647. * @returns a Engine
  25648. */
  25649. getEngine(): Engine;
  25650. private _behaviors;
  25651. /**
  25652. * Attach a behavior to the node
  25653. * @see http://doc.babylonjs.com/features/behaviour
  25654. * @param behavior defines the behavior to attach
  25655. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25656. * @returns the current Node
  25657. */
  25658. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25659. /**
  25660. * Remove an attached behavior
  25661. * @see http://doc.babylonjs.com/features/behaviour
  25662. * @param behavior defines the behavior to attach
  25663. * @returns the current Node
  25664. */
  25665. removeBehavior(behavior: Behavior<Node>): Node;
  25666. /**
  25667. * Gets the list of attached behaviors
  25668. * @see http://doc.babylonjs.com/features/behaviour
  25669. */
  25670. readonly behaviors: Behavior<Node>[];
  25671. /**
  25672. * Gets an attached behavior by name
  25673. * @param name defines the name of the behavior to look for
  25674. * @see http://doc.babylonjs.com/features/behaviour
  25675. * @returns null if behavior was not found else the requested behavior
  25676. */
  25677. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25678. /**
  25679. * Returns the latest update of the World matrix
  25680. * @returns a Matrix
  25681. */
  25682. getWorldMatrix(): Matrix;
  25683. /** @hidden */
  25684. _getWorldMatrixDeterminant(): number;
  25685. /**
  25686. * Returns directly the latest state of the mesh World matrix.
  25687. * A Matrix is returned.
  25688. */
  25689. readonly worldMatrixFromCache: Matrix;
  25690. /** @hidden */
  25691. _initCache(): void;
  25692. /** @hidden */
  25693. updateCache(force?: boolean): void;
  25694. /** @hidden */
  25695. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25696. /** @hidden */
  25697. _updateCache(ignoreParentClass?: boolean): void;
  25698. /** @hidden */
  25699. _isSynchronized(): boolean;
  25700. /** @hidden */
  25701. _markSyncedWithParent(): void;
  25702. /** @hidden */
  25703. isSynchronizedWithParent(): boolean;
  25704. /** @hidden */
  25705. isSynchronized(): boolean;
  25706. /**
  25707. * Is this node ready to be used/rendered
  25708. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25709. * @return true if the node is ready
  25710. */
  25711. isReady(completeCheck?: boolean): boolean;
  25712. /**
  25713. * Is this node enabled?
  25714. * 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
  25715. * @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
  25716. * @return whether this node (and its parent) is enabled
  25717. */
  25718. isEnabled(checkAncestors?: boolean): boolean;
  25719. /** @hidden */
  25720. protected _syncParentEnabledState(): void;
  25721. /**
  25722. * Set the enabled state of this node
  25723. * @param value defines the new enabled state
  25724. */
  25725. setEnabled(value: boolean): void;
  25726. /**
  25727. * Is this node a descendant of the given node?
  25728. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25729. * @param ancestor defines the parent node to inspect
  25730. * @returns a boolean indicating if this node is a descendant of the given node
  25731. */
  25732. isDescendantOf(ancestor: Node): boolean;
  25733. /** @hidden */
  25734. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25735. /**
  25736. * Will return all nodes that have this node as ascendant
  25737. * @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
  25738. * @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
  25739. * @return all children nodes of all types
  25740. */
  25741. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25742. /**
  25743. * Get all child-meshes of this node
  25744. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  25745. * @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
  25746. * @returns an array of AbstractMesh
  25747. */
  25748. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25749. /**
  25750. * Get all direct children of this node
  25751. * @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
  25752. * @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)
  25753. * @returns an array of Node
  25754. */
  25755. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25756. /** @hidden */
  25757. _setReady(state: boolean): void;
  25758. /**
  25759. * Get an animation by name
  25760. * @param name defines the name of the animation to look for
  25761. * @returns null if not found else the requested animation
  25762. */
  25763. getAnimationByName(name: string): Nullable<Animation>;
  25764. /**
  25765. * Creates an animation range for this node
  25766. * @param name defines the name of the range
  25767. * @param from defines the starting key
  25768. * @param to defines the end key
  25769. */
  25770. createAnimationRange(name: string, from: number, to: number): void;
  25771. /**
  25772. * Delete a specific animation range
  25773. * @param name defines the name of the range to delete
  25774. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25775. */
  25776. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25777. /**
  25778. * Get an animation range by name
  25779. * @param name defines the name of the animation range to look for
  25780. * @returns null if not found else the requested animation range
  25781. */
  25782. getAnimationRange(name: string): Nullable<AnimationRange>;
  25783. /**
  25784. * Gets the list of all animation ranges defined on this node
  25785. * @returns an array
  25786. */
  25787. getAnimationRanges(): Nullable<AnimationRange>[];
  25788. /**
  25789. * Will start the animation sequence
  25790. * @param name defines the range frames for animation sequence
  25791. * @param loop defines if the animation should loop (false by default)
  25792. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25793. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25794. * @returns the object created for this animation. If range does not exist, it will return null
  25795. */
  25796. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25797. /**
  25798. * Serialize animation ranges into a JSON compatible object
  25799. * @returns serialization object
  25800. */
  25801. serializeAnimationRanges(): any;
  25802. /**
  25803. * Computes the world matrix of the node
  25804. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25805. * @returns the world matrix
  25806. */
  25807. computeWorldMatrix(force?: boolean): Matrix;
  25808. /**
  25809. * Releases resources associated with this node.
  25810. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25811. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25812. */
  25813. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25814. /**
  25815. * Parse animation range data from a serialization object and store them into a given node
  25816. * @param node defines where to store the animation ranges
  25817. * @param parsedNode defines the serialization object to read data from
  25818. * @param scene defines the hosting scene
  25819. */
  25820. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25821. /**
  25822. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25823. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25824. * @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
  25825. * @returns the new bounding vectors
  25826. */
  25827. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25828. min: Vector3;
  25829. max: Vector3;
  25830. };
  25831. }
  25832. }
  25833. declare module BABYLON {
  25834. /**
  25835. * @hidden
  25836. */
  25837. export class _IAnimationState {
  25838. key: number;
  25839. repeatCount: number;
  25840. workValue?: any;
  25841. loopMode?: number;
  25842. offsetValue?: any;
  25843. highLimitValue?: any;
  25844. }
  25845. /**
  25846. * Class used to store any kind of animation
  25847. */
  25848. export class Animation {
  25849. /**Name of the animation */
  25850. name: string;
  25851. /**Property to animate */
  25852. targetProperty: string;
  25853. /**The frames per second of the animation */
  25854. framePerSecond: number;
  25855. /**The data type of the animation */
  25856. dataType: number;
  25857. /**The loop mode of the animation */
  25858. loopMode?: number | undefined;
  25859. /**Specifies if blending should be enabled */
  25860. enableBlending?: boolean | undefined;
  25861. /**
  25862. * Use matrix interpolation instead of using direct key value when animating matrices
  25863. */
  25864. static AllowMatricesInterpolation: boolean;
  25865. /**
  25866. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25867. */
  25868. static AllowMatrixDecomposeForInterpolation: boolean;
  25869. /**
  25870. * Stores the key frames of the animation
  25871. */
  25872. private _keys;
  25873. /**
  25874. * Stores the easing function of the animation
  25875. */
  25876. private _easingFunction;
  25877. /**
  25878. * @hidden Internal use only
  25879. */
  25880. _runtimeAnimations: RuntimeAnimation[];
  25881. /**
  25882. * The set of event that will be linked to this animation
  25883. */
  25884. private _events;
  25885. /**
  25886. * Stores an array of target property paths
  25887. */
  25888. targetPropertyPath: string[];
  25889. /**
  25890. * Stores the blending speed of the animation
  25891. */
  25892. blendingSpeed: number;
  25893. /**
  25894. * Stores the animation ranges for the animation
  25895. */
  25896. private _ranges;
  25897. /**
  25898. * @hidden Internal use
  25899. */
  25900. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25901. /**
  25902. * Sets up an animation
  25903. * @param property The property to animate
  25904. * @param animationType The animation type to apply
  25905. * @param framePerSecond The frames per second of the animation
  25906. * @param easingFunction The easing function used in the animation
  25907. * @returns The created animation
  25908. */
  25909. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25910. /**
  25911. * Create and start an animation on a node
  25912. * @param name defines the name of the global animation that will be run on all nodes
  25913. * @param node defines the root node where the animation will take place
  25914. * @param targetProperty defines property to animate
  25915. * @param framePerSecond defines the number of frame per second yo use
  25916. * @param totalFrame defines the number of frames in total
  25917. * @param from defines the initial value
  25918. * @param to defines the final value
  25919. * @param loopMode defines which loop mode you want to use (off by default)
  25920. * @param easingFunction defines the easing function to use (linear by default)
  25921. * @param onAnimationEnd defines the callback to call when animation end
  25922. * @returns the animatable created for this animation
  25923. */
  25924. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25925. /**
  25926. * Create and start an animation on a node and its descendants
  25927. * @param name defines the name of the global animation that will be run on all nodes
  25928. * @param node defines the root node where the animation will take place
  25929. * @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
  25930. * @param targetProperty defines property to animate
  25931. * @param framePerSecond defines the number of frame per second to use
  25932. * @param totalFrame defines the number of frames in total
  25933. * @param from defines the initial value
  25934. * @param to defines the final value
  25935. * @param loopMode defines which loop mode you want to use (off by default)
  25936. * @param easingFunction defines the easing function to use (linear by default)
  25937. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25938. * @returns the list of animatables created for all nodes
  25939. * @example https://www.babylonjs-playground.com/#MH0VLI
  25940. */
  25941. 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[]>;
  25942. /**
  25943. * Creates a new animation, merges it with the existing animations and starts it
  25944. * @param name Name of the animation
  25945. * @param node Node which contains the scene that begins the animations
  25946. * @param targetProperty Specifies which property to animate
  25947. * @param framePerSecond The frames per second of the animation
  25948. * @param totalFrame The total number of frames
  25949. * @param from The frame at the beginning of the animation
  25950. * @param to The frame at the end of the animation
  25951. * @param loopMode Specifies the loop mode of the animation
  25952. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25953. * @param onAnimationEnd Callback to run once the animation is complete
  25954. * @returns Nullable animation
  25955. */
  25956. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25957. /**
  25958. * Transition property of an host to the target Value
  25959. * @param property The property to transition
  25960. * @param targetValue The target Value of the property
  25961. * @param host The object where the property to animate belongs
  25962. * @param scene Scene used to run the animation
  25963. * @param frameRate Framerate (in frame/s) to use
  25964. * @param transition The transition type we want to use
  25965. * @param duration The duration of the animation, in milliseconds
  25966. * @param onAnimationEnd Callback trigger at the end of the animation
  25967. * @returns Nullable animation
  25968. */
  25969. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25970. /**
  25971. * Return the array of runtime animations currently using this animation
  25972. */
  25973. readonly runtimeAnimations: RuntimeAnimation[];
  25974. /**
  25975. * Specifies if any of the runtime animations are currently running
  25976. */
  25977. readonly hasRunningRuntimeAnimations: boolean;
  25978. /**
  25979. * Initializes the animation
  25980. * @param name Name of the animation
  25981. * @param targetProperty Property to animate
  25982. * @param framePerSecond The frames per second of the animation
  25983. * @param dataType The data type of the animation
  25984. * @param loopMode The loop mode of the animation
  25985. * @param enableBlending Specifies if blending should be enabled
  25986. */
  25987. constructor(
  25988. /**Name of the animation */
  25989. name: string,
  25990. /**Property to animate */
  25991. targetProperty: string,
  25992. /**The frames per second of the animation */
  25993. framePerSecond: number,
  25994. /**The data type of the animation */
  25995. dataType: number,
  25996. /**The loop mode of the animation */
  25997. loopMode?: number | undefined,
  25998. /**Specifies if blending should be enabled */
  25999. enableBlending?: boolean | undefined);
  26000. /**
  26001. * Converts the animation to a string
  26002. * @param fullDetails support for multiple levels of logging within scene loading
  26003. * @returns String form of the animation
  26004. */
  26005. toString(fullDetails?: boolean): string;
  26006. /**
  26007. * Add an event to this animation
  26008. * @param event Event to add
  26009. */
  26010. addEvent(event: AnimationEvent): void;
  26011. /**
  26012. * Remove all events found at the given frame
  26013. * @param frame The frame to remove events from
  26014. */
  26015. removeEvents(frame: number): void;
  26016. /**
  26017. * Retrieves all the events from the animation
  26018. * @returns Events from the animation
  26019. */
  26020. getEvents(): AnimationEvent[];
  26021. /**
  26022. * Creates an animation range
  26023. * @param name Name of the animation range
  26024. * @param from Starting frame of the animation range
  26025. * @param to Ending frame of the animation
  26026. */
  26027. createRange(name: string, from: number, to: number): void;
  26028. /**
  26029. * Deletes an animation range by name
  26030. * @param name Name of the animation range to delete
  26031. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26032. */
  26033. deleteRange(name: string, deleteFrames?: boolean): void;
  26034. /**
  26035. * Gets the animation range by name, or null if not defined
  26036. * @param name Name of the animation range
  26037. * @returns Nullable animation range
  26038. */
  26039. getRange(name: string): Nullable<AnimationRange>;
  26040. /**
  26041. * Gets the key frames from the animation
  26042. * @returns The key frames of the animation
  26043. */
  26044. getKeys(): Array<IAnimationKey>;
  26045. /**
  26046. * Gets the highest frame rate of the animation
  26047. * @returns Highest frame rate of the animation
  26048. */
  26049. getHighestFrame(): number;
  26050. /**
  26051. * Gets the easing function of the animation
  26052. * @returns Easing function of the animation
  26053. */
  26054. getEasingFunction(): IEasingFunction;
  26055. /**
  26056. * Sets the easing function of the animation
  26057. * @param easingFunction A custom mathematical formula for animation
  26058. */
  26059. setEasingFunction(easingFunction: EasingFunction): void;
  26060. /**
  26061. * Interpolates a scalar linearly
  26062. * @param startValue Start value of the animation curve
  26063. * @param endValue End value of the animation curve
  26064. * @param gradient Scalar amount to interpolate
  26065. * @returns Interpolated scalar value
  26066. */
  26067. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26068. /**
  26069. * Interpolates a scalar cubically
  26070. * @param startValue Start value of the animation curve
  26071. * @param outTangent End tangent of the animation
  26072. * @param endValue End value of the animation curve
  26073. * @param inTangent Start tangent of the animation curve
  26074. * @param gradient Scalar amount to interpolate
  26075. * @returns Interpolated scalar value
  26076. */
  26077. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26078. /**
  26079. * Interpolates a quaternion using a spherical linear interpolation
  26080. * @param startValue Start value of the animation curve
  26081. * @param endValue End value of the animation curve
  26082. * @param gradient Scalar amount to interpolate
  26083. * @returns Interpolated quaternion value
  26084. */
  26085. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26086. /**
  26087. * Interpolates a quaternion cubically
  26088. * @param startValue Start value of the animation curve
  26089. * @param outTangent End tangent of the animation curve
  26090. * @param endValue End value of the animation curve
  26091. * @param inTangent Start tangent of the animation curve
  26092. * @param gradient Scalar amount to interpolate
  26093. * @returns Interpolated quaternion value
  26094. */
  26095. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26096. /**
  26097. * Interpolates a Vector3 linearl
  26098. * @param startValue Start value of the animation curve
  26099. * @param endValue End value of the animation curve
  26100. * @param gradient Scalar amount to interpolate
  26101. * @returns Interpolated scalar value
  26102. */
  26103. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26104. /**
  26105. * Interpolates a Vector3 cubically
  26106. * @param startValue Start value of the animation curve
  26107. * @param outTangent End tangent of the animation
  26108. * @param endValue End value of the animation curve
  26109. * @param inTangent Start tangent of the animation curve
  26110. * @param gradient Scalar amount to interpolate
  26111. * @returns InterpolatedVector3 value
  26112. */
  26113. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26114. /**
  26115. * Interpolates a Vector2 linearly
  26116. * @param startValue Start value of the animation curve
  26117. * @param endValue End value of the animation curve
  26118. * @param gradient Scalar amount to interpolate
  26119. * @returns Interpolated Vector2 value
  26120. */
  26121. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26122. /**
  26123. * Interpolates a Vector2 cubically
  26124. * @param startValue Start value of the animation curve
  26125. * @param outTangent End tangent of the animation
  26126. * @param endValue End value of the animation curve
  26127. * @param inTangent Start tangent of the animation curve
  26128. * @param gradient Scalar amount to interpolate
  26129. * @returns Interpolated Vector2 value
  26130. */
  26131. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26132. /**
  26133. * Interpolates a size linearly
  26134. * @param startValue Start value of the animation curve
  26135. * @param endValue End value of the animation curve
  26136. * @param gradient Scalar amount to interpolate
  26137. * @returns Interpolated Size value
  26138. */
  26139. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26140. /**
  26141. * Interpolates a Color3 linearly
  26142. * @param startValue Start value of the animation curve
  26143. * @param endValue End value of the animation curve
  26144. * @param gradient Scalar amount to interpolate
  26145. * @returns Interpolated Color3 value
  26146. */
  26147. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26148. /**
  26149. * @hidden Internal use only
  26150. */
  26151. _getKeyValue(value: any): any;
  26152. /**
  26153. * @hidden Internal use only
  26154. */
  26155. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26156. /**
  26157. * Defines the function to use to interpolate matrices
  26158. * @param startValue defines the start matrix
  26159. * @param endValue defines the end matrix
  26160. * @param gradient defines the gradient between both matrices
  26161. * @param result defines an optional target matrix where to store the interpolation
  26162. * @returns the interpolated matrix
  26163. */
  26164. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26165. /**
  26166. * Makes a copy of the animation
  26167. * @returns Cloned animation
  26168. */
  26169. clone(): Animation;
  26170. /**
  26171. * Sets the key frames of the animation
  26172. * @param values The animation key frames to set
  26173. */
  26174. setKeys(values: Array<IAnimationKey>): void;
  26175. /**
  26176. * Serializes the animation to an object
  26177. * @returns Serialized object
  26178. */
  26179. serialize(): any;
  26180. /**
  26181. * Float animation type
  26182. */
  26183. private static _ANIMATIONTYPE_FLOAT;
  26184. /**
  26185. * Vector3 animation type
  26186. */
  26187. private static _ANIMATIONTYPE_VECTOR3;
  26188. /**
  26189. * Quaternion animation type
  26190. */
  26191. private static _ANIMATIONTYPE_QUATERNION;
  26192. /**
  26193. * Matrix animation type
  26194. */
  26195. private static _ANIMATIONTYPE_MATRIX;
  26196. /**
  26197. * Color3 animation type
  26198. */
  26199. private static _ANIMATIONTYPE_COLOR3;
  26200. /**
  26201. * Vector2 animation type
  26202. */
  26203. private static _ANIMATIONTYPE_VECTOR2;
  26204. /**
  26205. * Size animation type
  26206. */
  26207. private static _ANIMATIONTYPE_SIZE;
  26208. /**
  26209. * Relative Loop Mode
  26210. */
  26211. private static _ANIMATIONLOOPMODE_RELATIVE;
  26212. /**
  26213. * Cycle Loop Mode
  26214. */
  26215. private static _ANIMATIONLOOPMODE_CYCLE;
  26216. /**
  26217. * Constant Loop Mode
  26218. */
  26219. private static _ANIMATIONLOOPMODE_CONSTANT;
  26220. /**
  26221. * Get the float animation type
  26222. */
  26223. static readonly ANIMATIONTYPE_FLOAT: number;
  26224. /**
  26225. * Get the Vector3 animation type
  26226. */
  26227. static readonly ANIMATIONTYPE_VECTOR3: number;
  26228. /**
  26229. * Get the Vector2 animation type
  26230. */
  26231. static readonly ANIMATIONTYPE_VECTOR2: number;
  26232. /**
  26233. * Get the Size animation type
  26234. */
  26235. static readonly ANIMATIONTYPE_SIZE: number;
  26236. /**
  26237. * Get the Quaternion animation type
  26238. */
  26239. static readonly ANIMATIONTYPE_QUATERNION: number;
  26240. /**
  26241. * Get the Matrix animation type
  26242. */
  26243. static readonly ANIMATIONTYPE_MATRIX: number;
  26244. /**
  26245. * Get the Color3 animation type
  26246. */
  26247. static readonly ANIMATIONTYPE_COLOR3: number;
  26248. /**
  26249. * Get the Relative Loop Mode
  26250. */
  26251. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26252. /**
  26253. * Get the Cycle Loop Mode
  26254. */
  26255. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26256. /**
  26257. * Get the Constant Loop Mode
  26258. */
  26259. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26260. /** @hidden */
  26261. static _UniversalLerp(left: any, right: any, amount: number): any;
  26262. /**
  26263. * Parses an animation object and creates an animation
  26264. * @param parsedAnimation Parsed animation object
  26265. * @returns Animation object
  26266. */
  26267. static Parse(parsedAnimation: any): Animation;
  26268. /**
  26269. * Appends the serialized animations from the source animations
  26270. * @param source Source containing the animations
  26271. * @param destination Target to store the animations
  26272. */
  26273. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26274. }
  26275. }
  26276. declare module BABYLON {
  26277. /**
  26278. * Base class of all the textures in babylon.
  26279. * It groups all the common properties the materials, post process, lights... might need
  26280. * in order to make a correct use of the texture.
  26281. */
  26282. export class BaseTexture implements IAnimatable {
  26283. /**
  26284. * Default anisotropic filtering level for the application.
  26285. * It is set to 4 as a good tradeoff between perf and quality.
  26286. */
  26287. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26288. /**
  26289. * Gets or sets the unique id of the texture
  26290. */
  26291. uniqueId: number;
  26292. /**
  26293. * Define the name of the texture.
  26294. */
  26295. name: string;
  26296. /**
  26297. * Gets or sets an object used to store user defined information.
  26298. */
  26299. metadata: any;
  26300. /**
  26301. * For internal use only. Please do not use.
  26302. */
  26303. reservedDataStore: any;
  26304. private _hasAlpha;
  26305. /**
  26306. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26307. */
  26308. hasAlpha: boolean;
  26309. /**
  26310. * Defines if the alpha value should be determined via the rgb values.
  26311. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26312. */
  26313. getAlphaFromRGB: boolean;
  26314. /**
  26315. * Intensity or strength of the texture.
  26316. * It is commonly used by materials to fine tune the intensity of the texture
  26317. */
  26318. level: number;
  26319. /**
  26320. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26321. * This is part of the texture as textures usually maps to one uv set.
  26322. */
  26323. coordinatesIndex: number;
  26324. private _coordinatesMode;
  26325. /**
  26326. * How a texture is mapped.
  26327. *
  26328. * | Value | Type | Description |
  26329. * | ----- | ----------------------------------- | ----------- |
  26330. * | 0 | EXPLICIT_MODE | |
  26331. * | 1 | SPHERICAL_MODE | |
  26332. * | 2 | PLANAR_MODE | |
  26333. * | 3 | CUBIC_MODE | |
  26334. * | 4 | PROJECTION_MODE | |
  26335. * | 5 | SKYBOX_MODE | |
  26336. * | 6 | INVCUBIC_MODE | |
  26337. * | 7 | EQUIRECTANGULAR_MODE | |
  26338. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26339. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26340. */
  26341. coordinatesMode: number;
  26342. /**
  26343. * | Value | Type | Description |
  26344. * | ----- | ------------------ | ----------- |
  26345. * | 0 | CLAMP_ADDRESSMODE | |
  26346. * | 1 | WRAP_ADDRESSMODE | |
  26347. * | 2 | MIRROR_ADDRESSMODE | |
  26348. */
  26349. wrapU: number;
  26350. /**
  26351. * | Value | Type | Description |
  26352. * | ----- | ------------------ | ----------- |
  26353. * | 0 | CLAMP_ADDRESSMODE | |
  26354. * | 1 | WRAP_ADDRESSMODE | |
  26355. * | 2 | MIRROR_ADDRESSMODE | |
  26356. */
  26357. wrapV: number;
  26358. /**
  26359. * | Value | Type | Description |
  26360. * | ----- | ------------------ | ----------- |
  26361. * | 0 | CLAMP_ADDRESSMODE | |
  26362. * | 1 | WRAP_ADDRESSMODE | |
  26363. * | 2 | MIRROR_ADDRESSMODE | |
  26364. */
  26365. wrapR: number;
  26366. /**
  26367. * With compliant hardware and browser (supporting anisotropic filtering)
  26368. * this defines the level of anisotropic filtering in the texture.
  26369. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26370. */
  26371. anisotropicFilteringLevel: number;
  26372. /**
  26373. * Define if the texture is a cube texture or if false a 2d texture.
  26374. */
  26375. isCube: boolean;
  26376. /**
  26377. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26378. */
  26379. is3D: boolean;
  26380. /**
  26381. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26382. * HDR texture are usually stored in linear space.
  26383. * This only impacts the PBR and Background materials
  26384. */
  26385. gammaSpace: boolean;
  26386. /**
  26387. * Gets whether or not the texture contains RGBD data.
  26388. */
  26389. readonly isRGBD: boolean;
  26390. /**
  26391. * Is Z inverted in the texture (useful in a cube texture).
  26392. */
  26393. invertZ: boolean;
  26394. /**
  26395. * Are mip maps generated for this texture or not.
  26396. */
  26397. readonly noMipmap: boolean;
  26398. /**
  26399. * @hidden
  26400. */
  26401. lodLevelInAlpha: boolean;
  26402. /**
  26403. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26404. */
  26405. lodGenerationOffset: number;
  26406. /**
  26407. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26408. */
  26409. lodGenerationScale: number;
  26410. /**
  26411. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26412. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26413. * average roughness values.
  26414. */
  26415. linearSpecularLOD: boolean;
  26416. /**
  26417. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26418. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26419. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26420. */
  26421. irradianceTexture: Nullable<BaseTexture>;
  26422. /**
  26423. * Define if the texture is a render target.
  26424. */
  26425. isRenderTarget: boolean;
  26426. /**
  26427. * Define the unique id of the texture in the scene.
  26428. */
  26429. readonly uid: string;
  26430. /**
  26431. * Return a string representation of the texture.
  26432. * @returns the texture as a string
  26433. */
  26434. toString(): string;
  26435. /**
  26436. * Get the class name of the texture.
  26437. * @returns "BaseTexture"
  26438. */
  26439. getClassName(): string;
  26440. /**
  26441. * Define the list of animation attached to the texture.
  26442. */
  26443. animations: Animation[];
  26444. /**
  26445. * An event triggered when the texture is disposed.
  26446. */
  26447. onDisposeObservable: Observable<BaseTexture>;
  26448. private _onDisposeObserver;
  26449. /**
  26450. * Callback triggered when the texture has been disposed.
  26451. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26452. */
  26453. onDispose: () => void;
  26454. /**
  26455. * Define the current state of the loading sequence when in delayed load mode.
  26456. */
  26457. delayLoadState: number;
  26458. private _scene;
  26459. /** @hidden */
  26460. _texture: Nullable<InternalTexture>;
  26461. private _uid;
  26462. /**
  26463. * Define if the texture is preventinga material to render or not.
  26464. * If not and the texture is not ready, the engine will use a default black texture instead.
  26465. */
  26466. readonly isBlocking: boolean;
  26467. /**
  26468. * Instantiates a new BaseTexture.
  26469. * Base class of all the textures in babylon.
  26470. * It groups all the common properties the materials, post process, lights... might need
  26471. * in order to make a correct use of the texture.
  26472. * @param scene Define the scene the texture blongs to
  26473. */
  26474. constructor(scene: Nullable<Scene>);
  26475. /**
  26476. * Get the scene the texture belongs to.
  26477. * @returns the scene or null if undefined
  26478. */
  26479. getScene(): Nullable<Scene>;
  26480. /**
  26481. * Get the texture transform matrix used to offset tile the texture for istance.
  26482. * @returns the transformation matrix
  26483. */
  26484. getTextureMatrix(): Matrix;
  26485. /**
  26486. * Get the texture reflection matrix used to rotate/transform the reflection.
  26487. * @returns the reflection matrix
  26488. */
  26489. getReflectionTextureMatrix(): Matrix;
  26490. /**
  26491. * Get the underlying lower level texture from Babylon.
  26492. * @returns the insternal texture
  26493. */
  26494. getInternalTexture(): Nullable<InternalTexture>;
  26495. /**
  26496. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26497. * @returns true if ready or not blocking
  26498. */
  26499. isReadyOrNotBlocking(): boolean;
  26500. /**
  26501. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26502. * @returns true if fully ready
  26503. */
  26504. isReady(): boolean;
  26505. private _cachedSize;
  26506. /**
  26507. * Get the size of the texture.
  26508. * @returns the texture size.
  26509. */
  26510. getSize(): ISize;
  26511. /**
  26512. * Get the base size of the texture.
  26513. * It can be different from the size if the texture has been resized for POT for instance
  26514. * @returns the base size
  26515. */
  26516. getBaseSize(): ISize;
  26517. /**
  26518. * Update the sampling mode of the texture.
  26519. * Default is Trilinear mode.
  26520. *
  26521. * | Value | Type | Description |
  26522. * | ----- | ------------------ | ----------- |
  26523. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26524. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26525. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26526. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26527. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26528. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26529. * | 7 | NEAREST_LINEAR | |
  26530. * | 8 | NEAREST_NEAREST | |
  26531. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26532. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26533. * | 11 | LINEAR_LINEAR | |
  26534. * | 12 | LINEAR_NEAREST | |
  26535. *
  26536. * > _mag_: magnification filter (close to the viewer)
  26537. * > _min_: minification filter (far from the viewer)
  26538. * > _mip_: filter used between mip map levels
  26539. *@param samplingMode Define the new sampling mode of the texture
  26540. */
  26541. updateSamplingMode(samplingMode: number): void;
  26542. /**
  26543. * Scales the texture if is `canRescale()`
  26544. * @param ratio the resize factor we want to use to rescale
  26545. */
  26546. scale(ratio: number): void;
  26547. /**
  26548. * Get if the texture can rescale.
  26549. */
  26550. readonly canRescale: boolean;
  26551. /** @hidden */
  26552. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26553. /** @hidden */
  26554. _rebuild(): void;
  26555. /**
  26556. * Triggers the load sequence in delayed load mode.
  26557. */
  26558. delayLoad(): void;
  26559. /**
  26560. * Clones the texture.
  26561. * @returns the cloned texture
  26562. */
  26563. clone(): Nullable<BaseTexture>;
  26564. /**
  26565. * Get the texture underlying type (INT, FLOAT...)
  26566. */
  26567. readonly textureType: number;
  26568. /**
  26569. * Get the texture underlying format (RGB, RGBA...)
  26570. */
  26571. readonly textureFormat: number;
  26572. /**
  26573. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26574. * This will returns an RGBA array buffer containing either in values (0-255) or
  26575. * float values (0-1) depending of the underlying buffer type.
  26576. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26577. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26578. * @param buffer defines a user defined buffer to fill with data (can be null)
  26579. * @returns The Array buffer containing the pixels data.
  26580. */
  26581. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26582. /**
  26583. * Release and destroy the underlying lower level texture aka internalTexture.
  26584. */
  26585. releaseInternalTexture(): void;
  26586. /**
  26587. * Get the polynomial representation of the texture data.
  26588. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26589. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26590. */
  26591. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26592. /** @hidden */
  26593. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26594. /** @hidden */
  26595. readonly _lodTextureMid: Nullable<BaseTexture>;
  26596. /** @hidden */
  26597. readonly _lodTextureLow: Nullable<BaseTexture>;
  26598. /**
  26599. * Dispose the texture and release its associated resources.
  26600. */
  26601. dispose(): void;
  26602. /**
  26603. * Serialize the texture into a JSON representation that can be parsed later on.
  26604. * @returns the JSON representation of the texture
  26605. */
  26606. serialize(): any;
  26607. /**
  26608. * Helper function to be called back once a list of texture contains only ready textures.
  26609. * @param textures Define the list of textures to wait for
  26610. * @param callback Define the callback triggered once the entire list will be ready
  26611. */
  26612. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26613. }
  26614. }
  26615. declare module BABYLON {
  26616. /**
  26617. * Uniform buffer objects.
  26618. *
  26619. * Handles blocks of uniform on the GPU.
  26620. *
  26621. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26622. *
  26623. * For more information, please refer to :
  26624. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26625. */
  26626. export class UniformBuffer {
  26627. private _engine;
  26628. private _buffer;
  26629. private _data;
  26630. private _bufferData;
  26631. private _dynamic?;
  26632. private _uniformLocations;
  26633. private _uniformSizes;
  26634. private _uniformLocationPointer;
  26635. private _needSync;
  26636. private _noUBO;
  26637. private _currentEffect;
  26638. private static _MAX_UNIFORM_SIZE;
  26639. private static _tempBuffer;
  26640. /**
  26641. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26642. * This is dynamic to allow compat with webgl 1 and 2.
  26643. * You will need to pass the name of the uniform as well as the value.
  26644. */
  26645. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26646. /**
  26647. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26648. * This is dynamic to allow compat with webgl 1 and 2.
  26649. * You will need to pass the name of the uniform as well as the value.
  26650. */
  26651. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26652. /**
  26653. * Lambda to Update a single float in a uniform buffer.
  26654. * This is dynamic to allow compat with webgl 1 and 2.
  26655. * You will need to pass the name of the uniform as well as the value.
  26656. */
  26657. updateFloat: (name: string, x: number) => void;
  26658. /**
  26659. * Lambda to Update a vec2 of float in a uniform buffer.
  26660. * This is dynamic to allow compat with webgl 1 and 2.
  26661. * You will need to pass the name of the uniform as well as the value.
  26662. */
  26663. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26664. /**
  26665. * Lambda to Update a vec3 of float in a uniform buffer.
  26666. * This is dynamic to allow compat with webgl 1 and 2.
  26667. * You will need to pass the name of the uniform as well as the value.
  26668. */
  26669. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26670. /**
  26671. * Lambda to Update a vec4 of float in a uniform buffer.
  26672. * This is dynamic to allow compat with webgl 1 and 2.
  26673. * You will need to pass the name of the uniform as well as the value.
  26674. */
  26675. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26676. /**
  26677. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26678. * This is dynamic to allow compat with webgl 1 and 2.
  26679. * You will need to pass the name of the uniform as well as the value.
  26680. */
  26681. updateMatrix: (name: string, mat: Matrix) => void;
  26682. /**
  26683. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26684. * This is dynamic to allow compat with webgl 1 and 2.
  26685. * You will need to pass the name of the uniform as well as the value.
  26686. */
  26687. updateVector3: (name: string, vector: Vector3) => void;
  26688. /**
  26689. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26690. * This is dynamic to allow compat with webgl 1 and 2.
  26691. * You will need to pass the name of the uniform as well as the value.
  26692. */
  26693. updateVector4: (name: string, vector: Vector4) => void;
  26694. /**
  26695. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26696. * This is dynamic to allow compat with webgl 1 and 2.
  26697. * You will need to pass the name of the uniform as well as the value.
  26698. */
  26699. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26700. /**
  26701. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26702. * This is dynamic to allow compat with webgl 1 and 2.
  26703. * You will need to pass the name of the uniform as well as the value.
  26704. */
  26705. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26706. /**
  26707. * Instantiates a new Uniform buffer objects.
  26708. *
  26709. * Handles blocks of uniform on the GPU.
  26710. *
  26711. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26712. *
  26713. * For more information, please refer to :
  26714. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26715. * @param engine Define the engine the buffer is associated with
  26716. * @param data Define the data contained in the buffer
  26717. * @param dynamic Define if the buffer is updatable
  26718. */
  26719. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26720. /**
  26721. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26722. * or just falling back on setUniformXXX calls.
  26723. */
  26724. readonly useUbo: boolean;
  26725. /**
  26726. * Indicates if the WebGL underlying uniform buffer is in sync
  26727. * with the javascript cache data.
  26728. */
  26729. readonly isSync: boolean;
  26730. /**
  26731. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26732. * Also, a dynamic UniformBuffer will disable cache verification and always
  26733. * update the underlying WebGL uniform buffer to the GPU.
  26734. * @returns if Dynamic, otherwise false
  26735. */
  26736. isDynamic(): boolean;
  26737. /**
  26738. * The data cache on JS side.
  26739. * @returns the underlying data as a float array
  26740. */
  26741. getData(): Float32Array;
  26742. /**
  26743. * The underlying WebGL Uniform buffer.
  26744. * @returns the webgl buffer
  26745. */
  26746. getBuffer(): Nullable<DataBuffer>;
  26747. /**
  26748. * std140 layout specifies how to align data within an UBO structure.
  26749. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26750. * for specs.
  26751. */
  26752. private _fillAlignment;
  26753. /**
  26754. * Adds an uniform in the buffer.
  26755. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26756. * for the layout to be correct !
  26757. * @param name Name of the uniform, as used in the uniform block in the shader.
  26758. * @param size Data size, or data directly.
  26759. */
  26760. addUniform(name: string, size: number | number[]): void;
  26761. /**
  26762. * Adds a Matrix 4x4 to the uniform buffer.
  26763. * @param name Name of the uniform, as used in the uniform block in the shader.
  26764. * @param mat A 4x4 matrix.
  26765. */
  26766. addMatrix(name: string, mat: Matrix): void;
  26767. /**
  26768. * Adds a vec2 to the uniform buffer.
  26769. * @param name Name of the uniform, as used in the uniform block in the shader.
  26770. * @param x Define the x component value of the vec2
  26771. * @param y Define the y component value of the vec2
  26772. */
  26773. addFloat2(name: string, x: number, y: number): void;
  26774. /**
  26775. * Adds a vec3 to the uniform buffer.
  26776. * @param name Name of the uniform, as used in the uniform block in the shader.
  26777. * @param x Define the x component value of the vec3
  26778. * @param y Define the y component value of the vec3
  26779. * @param z Define the z component value of the vec3
  26780. */
  26781. addFloat3(name: string, x: number, y: number, z: number): void;
  26782. /**
  26783. * Adds a vec3 to the uniform buffer.
  26784. * @param name Name of the uniform, as used in the uniform block in the shader.
  26785. * @param color Define the vec3 from a Color
  26786. */
  26787. addColor3(name: string, color: Color3): void;
  26788. /**
  26789. * Adds a vec4 to the uniform buffer.
  26790. * @param name Name of the uniform, as used in the uniform block in the shader.
  26791. * @param color Define the rgb components from a Color
  26792. * @param alpha Define the a component of the vec4
  26793. */
  26794. addColor4(name: string, color: Color3, alpha: number): void;
  26795. /**
  26796. * Adds a vec3 to the uniform buffer.
  26797. * @param name Name of the uniform, as used in the uniform block in the shader.
  26798. * @param vector Define the vec3 components from a Vector
  26799. */
  26800. addVector3(name: string, vector: Vector3): void;
  26801. /**
  26802. * Adds a Matrix 3x3 to the uniform buffer.
  26803. * @param name Name of the uniform, as used in the uniform block in the shader.
  26804. */
  26805. addMatrix3x3(name: string): void;
  26806. /**
  26807. * Adds a Matrix 2x2 to the uniform buffer.
  26808. * @param name Name of the uniform, as used in the uniform block in the shader.
  26809. */
  26810. addMatrix2x2(name: string): void;
  26811. /**
  26812. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26813. */
  26814. create(): void;
  26815. /** @hidden */
  26816. _rebuild(): void;
  26817. /**
  26818. * Updates the WebGL Uniform Buffer on the GPU.
  26819. * If the `dynamic` flag is set to true, no cache comparison is done.
  26820. * Otherwise, the buffer will be updated only if the cache differs.
  26821. */
  26822. update(): void;
  26823. /**
  26824. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26825. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26826. * @param data Define the flattened data
  26827. * @param size Define the size of the data.
  26828. */
  26829. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26830. private _updateMatrix3x3ForUniform;
  26831. private _updateMatrix3x3ForEffect;
  26832. private _updateMatrix2x2ForEffect;
  26833. private _updateMatrix2x2ForUniform;
  26834. private _updateFloatForEffect;
  26835. private _updateFloatForUniform;
  26836. private _updateFloat2ForEffect;
  26837. private _updateFloat2ForUniform;
  26838. private _updateFloat3ForEffect;
  26839. private _updateFloat3ForUniform;
  26840. private _updateFloat4ForEffect;
  26841. private _updateFloat4ForUniform;
  26842. private _updateMatrixForEffect;
  26843. private _updateMatrixForUniform;
  26844. private _updateVector3ForEffect;
  26845. private _updateVector3ForUniform;
  26846. private _updateVector4ForEffect;
  26847. private _updateVector4ForUniform;
  26848. private _updateColor3ForEffect;
  26849. private _updateColor3ForUniform;
  26850. private _updateColor4ForEffect;
  26851. private _updateColor4ForUniform;
  26852. /**
  26853. * Sets a sampler uniform on the effect.
  26854. * @param name Define the name of the sampler.
  26855. * @param texture Define the texture to set in the sampler
  26856. */
  26857. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26858. /**
  26859. * Directly updates the value of the uniform in the cache AND on the GPU.
  26860. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26861. * @param data Define the flattened data
  26862. */
  26863. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26864. /**
  26865. * Binds this uniform buffer to an effect.
  26866. * @param effect Define the effect to bind the buffer to
  26867. * @param name Name of the uniform block in the shader.
  26868. */
  26869. bindToEffect(effect: Effect, name: string): void;
  26870. /**
  26871. * Disposes the uniform buffer.
  26872. */
  26873. dispose(): void;
  26874. }
  26875. }
  26876. declare module BABYLON {
  26877. /**
  26878. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26879. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26880. */
  26881. export class Analyser {
  26882. /**
  26883. * Gets or sets the smoothing
  26884. * @ignorenaming
  26885. */
  26886. SMOOTHING: number;
  26887. /**
  26888. * Gets or sets the FFT table size
  26889. * @ignorenaming
  26890. */
  26891. FFT_SIZE: number;
  26892. /**
  26893. * Gets or sets the bar graph amplitude
  26894. * @ignorenaming
  26895. */
  26896. BARGRAPHAMPLITUDE: number;
  26897. /**
  26898. * Gets or sets the position of the debug canvas
  26899. * @ignorenaming
  26900. */
  26901. DEBUGCANVASPOS: {
  26902. x: number;
  26903. y: number;
  26904. };
  26905. /**
  26906. * Gets or sets the debug canvas size
  26907. * @ignorenaming
  26908. */
  26909. DEBUGCANVASSIZE: {
  26910. width: number;
  26911. height: number;
  26912. };
  26913. private _byteFreqs;
  26914. private _byteTime;
  26915. private _floatFreqs;
  26916. private _webAudioAnalyser;
  26917. private _debugCanvas;
  26918. private _debugCanvasContext;
  26919. private _scene;
  26920. private _registerFunc;
  26921. private _audioEngine;
  26922. /**
  26923. * Creates a new analyser
  26924. * @param scene defines hosting scene
  26925. */
  26926. constructor(scene: Scene);
  26927. /**
  26928. * Get the number of data values you will have to play with for the visualization
  26929. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26930. * @returns a number
  26931. */
  26932. getFrequencyBinCount(): number;
  26933. /**
  26934. * Gets the current frequency data as a byte array
  26935. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26936. * @returns a Uint8Array
  26937. */
  26938. getByteFrequencyData(): Uint8Array;
  26939. /**
  26940. * Gets the current waveform as a byte array
  26941. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26942. * @returns a Uint8Array
  26943. */
  26944. getByteTimeDomainData(): Uint8Array;
  26945. /**
  26946. * Gets the current frequency data as a float array
  26947. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26948. * @returns a Float32Array
  26949. */
  26950. getFloatFrequencyData(): Float32Array;
  26951. /**
  26952. * Renders the debug canvas
  26953. */
  26954. drawDebugCanvas(): void;
  26955. /**
  26956. * Stops rendering the debug canvas and removes it
  26957. */
  26958. stopDebugCanvas(): void;
  26959. /**
  26960. * Connects two audio nodes
  26961. * @param inputAudioNode defines first node to connect
  26962. * @param outputAudioNode defines second node to connect
  26963. */
  26964. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26965. /**
  26966. * Releases all associated resources
  26967. */
  26968. dispose(): void;
  26969. }
  26970. }
  26971. declare module BABYLON {
  26972. /**
  26973. * This represents an audio engine and it is responsible
  26974. * to play, synchronize and analyse sounds throughout the application.
  26975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26976. */
  26977. export interface IAudioEngine extends IDisposable {
  26978. /**
  26979. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26980. */
  26981. readonly canUseWebAudio: boolean;
  26982. /**
  26983. * Gets the current AudioContext if available.
  26984. */
  26985. readonly audioContext: Nullable<AudioContext>;
  26986. /**
  26987. * The master gain node defines the global audio volume of your audio engine.
  26988. */
  26989. readonly masterGain: GainNode;
  26990. /**
  26991. * Gets whether or not mp3 are supported by your browser.
  26992. */
  26993. readonly isMP3supported: boolean;
  26994. /**
  26995. * Gets whether or not ogg are supported by your browser.
  26996. */
  26997. readonly isOGGsupported: boolean;
  26998. /**
  26999. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27000. * @ignoreNaming
  27001. */
  27002. WarnedWebAudioUnsupported: boolean;
  27003. /**
  27004. * Defines if the audio engine relies on a custom unlocked button.
  27005. * In this case, the embedded button will not be displayed.
  27006. */
  27007. useCustomUnlockedButton: boolean;
  27008. /**
  27009. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27010. */
  27011. readonly unlocked: boolean;
  27012. /**
  27013. * Event raised when audio has been unlocked on the browser.
  27014. */
  27015. onAudioUnlockedObservable: Observable<AudioEngine>;
  27016. /**
  27017. * Event raised when audio has been locked on the browser.
  27018. */
  27019. onAudioLockedObservable: Observable<AudioEngine>;
  27020. /**
  27021. * Flags the audio engine in Locked state.
  27022. * This happens due to new browser policies preventing audio to autoplay.
  27023. */
  27024. lock(): void;
  27025. /**
  27026. * Unlocks the audio engine once a user action has been done on the dom.
  27027. * This is helpful to resume play once browser policies have been satisfied.
  27028. */
  27029. unlock(): void;
  27030. }
  27031. /**
  27032. * This represents the default audio engine used in babylon.
  27033. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27035. */
  27036. export class AudioEngine implements IAudioEngine {
  27037. private _audioContext;
  27038. private _audioContextInitialized;
  27039. private _muteButton;
  27040. private _hostElement;
  27041. /**
  27042. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27043. */
  27044. canUseWebAudio: boolean;
  27045. /**
  27046. * The master gain node defines the global audio volume of your audio engine.
  27047. */
  27048. masterGain: GainNode;
  27049. /**
  27050. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27051. * @ignoreNaming
  27052. */
  27053. WarnedWebAudioUnsupported: boolean;
  27054. /**
  27055. * Gets whether or not mp3 are supported by your browser.
  27056. */
  27057. isMP3supported: boolean;
  27058. /**
  27059. * Gets whether or not ogg are supported by your browser.
  27060. */
  27061. isOGGsupported: boolean;
  27062. /**
  27063. * Gets whether audio has been unlocked on the device.
  27064. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27065. * a user interaction has happened.
  27066. */
  27067. unlocked: boolean;
  27068. /**
  27069. * Defines if the audio engine relies on a custom unlocked button.
  27070. * In this case, the embedded button will not be displayed.
  27071. */
  27072. useCustomUnlockedButton: boolean;
  27073. /**
  27074. * Event raised when audio has been unlocked on the browser.
  27075. */
  27076. onAudioUnlockedObservable: Observable<AudioEngine>;
  27077. /**
  27078. * Event raised when audio has been locked on the browser.
  27079. */
  27080. onAudioLockedObservable: Observable<AudioEngine>;
  27081. /**
  27082. * Gets the current AudioContext if available.
  27083. */
  27084. readonly audioContext: Nullable<AudioContext>;
  27085. private _connectedAnalyser;
  27086. /**
  27087. * Instantiates a new audio engine.
  27088. *
  27089. * There should be only one per page as some browsers restrict the number
  27090. * of audio contexts you can create.
  27091. * @param hostElement defines the host element where to display the mute icon if necessary
  27092. */
  27093. constructor(hostElement?: Nullable<HTMLElement>);
  27094. /**
  27095. * Flags the audio engine in Locked state.
  27096. * This happens due to new browser policies preventing audio to autoplay.
  27097. */
  27098. lock(): void;
  27099. /**
  27100. * Unlocks the audio engine once a user action has been done on the dom.
  27101. * This is helpful to resume play once browser policies have been satisfied.
  27102. */
  27103. unlock(): void;
  27104. private _resumeAudioContext;
  27105. private _initializeAudioContext;
  27106. private _tryToRun;
  27107. private _triggerRunningState;
  27108. private _triggerSuspendedState;
  27109. private _displayMuteButton;
  27110. private _moveButtonToTopLeft;
  27111. private _onResize;
  27112. private _hideMuteButton;
  27113. /**
  27114. * Destroy and release the resources associated with the audio ccontext.
  27115. */
  27116. dispose(): void;
  27117. /**
  27118. * Gets the global volume sets on the master gain.
  27119. * @returns the global volume if set or -1 otherwise
  27120. */
  27121. getGlobalVolume(): number;
  27122. /**
  27123. * Sets the global volume of your experience (sets on the master gain).
  27124. * @param newVolume Defines the new global volume of the application
  27125. */
  27126. setGlobalVolume(newVolume: number): void;
  27127. /**
  27128. * Connect the audio engine to an audio analyser allowing some amazing
  27129. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27131. * @param analyser The analyser to connect to the engine
  27132. */
  27133. connectToAnalyser(analyser: Analyser): void;
  27134. }
  27135. }
  27136. declare module BABYLON {
  27137. /**
  27138. * Interface used to present a loading screen while loading a scene
  27139. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27140. */
  27141. export interface ILoadingScreen {
  27142. /**
  27143. * Function called to display the loading screen
  27144. */
  27145. displayLoadingUI: () => void;
  27146. /**
  27147. * Function called to hide the loading screen
  27148. */
  27149. hideLoadingUI: () => void;
  27150. /**
  27151. * Gets or sets the color to use for the background
  27152. */
  27153. loadingUIBackgroundColor: string;
  27154. /**
  27155. * Gets or sets the text to display while loading
  27156. */
  27157. loadingUIText: string;
  27158. }
  27159. /**
  27160. * Class used for the default loading screen
  27161. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27162. */
  27163. export class DefaultLoadingScreen implements ILoadingScreen {
  27164. private _renderingCanvas;
  27165. private _loadingText;
  27166. private _loadingDivBackgroundColor;
  27167. private _loadingDiv;
  27168. private _loadingTextDiv;
  27169. /** Gets or sets the logo url to use for the default loading screen */
  27170. static DefaultLogoUrl: string;
  27171. /** Gets or sets the spinner url to use for the default loading screen */
  27172. static DefaultSpinnerUrl: string;
  27173. /**
  27174. * Creates a new default loading screen
  27175. * @param _renderingCanvas defines the canvas used to render the scene
  27176. * @param _loadingText defines the default text to display
  27177. * @param _loadingDivBackgroundColor defines the default background color
  27178. */
  27179. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27180. /**
  27181. * Function called to display the loading screen
  27182. */
  27183. displayLoadingUI(): void;
  27184. /**
  27185. * Function called to hide the loading screen
  27186. */
  27187. hideLoadingUI(): void;
  27188. /**
  27189. * Gets or sets the text to display while loading
  27190. */
  27191. loadingUIText: string;
  27192. /**
  27193. * Gets or sets the color to use for the background
  27194. */
  27195. loadingUIBackgroundColor: string;
  27196. private _resizeLoadingUI;
  27197. }
  27198. }
  27199. declare module BABYLON {
  27200. /** @hidden */
  27201. export class WebGLPipelineContext implements IPipelineContext {
  27202. engine: Engine;
  27203. program: Nullable<WebGLProgram>;
  27204. context?: WebGLRenderingContext;
  27205. vertexShader?: WebGLShader;
  27206. fragmentShader?: WebGLShader;
  27207. isParallelCompiled: boolean;
  27208. onCompiled?: () => void;
  27209. transformFeedback?: WebGLTransformFeedback | null;
  27210. readonly isAsync: boolean;
  27211. readonly isReady: boolean;
  27212. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27213. }
  27214. }
  27215. declare module BABYLON {
  27216. /** @hidden */
  27217. export class WebGLDataBuffer extends DataBuffer {
  27218. private _buffer;
  27219. constructor(resource: WebGLBuffer);
  27220. readonly underlyingResource: any;
  27221. }
  27222. }
  27223. declare module BABYLON {
  27224. /** @hidden */
  27225. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27226. attributeProcessor(attribute: string): string;
  27227. varyingProcessor(varying: string, isFragment: boolean): string;
  27228. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27229. }
  27230. }
  27231. declare module BABYLON {
  27232. /**
  27233. * Settings for finer control over video usage
  27234. */
  27235. export interface VideoTextureSettings {
  27236. /**
  27237. * Applies `autoplay` to video, if specified
  27238. */
  27239. autoPlay?: boolean;
  27240. /**
  27241. * Applies `loop` to video, if specified
  27242. */
  27243. loop?: boolean;
  27244. /**
  27245. * Automatically updates internal texture from video at every frame in the render loop
  27246. */
  27247. autoUpdateTexture: boolean;
  27248. /**
  27249. * Image src displayed during the video loading or until the user interacts with the video.
  27250. */
  27251. poster?: string;
  27252. }
  27253. /**
  27254. * If you want to display a video in your scene, this is the special texture for that.
  27255. * This special texture works similar to other textures, with the exception of a few parameters.
  27256. * @see https://doc.babylonjs.com/how_to/video_texture
  27257. */
  27258. export class VideoTexture extends Texture {
  27259. /**
  27260. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27261. */
  27262. readonly autoUpdateTexture: boolean;
  27263. /**
  27264. * The video instance used by the texture internally
  27265. */
  27266. readonly video: HTMLVideoElement;
  27267. private _onUserActionRequestedObservable;
  27268. /**
  27269. * Event triggerd when a dom action is required by the user to play the video.
  27270. * This happens due to recent changes in browser policies preventing video to auto start.
  27271. */
  27272. readonly onUserActionRequestedObservable: Observable<Texture>;
  27273. private _generateMipMaps;
  27274. private _engine;
  27275. private _stillImageCaptured;
  27276. private _displayingPosterTexture;
  27277. private _settings;
  27278. private _createInternalTextureOnEvent;
  27279. /**
  27280. * Creates a video texture.
  27281. * If you want to display a video in your scene, this is the special texture for that.
  27282. * This special texture works similar to other textures, with the exception of a few parameters.
  27283. * @see https://doc.babylonjs.com/how_to/video_texture
  27284. * @param name optional name, will detect from video source, if not defined
  27285. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27286. * @param scene is obviously the current scene.
  27287. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27288. * @param invertY is false by default but can be used to invert video on Y axis
  27289. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27290. * @param settings allows finer control over video usage
  27291. */
  27292. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27293. private _getName;
  27294. private _getVideo;
  27295. private _createInternalTexture;
  27296. private reset;
  27297. /**
  27298. * @hidden Internal method to initiate `update`.
  27299. */
  27300. _rebuild(): void;
  27301. /**
  27302. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27303. */
  27304. update(): void;
  27305. /**
  27306. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27307. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27308. */
  27309. updateTexture(isVisible: boolean): void;
  27310. protected _updateInternalTexture: () => void;
  27311. /**
  27312. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27313. * @param url New url.
  27314. */
  27315. updateURL(url: string): void;
  27316. /**
  27317. * Dispose the texture and release its associated resources.
  27318. */
  27319. dispose(): void;
  27320. /**
  27321. * Creates a video texture straight from a stream.
  27322. * @param scene Define the scene the texture should be created in
  27323. * @param stream Define the stream the texture should be created from
  27324. * @returns The created video texture as a promise
  27325. */
  27326. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27327. /**
  27328. * Creates a video texture straight from your WebCam video feed.
  27329. * @param scene Define the scene the texture should be created in
  27330. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27331. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27332. * @returns The created video texture as a promise
  27333. */
  27334. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27335. minWidth: number;
  27336. maxWidth: number;
  27337. minHeight: number;
  27338. maxHeight: number;
  27339. deviceId: string;
  27340. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27341. /**
  27342. * Creates a video texture straight from your WebCam video feed.
  27343. * @param scene Define the scene the texture should be created in
  27344. * @param onReady Define a callback to triggered once the texture will be ready
  27345. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27346. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27347. */
  27348. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27349. minWidth: number;
  27350. maxWidth: number;
  27351. minHeight: number;
  27352. maxHeight: number;
  27353. deviceId: string;
  27354. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27355. }
  27356. }
  27357. declare module BABYLON {
  27358. /**
  27359. * Interface for attribute information associated with buffer instanciation
  27360. */
  27361. export class InstancingAttributeInfo {
  27362. /**
  27363. * Index/offset of the attribute in the vertex shader
  27364. */
  27365. index: number;
  27366. /**
  27367. * size of the attribute, 1, 2, 3 or 4
  27368. */
  27369. attributeSize: number;
  27370. /**
  27371. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27372. * default is FLOAT
  27373. */
  27374. attribyteType: number;
  27375. /**
  27376. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27377. */
  27378. normalized: boolean;
  27379. /**
  27380. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27381. */
  27382. offset: number;
  27383. /**
  27384. * Name of the GLSL attribute, for debugging purpose only
  27385. */
  27386. attributeName: string;
  27387. }
  27388. /**
  27389. * Define options used to create a depth texture
  27390. */
  27391. export class DepthTextureCreationOptions {
  27392. /** Specifies whether or not a stencil should be allocated in the texture */
  27393. generateStencil?: boolean;
  27394. /** Specifies whether or not bilinear filtering is enable on the texture */
  27395. bilinearFiltering?: boolean;
  27396. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27397. comparisonFunction?: number;
  27398. /** Specifies if the created texture is a cube texture */
  27399. isCube?: boolean;
  27400. }
  27401. /**
  27402. * Class used to describe the capabilities of the engine relatively to the current browser
  27403. */
  27404. export class EngineCapabilities {
  27405. /** Maximum textures units per fragment shader */
  27406. maxTexturesImageUnits: number;
  27407. /** Maximum texture units per vertex shader */
  27408. maxVertexTextureImageUnits: number;
  27409. /** Maximum textures units in the entire pipeline */
  27410. maxCombinedTexturesImageUnits: number;
  27411. /** Maximum texture size */
  27412. maxTextureSize: number;
  27413. /** Maximum cube texture size */
  27414. maxCubemapTextureSize: number;
  27415. /** Maximum render texture size */
  27416. maxRenderTextureSize: number;
  27417. /** Maximum number of vertex attributes */
  27418. maxVertexAttribs: number;
  27419. /** Maximum number of varyings */
  27420. maxVaryingVectors: number;
  27421. /** Maximum number of uniforms per vertex shader */
  27422. maxVertexUniformVectors: number;
  27423. /** Maximum number of uniforms per fragment shader */
  27424. maxFragmentUniformVectors: number;
  27425. /** Defines if standard derivates (dx/dy) are supported */
  27426. standardDerivatives: boolean;
  27427. /** Defines if s3tc texture compression is supported */
  27428. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27429. /** Defines if pvrtc texture compression is supported */
  27430. pvrtc: any;
  27431. /** Defines if etc1 texture compression is supported */
  27432. etc1: any;
  27433. /** Defines if etc2 texture compression is supported */
  27434. etc2: any;
  27435. /** Defines if astc texture compression is supported */
  27436. astc: any;
  27437. /** Defines if float textures are supported */
  27438. textureFloat: boolean;
  27439. /** Defines if vertex array objects are supported */
  27440. vertexArrayObject: boolean;
  27441. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27442. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27443. /** Gets the maximum level of anisotropy supported */
  27444. maxAnisotropy: number;
  27445. /** Defines if instancing is supported */
  27446. instancedArrays: boolean;
  27447. /** Defines if 32 bits indices are supported */
  27448. uintIndices: boolean;
  27449. /** Defines if high precision shaders are supported */
  27450. highPrecisionShaderSupported: boolean;
  27451. /** Defines if depth reading in the fragment shader is supported */
  27452. fragmentDepthSupported: boolean;
  27453. /** Defines if float texture linear filtering is supported*/
  27454. textureFloatLinearFiltering: boolean;
  27455. /** Defines if rendering to float textures is supported */
  27456. textureFloatRender: boolean;
  27457. /** Defines if half float textures are supported*/
  27458. textureHalfFloat: boolean;
  27459. /** Defines if half float texture linear filtering is supported*/
  27460. textureHalfFloatLinearFiltering: boolean;
  27461. /** Defines if rendering to half float textures is supported */
  27462. textureHalfFloatRender: boolean;
  27463. /** Defines if textureLOD shader command is supported */
  27464. textureLOD: boolean;
  27465. /** Defines if draw buffers extension is supported */
  27466. drawBuffersExtension: boolean;
  27467. /** Defines if depth textures are supported */
  27468. depthTextureExtension: boolean;
  27469. /** Defines if float color buffer are supported */
  27470. colorBufferFloat: boolean;
  27471. /** Gets disjoint timer query extension (null if not supported) */
  27472. timerQuery: EXT_disjoint_timer_query;
  27473. /** Defines if timestamp can be used with timer query */
  27474. canUseTimestampForTimerQuery: boolean;
  27475. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27476. multiview: any;
  27477. /** Function used to let the system compiles shaders in background */
  27478. parallelShaderCompile: {
  27479. COMPLETION_STATUS_KHR: number;
  27480. };
  27481. }
  27482. /** Interface defining initialization parameters for Engine class */
  27483. export interface EngineOptions extends WebGLContextAttributes {
  27484. /**
  27485. * Defines if the engine should no exceed a specified device ratio
  27486. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27487. */
  27488. limitDeviceRatio?: number;
  27489. /**
  27490. * Defines if webvr should be enabled automatically
  27491. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27492. */
  27493. autoEnableWebVR?: boolean;
  27494. /**
  27495. * Defines if webgl2 should be turned off even if supported
  27496. * @see http://doc.babylonjs.com/features/webgl2
  27497. */
  27498. disableWebGL2Support?: boolean;
  27499. /**
  27500. * Defines if webaudio should be initialized as well
  27501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27502. */
  27503. audioEngine?: boolean;
  27504. /**
  27505. * Defines if animations should run using a deterministic lock step
  27506. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27507. */
  27508. deterministicLockstep?: boolean;
  27509. /** Defines the maximum steps to use with deterministic lock step mode */
  27510. lockstepMaxSteps?: number;
  27511. /**
  27512. * Defines that engine should ignore context lost events
  27513. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27514. */
  27515. doNotHandleContextLost?: boolean;
  27516. /**
  27517. * Defines that engine should ignore modifying touch action attribute and style
  27518. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27519. */
  27520. doNotHandleTouchAction?: boolean;
  27521. /**
  27522. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27523. */
  27524. useHighPrecisionFloats?: boolean;
  27525. }
  27526. /**
  27527. * Defines the interface used by display changed events
  27528. */
  27529. export interface IDisplayChangedEventArgs {
  27530. /** Gets the vrDisplay object (if any) */
  27531. vrDisplay: Nullable<any>;
  27532. /** Gets a boolean indicating if webVR is supported */
  27533. vrSupported: boolean;
  27534. }
  27535. /**
  27536. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27537. */
  27538. export class Engine {
  27539. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27540. static ExceptionList: ({
  27541. key: string;
  27542. capture: string;
  27543. captureConstraint: number;
  27544. targets: string[];
  27545. } | {
  27546. key: string;
  27547. capture: null;
  27548. captureConstraint: null;
  27549. targets: string[];
  27550. })[];
  27551. /** Gets the list of created engines */
  27552. static readonly Instances: Engine[];
  27553. /**
  27554. * Gets the latest created engine
  27555. */
  27556. static readonly LastCreatedEngine: Nullable<Engine>;
  27557. /**
  27558. * Gets the latest created scene
  27559. */
  27560. static readonly LastCreatedScene: Nullable<Scene>;
  27561. /**
  27562. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27563. * @param flag defines which part of the materials must be marked as dirty
  27564. * @param predicate defines a predicate used to filter which materials should be affected
  27565. */
  27566. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27567. /** @hidden */
  27568. static _TextureLoaders: IInternalTextureLoader[];
  27569. /** Defines that alpha blending is disabled */
  27570. static readonly ALPHA_DISABLE: number;
  27571. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27572. static readonly ALPHA_ADD: number;
  27573. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27574. static readonly ALPHA_COMBINE: number;
  27575. /** Defines that alpha blending to DEST - SRC * DEST */
  27576. static readonly ALPHA_SUBTRACT: number;
  27577. /** Defines that alpha blending to SRC * DEST */
  27578. static readonly ALPHA_MULTIPLY: number;
  27579. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27580. static readonly ALPHA_MAXIMIZED: number;
  27581. /** Defines that alpha blending to SRC + DEST */
  27582. static readonly ALPHA_ONEONE: number;
  27583. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27584. static readonly ALPHA_PREMULTIPLIED: number;
  27585. /**
  27586. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27587. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27588. */
  27589. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27590. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27591. static readonly ALPHA_INTERPOLATE: number;
  27592. /**
  27593. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27594. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27595. */
  27596. static readonly ALPHA_SCREENMODE: number;
  27597. /** Defines that the ressource is not delayed*/
  27598. static readonly DELAYLOADSTATE_NONE: number;
  27599. /** Defines that the ressource was successfully delay loaded */
  27600. static readonly DELAYLOADSTATE_LOADED: number;
  27601. /** Defines that the ressource is currently delay loading */
  27602. static readonly DELAYLOADSTATE_LOADING: number;
  27603. /** Defines that the ressource is delayed and has not started loading */
  27604. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27605. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27606. static readonly NEVER: number;
  27607. /** 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 */
  27608. static readonly ALWAYS: number;
  27609. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27610. static readonly LESS: number;
  27611. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27612. static readonly EQUAL: number;
  27613. /** 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 */
  27614. static readonly LEQUAL: number;
  27615. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27616. static readonly GREATER: number;
  27617. /** 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 */
  27618. static readonly GEQUAL: number;
  27619. /** 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 */
  27620. static readonly NOTEQUAL: number;
  27621. /** Passed to stencilOperation to specify that stencil value must be kept */
  27622. static readonly KEEP: number;
  27623. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27624. static readonly REPLACE: number;
  27625. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27626. static readonly INCR: number;
  27627. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27628. static readonly DECR: number;
  27629. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27630. static readonly INVERT: number;
  27631. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27632. static readonly INCR_WRAP: number;
  27633. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27634. static readonly DECR_WRAP: number;
  27635. /** Texture is not repeating outside of 0..1 UVs */
  27636. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27637. /** Texture is repeating outside of 0..1 UVs */
  27638. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27639. /** Texture is repeating and mirrored */
  27640. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27641. /** ALPHA */
  27642. static readonly TEXTUREFORMAT_ALPHA: number;
  27643. /** LUMINANCE */
  27644. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27645. /** LUMINANCE_ALPHA */
  27646. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27647. /** RGB */
  27648. static readonly TEXTUREFORMAT_RGB: number;
  27649. /** RGBA */
  27650. static readonly TEXTUREFORMAT_RGBA: number;
  27651. /** RED */
  27652. static readonly TEXTUREFORMAT_RED: number;
  27653. /** RED (2nd reference) */
  27654. static readonly TEXTUREFORMAT_R: number;
  27655. /** RG */
  27656. static readonly TEXTUREFORMAT_RG: number;
  27657. /** RED_INTEGER */
  27658. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27659. /** RED_INTEGER (2nd reference) */
  27660. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27661. /** RG_INTEGER */
  27662. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27663. /** RGB_INTEGER */
  27664. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27665. /** RGBA_INTEGER */
  27666. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27667. /** UNSIGNED_BYTE */
  27668. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27669. /** UNSIGNED_BYTE (2nd reference) */
  27670. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27671. /** FLOAT */
  27672. static readonly TEXTURETYPE_FLOAT: number;
  27673. /** HALF_FLOAT */
  27674. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27675. /** BYTE */
  27676. static readonly TEXTURETYPE_BYTE: number;
  27677. /** SHORT */
  27678. static readonly TEXTURETYPE_SHORT: number;
  27679. /** UNSIGNED_SHORT */
  27680. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27681. /** INT */
  27682. static readonly TEXTURETYPE_INT: number;
  27683. /** UNSIGNED_INT */
  27684. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27685. /** UNSIGNED_SHORT_4_4_4_4 */
  27686. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27687. /** UNSIGNED_SHORT_5_5_5_1 */
  27688. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27689. /** UNSIGNED_SHORT_5_6_5 */
  27690. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27691. /** UNSIGNED_INT_2_10_10_10_REV */
  27692. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27693. /** UNSIGNED_INT_24_8 */
  27694. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27695. /** UNSIGNED_INT_10F_11F_11F_REV */
  27696. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27697. /** UNSIGNED_INT_5_9_9_9_REV */
  27698. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27699. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27700. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27701. /** nearest is mag = nearest and min = nearest and mip = linear */
  27702. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27703. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27704. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27705. /** Trilinear is mag = linear and min = linear and mip = linear */
  27706. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27707. /** nearest is mag = nearest and min = nearest and mip = linear */
  27708. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27709. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27710. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27711. /** Trilinear is mag = linear and min = linear and mip = linear */
  27712. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27713. /** mag = nearest and min = nearest and mip = nearest */
  27714. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27715. /** mag = nearest and min = linear and mip = nearest */
  27716. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27717. /** mag = nearest and min = linear and mip = linear */
  27718. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27719. /** mag = nearest and min = linear and mip = none */
  27720. static readonly TEXTURE_NEAREST_LINEAR: number;
  27721. /** mag = nearest and min = nearest and mip = none */
  27722. static readonly TEXTURE_NEAREST_NEAREST: number;
  27723. /** mag = linear and min = nearest and mip = nearest */
  27724. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27725. /** mag = linear and min = nearest and mip = linear */
  27726. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27727. /** mag = linear and min = linear and mip = none */
  27728. static readonly TEXTURE_LINEAR_LINEAR: number;
  27729. /** mag = linear and min = nearest and mip = none */
  27730. static readonly TEXTURE_LINEAR_NEAREST: number;
  27731. /** Explicit coordinates mode */
  27732. static readonly TEXTURE_EXPLICIT_MODE: number;
  27733. /** Spherical coordinates mode */
  27734. static readonly TEXTURE_SPHERICAL_MODE: number;
  27735. /** Planar coordinates mode */
  27736. static readonly TEXTURE_PLANAR_MODE: number;
  27737. /** Cubic coordinates mode */
  27738. static readonly TEXTURE_CUBIC_MODE: number;
  27739. /** Projection coordinates mode */
  27740. static readonly TEXTURE_PROJECTION_MODE: number;
  27741. /** Skybox coordinates mode */
  27742. static readonly TEXTURE_SKYBOX_MODE: number;
  27743. /** Inverse Cubic coordinates mode */
  27744. static readonly TEXTURE_INVCUBIC_MODE: number;
  27745. /** Equirectangular coordinates mode */
  27746. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27747. /** Equirectangular Fixed coordinates mode */
  27748. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27749. /** Equirectangular Fixed Mirrored coordinates mode */
  27750. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27751. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27752. static readonly SCALEMODE_FLOOR: number;
  27753. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27754. static readonly SCALEMODE_NEAREST: number;
  27755. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27756. static readonly SCALEMODE_CEILING: number;
  27757. /**
  27758. * Returns the current npm package of the sdk
  27759. */
  27760. static readonly NpmPackage: string;
  27761. /**
  27762. * Returns the current version of the framework
  27763. */
  27764. static readonly Version: string;
  27765. /**
  27766. * Returns a string describing the current engine
  27767. */
  27768. readonly description: string;
  27769. /**
  27770. * Gets or sets the epsilon value used by collision engine
  27771. */
  27772. static CollisionsEpsilon: number;
  27773. /**
  27774. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27775. */
  27776. static ShadersRepository: string;
  27777. /**
  27778. * Method called to create the default loading screen.
  27779. * This can be overriden in your own app.
  27780. * @param canvas The rendering canvas element
  27781. * @returns The loading screen
  27782. */
  27783. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27784. /**
  27785. * Method called to create the default rescale post process on each engine.
  27786. */
  27787. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27788. /** @hidden */
  27789. _shaderProcessor: IShaderProcessor;
  27790. /**
  27791. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27792. */
  27793. forcePOTTextures: boolean;
  27794. /**
  27795. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27796. */
  27797. isFullscreen: boolean;
  27798. /**
  27799. * Gets a boolean indicating if the pointer is currently locked
  27800. */
  27801. isPointerLock: boolean;
  27802. /**
  27803. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27804. */
  27805. cullBackFaces: boolean;
  27806. /**
  27807. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27808. */
  27809. renderEvenInBackground: boolean;
  27810. /**
  27811. * Gets or sets a boolean indicating that cache can be kept between frames
  27812. */
  27813. preventCacheWipeBetweenFrames: boolean;
  27814. /**
  27815. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27816. **/
  27817. enableOfflineSupport: boolean;
  27818. /**
  27819. * 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)
  27820. **/
  27821. disableManifestCheck: boolean;
  27822. /**
  27823. * Gets the list of created scenes
  27824. */
  27825. scenes: Scene[];
  27826. /**
  27827. * Event raised when a new scene is created
  27828. */
  27829. onNewSceneAddedObservable: Observable<Scene>;
  27830. /**
  27831. * Gets the list of created postprocesses
  27832. */
  27833. postProcesses: PostProcess[];
  27834. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27835. validateShaderPrograms: boolean;
  27836. /**
  27837. * Observable event triggered each time the rendering canvas is resized
  27838. */
  27839. onResizeObservable: Observable<Engine>;
  27840. /**
  27841. * Observable event triggered each time the canvas loses focus
  27842. */
  27843. onCanvasBlurObservable: Observable<Engine>;
  27844. /**
  27845. * Observable event triggered each time the canvas gains focus
  27846. */
  27847. onCanvasFocusObservable: Observable<Engine>;
  27848. /**
  27849. * Observable event triggered each time the canvas receives pointerout event
  27850. */
  27851. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27852. /**
  27853. * Observable event triggered before each texture is initialized
  27854. */
  27855. onBeforeTextureInitObservable: Observable<Texture>;
  27856. /**
  27857. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27858. */
  27859. disableUniformBuffers: boolean;
  27860. /** @hidden */
  27861. _uniformBuffers: UniformBuffer[];
  27862. /**
  27863. * Gets a boolean indicating that the engine supports uniform buffers
  27864. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27865. */
  27866. readonly supportsUniformBuffers: boolean;
  27867. /**
  27868. * Observable raised when the engine begins a new frame
  27869. */
  27870. onBeginFrameObservable: Observable<Engine>;
  27871. /**
  27872. * If set, will be used to request the next animation frame for the render loop
  27873. */
  27874. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27875. /**
  27876. * Observable raised when the engine ends the current frame
  27877. */
  27878. onEndFrameObservable: Observable<Engine>;
  27879. /**
  27880. * Observable raised when the engine is about to compile a shader
  27881. */
  27882. onBeforeShaderCompilationObservable: Observable<Engine>;
  27883. /**
  27884. * Observable raised when the engine has jsut compiled a shader
  27885. */
  27886. onAfterShaderCompilationObservable: Observable<Engine>;
  27887. /** @hidden */
  27888. _gl: WebGLRenderingContext;
  27889. private _renderingCanvas;
  27890. private _windowIsBackground;
  27891. private _webGLVersion;
  27892. protected _highPrecisionShadersAllowed: boolean;
  27893. /** @hidden */
  27894. readonly _shouldUseHighPrecisionShader: boolean;
  27895. /**
  27896. * Gets a boolean indicating that only power of 2 textures are supported
  27897. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27898. */
  27899. readonly needPOTTextures: boolean;
  27900. /** @hidden */
  27901. _badOS: boolean;
  27902. /** @hidden */
  27903. _badDesktopOS: boolean;
  27904. /**
  27905. * Gets the audio engine
  27906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27907. * @ignorenaming
  27908. */
  27909. static audioEngine: IAudioEngine;
  27910. /**
  27911. * Default AudioEngine factory responsible of creating the Audio Engine.
  27912. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27913. */
  27914. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27915. /**
  27916. * Default offline support factory responsible of creating a tool used to store data locally.
  27917. * By default, this will create a Database object if the workload has been embedded.
  27918. */
  27919. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27920. private _onFocus;
  27921. private _onBlur;
  27922. private _onCanvasPointerOut;
  27923. private _onCanvasBlur;
  27924. private _onCanvasFocus;
  27925. private _onFullscreenChange;
  27926. private _onPointerLockChange;
  27927. private _hardwareScalingLevel;
  27928. /** @hidden */
  27929. _caps: EngineCapabilities;
  27930. private _pointerLockRequested;
  27931. private _isStencilEnable;
  27932. private _colorWrite;
  27933. private _loadingScreen;
  27934. /** @hidden */
  27935. _drawCalls: PerfCounter;
  27936. private _glVersion;
  27937. private _glRenderer;
  27938. private _glVendor;
  27939. private _videoTextureSupported;
  27940. private _renderingQueueLaunched;
  27941. private _activeRenderLoops;
  27942. private _deterministicLockstep;
  27943. private _lockstepMaxSteps;
  27944. /**
  27945. * Observable signaled when a context lost event is raised
  27946. */
  27947. onContextLostObservable: Observable<Engine>;
  27948. /**
  27949. * Observable signaled when a context restored event is raised
  27950. */
  27951. onContextRestoredObservable: Observable<Engine>;
  27952. private _onContextLost;
  27953. private _onContextRestored;
  27954. private _contextWasLost;
  27955. /** @hidden */
  27956. _doNotHandleContextLost: boolean;
  27957. /**
  27958. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27959. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27960. */
  27961. doNotHandleContextLost: boolean;
  27962. private _performanceMonitor;
  27963. private _fps;
  27964. private _deltaTime;
  27965. /**
  27966. * Turn this value on if you want to pause FPS computation when in background
  27967. */
  27968. disablePerformanceMonitorInBackground: boolean;
  27969. /**
  27970. * Gets the performance monitor attached to this engine
  27971. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27972. */
  27973. readonly performanceMonitor: PerformanceMonitor;
  27974. /**
  27975. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27976. */
  27977. disableVertexArrayObjects: boolean;
  27978. /** @hidden */
  27979. protected _depthCullingState: _DepthCullingState;
  27980. /** @hidden */
  27981. protected _stencilState: _StencilState;
  27982. /** @hidden */
  27983. protected _alphaState: _AlphaState;
  27984. /** @hidden */
  27985. protected _alphaMode: number;
  27986. /** @hidden */
  27987. _internalTexturesCache: InternalTexture[];
  27988. /** @hidden */
  27989. protected _activeChannel: number;
  27990. private _currentTextureChannel;
  27991. /** @hidden */
  27992. protected _boundTexturesCache: {
  27993. [key: string]: Nullable<InternalTexture>;
  27994. };
  27995. /** @hidden */
  27996. protected _currentEffect: Nullable<Effect>;
  27997. /** @hidden */
  27998. protected _currentProgram: Nullable<WebGLProgram>;
  27999. private _compiledEffects;
  28000. private _vertexAttribArraysEnabled;
  28001. /** @hidden */
  28002. protected _cachedViewport: Nullable<Viewport>;
  28003. private _cachedVertexArrayObject;
  28004. /** @hidden */
  28005. protected _cachedVertexBuffers: any;
  28006. /** @hidden */
  28007. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28008. /** @hidden */
  28009. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28010. /** @hidden */
  28011. _currentRenderTarget: Nullable<InternalTexture>;
  28012. private _uintIndicesCurrentlySet;
  28013. private _currentBoundBuffer;
  28014. /** @hidden */
  28015. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28016. private _currentBufferPointers;
  28017. private _currentInstanceLocations;
  28018. private _currentInstanceBuffers;
  28019. private _textureUnits;
  28020. /** @hidden */
  28021. _workingCanvas: Nullable<HTMLCanvasElement>;
  28022. /** @hidden */
  28023. _workingContext: Nullable<CanvasRenderingContext2D>;
  28024. private _rescalePostProcess;
  28025. private _dummyFramebuffer;
  28026. private _externalData;
  28027. /** @hidden */
  28028. _bindedRenderFunction: any;
  28029. private _vaoRecordInProgress;
  28030. private _mustWipeVertexAttributes;
  28031. private _emptyTexture;
  28032. private _emptyCubeTexture;
  28033. private _emptyTexture3D;
  28034. /** @hidden */
  28035. _frameHandler: number;
  28036. private _nextFreeTextureSlots;
  28037. private _maxSimultaneousTextures;
  28038. private _activeRequests;
  28039. private _texturesSupported;
  28040. /** @hidden */
  28041. _textureFormatInUse: Nullable<string>;
  28042. /**
  28043. * Gets the list of texture formats supported
  28044. */
  28045. readonly texturesSupported: Array<string>;
  28046. /**
  28047. * Gets the list of texture formats in use
  28048. */
  28049. readonly textureFormatInUse: Nullable<string>;
  28050. /**
  28051. * Gets the current viewport
  28052. */
  28053. readonly currentViewport: Nullable<Viewport>;
  28054. /**
  28055. * Gets the default empty texture
  28056. */
  28057. readonly emptyTexture: InternalTexture;
  28058. /**
  28059. * Gets the default empty 3D texture
  28060. */
  28061. readonly emptyTexture3D: InternalTexture;
  28062. /**
  28063. * Gets the default empty cube texture
  28064. */
  28065. readonly emptyCubeTexture: InternalTexture;
  28066. /**
  28067. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28068. */
  28069. readonly premultipliedAlpha: boolean;
  28070. /**
  28071. * Creates a new engine
  28072. * @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
  28073. * @param antialias defines enable antialiasing (default: false)
  28074. * @param options defines further options to be sent to the getContext() function
  28075. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28076. */
  28077. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28078. /**
  28079. * Initializes a webVR display and starts listening to display change events
  28080. * The onVRDisplayChangedObservable will be notified upon these changes
  28081. * @returns The onVRDisplayChangedObservable
  28082. */
  28083. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28084. /** @hidden */
  28085. _prepareVRComponent(): void;
  28086. /** @hidden */
  28087. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28088. /** @hidden */
  28089. _submitVRFrame(): void;
  28090. /**
  28091. * Call this function to leave webVR mode
  28092. * Will do nothing if webVR is not supported or if there is no webVR device
  28093. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28094. */
  28095. disableVR(): void;
  28096. /**
  28097. * Gets a boolean indicating that the system is in VR mode and is presenting
  28098. * @returns true if VR mode is engaged
  28099. */
  28100. isVRPresenting(): boolean;
  28101. /** @hidden */
  28102. _requestVRFrame(): void;
  28103. private _disableTouchAction;
  28104. private _rebuildInternalTextures;
  28105. private _rebuildEffects;
  28106. /**
  28107. * Gets a boolean indicating if all created effects are ready
  28108. * @returns true if all effects are ready
  28109. */
  28110. areAllEffectsReady(): boolean;
  28111. private _rebuildBuffers;
  28112. private _initGLContext;
  28113. /**
  28114. * Gets version of the current webGL context
  28115. */
  28116. readonly webGLVersion: number;
  28117. /**
  28118. * Gets a string idenfifying the name of the class
  28119. * @returns "Engine" string
  28120. */
  28121. getClassName(): string;
  28122. /**
  28123. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28124. */
  28125. readonly isStencilEnable: boolean;
  28126. /** @hidden */
  28127. _prepareWorkingCanvas(): void;
  28128. /**
  28129. * Reset the texture cache to empty state
  28130. */
  28131. resetTextureCache(): void;
  28132. /**
  28133. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28134. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28135. * @returns true if engine is in deterministic lock step mode
  28136. */
  28137. isDeterministicLockStep(): boolean;
  28138. /**
  28139. * Gets the max steps when engine is running in deterministic lock step
  28140. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28141. * @returns the max steps
  28142. */
  28143. getLockstepMaxSteps(): number;
  28144. /**
  28145. * Gets an object containing information about the current webGL context
  28146. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28147. */
  28148. getGlInfo(): {
  28149. vendor: string;
  28150. renderer: string;
  28151. version: string;
  28152. };
  28153. /**
  28154. * Gets current aspect ratio
  28155. * @param camera defines the camera to use to get the aspect ratio
  28156. * @param useScreen defines if screen size must be used (or the current render target if any)
  28157. * @returns a number defining the aspect ratio
  28158. */
  28159. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28160. /**
  28161. * Gets current screen aspect ratio
  28162. * @returns a number defining the aspect ratio
  28163. */
  28164. getScreenAspectRatio(): number;
  28165. /**
  28166. * Gets the current render width
  28167. * @param useScreen defines if screen size must be used (or the current render target if any)
  28168. * @returns a number defining the current render width
  28169. */
  28170. getRenderWidth(useScreen?: boolean): number;
  28171. /**
  28172. * Gets the current render height
  28173. * @param useScreen defines if screen size must be used (or the current render target if any)
  28174. * @returns a number defining the current render height
  28175. */
  28176. getRenderHeight(useScreen?: boolean): number;
  28177. /**
  28178. * Gets the HTML canvas attached with the current webGL context
  28179. * @returns a HTML canvas
  28180. */
  28181. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28182. /**
  28183. * Gets the client rect of the HTML canvas attached with the current webGL context
  28184. * @returns a client rectanglee
  28185. */
  28186. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28187. /**
  28188. * Defines the hardware scaling level.
  28189. * By default the hardware scaling level is computed from the window device ratio.
  28190. * 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.
  28191. * @param level defines the level to use
  28192. */
  28193. setHardwareScalingLevel(level: number): void;
  28194. /**
  28195. * Gets the current hardware scaling level.
  28196. * By default the hardware scaling level is computed from the window device ratio.
  28197. * 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.
  28198. * @returns a number indicating the current hardware scaling level
  28199. */
  28200. getHardwareScalingLevel(): number;
  28201. /**
  28202. * Gets the list of loaded textures
  28203. * @returns an array containing all loaded textures
  28204. */
  28205. getLoadedTexturesCache(): InternalTexture[];
  28206. /**
  28207. * Gets the object containing all engine capabilities
  28208. * @returns the EngineCapabilities object
  28209. */
  28210. getCaps(): EngineCapabilities;
  28211. /**
  28212. * Gets the current depth function
  28213. * @returns a number defining the depth function
  28214. */
  28215. getDepthFunction(): Nullable<number>;
  28216. /**
  28217. * Sets the current depth function
  28218. * @param depthFunc defines the function to use
  28219. */
  28220. setDepthFunction(depthFunc: number): void;
  28221. /**
  28222. * Sets the current depth function to GREATER
  28223. */
  28224. setDepthFunctionToGreater(): void;
  28225. /**
  28226. * Sets the current depth function to GEQUAL
  28227. */
  28228. setDepthFunctionToGreaterOrEqual(): void;
  28229. /**
  28230. * Sets the current depth function to LESS
  28231. */
  28232. setDepthFunctionToLess(): void;
  28233. private _cachedStencilBuffer;
  28234. private _cachedStencilFunction;
  28235. private _cachedStencilMask;
  28236. private _cachedStencilOperationPass;
  28237. private _cachedStencilOperationFail;
  28238. private _cachedStencilOperationDepthFail;
  28239. private _cachedStencilReference;
  28240. /**
  28241. * Caches the the state of the stencil buffer
  28242. */
  28243. cacheStencilState(): void;
  28244. /**
  28245. * Restores the state of the stencil buffer
  28246. */
  28247. restoreStencilState(): void;
  28248. /**
  28249. * Sets the current depth function to LEQUAL
  28250. */
  28251. setDepthFunctionToLessOrEqual(): void;
  28252. /**
  28253. * Gets a boolean indicating if stencil buffer is enabled
  28254. * @returns the current stencil buffer state
  28255. */
  28256. getStencilBuffer(): boolean;
  28257. /**
  28258. * Enable or disable the stencil buffer
  28259. * @param enable defines if the stencil buffer must be enabled or disabled
  28260. */
  28261. setStencilBuffer(enable: boolean): void;
  28262. /**
  28263. * Gets the current stencil mask
  28264. * @returns a number defining the new stencil mask to use
  28265. */
  28266. getStencilMask(): number;
  28267. /**
  28268. * Sets the current stencil mask
  28269. * @param mask defines the new stencil mask to use
  28270. */
  28271. setStencilMask(mask: number): void;
  28272. /**
  28273. * Gets the current stencil function
  28274. * @returns a number defining the stencil function to use
  28275. */
  28276. getStencilFunction(): number;
  28277. /**
  28278. * Gets the current stencil reference value
  28279. * @returns a number defining the stencil reference value to use
  28280. */
  28281. getStencilFunctionReference(): number;
  28282. /**
  28283. * Gets the current stencil mask
  28284. * @returns a number defining the stencil mask to use
  28285. */
  28286. getStencilFunctionMask(): number;
  28287. /**
  28288. * Sets the current stencil function
  28289. * @param stencilFunc defines the new stencil function to use
  28290. */
  28291. setStencilFunction(stencilFunc: number): void;
  28292. /**
  28293. * Sets the current stencil reference
  28294. * @param reference defines the new stencil reference to use
  28295. */
  28296. setStencilFunctionReference(reference: number): void;
  28297. /**
  28298. * Sets the current stencil mask
  28299. * @param mask defines the new stencil mask to use
  28300. */
  28301. setStencilFunctionMask(mask: number): void;
  28302. /**
  28303. * Gets the current stencil operation when stencil fails
  28304. * @returns a number defining stencil operation to use when stencil fails
  28305. */
  28306. getStencilOperationFail(): number;
  28307. /**
  28308. * Gets the current stencil operation when depth fails
  28309. * @returns a number defining stencil operation to use when depth fails
  28310. */
  28311. getStencilOperationDepthFail(): number;
  28312. /**
  28313. * Gets the current stencil operation when stencil passes
  28314. * @returns a number defining stencil operation to use when stencil passes
  28315. */
  28316. getStencilOperationPass(): number;
  28317. /**
  28318. * Sets the stencil operation to use when stencil fails
  28319. * @param operation defines the stencil operation to use when stencil fails
  28320. */
  28321. setStencilOperationFail(operation: number): void;
  28322. /**
  28323. * Sets the stencil operation to use when depth fails
  28324. * @param operation defines the stencil operation to use when depth fails
  28325. */
  28326. setStencilOperationDepthFail(operation: number): void;
  28327. /**
  28328. * Sets the stencil operation to use when stencil passes
  28329. * @param operation defines the stencil operation to use when stencil passes
  28330. */
  28331. setStencilOperationPass(operation: number): void;
  28332. /**
  28333. * Sets a boolean indicating if the dithering state is enabled or disabled
  28334. * @param value defines the dithering state
  28335. */
  28336. setDitheringState(value: boolean): void;
  28337. /**
  28338. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28339. * @param value defines the rasterizer state
  28340. */
  28341. setRasterizerState(value: boolean): void;
  28342. /**
  28343. * stop executing a render loop function and remove it from the execution array
  28344. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28345. */
  28346. stopRenderLoop(renderFunction?: () => void): void;
  28347. /** @hidden */
  28348. _renderLoop(): void;
  28349. /**
  28350. * Register and execute a render loop. The engine can have more than one render function
  28351. * @param renderFunction defines the function to continuously execute
  28352. */
  28353. runRenderLoop(renderFunction: () => void): void;
  28354. /**
  28355. * Toggle full screen mode
  28356. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28357. */
  28358. switchFullscreen(requestPointerLock: boolean): void;
  28359. /**
  28360. * Enters full screen mode
  28361. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28362. */
  28363. enterFullscreen(requestPointerLock: boolean): void;
  28364. /**
  28365. * Exits full screen mode
  28366. */
  28367. exitFullscreen(): void;
  28368. /**
  28369. * Enters Pointerlock mode
  28370. */
  28371. enterPointerlock(): void;
  28372. /**
  28373. * Exits Pointerlock mode
  28374. */
  28375. exitPointerlock(): void;
  28376. /**
  28377. * Clear the current render buffer or the current render target (if any is set up)
  28378. * @param color defines the color to use
  28379. * @param backBuffer defines if the back buffer must be cleared
  28380. * @param depth defines if the depth buffer must be cleared
  28381. * @param stencil defines if the stencil buffer must be cleared
  28382. */
  28383. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28384. /**
  28385. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28386. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28387. * @param y defines the y-coordinate of the corner of the clear rectangle
  28388. * @param width defines the width of the clear rectangle
  28389. * @param height defines the height of the clear rectangle
  28390. * @param clearColor defines the clear color
  28391. */
  28392. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28393. /**
  28394. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28395. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28396. * @param y defines the y-coordinate of the corner of the clear rectangle
  28397. * @param width defines the width of the clear rectangle
  28398. * @param height defines the height of the clear rectangle
  28399. */
  28400. enableScissor(x: number, y: number, width: number, height: number): void;
  28401. /**
  28402. * Disable previously set scissor test rectangle
  28403. */
  28404. disableScissor(): void;
  28405. private _viewportCached;
  28406. /** @hidden */
  28407. _viewport(x: number, y: number, width: number, height: number): void;
  28408. /**
  28409. * Set the WebGL's viewport
  28410. * @param viewport defines the viewport element to be used
  28411. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28412. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28413. */
  28414. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28415. /**
  28416. * Directly set the WebGL Viewport
  28417. * @param x defines the x coordinate of the viewport (in screen space)
  28418. * @param y defines the y coordinate of the viewport (in screen space)
  28419. * @param width defines the width of the viewport (in screen space)
  28420. * @param height defines the height of the viewport (in screen space)
  28421. * @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
  28422. */
  28423. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28424. /**
  28425. * Begin a new frame
  28426. */
  28427. beginFrame(): void;
  28428. /**
  28429. * Enf the current frame
  28430. */
  28431. endFrame(): void;
  28432. /**
  28433. * Resize the view according to the canvas' size
  28434. */
  28435. resize(): void;
  28436. /**
  28437. * Force a specific size of the canvas
  28438. * @param width defines the new canvas' width
  28439. * @param height defines the new canvas' height
  28440. */
  28441. setSize(width: number, height: number): void;
  28442. /**
  28443. * Binds the frame buffer to the specified texture.
  28444. * @param texture The texture to render to or null for the default canvas
  28445. * @param faceIndex The face of the texture to render to in case of cube texture
  28446. * @param requiredWidth The width of the target to render to
  28447. * @param requiredHeight The height of the target to render to
  28448. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28449. * @param depthStencilTexture The depth stencil texture to use to render
  28450. * @param lodLevel defines le lod level to bind to the frame buffer
  28451. */
  28452. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28453. /** @hidden */
  28454. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28455. /**
  28456. * Unbind the current render target texture from the webGL context
  28457. * @param texture defines the render target texture to unbind
  28458. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28459. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28460. */
  28461. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28462. /**
  28463. * Force the mipmap generation for the given render target texture
  28464. * @param texture defines the render target texture to use
  28465. */
  28466. generateMipMapsForCubemap(texture: InternalTexture): void;
  28467. /**
  28468. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28469. */
  28470. flushFramebuffer(): void;
  28471. /**
  28472. * Unbind the current render target and bind the default framebuffer
  28473. */
  28474. restoreDefaultFramebuffer(): void;
  28475. /**
  28476. * Create an uniform buffer
  28477. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28478. * @param elements defines the content of the uniform buffer
  28479. * @returns the webGL uniform buffer
  28480. */
  28481. createUniformBuffer(elements: FloatArray): DataBuffer;
  28482. /**
  28483. * Create a dynamic uniform buffer
  28484. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28485. * @param elements defines the content of the uniform buffer
  28486. * @returns the webGL uniform buffer
  28487. */
  28488. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28489. /**
  28490. * Update an existing uniform buffer
  28491. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28492. * @param uniformBuffer defines the target uniform buffer
  28493. * @param elements defines the content to update
  28494. * @param offset defines the offset in the uniform buffer where update should start
  28495. * @param count defines the size of the data to update
  28496. */
  28497. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28498. private _resetVertexBufferBinding;
  28499. /**
  28500. * Creates a vertex buffer
  28501. * @param data the data for the vertex buffer
  28502. * @returns the new WebGL static buffer
  28503. */
  28504. createVertexBuffer(data: DataArray): DataBuffer;
  28505. /**
  28506. * Creates a dynamic vertex buffer
  28507. * @param data the data for the dynamic vertex buffer
  28508. * @returns the new WebGL dynamic buffer
  28509. */
  28510. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28511. /**
  28512. * Update a dynamic index buffer
  28513. * @param indexBuffer defines the target index buffer
  28514. * @param indices defines the data to update
  28515. * @param offset defines the offset in the target index buffer where update should start
  28516. */
  28517. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28518. /**
  28519. * Updates a dynamic vertex buffer.
  28520. * @param vertexBuffer the vertex buffer to update
  28521. * @param data the data used to update the vertex buffer
  28522. * @param byteOffset the byte offset of the data
  28523. * @param byteLength the byte length of the data
  28524. */
  28525. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28526. private _resetIndexBufferBinding;
  28527. /**
  28528. * Creates a new index buffer
  28529. * @param indices defines the content of the index buffer
  28530. * @param updatable defines if the index buffer must be updatable
  28531. * @returns a new webGL buffer
  28532. */
  28533. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28534. /**
  28535. * Bind a webGL buffer to the webGL context
  28536. * @param buffer defines the buffer to bind
  28537. */
  28538. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28539. /**
  28540. * Bind an uniform buffer to the current webGL context
  28541. * @param buffer defines the buffer to bind
  28542. */
  28543. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28544. /**
  28545. * Bind a buffer to the current webGL context at a given location
  28546. * @param buffer defines the buffer to bind
  28547. * @param location defines the index where to bind the buffer
  28548. */
  28549. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28550. /**
  28551. * Bind a specific block at a given index in a specific shader program
  28552. * @param pipelineContext defines the pipeline context to use
  28553. * @param blockName defines the block name
  28554. * @param index defines the index where to bind the block
  28555. */
  28556. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28557. private bindIndexBuffer;
  28558. private bindBuffer;
  28559. /**
  28560. * update the bound buffer with the given data
  28561. * @param data defines the data to update
  28562. */
  28563. updateArrayBuffer(data: Float32Array): void;
  28564. private _vertexAttribPointer;
  28565. private _bindIndexBufferWithCache;
  28566. private _bindVertexBuffersAttributes;
  28567. /**
  28568. * Records a vertex array object
  28569. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28570. * @param vertexBuffers defines the list of vertex buffers to store
  28571. * @param indexBuffer defines the index buffer to store
  28572. * @param effect defines the effect to store
  28573. * @returns the new vertex array object
  28574. */
  28575. recordVertexArrayObject(vertexBuffers: {
  28576. [key: string]: VertexBuffer;
  28577. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28578. /**
  28579. * Bind a specific vertex array object
  28580. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28581. * @param vertexArrayObject defines the vertex array object to bind
  28582. * @param indexBuffer defines the index buffer to bind
  28583. */
  28584. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28585. /**
  28586. * Bind webGl buffers directly to the webGL context
  28587. * @param vertexBuffer defines the vertex buffer to bind
  28588. * @param indexBuffer defines the index buffer to bind
  28589. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28590. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28591. * @param effect defines the effect associated with the vertex buffer
  28592. */
  28593. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28594. private _unbindVertexArrayObject;
  28595. /**
  28596. * Bind a list of vertex buffers to the webGL context
  28597. * @param vertexBuffers defines the list of vertex buffers to bind
  28598. * @param indexBuffer defines the index buffer to bind
  28599. * @param effect defines the effect associated with the vertex buffers
  28600. */
  28601. bindBuffers(vertexBuffers: {
  28602. [key: string]: Nullable<VertexBuffer>;
  28603. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28604. /**
  28605. * Unbind all instance attributes
  28606. */
  28607. unbindInstanceAttributes(): void;
  28608. /**
  28609. * Release and free the memory of a vertex array object
  28610. * @param vao defines the vertex array object to delete
  28611. */
  28612. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28613. /** @hidden */
  28614. _releaseBuffer(buffer: DataBuffer): boolean;
  28615. /**
  28616. * Creates a webGL buffer to use with instanciation
  28617. * @param capacity defines the size of the buffer
  28618. * @returns the webGL buffer
  28619. */
  28620. createInstancesBuffer(capacity: number): DataBuffer;
  28621. /**
  28622. * Delete a webGL buffer used with instanciation
  28623. * @param buffer defines the webGL buffer to delete
  28624. */
  28625. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28626. /**
  28627. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28628. * @param instancesBuffer defines the webGL buffer to update and bind
  28629. * @param data defines the data to store in the buffer
  28630. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28631. */
  28632. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28633. /**
  28634. * Apply all cached states (depth, culling, stencil and alpha)
  28635. */
  28636. applyStates(): void;
  28637. /**
  28638. * Send a draw order
  28639. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28640. * @param indexStart defines the starting index
  28641. * @param indexCount defines the number of index to draw
  28642. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28643. */
  28644. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28645. /**
  28646. * Draw a list of points
  28647. * @param verticesStart defines the index of first vertex to draw
  28648. * @param verticesCount defines the count of vertices to draw
  28649. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28650. */
  28651. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28652. /**
  28653. * Draw a list of unindexed primitives
  28654. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28655. * @param verticesStart defines the index of first vertex to draw
  28656. * @param verticesCount defines the count of vertices to draw
  28657. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28658. */
  28659. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28660. /**
  28661. * Draw a list of indexed primitives
  28662. * @param fillMode defines the primitive to use
  28663. * @param indexStart defines the starting index
  28664. * @param indexCount defines the number of index to draw
  28665. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28666. */
  28667. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28668. /**
  28669. * Draw a list of unindexed primitives
  28670. * @param fillMode defines the primitive to use
  28671. * @param verticesStart defines the index of first vertex to draw
  28672. * @param verticesCount defines the count of vertices to draw
  28673. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28674. */
  28675. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28676. private _drawMode;
  28677. /** @hidden */
  28678. _releaseEffect(effect: Effect): void;
  28679. /** @hidden */
  28680. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28681. /**
  28682. * Create a new effect (used to store vertex/fragment shaders)
  28683. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28684. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28685. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28686. * @param samplers defines an array of string used to represent textures
  28687. * @param defines defines the string containing the defines to use to compile the shaders
  28688. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28689. * @param onCompiled defines a function to call when the effect creation is successful
  28690. * @param onError defines a function to call when the effect creation has failed
  28691. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28692. * @returns the new Effect
  28693. */
  28694. 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;
  28695. private _compileShader;
  28696. private _compileRawShader;
  28697. /**
  28698. * Directly creates a webGL program
  28699. * @param pipelineContext defines the pipeline context to attach to
  28700. * @param vertexCode defines the vertex shader code to use
  28701. * @param fragmentCode defines the fragment shader code to use
  28702. * @param context defines the webGL context to use (if not set, the current one will be used)
  28703. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28704. * @returns the new webGL program
  28705. */
  28706. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28707. /**
  28708. * Creates a webGL program
  28709. * @param pipelineContext defines the pipeline context to attach to
  28710. * @param vertexCode defines the vertex shader code to use
  28711. * @param fragmentCode defines the fragment shader code to use
  28712. * @param defines defines the string containing the defines to use to compile the shaders
  28713. * @param context defines the webGL context to use (if not set, the current one will be used)
  28714. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28715. * @returns the new webGL program
  28716. */
  28717. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28718. /**
  28719. * Creates a new pipeline context
  28720. * @returns the new pipeline
  28721. */
  28722. createPipelineContext(): WebGLPipelineContext;
  28723. private _createShaderProgram;
  28724. private _finalizePipelineContext;
  28725. /** @hidden */
  28726. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28727. /** @hidden */
  28728. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28729. /** @hidden */
  28730. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28731. /**
  28732. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28733. * @param pipelineContext defines the pipeline context to use
  28734. * @param uniformsNames defines the list of uniform names
  28735. * @returns an array of webGL uniform locations
  28736. */
  28737. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28738. /**
  28739. * Gets the lsit of active attributes for a given webGL program
  28740. * @param pipelineContext defines the pipeline context to use
  28741. * @param attributesNames defines the list of attribute names to get
  28742. * @returns an array of indices indicating the offset of each attribute
  28743. */
  28744. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28745. /**
  28746. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28747. * @param effect defines the effect to activate
  28748. */
  28749. enableEffect(effect: Nullable<Effect>): void;
  28750. /**
  28751. * Set the value of an uniform to an array of int32
  28752. * @param uniform defines the webGL uniform location where to store the value
  28753. * @param array defines the array of int32 to store
  28754. */
  28755. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28756. /**
  28757. * Set the value of an uniform to an array of int32 (stored as vec2)
  28758. * @param uniform defines the webGL uniform location where to store the value
  28759. * @param array defines the array of int32 to store
  28760. */
  28761. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28762. /**
  28763. * Set the value of an uniform to an array of int32 (stored as vec3)
  28764. * @param uniform defines the webGL uniform location where to store the value
  28765. * @param array defines the array of int32 to store
  28766. */
  28767. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28768. /**
  28769. * Set the value of an uniform to an array of int32 (stored as vec4)
  28770. * @param uniform defines the webGL uniform location where to store the value
  28771. * @param array defines the array of int32 to store
  28772. */
  28773. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28774. /**
  28775. * Set the value of an uniform to an array of float32
  28776. * @param uniform defines the webGL uniform location where to store the value
  28777. * @param array defines the array of float32 to store
  28778. */
  28779. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28780. /**
  28781. * Set the value of an uniform to an array of float32 (stored as vec2)
  28782. * @param uniform defines the webGL uniform location where to store the value
  28783. * @param array defines the array of float32 to store
  28784. */
  28785. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28786. /**
  28787. * Set the value of an uniform to an array of float32 (stored as vec3)
  28788. * @param uniform defines the webGL uniform location where to store the value
  28789. * @param array defines the array of float32 to store
  28790. */
  28791. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28792. /**
  28793. * Set the value of an uniform to an array of float32 (stored as vec4)
  28794. * @param uniform defines the webGL uniform location where to store the value
  28795. * @param array defines the array of float32 to store
  28796. */
  28797. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28798. /**
  28799. * Set the value of an uniform to an array of number
  28800. * @param uniform defines the webGL uniform location where to store the value
  28801. * @param array defines the array of number to store
  28802. */
  28803. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28804. /**
  28805. * Set the value of an uniform to an array of number (stored as vec2)
  28806. * @param uniform defines the webGL uniform location where to store the value
  28807. * @param array defines the array of number to store
  28808. */
  28809. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28810. /**
  28811. * Set the value of an uniform to an array of number (stored as vec3)
  28812. * @param uniform defines the webGL uniform location where to store the value
  28813. * @param array defines the array of number to store
  28814. */
  28815. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28816. /**
  28817. * Set the value of an uniform to an array of number (stored as vec4)
  28818. * @param uniform defines the webGL uniform location where to store the value
  28819. * @param array defines the array of number to store
  28820. */
  28821. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28822. /**
  28823. * Set the value of an uniform to an array of float32 (stored as matrices)
  28824. * @param uniform defines the webGL uniform location where to store the value
  28825. * @param matrices defines the array of float32 to store
  28826. */
  28827. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28828. /**
  28829. * Set the value of an uniform to a matrix
  28830. * @param uniform defines the webGL uniform location where to store the value
  28831. * @param matrix defines the matrix to store
  28832. */
  28833. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28834. /**
  28835. * Set the value of an uniform to a matrix (3x3)
  28836. * @param uniform defines the webGL uniform location where to store the value
  28837. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28838. */
  28839. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28840. /**
  28841. * Set the value of an uniform to a matrix (2x2)
  28842. * @param uniform defines the webGL uniform location where to store the value
  28843. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28844. */
  28845. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28846. /**
  28847. * Set the value of an uniform to a number (int)
  28848. * @param uniform defines the webGL uniform location where to store the value
  28849. * @param value defines the int number to store
  28850. */
  28851. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28852. /**
  28853. * Set the value of an uniform to a number (float)
  28854. * @param uniform defines the webGL uniform location where to store the value
  28855. * @param value defines the float number to store
  28856. */
  28857. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28858. /**
  28859. * Set the value of an uniform to a vec2
  28860. * @param uniform defines the webGL uniform location where to store the value
  28861. * @param x defines the 1st component of the value
  28862. * @param y defines the 2nd component of the value
  28863. */
  28864. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28865. /**
  28866. * Set the value of an uniform to a vec3
  28867. * @param uniform defines the webGL uniform location where to store the value
  28868. * @param x defines the 1st component of the value
  28869. * @param y defines the 2nd component of the value
  28870. * @param z defines the 3rd component of the value
  28871. */
  28872. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28873. /**
  28874. * Set the value of an uniform to a boolean
  28875. * @param uniform defines the webGL uniform location where to store the value
  28876. * @param bool defines the boolean to store
  28877. */
  28878. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28879. /**
  28880. * Set the value of an uniform to a vec4
  28881. * @param uniform defines the webGL uniform location where to store the value
  28882. * @param x defines the 1st component of the value
  28883. * @param y defines the 2nd component of the value
  28884. * @param z defines the 3rd component of the value
  28885. * @param w defines the 4th component of the value
  28886. */
  28887. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28888. /**
  28889. * Set the value of an uniform to a Color3
  28890. * @param uniform defines the webGL uniform location where to store the value
  28891. * @param color3 defines the color to store
  28892. */
  28893. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28894. /**
  28895. * Set the value of an uniform to a Color3 and an alpha value
  28896. * @param uniform defines the webGL uniform location where to store the value
  28897. * @param color3 defines the color to store
  28898. * @param alpha defines the alpha component to store
  28899. */
  28900. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28901. /**
  28902. * Sets a Color4 on a uniform variable
  28903. * @param uniform defines the uniform location
  28904. * @param color4 defines the value to be set
  28905. */
  28906. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28907. /**
  28908. * Set various states to the webGL context
  28909. * @param culling defines backface culling state
  28910. * @param zOffset defines the value to apply to zOffset (0 by default)
  28911. * @param force defines if states must be applied even if cache is up to date
  28912. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28913. */
  28914. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28915. /**
  28916. * Set the z offset to apply to current rendering
  28917. * @param value defines the offset to apply
  28918. */
  28919. setZOffset(value: number): void;
  28920. /**
  28921. * Gets the current value of the zOffset
  28922. * @returns the current zOffset state
  28923. */
  28924. getZOffset(): number;
  28925. /**
  28926. * Enable or disable depth buffering
  28927. * @param enable defines the state to set
  28928. */
  28929. setDepthBuffer(enable: boolean): void;
  28930. /**
  28931. * Gets a boolean indicating if depth writing is enabled
  28932. * @returns the current depth writing state
  28933. */
  28934. getDepthWrite(): boolean;
  28935. /**
  28936. * Enable or disable depth writing
  28937. * @param enable defines the state to set
  28938. */
  28939. setDepthWrite(enable: boolean): void;
  28940. /**
  28941. * Enable or disable color writing
  28942. * @param enable defines the state to set
  28943. */
  28944. setColorWrite(enable: boolean): void;
  28945. /**
  28946. * Gets a boolean indicating if color writing is enabled
  28947. * @returns the current color writing state
  28948. */
  28949. getColorWrite(): boolean;
  28950. /**
  28951. * Sets alpha constants used by some alpha blending modes
  28952. * @param r defines the red component
  28953. * @param g defines the green component
  28954. * @param b defines the blue component
  28955. * @param a defines the alpha component
  28956. */
  28957. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28958. /**
  28959. * Sets the current alpha mode
  28960. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28961. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28962. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28963. */
  28964. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28965. /**
  28966. * Gets the current alpha mode
  28967. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28968. * @returns the current alpha mode
  28969. */
  28970. getAlphaMode(): number;
  28971. /**
  28972. * Clears the list of texture accessible through engine.
  28973. * This can help preventing texture load conflict due to name collision.
  28974. */
  28975. clearInternalTexturesCache(): void;
  28976. /**
  28977. * Force the entire cache to be cleared
  28978. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28979. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28980. */
  28981. wipeCaches(bruteForce?: boolean): void;
  28982. /**
  28983. * Set the compressed texture format to use, based on the formats you have, and the formats
  28984. * supported by the hardware / browser.
  28985. *
  28986. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28987. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28988. * to API arguments needed to compressed textures. This puts the burden on the container
  28989. * generator to house the arcane code for determining these for current & future formats.
  28990. *
  28991. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28992. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28993. *
  28994. * Note: The result of this call is not taken into account when a texture is base64.
  28995. *
  28996. * @param formatsAvailable defines the list of those format families you have created
  28997. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28998. *
  28999. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29000. * @returns The extension selected.
  29001. */
  29002. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29003. /** @hidden */
  29004. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29005. min: number;
  29006. mag: number;
  29007. };
  29008. /** @hidden */
  29009. _createTexture(): WebGLTexture;
  29010. /**
  29011. * Usually called from Texture.ts.
  29012. * Passed information to create a WebGLTexture
  29013. * @param urlArg defines a value which contains one of the following:
  29014. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29015. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29016. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29017. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29018. * @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)
  29019. * @param scene needed for loading to the correct scene
  29020. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29021. * @param onLoad optional callback to be called upon successful completion
  29022. * @param onError optional callback to be called upon failure
  29023. * @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
  29024. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29025. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29026. * @param forcedExtension defines the extension to use to pick the right loader
  29027. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29028. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29029. */
  29030. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29031. /**
  29032. * @hidden
  29033. * Rescales a texture
  29034. * @param source input texutre
  29035. * @param destination destination texture
  29036. * @param scene scene to use to render the resize
  29037. * @param internalFormat format to use when resizing
  29038. * @param onComplete callback to be called when resize has completed
  29039. */
  29040. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29041. private _unpackFlipYCached;
  29042. /**
  29043. * In case you are sharing the context with other applications, it might
  29044. * be interested to not cache the unpack flip y state to ensure a consistent
  29045. * value would be set.
  29046. */
  29047. enableUnpackFlipYCached: boolean;
  29048. /** @hidden */
  29049. _unpackFlipY(value: boolean): void;
  29050. /** @hidden */
  29051. _getUnpackAlignement(): number;
  29052. /**
  29053. * Creates a dynamic texture
  29054. * @param width defines the width of the texture
  29055. * @param height defines the height of the texture
  29056. * @param generateMipMaps defines if the engine should generate the mip levels
  29057. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29058. * @returns the dynamic texture inside an InternalTexture
  29059. */
  29060. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29061. /**
  29062. * Update the sampling mode of a given texture
  29063. * @param samplingMode defines the required sampling mode
  29064. * @param texture defines the texture to update
  29065. */
  29066. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29067. /**
  29068. * Update the content of a dynamic texture
  29069. * @param texture defines the texture to update
  29070. * @param canvas defines the canvas containing the source
  29071. * @param invertY defines if data must be stored with Y axis inverted
  29072. * @param premulAlpha defines if alpha is stored as premultiplied
  29073. * @param format defines the format of the data
  29074. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29075. */
  29076. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29077. /**
  29078. * Update a video texture
  29079. * @param texture defines the texture to update
  29080. * @param video defines the video element to use
  29081. * @param invertY defines if data must be stored with Y axis inverted
  29082. */
  29083. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29084. /**
  29085. * Updates a depth texture Comparison Mode and Function.
  29086. * If the comparison Function is equal to 0, the mode will be set to none.
  29087. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29088. * @param texture The texture to set the comparison function for
  29089. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29090. */
  29091. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29092. /** @hidden */
  29093. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29094. width: number;
  29095. height: number;
  29096. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29097. /**
  29098. * Creates a depth stencil texture.
  29099. * This is only available in WebGL 2 or with the depth texture extension available.
  29100. * @param size The size of face edge in the texture.
  29101. * @param options The options defining the texture.
  29102. * @returns The texture
  29103. */
  29104. createDepthStencilTexture(size: number | {
  29105. width: number;
  29106. height: number;
  29107. }, options: DepthTextureCreationOptions): InternalTexture;
  29108. /**
  29109. * Creates a depth stencil texture.
  29110. * This is only available in WebGL 2 or with the depth texture extension available.
  29111. * @param size The size of face edge in the texture.
  29112. * @param options The options defining the texture.
  29113. * @returns The texture
  29114. */
  29115. private _createDepthStencilTexture;
  29116. /**
  29117. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29118. * @param renderTarget The render target to set the frame buffer for
  29119. */
  29120. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29121. /**
  29122. * Creates a new render target texture
  29123. * @param size defines the size of the texture
  29124. * @param options defines the options used to create the texture
  29125. * @returns a new render target texture stored in an InternalTexture
  29126. */
  29127. createRenderTargetTexture(size: number | {
  29128. width: number;
  29129. height: number;
  29130. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29131. /** @hidden */
  29132. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29133. /**
  29134. * Updates the sample count of a render target texture
  29135. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29136. * @param texture defines the texture to update
  29137. * @param samples defines the sample count to set
  29138. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29139. */
  29140. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29141. /** @hidden */
  29142. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29143. /** @hidden */
  29144. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29145. /** @hidden */
  29146. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29147. /** @hidden */
  29148. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29149. /**
  29150. * @hidden
  29151. */
  29152. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29153. private _prepareWebGLTextureContinuation;
  29154. private _prepareWebGLTexture;
  29155. /** @hidden */
  29156. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29157. /** @hidden */
  29158. _releaseFramebufferObjects(texture: InternalTexture): void;
  29159. /** @hidden */
  29160. _releaseTexture(texture: InternalTexture): void;
  29161. private setProgram;
  29162. private _boundUniforms;
  29163. /**
  29164. * Binds an effect to the webGL context
  29165. * @param effect defines the effect to bind
  29166. */
  29167. bindSamplers(effect: Effect): void;
  29168. private _activateCurrentTexture;
  29169. /** @hidden */
  29170. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29171. /** @hidden */
  29172. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29173. /**
  29174. * Sets a texture to the webGL context from a postprocess
  29175. * @param channel defines the channel to use
  29176. * @param postProcess defines the source postprocess
  29177. */
  29178. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29179. /**
  29180. * Binds the output of the passed in post process to the texture channel specified
  29181. * @param channel The channel the texture should be bound to
  29182. * @param postProcess The post process which's output should be bound
  29183. */
  29184. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29185. /**
  29186. * Unbind all textures from the webGL context
  29187. */
  29188. unbindAllTextures(): void;
  29189. /**
  29190. * Sets a texture to the according uniform.
  29191. * @param channel The texture channel
  29192. * @param uniform The uniform to set
  29193. * @param texture The texture to apply
  29194. */
  29195. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29196. /**
  29197. * Sets a depth stencil texture from a render target to the according uniform.
  29198. * @param channel The texture channel
  29199. * @param uniform The uniform to set
  29200. * @param texture The render target texture containing the depth stencil texture to apply
  29201. */
  29202. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29203. private _bindSamplerUniformToChannel;
  29204. private _getTextureWrapMode;
  29205. private _setTexture;
  29206. /**
  29207. * Sets an array of texture to the webGL context
  29208. * @param channel defines the channel where the texture array must be set
  29209. * @param uniform defines the associated uniform location
  29210. * @param textures defines the array of textures to bind
  29211. */
  29212. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29213. /** @hidden */
  29214. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29215. private _setTextureParameterFloat;
  29216. private _setTextureParameterInteger;
  29217. /**
  29218. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29219. * @param x defines the x coordinate of the rectangle where pixels must be read
  29220. * @param y defines the y coordinate of the rectangle where pixels must be read
  29221. * @param width defines the width of the rectangle where pixels must be read
  29222. * @param height defines the height of the rectangle where pixels must be read
  29223. * @returns a Uint8Array containing RGBA colors
  29224. */
  29225. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29226. /**
  29227. * Add an externaly attached data from its key.
  29228. * This method call will fail and return false, if such key already exists.
  29229. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29230. * @param key the unique key that identifies the data
  29231. * @param data the data object to associate to the key for this Engine instance
  29232. * @return true if no such key were already present and the data was added successfully, false otherwise
  29233. */
  29234. addExternalData<T>(key: string, data: T): boolean;
  29235. /**
  29236. * Get an externaly attached data from its key
  29237. * @param key the unique key that identifies the data
  29238. * @return the associated data, if present (can be null), or undefined if not present
  29239. */
  29240. getExternalData<T>(key: string): T;
  29241. /**
  29242. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29243. * @param key the unique key that identifies the data
  29244. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29245. * @return the associated data, can be null if the factory returned null.
  29246. */
  29247. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29248. /**
  29249. * Remove an externaly attached data from the Engine instance
  29250. * @param key the unique key that identifies the data
  29251. * @return true if the data was successfully removed, false if it doesn't exist
  29252. */
  29253. removeExternalData(key: string): boolean;
  29254. /**
  29255. * Unbind all vertex attributes from the webGL context
  29256. */
  29257. unbindAllAttributes(): void;
  29258. /**
  29259. * 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
  29260. */
  29261. releaseEffects(): void;
  29262. /**
  29263. * Dispose and release all associated resources
  29264. */
  29265. dispose(): void;
  29266. /**
  29267. * Display the loading screen
  29268. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29269. */
  29270. displayLoadingUI(): void;
  29271. /**
  29272. * Hide the loading screen
  29273. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29274. */
  29275. hideLoadingUI(): void;
  29276. /**
  29277. * Gets the current loading screen object
  29278. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29279. */
  29280. /**
  29281. * Sets the current loading screen object
  29282. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29283. */
  29284. loadingScreen: ILoadingScreen;
  29285. /**
  29286. * Sets the current loading screen text
  29287. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29288. */
  29289. loadingUIText: string;
  29290. /**
  29291. * Sets the current loading screen background color
  29292. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29293. */
  29294. loadingUIBackgroundColor: string;
  29295. /**
  29296. * Attach a new callback raised when context lost event is fired
  29297. * @param callback defines the callback to call
  29298. */
  29299. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29300. /**
  29301. * Attach a new callback raised when context restored event is fired
  29302. * @param callback defines the callback to call
  29303. */
  29304. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29305. /**
  29306. * Gets the source code of the vertex shader associated with a specific webGL program
  29307. * @param program defines the program to use
  29308. * @returns a string containing the source code of the vertex shader associated with the program
  29309. */
  29310. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29311. /**
  29312. * Gets the source code of the fragment shader associated with a specific webGL program
  29313. * @param program defines the program to use
  29314. * @returns a string containing the source code of the fragment shader associated with the program
  29315. */
  29316. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29317. /**
  29318. * Get the current error code of the webGL context
  29319. * @returns the error code
  29320. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29321. */
  29322. getError(): number;
  29323. /**
  29324. * Gets the current framerate
  29325. * @returns a number representing the framerate
  29326. */
  29327. getFps(): number;
  29328. /**
  29329. * Gets the time spent between current and previous frame
  29330. * @returns a number representing the delta time in ms
  29331. */
  29332. getDeltaTime(): number;
  29333. private _measureFps;
  29334. /** @hidden */
  29335. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29336. private _canRenderToFloatFramebuffer;
  29337. private _canRenderToHalfFloatFramebuffer;
  29338. private _canRenderToFramebuffer;
  29339. /** @hidden */
  29340. _getWebGLTextureType(type: number): number;
  29341. /** @hidden */
  29342. _getInternalFormat(format: number): number;
  29343. /** @hidden */
  29344. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29345. /** @hidden */
  29346. _getRGBAMultiSampleBufferFormat(type: number): number;
  29347. /** @hidden */
  29348. _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;
  29349. /** @hidden */
  29350. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29351. /**
  29352. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29353. * @returns true if the engine can be created
  29354. * @ignorenaming
  29355. */
  29356. static isSupported(): boolean;
  29357. }
  29358. }
  29359. declare module BABYLON {
  29360. /**
  29361. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29362. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29363. */
  29364. export class EffectFallbacks {
  29365. private _defines;
  29366. private _currentRank;
  29367. private _maxRank;
  29368. private _mesh;
  29369. /**
  29370. * Removes the fallback from the bound mesh.
  29371. */
  29372. unBindMesh(): void;
  29373. /**
  29374. * Adds a fallback on the specified property.
  29375. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29376. * @param define The name of the define in the shader
  29377. */
  29378. addFallback(rank: number, define: string): void;
  29379. /**
  29380. * Sets the mesh to use CPU skinning when needing to fallback.
  29381. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29382. * @param mesh The mesh to use the fallbacks.
  29383. */
  29384. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29385. /**
  29386. * Checks to see if more fallbacks are still availible.
  29387. */
  29388. readonly isMoreFallbacks: boolean;
  29389. /**
  29390. * Removes the defines that should be removed when falling back.
  29391. * @param currentDefines defines the current define statements for the shader.
  29392. * @param effect defines the current effect we try to compile
  29393. * @returns The resulting defines with defines of the current rank removed.
  29394. */
  29395. reduce(currentDefines: string, effect: Effect): string;
  29396. }
  29397. /**
  29398. * Options to be used when creating an effect.
  29399. */
  29400. export class EffectCreationOptions {
  29401. /**
  29402. * Atrributes that will be used in the shader.
  29403. */
  29404. attributes: string[];
  29405. /**
  29406. * Uniform varible names that will be set in the shader.
  29407. */
  29408. uniformsNames: string[];
  29409. /**
  29410. * Uniform buffer varible names that will be set in the shader.
  29411. */
  29412. uniformBuffersNames: string[];
  29413. /**
  29414. * Sampler texture variable names that will be set in the shader.
  29415. */
  29416. samplers: string[];
  29417. /**
  29418. * Define statements that will be set in the shader.
  29419. */
  29420. defines: any;
  29421. /**
  29422. * Possible fallbacks for this effect to improve performance when needed.
  29423. */
  29424. fallbacks: Nullable<EffectFallbacks>;
  29425. /**
  29426. * Callback that will be called when the shader is compiled.
  29427. */
  29428. onCompiled: Nullable<(effect: Effect) => void>;
  29429. /**
  29430. * Callback that will be called if an error occurs during shader compilation.
  29431. */
  29432. onError: Nullable<(effect: Effect, errors: string) => void>;
  29433. /**
  29434. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29435. */
  29436. indexParameters: any;
  29437. /**
  29438. * Max number of lights that can be used in the shader.
  29439. */
  29440. maxSimultaneousLights: number;
  29441. /**
  29442. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29443. */
  29444. transformFeedbackVaryings: Nullable<string[]>;
  29445. }
  29446. /**
  29447. * Effect containing vertex and fragment shader that can be executed on an object.
  29448. */
  29449. export class Effect implements IDisposable {
  29450. /**
  29451. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29452. */
  29453. static ShadersRepository: string;
  29454. /**
  29455. * Name of the effect.
  29456. */
  29457. name: any;
  29458. /**
  29459. * String container all the define statements that should be set on the shader.
  29460. */
  29461. defines: string;
  29462. /**
  29463. * Callback that will be called when the shader is compiled.
  29464. */
  29465. onCompiled: Nullable<(effect: Effect) => void>;
  29466. /**
  29467. * Callback that will be called if an error occurs during shader compilation.
  29468. */
  29469. onError: Nullable<(effect: Effect, errors: string) => void>;
  29470. /**
  29471. * Callback that will be called when effect is bound.
  29472. */
  29473. onBind: Nullable<(effect: Effect) => void>;
  29474. /**
  29475. * Unique ID of the effect.
  29476. */
  29477. uniqueId: number;
  29478. /**
  29479. * Observable that will be called when the shader is compiled.
  29480. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29481. */
  29482. onCompileObservable: Observable<Effect>;
  29483. /**
  29484. * Observable that will be called if an error occurs during shader compilation.
  29485. */
  29486. onErrorObservable: Observable<Effect>;
  29487. /** @hidden */
  29488. _onBindObservable: Nullable<Observable<Effect>>;
  29489. /**
  29490. * Observable that will be called when effect is bound.
  29491. */
  29492. readonly onBindObservable: Observable<Effect>;
  29493. /** @hidden */
  29494. _bonesComputationForcedToCPU: boolean;
  29495. private static _uniqueIdSeed;
  29496. private _engine;
  29497. private _uniformBuffersNames;
  29498. private _uniformsNames;
  29499. private _samplerList;
  29500. private _samplers;
  29501. private _isReady;
  29502. private _compilationError;
  29503. private _attributesNames;
  29504. private _attributes;
  29505. private _uniforms;
  29506. /**
  29507. * Key for the effect.
  29508. * @hidden
  29509. */
  29510. _key: string;
  29511. private _indexParameters;
  29512. private _fallbacks;
  29513. private _vertexSourceCode;
  29514. private _fragmentSourceCode;
  29515. private _vertexSourceCodeOverride;
  29516. private _fragmentSourceCodeOverride;
  29517. private _transformFeedbackVaryings;
  29518. /**
  29519. * Compiled shader to webGL program.
  29520. * @hidden
  29521. */
  29522. _pipelineContext: Nullable<IPipelineContext>;
  29523. private _valueCache;
  29524. private static _baseCache;
  29525. /**
  29526. * Instantiates an effect.
  29527. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29528. * @param baseName Name of the effect.
  29529. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29530. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29531. * @param samplers List of sampler variables that will be passed to the shader.
  29532. * @param engine Engine to be used to render the effect
  29533. * @param defines Define statements to be added to the shader.
  29534. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29535. * @param onCompiled Callback that will be called when the shader is compiled.
  29536. * @param onError Callback that will be called if an error occurs during shader compilation.
  29537. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29538. */
  29539. 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);
  29540. private _useFinalCode;
  29541. /**
  29542. * Unique key for this effect
  29543. */
  29544. readonly key: string;
  29545. /**
  29546. * If the effect has been compiled and prepared.
  29547. * @returns if the effect is compiled and prepared.
  29548. */
  29549. isReady(): boolean;
  29550. /**
  29551. * The engine the effect was initialized with.
  29552. * @returns the engine.
  29553. */
  29554. getEngine(): Engine;
  29555. /**
  29556. * The pipeline context for this effect
  29557. * @returns the associated pipeline context
  29558. */
  29559. getPipelineContext(): Nullable<IPipelineContext>;
  29560. /**
  29561. * The set of names of attribute variables for the shader.
  29562. * @returns An array of attribute names.
  29563. */
  29564. getAttributesNames(): string[];
  29565. /**
  29566. * Returns the attribute at the given index.
  29567. * @param index The index of the attribute.
  29568. * @returns The location of the attribute.
  29569. */
  29570. getAttributeLocation(index: number): number;
  29571. /**
  29572. * Returns the attribute based on the name of the variable.
  29573. * @param name of the attribute to look up.
  29574. * @returns the attribute location.
  29575. */
  29576. getAttributeLocationByName(name: string): number;
  29577. /**
  29578. * The number of attributes.
  29579. * @returns the numnber of attributes.
  29580. */
  29581. getAttributesCount(): number;
  29582. /**
  29583. * Gets the index of a uniform variable.
  29584. * @param uniformName of the uniform to look up.
  29585. * @returns the index.
  29586. */
  29587. getUniformIndex(uniformName: string): number;
  29588. /**
  29589. * Returns the attribute based on the name of the variable.
  29590. * @param uniformName of the uniform to look up.
  29591. * @returns the location of the uniform.
  29592. */
  29593. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29594. /**
  29595. * Returns an array of sampler variable names
  29596. * @returns The array of sampler variable neames.
  29597. */
  29598. getSamplers(): string[];
  29599. /**
  29600. * The error from the last compilation.
  29601. * @returns the error string.
  29602. */
  29603. getCompilationError(): string;
  29604. /**
  29605. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29606. * @param func The callback to be used.
  29607. */
  29608. executeWhenCompiled(func: (effect: Effect) => void): void;
  29609. private _checkIsReady;
  29610. /** @hidden */
  29611. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29612. /** @hidden */
  29613. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29614. /** @hidden */
  29615. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29616. /**
  29617. * Recompiles the webGL program
  29618. * @param vertexSourceCode The source code for the vertex shader.
  29619. * @param fragmentSourceCode The source code for the fragment shader.
  29620. * @param onCompiled Callback called when completed.
  29621. * @param onError Callback called on error.
  29622. * @hidden
  29623. */
  29624. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29625. /**
  29626. * Prepares the effect
  29627. * @hidden
  29628. */
  29629. _prepareEffect(): void;
  29630. /**
  29631. * Checks if the effect is supported. (Must be called after compilation)
  29632. */
  29633. readonly isSupported: boolean;
  29634. /**
  29635. * Binds a texture to the engine to be used as output of the shader.
  29636. * @param channel Name of the output variable.
  29637. * @param texture Texture to bind.
  29638. * @hidden
  29639. */
  29640. _bindTexture(channel: string, texture: InternalTexture): void;
  29641. /**
  29642. * Sets a texture on the engine to be used in the shader.
  29643. * @param channel Name of the sampler variable.
  29644. * @param texture Texture to set.
  29645. */
  29646. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29647. /**
  29648. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29649. * @param channel Name of the sampler variable.
  29650. * @param texture Texture to set.
  29651. */
  29652. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29653. /**
  29654. * Sets an array of textures on the engine to be used in the shader.
  29655. * @param channel Name of the variable.
  29656. * @param textures Textures to set.
  29657. */
  29658. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29659. /**
  29660. * 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)
  29661. * @param channel Name of the sampler variable.
  29662. * @param postProcess Post process to get the input texture from.
  29663. */
  29664. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29665. /**
  29666. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29667. * 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)
  29668. * @param channel Name of the sampler variable.
  29669. * @param postProcess Post process to get the output texture from.
  29670. */
  29671. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29672. /** @hidden */
  29673. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29674. /** @hidden */
  29675. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29676. /** @hidden */
  29677. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29678. /** @hidden */
  29679. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29680. /**
  29681. * Binds a buffer to a uniform.
  29682. * @param buffer Buffer to bind.
  29683. * @param name Name of the uniform variable to bind to.
  29684. */
  29685. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29686. /**
  29687. * Binds block to a uniform.
  29688. * @param blockName Name of the block to bind.
  29689. * @param index Index to bind.
  29690. */
  29691. bindUniformBlock(blockName: string, index: number): void;
  29692. /**
  29693. * Sets an interger value on a uniform variable.
  29694. * @param uniformName Name of the variable.
  29695. * @param value Value to be set.
  29696. * @returns this effect.
  29697. */
  29698. setInt(uniformName: string, value: number): Effect;
  29699. /**
  29700. * Sets an int array on a uniform variable.
  29701. * @param uniformName Name of the variable.
  29702. * @param array array to be set.
  29703. * @returns this effect.
  29704. */
  29705. setIntArray(uniformName: string, array: Int32Array): Effect;
  29706. /**
  29707. * 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)
  29708. * @param uniformName Name of the variable.
  29709. * @param array array to be set.
  29710. * @returns this effect.
  29711. */
  29712. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29713. /**
  29714. * 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)
  29715. * @param uniformName Name of the variable.
  29716. * @param array array to be set.
  29717. * @returns this effect.
  29718. */
  29719. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29720. /**
  29721. * 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)
  29722. * @param uniformName Name of the variable.
  29723. * @param array array to be set.
  29724. * @returns this effect.
  29725. */
  29726. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29727. /**
  29728. * Sets an float array on a uniform variable.
  29729. * @param uniformName Name of the variable.
  29730. * @param array array to be set.
  29731. * @returns this effect.
  29732. */
  29733. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29734. /**
  29735. * 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)
  29736. * @param uniformName Name of the variable.
  29737. * @param array array to be set.
  29738. * @returns this effect.
  29739. */
  29740. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29741. /**
  29742. * 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)
  29743. * @param uniformName Name of the variable.
  29744. * @param array array to be set.
  29745. * @returns this effect.
  29746. */
  29747. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29748. /**
  29749. * 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)
  29750. * @param uniformName Name of the variable.
  29751. * @param array array to be set.
  29752. * @returns this effect.
  29753. */
  29754. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29755. /**
  29756. * Sets an array on a uniform variable.
  29757. * @param uniformName Name of the variable.
  29758. * @param array array to be set.
  29759. * @returns this effect.
  29760. */
  29761. setArray(uniformName: string, array: number[]): Effect;
  29762. /**
  29763. * 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)
  29764. * @param uniformName Name of the variable.
  29765. * @param array array to be set.
  29766. * @returns this effect.
  29767. */
  29768. setArray2(uniformName: string, array: number[]): Effect;
  29769. /**
  29770. * 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)
  29771. * @param uniformName Name of the variable.
  29772. * @param array array to be set.
  29773. * @returns this effect.
  29774. */
  29775. setArray3(uniformName: string, array: number[]): Effect;
  29776. /**
  29777. * 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)
  29778. * @param uniformName Name of the variable.
  29779. * @param array array to be set.
  29780. * @returns this effect.
  29781. */
  29782. setArray4(uniformName: string, array: number[]): Effect;
  29783. /**
  29784. * Sets matrices on a uniform variable.
  29785. * @param uniformName Name of the variable.
  29786. * @param matrices matrices to be set.
  29787. * @returns this effect.
  29788. */
  29789. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29790. /**
  29791. * Sets matrix on a uniform variable.
  29792. * @param uniformName Name of the variable.
  29793. * @param matrix matrix to be set.
  29794. * @returns this effect.
  29795. */
  29796. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29797. /**
  29798. * 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)
  29799. * @param uniformName Name of the variable.
  29800. * @param matrix matrix to be set.
  29801. * @returns this effect.
  29802. */
  29803. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29804. /**
  29805. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29806. * @param uniformName Name of the variable.
  29807. * @param matrix matrix to be set.
  29808. * @returns this effect.
  29809. */
  29810. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29811. /**
  29812. * Sets a float on a uniform variable.
  29813. * @param uniformName Name of the variable.
  29814. * @param value value to be set.
  29815. * @returns this effect.
  29816. */
  29817. setFloat(uniformName: string, value: number): Effect;
  29818. /**
  29819. * Sets a boolean on a uniform variable.
  29820. * @param uniformName Name of the variable.
  29821. * @param bool value to be set.
  29822. * @returns this effect.
  29823. */
  29824. setBool(uniformName: string, bool: boolean): Effect;
  29825. /**
  29826. * Sets a Vector2 on a uniform variable.
  29827. * @param uniformName Name of the variable.
  29828. * @param vector2 vector2 to be set.
  29829. * @returns this effect.
  29830. */
  29831. setVector2(uniformName: string, vector2: Vector2): Effect;
  29832. /**
  29833. * Sets a float2 on a uniform variable.
  29834. * @param uniformName Name of the variable.
  29835. * @param x First float in float2.
  29836. * @param y Second float in float2.
  29837. * @returns this effect.
  29838. */
  29839. setFloat2(uniformName: string, x: number, y: number): Effect;
  29840. /**
  29841. * Sets a Vector3 on a uniform variable.
  29842. * @param uniformName Name of the variable.
  29843. * @param vector3 Value to be set.
  29844. * @returns this effect.
  29845. */
  29846. setVector3(uniformName: string, vector3: Vector3): Effect;
  29847. /**
  29848. * Sets a float3 on a uniform variable.
  29849. * @param uniformName Name of the variable.
  29850. * @param x First float in float3.
  29851. * @param y Second float in float3.
  29852. * @param z Third float in float3.
  29853. * @returns this effect.
  29854. */
  29855. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29856. /**
  29857. * Sets a Vector4 on a uniform variable.
  29858. * @param uniformName Name of the variable.
  29859. * @param vector4 Value to be set.
  29860. * @returns this effect.
  29861. */
  29862. setVector4(uniformName: string, vector4: Vector4): Effect;
  29863. /**
  29864. * Sets a float4 on a uniform variable.
  29865. * @param uniformName Name of the variable.
  29866. * @param x First float in float4.
  29867. * @param y Second float in float4.
  29868. * @param z Third float in float4.
  29869. * @param w Fourth float in float4.
  29870. * @returns this effect.
  29871. */
  29872. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29873. /**
  29874. * Sets a Color3 on a uniform variable.
  29875. * @param uniformName Name of the variable.
  29876. * @param color3 Value to be set.
  29877. * @returns this effect.
  29878. */
  29879. setColor3(uniformName: string, color3: Color3): Effect;
  29880. /**
  29881. * Sets a Color4 on a uniform variable.
  29882. * @param uniformName Name of the variable.
  29883. * @param color3 Value to be set.
  29884. * @param alpha Alpha value to be set.
  29885. * @returns this effect.
  29886. */
  29887. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29888. /**
  29889. * Sets a Color4 on a uniform variable
  29890. * @param uniformName defines the name of the variable
  29891. * @param color4 defines the value to be set
  29892. * @returns this effect.
  29893. */
  29894. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29895. /** Release all associated resources */
  29896. dispose(): void;
  29897. /**
  29898. * This function will add a new shader to the shader store
  29899. * @param name the name of the shader
  29900. * @param pixelShader optional pixel shader content
  29901. * @param vertexShader optional vertex shader content
  29902. */
  29903. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29904. /**
  29905. * Store of each shader (The can be looked up using effect.key)
  29906. */
  29907. static ShadersStore: {
  29908. [key: string]: string;
  29909. };
  29910. /**
  29911. * Store of each included file for a shader (The can be looked up using effect.key)
  29912. */
  29913. static IncludesShadersStore: {
  29914. [key: string]: string;
  29915. };
  29916. /**
  29917. * Resets the cache of effects.
  29918. */
  29919. static ResetCache(): void;
  29920. }
  29921. }
  29922. declare module BABYLON {
  29923. /**
  29924. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29925. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29926. * 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;
  29927. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29928. */
  29929. export class ColorCurves {
  29930. private _dirty;
  29931. private _tempColor;
  29932. private _globalCurve;
  29933. private _highlightsCurve;
  29934. private _midtonesCurve;
  29935. private _shadowsCurve;
  29936. private _positiveCurve;
  29937. private _negativeCurve;
  29938. private _globalHue;
  29939. private _globalDensity;
  29940. private _globalSaturation;
  29941. private _globalExposure;
  29942. /**
  29943. * Gets the global Hue value.
  29944. * 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).
  29945. */
  29946. /**
  29947. * Sets the global Hue value.
  29948. * 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).
  29949. */
  29950. globalHue: number;
  29951. /**
  29952. * Gets the global Density value.
  29953. * 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.
  29954. * Values less than zero provide a filter of opposite hue.
  29955. */
  29956. /**
  29957. * Sets the global Density value.
  29958. * 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.
  29959. * Values less than zero provide a filter of opposite hue.
  29960. */
  29961. globalDensity: number;
  29962. /**
  29963. * Gets the global Saturation value.
  29964. * 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.
  29965. */
  29966. /**
  29967. * Sets the global Saturation value.
  29968. * 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.
  29969. */
  29970. globalSaturation: number;
  29971. /**
  29972. * Gets the global Exposure value.
  29973. * 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.
  29974. */
  29975. /**
  29976. * Sets the global Exposure value.
  29977. * 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.
  29978. */
  29979. globalExposure: number;
  29980. private _highlightsHue;
  29981. private _highlightsDensity;
  29982. private _highlightsSaturation;
  29983. private _highlightsExposure;
  29984. /**
  29985. * Gets the highlights Hue value.
  29986. * 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).
  29987. */
  29988. /**
  29989. * Sets the highlights Hue value.
  29990. * 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).
  29991. */
  29992. highlightsHue: number;
  29993. /**
  29994. * Gets the highlights Density value.
  29995. * 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.
  29996. * Values less than zero provide a filter of opposite hue.
  29997. */
  29998. /**
  29999. * Sets the highlights Density value.
  30000. * 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.
  30001. * Values less than zero provide a filter of opposite hue.
  30002. */
  30003. highlightsDensity: number;
  30004. /**
  30005. * Gets the highlights Saturation value.
  30006. * 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.
  30007. */
  30008. /**
  30009. * Sets the highlights Saturation value.
  30010. * 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.
  30011. */
  30012. highlightsSaturation: number;
  30013. /**
  30014. * Gets the highlights Exposure value.
  30015. * 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.
  30016. */
  30017. /**
  30018. * Sets the highlights Exposure value.
  30019. * 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.
  30020. */
  30021. highlightsExposure: number;
  30022. private _midtonesHue;
  30023. private _midtonesDensity;
  30024. private _midtonesSaturation;
  30025. private _midtonesExposure;
  30026. /**
  30027. * Gets the midtones Hue value.
  30028. * 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).
  30029. */
  30030. /**
  30031. * Sets the midtones Hue value.
  30032. * 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).
  30033. */
  30034. midtonesHue: number;
  30035. /**
  30036. * Gets the midtones Density value.
  30037. * 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.
  30038. * Values less than zero provide a filter of opposite hue.
  30039. */
  30040. /**
  30041. * Sets the midtones Density value.
  30042. * 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.
  30043. * Values less than zero provide a filter of opposite hue.
  30044. */
  30045. midtonesDensity: number;
  30046. /**
  30047. * Gets the midtones Saturation value.
  30048. * 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.
  30049. */
  30050. /**
  30051. * Sets the midtones Saturation value.
  30052. * 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.
  30053. */
  30054. midtonesSaturation: number;
  30055. /**
  30056. * Gets the midtones Exposure value.
  30057. * 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.
  30058. */
  30059. /**
  30060. * Sets the midtones Exposure value.
  30061. * 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.
  30062. */
  30063. midtonesExposure: number;
  30064. private _shadowsHue;
  30065. private _shadowsDensity;
  30066. private _shadowsSaturation;
  30067. private _shadowsExposure;
  30068. /**
  30069. * Gets the shadows Hue value.
  30070. * 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).
  30071. */
  30072. /**
  30073. * Sets the shadows Hue value.
  30074. * 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).
  30075. */
  30076. shadowsHue: number;
  30077. /**
  30078. * Gets the shadows Density value.
  30079. * 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.
  30080. * Values less than zero provide a filter of opposite hue.
  30081. */
  30082. /**
  30083. * Sets the shadows Density value.
  30084. * 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.
  30085. * Values less than zero provide a filter of opposite hue.
  30086. */
  30087. shadowsDensity: number;
  30088. /**
  30089. * Gets the shadows Saturation value.
  30090. * 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.
  30091. */
  30092. /**
  30093. * Sets the shadows Saturation value.
  30094. * 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.
  30095. */
  30096. shadowsSaturation: number;
  30097. /**
  30098. * Gets the shadows Exposure value.
  30099. * 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.
  30100. */
  30101. /**
  30102. * Sets the shadows Exposure value.
  30103. * 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.
  30104. */
  30105. shadowsExposure: number;
  30106. /**
  30107. * Returns the class name
  30108. * @returns The class name
  30109. */
  30110. getClassName(): string;
  30111. /**
  30112. * Binds the color curves to the shader.
  30113. * @param colorCurves The color curve to bind
  30114. * @param effect The effect to bind to
  30115. * @param positiveUniform The positive uniform shader parameter
  30116. * @param neutralUniform The neutral uniform shader parameter
  30117. * @param negativeUniform The negative uniform shader parameter
  30118. */
  30119. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30120. /**
  30121. * Prepare the list of uniforms associated with the ColorCurves effects.
  30122. * @param uniformsList The list of uniforms used in the effect
  30123. */
  30124. static PrepareUniforms(uniformsList: string[]): void;
  30125. /**
  30126. * Returns color grading data based on a hue, density, saturation and exposure value.
  30127. * @param filterHue The hue of the color filter.
  30128. * @param filterDensity The density of the color filter.
  30129. * @param saturation The saturation.
  30130. * @param exposure The exposure.
  30131. * @param result The result data container.
  30132. */
  30133. private getColorGradingDataToRef;
  30134. /**
  30135. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30136. * @param value The input slider value in range [-100,100].
  30137. * @returns Adjusted value.
  30138. */
  30139. private static applyColorGradingSliderNonlinear;
  30140. /**
  30141. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30142. * @param hue The hue (H) input.
  30143. * @param saturation The saturation (S) input.
  30144. * @param brightness The brightness (B) input.
  30145. * @result An RGBA color represented as Vector4.
  30146. */
  30147. private static fromHSBToRef;
  30148. /**
  30149. * Returns a value clamped between min and max
  30150. * @param value The value to clamp
  30151. * @param min The minimum of value
  30152. * @param max The maximum of value
  30153. * @returns The clamped value.
  30154. */
  30155. private static clamp;
  30156. /**
  30157. * Clones the current color curve instance.
  30158. * @return The cloned curves
  30159. */
  30160. clone(): ColorCurves;
  30161. /**
  30162. * Serializes the current color curve instance to a json representation.
  30163. * @return a JSON representation
  30164. */
  30165. serialize(): any;
  30166. /**
  30167. * Parses the color curve from a json representation.
  30168. * @param source the JSON source to parse
  30169. * @return The parsed curves
  30170. */
  30171. static Parse(source: any): ColorCurves;
  30172. }
  30173. }
  30174. declare module BABYLON {
  30175. /**
  30176. * Interface to follow in your material defines to integrate easily the
  30177. * Image proccessing functions.
  30178. * @hidden
  30179. */
  30180. export interface IImageProcessingConfigurationDefines {
  30181. IMAGEPROCESSING: boolean;
  30182. VIGNETTE: boolean;
  30183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30184. VIGNETTEBLENDMODEOPAQUE: boolean;
  30185. TONEMAPPING: boolean;
  30186. TONEMAPPING_ACES: boolean;
  30187. CONTRAST: boolean;
  30188. EXPOSURE: boolean;
  30189. COLORCURVES: boolean;
  30190. COLORGRADING: boolean;
  30191. COLORGRADING3D: boolean;
  30192. SAMPLER3DGREENDEPTH: boolean;
  30193. SAMPLER3DBGRMAP: boolean;
  30194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30195. }
  30196. /**
  30197. * @hidden
  30198. */
  30199. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30200. IMAGEPROCESSING: boolean;
  30201. VIGNETTE: boolean;
  30202. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30203. VIGNETTEBLENDMODEOPAQUE: boolean;
  30204. TONEMAPPING: boolean;
  30205. TONEMAPPING_ACES: boolean;
  30206. CONTRAST: boolean;
  30207. COLORCURVES: boolean;
  30208. COLORGRADING: boolean;
  30209. COLORGRADING3D: boolean;
  30210. SAMPLER3DGREENDEPTH: boolean;
  30211. SAMPLER3DBGRMAP: boolean;
  30212. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30213. EXPOSURE: boolean;
  30214. constructor();
  30215. }
  30216. /**
  30217. * This groups together the common properties used for image processing either in direct forward pass
  30218. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30219. * or not.
  30220. */
  30221. export class ImageProcessingConfiguration {
  30222. /**
  30223. * Default tone mapping applied in BabylonJS.
  30224. */
  30225. static readonly TONEMAPPING_STANDARD: number;
  30226. /**
  30227. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30228. * to other engines rendering to increase portability.
  30229. */
  30230. static readonly TONEMAPPING_ACES: number;
  30231. /**
  30232. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30233. */
  30234. colorCurves: Nullable<ColorCurves>;
  30235. private _colorCurvesEnabled;
  30236. /**
  30237. * Gets wether the color curves effect is enabled.
  30238. */
  30239. /**
  30240. * Sets wether the color curves effect is enabled.
  30241. */
  30242. colorCurvesEnabled: boolean;
  30243. private _colorGradingTexture;
  30244. /**
  30245. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30246. */
  30247. /**
  30248. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30249. */
  30250. colorGradingTexture: Nullable<BaseTexture>;
  30251. private _colorGradingEnabled;
  30252. /**
  30253. * Gets wether the color grading effect is enabled.
  30254. */
  30255. /**
  30256. * Sets wether the color grading effect is enabled.
  30257. */
  30258. colorGradingEnabled: boolean;
  30259. private _colorGradingWithGreenDepth;
  30260. /**
  30261. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30262. */
  30263. /**
  30264. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30265. */
  30266. colorGradingWithGreenDepth: boolean;
  30267. private _colorGradingBGR;
  30268. /**
  30269. * Gets wether the color grading texture contains BGR values.
  30270. */
  30271. /**
  30272. * Sets wether the color grading texture contains BGR values.
  30273. */
  30274. colorGradingBGR: boolean;
  30275. /** @hidden */
  30276. _exposure: number;
  30277. /**
  30278. * Gets the Exposure used in the effect.
  30279. */
  30280. /**
  30281. * Sets the Exposure used in the effect.
  30282. */
  30283. exposure: number;
  30284. private _toneMappingEnabled;
  30285. /**
  30286. * Gets wether the tone mapping effect is enabled.
  30287. */
  30288. /**
  30289. * Sets wether the tone mapping effect is enabled.
  30290. */
  30291. toneMappingEnabled: boolean;
  30292. private _toneMappingType;
  30293. /**
  30294. * Gets the type of tone mapping effect.
  30295. */
  30296. /**
  30297. * Sets the type of tone mapping effect used in BabylonJS.
  30298. */
  30299. toneMappingType: number;
  30300. protected _contrast: number;
  30301. /**
  30302. * Gets the contrast used in the effect.
  30303. */
  30304. /**
  30305. * Sets the contrast used in the effect.
  30306. */
  30307. contrast: number;
  30308. /**
  30309. * Vignette stretch size.
  30310. */
  30311. vignetteStretch: number;
  30312. /**
  30313. * Vignette centre X Offset.
  30314. */
  30315. vignetteCentreX: number;
  30316. /**
  30317. * Vignette centre Y Offset.
  30318. */
  30319. vignetteCentreY: number;
  30320. /**
  30321. * Vignette weight or intensity of the vignette effect.
  30322. */
  30323. vignetteWeight: number;
  30324. /**
  30325. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30326. * if vignetteEnabled is set to true.
  30327. */
  30328. vignetteColor: Color4;
  30329. /**
  30330. * Camera field of view used by the Vignette effect.
  30331. */
  30332. vignetteCameraFov: number;
  30333. private _vignetteBlendMode;
  30334. /**
  30335. * Gets the vignette blend mode allowing different kind of effect.
  30336. */
  30337. /**
  30338. * Sets the vignette blend mode allowing different kind of effect.
  30339. */
  30340. vignetteBlendMode: number;
  30341. private _vignetteEnabled;
  30342. /**
  30343. * Gets wether the vignette effect is enabled.
  30344. */
  30345. /**
  30346. * Sets wether the vignette effect is enabled.
  30347. */
  30348. vignetteEnabled: boolean;
  30349. private _applyByPostProcess;
  30350. /**
  30351. * Gets wether the image processing is applied through a post process or not.
  30352. */
  30353. /**
  30354. * Sets wether the image processing is applied through a post process or not.
  30355. */
  30356. applyByPostProcess: boolean;
  30357. private _isEnabled;
  30358. /**
  30359. * Gets wether the image processing is enabled or not.
  30360. */
  30361. /**
  30362. * Sets wether the image processing is enabled or not.
  30363. */
  30364. isEnabled: boolean;
  30365. /**
  30366. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30367. */
  30368. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30369. /**
  30370. * Method called each time the image processing information changes requires to recompile the effect.
  30371. */
  30372. protected _updateParameters(): void;
  30373. /**
  30374. * Gets the current class name.
  30375. * @return "ImageProcessingConfiguration"
  30376. */
  30377. getClassName(): string;
  30378. /**
  30379. * Prepare the list of uniforms associated with the Image Processing effects.
  30380. * @param uniforms The list of uniforms used in the effect
  30381. * @param defines the list of defines currently in use
  30382. */
  30383. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30384. /**
  30385. * Prepare the list of samplers associated with the Image Processing effects.
  30386. * @param samplersList The list of uniforms used in the effect
  30387. * @param defines the list of defines currently in use
  30388. */
  30389. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30390. /**
  30391. * Prepare the list of defines associated to the shader.
  30392. * @param defines the list of defines to complete
  30393. * @param forPostProcess Define if we are currently in post process mode or not
  30394. */
  30395. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30396. /**
  30397. * Returns true if all the image processing information are ready.
  30398. * @returns True if ready, otherwise, false
  30399. */
  30400. isReady(): boolean;
  30401. /**
  30402. * Binds the image processing to the shader.
  30403. * @param effect The effect to bind to
  30404. * @param aspectRatio Define the current aspect ratio of the effect
  30405. */
  30406. bind(effect: Effect, aspectRatio?: number): void;
  30407. /**
  30408. * Clones the current image processing instance.
  30409. * @return The cloned image processing
  30410. */
  30411. clone(): ImageProcessingConfiguration;
  30412. /**
  30413. * Serializes the current image processing instance to a json representation.
  30414. * @return a JSON representation
  30415. */
  30416. serialize(): any;
  30417. /**
  30418. * Parses the image processing from a json representation.
  30419. * @param source the JSON source to parse
  30420. * @return The parsed image processing
  30421. */
  30422. static Parse(source: any): ImageProcessingConfiguration;
  30423. private static _VIGNETTEMODE_MULTIPLY;
  30424. private static _VIGNETTEMODE_OPAQUE;
  30425. /**
  30426. * Used to apply the vignette as a mix with the pixel color.
  30427. */
  30428. static readonly VIGNETTEMODE_MULTIPLY: number;
  30429. /**
  30430. * Used to apply the vignette as a replacement of the pixel color.
  30431. */
  30432. static readonly VIGNETTEMODE_OPAQUE: number;
  30433. }
  30434. }
  30435. declare module BABYLON {
  30436. /**
  30437. * This represents all the required information to add a fresnel effect on a material:
  30438. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30439. */
  30440. export class FresnelParameters {
  30441. private _isEnabled;
  30442. /**
  30443. * Define if the fresnel effect is enable or not.
  30444. */
  30445. isEnabled: boolean;
  30446. /**
  30447. * Define the color used on edges (grazing angle)
  30448. */
  30449. leftColor: Color3;
  30450. /**
  30451. * Define the color used on center
  30452. */
  30453. rightColor: Color3;
  30454. /**
  30455. * Define bias applied to computed fresnel term
  30456. */
  30457. bias: number;
  30458. /**
  30459. * Defined the power exponent applied to fresnel term
  30460. */
  30461. power: number;
  30462. /**
  30463. * Clones the current fresnel and its valuues
  30464. * @returns a clone fresnel configuration
  30465. */
  30466. clone(): FresnelParameters;
  30467. /**
  30468. * Serializes the current fresnel parameters to a JSON representation.
  30469. * @return the JSON serialization
  30470. */
  30471. serialize(): any;
  30472. /**
  30473. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30474. * @param parsedFresnelParameters Define the JSON representation
  30475. * @returns the parsed parameters
  30476. */
  30477. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30478. }
  30479. }
  30480. declare module BABYLON {
  30481. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30482. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30483. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30484. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30485. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30486. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30487. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30488. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30489. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30490. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30491. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30492. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30493. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30494. /**
  30495. * Decorator used to define property that can be serialized as reference to a camera
  30496. * @param sourceName defines the name of the property to decorate
  30497. */
  30498. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30499. /**
  30500. * Class used to help serialization objects
  30501. */
  30502. export class SerializationHelper {
  30503. /** @hidden */
  30504. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30505. /** @hidden */
  30506. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30507. /** @hidden */
  30508. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30509. /** @hidden */
  30510. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30511. /**
  30512. * Appends the serialized animations from the source animations
  30513. * @param source Source containing the animations
  30514. * @param destination Target to store the animations
  30515. */
  30516. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30517. /**
  30518. * Static function used to serialized a specific entity
  30519. * @param entity defines the entity to serialize
  30520. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30521. * @returns a JSON compatible object representing the serialization of the entity
  30522. */
  30523. static Serialize<T>(entity: T, serializationObject?: any): any;
  30524. /**
  30525. * Creates a new entity from a serialization data object
  30526. * @param creationFunction defines a function used to instanciated the new entity
  30527. * @param source defines the source serialization data
  30528. * @param scene defines the hosting scene
  30529. * @param rootUrl defines the root url for resources
  30530. * @returns a new entity
  30531. */
  30532. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30533. /**
  30534. * Clones an object
  30535. * @param creationFunction defines the function used to instanciate the new object
  30536. * @param source defines the source object
  30537. * @returns the cloned object
  30538. */
  30539. static Clone<T>(creationFunction: () => T, source: T): T;
  30540. /**
  30541. * Instanciates a new object based on a source one (some data will be shared between both object)
  30542. * @param creationFunction defines the function used to instanciate the new object
  30543. * @param source defines the source object
  30544. * @returns the new object
  30545. */
  30546. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30547. }
  30548. }
  30549. declare module BABYLON {
  30550. /**
  30551. * This is the base class of all the camera used in the application.
  30552. * @see http://doc.babylonjs.com/features/cameras
  30553. */
  30554. export class Camera extends Node {
  30555. /** @hidden */
  30556. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30557. /**
  30558. * This is the default projection mode used by the cameras.
  30559. * It helps recreating a feeling of perspective and better appreciate depth.
  30560. * This is the best way to simulate real life cameras.
  30561. */
  30562. static readonly PERSPECTIVE_CAMERA: number;
  30563. /**
  30564. * This helps creating camera with an orthographic mode.
  30565. * 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.
  30566. */
  30567. static readonly ORTHOGRAPHIC_CAMERA: number;
  30568. /**
  30569. * This is the default FOV mode for perspective cameras.
  30570. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30571. */
  30572. static readonly FOVMODE_VERTICAL_FIXED: number;
  30573. /**
  30574. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30575. */
  30576. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30577. /**
  30578. * This specifies ther is no need for a camera rig.
  30579. * Basically only one eye is rendered corresponding to the camera.
  30580. */
  30581. static readonly RIG_MODE_NONE: number;
  30582. /**
  30583. * Simulates a camera Rig with one blue eye and one red eye.
  30584. * This can be use with 3d blue and red glasses.
  30585. */
  30586. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30587. /**
  30588. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30589. */
  30590. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30591. /**
  30592. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30593. */
  30594. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30595. /**
  30596. * Defines that both eyes of the camera will be rendered over under each other.
  30597. */
  30598. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30599. /**
  30600. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30601. */
  30602. static readonly RIG_MODE_VR: number;
  30603. /**
  30604. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30605. */
  30606. static readonly RIG_MODE_WEBVR: number;
  30607. /**
  30608. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30609. */
  30610. static readonly RIG_MODE_CUSTOM: number;
  30611. /**
  30612. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30613. */
  30614. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30615. /**
  30616. * Define the input manager associated with the camera.
  30617. */
  30618. inputs: CameraInputsManager<Camera>;
  30619. /** @hidden */
  30620. _position: Vector3;
  30621. /**
  30622. * Define the current local position of the camera in the scene
  30623. */
  30624. position: Vector3;
  30625. /**
  30626. * The vector the camera should consider as up.
  30627. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30628. */
  30629. upVector: Vector3;
  30630. /**
  30631. * Define the current limit on the left side for an orthographic camera
  30632. * In scene unit
  30633. */
  30634. orthoLeft: Nullable<number>;
  30635. /**
  30636. * Define the current limit on the right side for an orthographic camera
  30637. * In scene unit
  30638. */
  30639. orthoRight: Nullable<number>;
  30640. /**
  30641. * Define the current limit on the bottom side for an orthographic camera
  30642. * In scene unit
  30643. */
  30644. orthoBottom: Nullable<number>;
  30645. /**
  30646. * Define the current limit on the top side for an orthographic camera
  30647. * In scene unit
  30648. */
  30649. orthoTop: Nullable<number>;
  30650. /**
  30651. * Field Of View is set in Radians. (default is 0.8)
  30652. */
  30653. fov: number;
  30654. /**
  30655. * Define the minimum distance the camera can see from.
  30656. * This is important to note that the depth buffer are not infinite and the closer it starts
  30657. * the more your scene might encounter depth fighting issue.
  30658. */
  30659. minZ: number;
  30660. /**
  30661. * Define the maximum distance the camera can see to.
  30662. * This is important to note that the depth buffer are not infinite and the further it end
  30663. * the more your scene might encounter depth fighting issue.
  30664. */
  30665. maxZ: number;
  30666. /**
  30667. * Define the default inertia of the camera.
  30668. * This helps giving a smooth feeling to the camera movement.
  30669. */
  30670. inertia: number;
  30671. /**
  30672. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30673. */
  30674. mode: number;
  30675. /**
  30676. * Define wether the camera is intermediate.
  30677. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30678. */
  30679. isIntermediate: boolean;
  30680. /**
  30681. * Define the viewport of the camera.
  30682. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30683. */
  30684. viewport: Viewport;
  30685. /**
  30686. * Restricts the camera to viewing objects with the same layerMask.
  30687. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30688. */
  30689. layerMask: number;
  30690. /**
  30691. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30692. */
  30693. fovMode: number;
  30694. /**
  30695. * Rig mode of the camera.
  30696. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30697. * This is normally controlled byt the camera themselves as internal use.
  30698. */
  30699. cameraRigMode: number;
  30700. /**
  30701. * Defines the distance between both "eyes" in case of a RIG
  30702. */
  30703. interaxialDistance: number;
  30704. /**
  30705. * Defines if stereoscopic rendering is done side by side or over under.
  30706. */
  30707. isStereoscopicSideBySide: boolean;
  30708. /**
  30709. * 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
  30710. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30711. * else in the scene.
  30712. */
  30713. customRenderTargets: RenderTargetTexture[];
  30714. /**
  30715. * When set, the camera will render to this render target instead of the default canvas
  30716. */
  30717. outputRenderTarget: Nullable<RenderTargetTexture>;
  30718. /**
  30719. * Observable triggered when the camera view matrix has changed.
  30720. */
  30721. onViewMatrixChangedObservable: Observable<Camera>;
  30722. /**
  30723. * Observable triggered when the camera Projection matrix has changed.
  30724. */
  30725. onProjectionMatrixChangedObservable: Observable<Camera>;
  30726. /**
  30727. * Observable triggered when the inputs have been processed.
  30728. */
  30729. onAfterCheckInputsObservable: Observable<Camera>;
  30730. /**
  30731. * Observable triggered when reset has been called and applied to the camera.
  30732. */
  30733. onRestoreStateObservable: Observable<Camera>;
  30734. /** @hidden */
  30735. _cameraRigParams: any;
  30736. /** @hidden */
  30737. _rigCameras: Camera[];
  30738. /** @hidden */
  30739. _rigPostProcess: Nullable<PostProcess>;
  30740. protected _webvrViewMatrix: Matrix;
  30741. /** @hidden */
  30742. _skipRendering: boolean;
  30743. /** @hidden */
  30744. _projectionMatrix: Matrix;
  30745. /** @hidden */
  30746. _postProcesses: Nullable<PostProcess>[];
  30747. /** @hidden */
  30748. _activeMeshes: SmartArray<AbstractMesh>;
  30749. protected _globalPosition: Vector3;
  30750. /** @hidden */
  30751. _computedViewMatrix: Matrix;
  30752. private _doNotComputeProjectionMatrix;
  30753. private _transformMatrix;
  30754. private _frustumPlanes;
  30755. private _refreshFrustumPlanes;
  30756. private _storedFov;
  30757. private _stateStored;
  30758. /**
  30759. * Instantiates a new camera object.
  30760. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30761. * @see http://doc.babylonjs.com/features/cameras
  30762. * @param name Defines the name of the camera in the scene
  30763. * @param position Defines the position of the camera
  30764. * @param scene Defines the scene the camera belongs too
  30765. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30766. */
  30767. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30768. /**
  30769. * Store current camera state (fov, position, etc..)
  30770. * @returns the camera
  30771. */
  30772. storeState(): Camera;
  30773. /**
  30774. * Restores the camera state values if it has been stored. You must call storeState() first
  30775. */
  30776. protected _restoreStateValues(): boolean;
  30777. /**
  30778. * Restored camera state. You must call storeState() first.
  30779. * @returns true if restored and false otherwise
  30780. */
  30781. restoreState(): boolean;
  30782. /**
  30783. * Gets the class name of the camera.
  30784. * @returns the class name
  30785. */
  30786. getClassName(): string;
  30787. /** @hidden */
  30788. readonly _isCamera: boolean;
  30789. /**
  30790. * Gets a string representation of the camera useful for debug purpose.
  30791. * @param fullDetails Defines that a more verboe level of logging is required
  30792. * @returns the string representation
  30793. */
  30794. toString(fullDetails?: boolean): string;
  30795. /**
  30796. * Gets the current world space position of the camera.
  30797. */
  30798. readonly globalPosition: Vector3;
  30799. /**
  30800. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30801. * @returns the active meshe list
  30802. */
  30803. getActiveMeshes(): SmartArray<AbstractMesh>;
  30804. /**
  30805. * Check wether a mesh is part of the current active mesh list of the camera
  30806. * @param mesh Defines the mesh to check
  30807. * @returns true if active, false otherwise
  30808. */
  30809. isActiveMesh(mesh: Mesh): boolean;
  30810. /**
  30811. * Is this camera ready to be used/rendered
  30812. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30813. * @return true if the camera is ready
  30814. */
  30815. isReady(completeCheck?: boolean): boolean;
  30816. /** @hidden */
  30817. _initCache(): void;
  30818. /** @hidden */
  30819. _updateCache(ignoreParentClass?: boolean): void;
  30820. /** @hidden */
  30821. _isSynchronized(): boolean;
  30822. /** @hidden */
  30823. _isSynchronizedViewMatrix(): boolean;
  30824. /** @hidden */
  30825. _isSynchronizedProjectionMatrix(): boolean;
  30826. /**
  30827. * Attach the input controls to a specific dom element to get the input from.
  30828. * @param element Defines the element the controls should be listened from
  30829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30830. */
  30831. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30832. /**
  30833. * Detach the current controls from the specified dom element.
  30834. * @param element Defines the element to stop listening the inputs from
  30835. */
  30836. detachControl(element: HTMLElement): void;
  30837. /**
  30838. * Update the camera state according to the different inputs gathered during the frame.
  30839. */
  30840. update(): void;
  30841. /** @hidden */
  30842. _checkInputs(): void;
  30843. /** @hidden */
  30844. readonly rigCameras: Camera[];
  30845. /**
  30846. * Gets the post process used by the rig cameras
  30847. */
  30848. readonly rigPostProcess: Nullable<PostProcess>;
  30849. /**
  30850. * Internal, gets the first post proces.
  30851. * @returns the first post process to be run on this camera.
  30852. */
  30853. _getFirstPostProcess(): Nullable<PostProcess>;
  30854. private _cascadePostProcessesToRigCams;
  30855. /**
  30856. * Attach a post process to the camera.
  30857. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30858. * @param postProcess The post process to attach to the camera
  30859. * @param insertAt The position of the post process in case several of them are in use in the scene
  30860. * @returns the position the post process has been inserted at
  30861. */
  30862. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30863. /**
  30864. * Detach a post process to the camera.
  30865. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30866. * @param postProcess The post process to detach from the camera
  30867. */
  30868. detachPostProcess(postProcess: PostProcess): void;
  30869. /**
  30870. * Gets the current world matrix of the camera
  30871. */
  30872. getWorldMatrix(): Matrix;
  30873. /** @hidden */
  30874. _getViewMatrix(): Matrix;
  30875. /**
  30876. * Gets the current view matrix of the camera.
  30877. * @param force forces the camera to recompute the matrix without looking at the cached state
  30878. * @returns the view matrix
  30879. */
  30880. getViewMatrix(force?: boolean): Matrix;
  30881. /**
  30882. * Freeze the projection matrix.
  30883. * It will prevent the cache check of the camera projection compute and can speed up perf
  30884. * if no parameter of the camera are meant to change
  30885. * @param projection Defines manually a projection if necessary
  30886. */
  30887. freezeProjectionMatrix(projection?: Matrix): void;
  30888. /**
  30889. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30890. */
  30891. unfreezeProjectionMatrix(): void;
  30892. /**
  30893. * Gets the current projection matrix of the camera.
  30894. * @param force forces the camera to recompute the matrix without looking at the cached state
  30895. * @returns the projection matrix
  30896. */
  30897. getProjectionMatrix(force?: boolean): Matrix;
  30898. /**
  30899. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30900. * @returns a Matrix
  30901. */
  30902. getTransformationMatrix(): Matrix;
  30903. private _updateFrustumPlanes;
  30904. /**
  30905. * Checks if a cullable object (mesh...) is in the camera frustum
  30906. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30907. * @param target The object to check
  30908. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30909. * @returns true if the object is in frustum otherwise false
  30910. */
  30911. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30912. /**
  30913. * Checks if a cullable object (mesh...) is in the camera frustum
  30914. * Unlike isInFrustum this cheks the full bounding box
  30915. * @param target The object to check
  30916. * @returns true if the object is in frustum otherwise false
  30917. */
  30918. isCompletelyInFrustum(target: ICullable): boolean;
  30919. /**
  30920. * Gets a ray in the forward direction from the camera.
  30921. * @param length Defines the length of the ray to create
  30922. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30923. * @param origin Defines the start point of the ray which defaults to the camera position
  30924. * @returns the forward ray
  30925. */
  30926. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30927. /**
  30928. * Releases resources associated with this node.
  30929. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30930. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30931. */
  30932. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30933. /** @hidden */
  30934. _isLeftCamera: boolean;
  30935. /**
  30936. * Gets the left camera of a rig setup in case of Rigged Camera
  30937. */
  30938. readonly isLeftCamera: boolean;
  30939. /** @hidden */
  30940. _isRightCamera: boolean;
  30941. /**
  30942. * Gets the right camera of a rig setup in case of Rigged Camera
  30943. */
  30944. readonly isRightCamera: boolean;
  30945. /**
  30946. * Gets the left camera of a rig setup in case of Rigged Camera
  30947. */
  30948. readonly leftCamera: Nullable<FreeCamera>;
  30949. /**
  30950. * Gets the right camera of a rig setup in case of Rigged Camera
  30951. */
  30952. readonly rightCamera: Nullable<FreeCamera>;
  30953. /**
  30954. * Gets the left camera target of a rig setup in case of Rigged Camera
  30955. * @returns the target position
  30956. */
  30957. getLeftTarget(): Nullable<Vector3>;
  30958. /**
  30959. * Gets the right camera target of a rig setup in case of Rigged Camera
  30960. * @returns the target position
  30961. */
  30962. getRightTarget(): Nullable<Vector3>;
  30963. /**
  30964. * @hidden
  30965. */
  30966. setCameraRigMode(mode: number, rigParams: any): void;
  30967. /** @hidden */
  30968. static _setStereoscopicRigMode(camera: Camera): void;
  30969. /** @hidden */
  30970. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30971. /** @hidden */
  30972. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30973. /** @hidden */
  30974. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30975. /** @hidden */
  30976. _getVRProjectionMatrix(): Matrix;
  30977. protected _updateCameraRotationMatrix(): void;
  30978. protected _updateWebVRCameraRotationMatrix(): void;
  30979. /**
  30980. * This function MUST be overwritten by the different WebVR cameras available.
  30981. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30982. * @hidden
  30983. */
  30984. _getWebVRProjectionMatrix(): Matrix;
  30985. /**
  30986. * This function MUST be overwritten by the different WebVR cameras available.
  30987. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30988. * @hidden
  30989. */
  30990. _getWebVRViewMatrix(): Matrix;
  30991. /** @hidden */
  30992. setCameraRigParameter(name: string, value: any): void;
  30993. /**
  30994. * needs to be overridden by children so sub has required properties to be copied
  30995. * @hidden
  30996. */
  30997. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30998. /**
  30999. * May need to be overridden by children
  31000. * @hidden
  31001. */
  31002. _updateRigCameras(): void;
  31003. /** @hidden */
  31004. _setupInputs(): void;
  31005. /**
  31006. * Serialiaze the camera setup to a json represention
  31007. * @returns the JSON representation
  31008. */
  31009. serialize(): any;
  31010. /**
  31011. * Clones the current camera.
  31012. * @param name The cloned camera name
  31013. * @returns the cloned camera
  31014. */
  31015. clone(name: string): Camera;
  31016. /**
  31017. * Gets the direction of the camera relative to a given local axis.
  31018. * @param localAxis Defines the reference axis to provide a relative direction.
  31019. * @return the direction
  31020. */
  31021. getDirection(localAxis: Vector3): Vector3;
  31022. /**
  31023. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31024. * @param localAxis Defines the reference axis to provide a relative direction.
  31025. * @param result Defines the vector to store the result in
  31026. */
  31027. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31028. /**
  31029. * Gets a camera constructor for a given camera type
  31030. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31031. * @param name The name of the camera the result will be able to instantiate
  31032. * @param scene The scene the result will construct the camera in
  31033. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31034. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31035. * @returns a factory method to construc the camera
  31036. */
  31037. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31038. /**
  31039. * Compute the world matrix of the camera.
  31040. * @returns the camera workd matrix
  31041. */
  31042. computeWorldMatrix(): Matrix;
  31043. /**
  31044. * Parse a JSON and creates the camera from the parsed information
  31045. * @param parsedCamera The JSON to parse
  31046. * @param scene The scene to instantiate the camera in
  31047. * @returns the newly constructed camera
  31048. */
  31049. static Parse(parsedCamera: any, scene: Scene): Camera;
  31050. }
  31051. }
  31052. declare module BABYLON {
  31053. /**
  31054. * Interface for any object that can request an animation frame
  31055. */
  31056. export interface ICustomAnimationFrameRequester {
  31057. /**
  31058. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31059. */
  31060. renderFunction?: Function;
  31061. /**
  31062. * Called to request the next frame to render to
  31063. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31064. */
  31065. requestAnimationFrame: Function;
  31066. /**
  31067. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31068. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31069. */
  31070. requestID?: number;
  31071. }
  31072. /**
  31073. * Interface containing an array of animations
  31074. */
  31075. export interface IAnimatable {
  31076. /**
  31077. * Array of animations
  31078. */
  31079. animations: Nullable<Array<Animation>>;
  31080. }
  31081. /** Interface used by value gradients (color, factor, ...) */
  31082. export interface IValueGradient {
  31083. /**
  31084. * Gets or sets the gradient value (between 0 and 1)
  31085. */
  31086. gradient: number;
  31087. }
  31088. /** Class used to store color4 gradient */
  31089. export class ColorGradient implements IValueGradient {
  31090. /**
  31091. * Gets or sets the gradient value (between 0 and 1)
  31092. */
  31093. gradient: number;
  31094. /**
  31095. * Gets or sets first associated color
  31096. */
  31097. color1: Color4;
  31098. /**
  31099. * Gets or sets second associated color
  31100. */
  31101. color2?: Color4;
  31102. /**
  31103. * Will get a color picked randomly between color1 and color2.
  31104. * If color2 is undefined then color1 will be used
  31105. * @param result defines the target Color4 to store the result in
  31106. */
  31107. getColorToRef(result: Color4): void;
  31108. }
  31109. /** Class used to store color 3 gradient */
  31110. export class Color3Gradient implements IValueGradient {
  31111. /**
  31112. * Gets or sets the gradient value (between 0 and 1)
  31113. */
  31114. gradient: number;
  31115. /**
  31116. * Gets or sets the associated color
  31117. */
  31118. color: Color3;
  31119. }
  31120. /** Class used to store factor gradient */
  31121. export class FactorGradient implements IValueGradient {
  31122. /**
  31123. * Gets or sets the gradient value (between 0 and 1)
  31124. */
  31125. gradient: number;
  31126. /**
  31127. * Gets or sets first associated factor
  31128. */
  31129. factor1: number;
  31130. /**
  31131. * Gets or sets second associated factor
  31132. */
  31133. factor2?: number;
  31134. /**
  31135. * Will get a number picked randomly between factor1 and factor2.
  31136. * If factor2 is undefined then factor1 will be used
  31137. * @returns the picked number
  31138. */
  31139. getFactor(): number;
  31140. }
  31141. /**
  31142. * @ignore
  31143. * Application error to support additional information when loading a file
  31144. */
  31145. export class LoadFileError extends Error {
  31146. /** defines the optional web request */
  31147. request?: WebRequest | undefined;
  31148. private static _setPrototypeOf;
  31149. /**
  31150. * Creates a new LoadFileError
  31151. * @param message defines the message of the error
  31152. * @param request defines the optional web request
  31153. */
  31154. constructor(message: string,
  31155. /** defines the optional web request */
  31156. request?: WebRequest | undefined);
  31157. }
  31158. /**
  31159. * Class used to define a retry strategy when error happens while loading assets
  31160. */
  31161. export class RetryStrategy {
  31162. /**
  31163. * Function used to defines an exponential back off strategy
  31164. * @param maxRetries defines the maximum number of retries (3 by default)
  31165. * @param baseInterval defines the interval between retries
  31166. * @returns the strategy function to use
  31167. */
  31168. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31169. }
  31170. /**
  31171. * File request interface
  31172. */
  31173. export interface IFileRequest {
  31174. /**
  31175. * Raised when the request is complete (success or error).
  31176. */
  31177. onCompleteObservable: Observable<IFileRequest>;
  31178. /**
  31179. * Aborts the request for a file.
  31180. */
  31181. abort: () => void;
  31182. }
  31183. /**
  31184. * Class containing a set of static utilities functions
  31185. */
  31186. export class Tools {
  31187. /**
  31188. * Gets or sets the base URL to use to load assets
  31189. */
  31190. static BaseUrl: string;
  31191. /**
  31192. * Enable/Disable Custom HTTP Request Headers globally.
  31193. * default = false
  31194. * @see CustomRequestHeaders
  31195. */
  31196. static UseCustomRequestHeaders: boolean;
  31197. /**
  31198. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31199. * i.e. when loading files, where the server/service expects an Authorization header
  31200. */
  31201. static CustomRequestHeaders: {
  31202. [key: string]: string;
  31203. };
  31204. /**
  31205. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31206. */
  31207. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31208. /**
  31209. * Default behaviour for cors in the application.
  31210. * It can be a string if the expected behavior is identical in the entire app.
  31211. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31212. */
  31213. static CorsBehavior: string | ((url: string | string[]) => string);
  31214. /**
  31215. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31216. * @ignorenaming
  31217. */
  31218. static UseFallbackTexture: boolean;
  31219. /**
  31220. * Use this object to register external classes like custom textures or material
  31221. * to allow the laoders to instantiate them
  31222. */
  31223. static RegisteredExternalClasses: {
  31224. [key: string]: Object;
  31225. };
  31226. /**
  31227. * Texture content used if a texture cannot loaded
  31228. * @ignorenaming
  31229. */
  31230. static fallbackTexture: string;
  31231. /**
  31232. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31233. * @param u defines the coordinate on X axis
  31234. * @param v defines the coordinate on Y axis
  31235. * @param width defines the width of the source data
  31236. * @param height defines the height of the source data
  31237. * @param pixels defines the source byte array
  31238. * @param color defines the output color
  31239. */
  31240. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31241. /**
  31242. * Interpolates between a and b via alpha
  31243. * @param a The lower value (returned when alpha = 0)
  31244. * @param b The upper value (returned when alpha = 1)
  31245. * @param alpha The interpolation-factor
  31246. * @return The mixed value
  31247. */
  31248. static Mix(a: number, b: number, alpha: number): number;
  31249. /**
  31250. * Tries to instantiate a new object from a given class name
  31251. * @param className defines the class name to instantiate
  31252. * @returns the new object or null if the system was not able to do the instantiation
  31253. */
  31254. static Instantiate(className: string): any;
  31255. /**
  31256. * Provides a slice function that will work even on IE
  31257. * @param data defines the array to slice
  31258. * @param start defines the start of the data (optional)
  31259. * @param end defines the end of the data (optional)
  31260. * @returns the new sliced array
  31261. */
  31262. static Slice<T>(data: T, start?: number, end?: number): T;
  31263. /**
  31264. * Polyfill for setImmediate
  31265. * @param action defines the action to execute after the current execution block
  31266. */
  31267. static SetImmediate(action: () => void): void;
  31268. /**
  31269. * Function indicating if a number is an exponent of 2
  31270. * @param value defines the value to test
  31271. * @returns true if the value is an exponent of 2
  31272. */
  31273. static IsExponentOfTwo(value: number): boolean;
  31274. private static _tmpFloatArray;
  31275. /**
  31276. * Returns the nearest 32-bit single precision float representation of a Number
  31277. * @param value A Number. If the parameter is of a different type, it will get converted
  31278. * to a number or to NaN if it cannot be converted
  31279. * @returns number
  31280. */
  31281. static FloatRound(value: number): number;
  31282. /**
  31283. * Find the next highest power of two.
  31284. * @param x Number to start search from.
  31285. * @return Next highest power of two.
  31286. */
  31287. static CeilingPOT(x: number): number;
  31288. /**
  31289. * Find the next lowest power of two.
  31290. * @param x Number to start search from.
  31291. * @return Next lowest power of two.
  31292. */
  31293. static FloorPOT(x: number): number;
  31294. /**
  31295. * Find the nearest power of two.
  31296. * @param x Number to start search from.
  31297. * @return Next nearest power of two.
  31298. */
  31299. static NearestPOT(x: number): number;
  31300. /**
  31301. * Get the closest exponent of two
  31302. * @param value defines the value to approximate
  31303. * @param max defines the maximum value to return
  31304. * @param mode defines how to define the closest value
  31305. * @returns closest exponent of two of the given value
  31306. */
  31307. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31308. /**
  31309. * Extracts the filename from a path
  31310. * @param path defines the path to use
  31311. * @returns the filename
  31312. */
  31313. static GetFilename(path: string): string;
  31314. /**
  31315. * Extracts the "folder" part of a path (everything before the filename).
  31316. * @param uri The URI to extract the info from
  31317. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31318. * @returns The "folder" part of the path
  31319. */
  31320. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31321. /**
  31322. * Extracts text content from a DOM element hierarchy
  31323. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31324. */
  31325. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31326. /**
  31327. * Convert an angle in radians to degrees
  31328. * @param angle defines the angle to convert
  31329. * @returns the angle in degrees
  31330. */
  31331. static ToDegrees(angle: number): number;
  31332. /**
  31333. * Convert an angle in degrees to radians
  31334. * @param angle defines the angle to convert
  31335. * @returns the angle in radians
  31336. */
  31337. static ToRadians(angle: number): number;
  31338. /**
  31339. * Encode a buffer to a base64 string
  31340. * @param buffer defines the buffer to encode
  31341. * @returns the encoded string
  31342. */
  31343. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31344. /**
  31345. * Extracts minimum and maximum values from a list of indexed positions
  31346. * @param positions defines the positions to use
  31347. * @param indices defines the indices to the positions
  31348. * @param indexStart defines the start index
  31349. * @param indexCount defines the end index
  31350. * @param bias defines bias value to add to the result
  31351. * @return minimum and maximum values
  31352. */
  31353. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31354. minimum: Vector3;
  31355. maximum: Vector3;
  31356. };
  31357. /**
  31358. * Extracts minimum and maximum values from a list of positions
  31359. * @param positions defines the positions to use
  31360. * @param start defines the start index in the positions array
  31361. * @param count defines the number of positions to handle
  31362. * @param bias defines bias value to add to the result
  31363. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31364. * @return minimum and maximum values
  31365. */
  31366. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31367. minimum: Vector3;
  31368. maximum: Vector3;
  31369. };
  31370. /**
  31371. * Returns an array if obj is not an array
  31372. * @param obj defines the object to evaluate as an array
  31373. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31374. * @returns either obj directly if obj is an array or a new array containing obj
  31375. */
  31376. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31377. /**
  31378. * Gets the pointer prefix to use
  31379. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31380. */
  31381. static GetPointerPrefix(): string;
  31382. /**
  31383. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31384. * @param func - the function to be called
  31385. * @param requester - the object that will request the next frame. Falls back to window.
  31386. * @returns frame number
  31387. */
  31388. static QueueNewFrame(func: () => void, requester?: any): number;
  31389. /**
  31390. * Ask the browser to promote the current element to fullscreen rendering mode
  31391. * @param element defines the DOM element to promote
  31392. */
  31393. static RequestFullscreen(element: HTMLElement): void;
  31394. /**
  31395. * Asks the browser to exit fullscreen mode
  31396. */
  31397. static ExitFullscreen(): void;
  31398. /**
  31399. * Ask the browser to promote the current element to pointerlock mode
  31400. * @param element defines the DOM element to promote
  31401. */
  31402. static RequestPointerlock(element: HTMLElement): void;
  31403. /**
  31404. * Asks the browser to exit pointerlock mode
  31405. */
  31406. static ExitPointerlock(): void;
  31407. /**
  31408. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31409. * @param url define the url we are trying
  31410. * @param element define the dom element where to configure the cors policy
  31411. */
  31412. static SetCorsBehavior(url: string | string[], element: {
  31413. crossOrigin: string | null;
  31414. }): void;
  31415. /**
  31416. * Removes unwanted characters from an url
  31417. * @param url defines the url to clean
  31418. * @returns the cleaned url
  31419. */
  31420. static CleanUrl(url: string): string;
  31421. /**
  31422. * Gets or sets a function used to pre-process url before using them to load assets
  31423. */
  31424. static PreprocessUrl: (url: string) => string;
  31425. /**
  31426. * Loads an image as an HTMLImageElement.
  31427. * @param input url string, ArrayBuffer, or Blob to load
  31428. * @param onLoad callback called when the image successfully loads
  31429. * @param onError callback called when the image fails to load
  31430. * @param offlineProvider offline provider for caching
  31431. * @returns the HTMLImageElement of the loaded image
  31432. */
  31433. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31434. /**
  31435. * Loads a file
  31436. * @param url url string, ArrayBuffer, or Blob to load
  31437. * @param onSuccess callback called when the file successfully loads
  31438. * @param onProgress callback called while file is loading (if the server supports this mode)
  31439. * @param offlineProvider defines the offline provider for caching
  31440. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31441. * @param onError callback called when the file fails to load
  31442. * @returns a file request object
  31443. */
  31444. 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;
  31445. /**
  31446. * Loads a file from a url
  31447. * @param url the file url to load
  31448. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31449. */
  31450. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31451. /**
  31452. * Load a script (identified by an url). When the url returns, the
  31453. * content of this file is added into a new script element, attached to the DOM (body element)
  31454. * @param scriptUrl defines the url of the script to laod
  31455. * @param onSuccess defines the callback called when the script is loaded
  31456. * @param onError defines the callback to call if an error occurs
  31457. * @param scriptId defines the id of the script element
  31458. */
  31459. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31460. /**
  31461. * Load an asynchronous script (identified by an url). When the url returns, the
  31462. * content of this file is added into a new script element, attached to the DOM (body element)
  31463. * @param scriptUrl defines the url of the script to laod
  31464. * @param scriptId defines the id of the script element
  31465. * @returns a promise request object
  31466. */
  31467. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31468. /**
  31469. * Loads a file from a blob
  31470. * @param fileToLoad defines the blob to use
  31471. * @param callback defines the callback to call when data is loaded
  31472. * @param progressCallback defines the callback to call during loading process
  31473. * @returns a file request object
  31474. */
  31475. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31476. /**
  31477. * Loads a file
  31478. * @param fileToLoad defines the file to load
  31479. * @param callback defines the callback to call when data is loaded
  31480. * @param progressCallBack defines the callback to call during loading process
  31481. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31482. * @returns a file request object
  31483. */
  31484. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31485. /**
  31486. * Creates a data url from a given string content
  31487. * @param content defines the content to convert
  31488. * @returns the new data url link
  31489. */
  31490. static FileAsURL(content: string): string;
  31491. /**
  31492. * Format the given number to a specific decimal format
  31493. * @param value defines the number to format
  31494. * @param decimals defines the number of decimals to use
  31495. * @returns the formatted string
  31496. */
  31497. static Format(value: number, decimals?: number): string;
  31498. /**
  31499. * Checks if a given vector is inside a specific range
  31500. * @param v defines the vector to test
  31501. * @param min defines the minimum range
  31502. * @param max defines the maximum range
  31503. */
  31504. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31505. /**
  31506. * Tries to copy an object by duplicating every property
  31507. * @param source defines the source object
  31508. * @param destination defines the target object
  31509. * @param doNotCopyList defines a list of properties to avoid
  31510. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31511. */
  31512. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31513. /**
  31514. * Gets a boolean indicating if the given object has no own property
  31515. * @param obj defines the object to test
  31516. * @returns true if object has no own property
  31517. */
  31518. static IsEmpty(obj: any): boolean;
  31519. /**
  31520. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31521. * @param str Source string
  31522. * @param suffix Suffix to search for in the source string
  31523. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31524. */
  31525. static EndsWith(str: string, suffix: string): boolean;
  31526. /**
  31527. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  31528. * @param str Source string
  31529. * @param suffix Suffix to search for in the source string
  31530. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31531. */
  31532. static StartsWith(str: string, suffix: string): boolean;
  31533. /**
  31534. * Function used to register events at window level
  31535. * @param events defines the events to register
  31536. */
  31537. static RegisterTopRootEvents(events: {
  31538. name: string;
  31539. handler: Nullable<(e: FocusEvent) => any>;
  31540. }[]): void;
  31541. /**
  31542. * Function used to unregister events from window level
  31543. * @param events defines the events to unregister
  31544. */
  31545. static UnregisterTopRootEvents(events: {
  31546. name: string;
  31547. handler: Nullable<(e: FocusEvent) => any>;
  31548. }[]): void;
  31549. /**
  31550. * @ignore
  31551. */
  31552. static _ScreenshotCanvas: HTMLCanvasElement;
  31553. /**
  31554. * Dumps the current bound framebuffer
  31555. * @param width defines the rendering width
  31556. * @param height defines the rendering height
  31557. * @param engine defines the hosting engine
  31558. * @param successCallback defines the callback triggered once the data are available
  31559. * @param mimeType defines the mime type of the result
  31560. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31561. */
  31562. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31563. /**
  31564. * Converts the canvas data to blob.
  31565. * This acts as a polyfill for browsers not supporting the to blob function.
  31566. * @param canvas Defines the canvas to extract the data from
  31567. * @param successCallback Defines the callback triggered once the data are available
  31568. * @param mimeType Defines the mime type of the result
  31569. */
  31570. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31571. /**
  31572. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31573. * @param successCallback defines the callback triggered once the data are available
  31574. * @param mimeType defines the mime type of the result
  31575. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31576. */
  31577. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31578. /**
  31579. * Downloads a blob in the browser
  31580. * @param blob defines the blob to download
  31581. * @param fileName defines the name of the downloaded file
  31582. */
  31583. static Download(blob: Blob, fileName: string): void;
  31584. /**
  31585. * Captures a screenshot of the current rendering
  31586. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31587. * @param engine defines the rendering engine
  31588. * @param camera defines the source camera
  31589. * @param size This parameter can be set to a single number or to an object with the
  31590. * following (optional) properties: precision, width, height. If a single number is passed,
  31591. * it will be used for both width and height. If an object is passed, the screenshot size
  31592. * will be derived from the parameters. The precision property is a multiplier allowing
  31593. * rendering at a higher or lower resolution
  31594. * @param successCallback defines the callback receives a single parameter which contains the
  31595. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31596. * src parameter of an <img> to display it
  31597. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31598. * Check your browser for supported MIME types
  31599. */
  31600. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31601. /**
  31602. * Generates an image screenshot from the specified camera.
  31603. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31604. * @param engine The engine to use for rendering
  31605. * @param camera The camera to use for rendering
  31606. * @param size This parameter can be set to a single number or to an object with the
  31607. * following (optional) properties: precision, width, height. If a single number is passed,
  31608. * it will be used for both width and height. If an object is passed, the screenshot size
  31609. * will be derived from the parameters. The precision property is a multiplier allowing
  31610. * rendering at a higher or lower resolution
  31611. * @param successCallback The callback receives a single parameter which contains the
  31612. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31613. * src parameter of an <img> to display it
  31614. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31615. * Check your browser for supported MIME types
  31616. * @param samples Texture samples (default: 1)
  31617. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31618. * @param fileName A name for for the downloaded file.
  31619. */
  31620. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31621. /**
  31622. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31623. * Be aware Math.random() could cause collisions, but:
  31624. * "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"
  31625. * @returns a pseudo random id
  31626. */
  31627. static RandomId(): string;
  31628. /**
  31629. * Test if the given uri is a base64 string
  31630. * @param uri The uri to test
  31631. * @return True if the uri is a base64 string or false otherwise
  31632. */
  31633. static IsBase64(uri: string): boolean;
  31634. /**
  31635. * Decode the given base64 uri.
  31636. * @param uri The uri to decode
  31637. * @return The decoded base64 data.
  31638. */
  31639. static DecodeBase64(uri: string): ArrayBuffer;
  31640. /**
  31641. * Gets the absolute url.
  31642. * @param url the input url
  31643. * @return the absolute url
  31644. */
  31645. static GetAbsoluteUrl(url: string): string;
  31646. /**
  31647. * No log
  31648. */
  31649. static readonly NoneLogLevel: number;
  31650. /**
  31651. * Only message logs
  31652. */
  31653. static readonly MessageLogLevel: number;
  31654. /**
  31655. * Only warning logs
  31656. */
  31657. static readonly WarningLogLevel: number;
  31658. /**
  31659. * Only error logs
  31660. */
  31661. static readonly ErrorLogLevel: number;
  31662. /**
  31663. * All logs
  31664. */
  31665. static readonly AllLogLevel: number;
  31666. /**
  31667. * Gets a value indicating the number of loading errors
  31668. * @ignorenaming
  31669. */
  31670. static readonly errorsCount: number;
  31671. /**
  31672. * Callback called when a new log is added
  31673. */
  31674. static OnNewCacheEntry: (entry: string) => void;
  31675. /**
  31676. * Log a message to the console
  31677. * @param message defines the message to log
  31678. */
  31679. static Log(message: string): void;
  31680. /**
  31681. * Write a warning message to the console
  31682. * @param message defines the message to log
  31683. */
  31684. static Warn(message: string): void;
  31685. /**
  31686. * Write an error message to the console
  31687. * @param message defines the message to log
  31688. */
  31689. static Error(message: string): void;
  31690. /**
  31691. * Gets current log cache (list of logs)
  31692. */
  31693. static readonly LogCache: string;
  31694. /**
  31695. * Clears the log cache
  31696. */
  31697. static ClearLogCache(): void;
  31698. /**
  31699. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31700. */
  31701. static LogLevels: number;
  31702. /**
  31703. * Checks if the loaded document was accessed via `file:`-Protocol.
  31704. * @returns boolean
  31705. */
  31706. static IsFileURL(): boolean;
  31707. /**
  31708. * Checks if the window object exists
  31709. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31710. */
  31711. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31712. /**
  31713. * No performance log
  31714. */
  31715. static readonly PerformanceNoneLogLevel: number;
  31716. /**
  31717. * Use user marks to log performance
  31718. */
  31719. static readonly PerformanceUserMarkLogLevel: number;
  31720. /**
  31721. * Log performance to the console
  31722. */
  31723. static readonly PerformanceConsoleLogLevel: number;
  31724. private static _performance;
  31725. /**
  31726. * Sets the current performance log level
  31727. */
  31728. static PerformanceLogLevel: number;
  31729. private static _StartPerformanceCounterDisabled;
  31730. private static _EndPerformanceCounterDisabled;
  31731. private static _StartUserMark;
  31732. private static _EndUserMark;
  31733. private static _StartPerformanceConsole;
  31734. private static _EndPerformanceConsole;
  31735. /**
  31736. * Starts a performance counter
  31737. */
  31738. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31739. /**
  31740. * Ends a specific performance coutner
  31741. */
  31742. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31743. /**
  31744. * Gets either window.performance.now() if supported or Date.now() else
  31745. */
  31746. static readonly Now: number;
  31747. /**
  31748. * This method will return the name of the class used to create the instance of the given object.
  31749. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31750. * @param object the object to get the class name from
  31751. * @param isType defines if the object is actually a type
  31752. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31753. */
  31754. static GetClassName(object: any, isType?: boolean): string;
  31755. /**
  31756. * Gets the first element of an array satisfying a given predicate
  31757. * @param array defines the array to browse
  31758. * @param predicate defines the predicate to use
  31759. * @returns null if not found or the element
  31760. */
  31761. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31762. /**
  31763. * This method will return the name of the full name of the class, including its owning module (if any).
  31764. * 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).
  31765. * @param object the object to get the class name from
  31766. * @param isType defines if the object is actually a type
  31767. * @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.
  31768. * @ignorenaming
  31769. */
  31770. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31771. /**
  31772. * Returns a promise that resolves after the given amount of time.
  31773. * @param delay Number of milliseconds to delay
  31774. * @returns Promise that resolves after the given amount of time
  31775. */
  31776. static DelayAsync(delay: number): Promise<void>;
  31777. /**
  31778. * Gets the current gradient from an array of IValueGradient
  31779. * @param ratio defines the current ratio to get
  31780. * @param gradients defines the array of IValueGradient
  31781. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31782. */
  31783. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31784. }
  31785. /**
  31786. * This class is used to track a performance counter which is number based.
  31787. * The user has access to many properties which give statistics of different nature.
  31788. *
  31789. * The implementer can track two kinds of Performance Counter: time and count.
  31790. * 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.
  31791. * 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.
  31792. */
  31793. export class PerfCounter {
  31794. /**
  31795. * Gets or sets a global boolean to turn on and off all the counters
  31796. */
  31797. static Enabled: boolean;
  31798. /**
  31799. * Returns the smallest value ever
  31800. */
  31801. readonly min: number;
  31802. /**
  31803. * Returns the biggest value ever
  31804. */
  31805. readonly max: number;
  31806. /**
  31807. * Returns the average value since the performance counter is running
  31808. */
  31809. readonly average: number;
  31810. /**
  31811. * Returns the average value of the last second the counter was monitored
  31812. */
  31813. readonly lastSecAverage: number;
  31814. /**
  31815. * Returns the current value
  31816. */
  31817. readonly current: number;
  31818. /**
  31819. * Gets the accumulated total
  31820. */
  31821. readonly total: number;
  31822. /**
  31823. * Gets the total value count
  31824. */
  31825. readonly count: number;
  31826. /**
  31827. * Creates a new counter
  31828. */
  31829. constructor();
  31830. /**
  31831. * Call this method to start monitoring a new frame.
  31832. * 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.
  31833. */
  31834. fetchNewFrame(): void;
  31835. /**
  31836. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31837. * @param newCount the count value to add to the monitored count
  31838. * @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.
  31839. */
  31840. addCount(newCount: number, fetchResult: boolean): void;
  31841. /**
  31842. * Start monitoring this performance counter
  31843. */
  31844. beginMonitoring(): void;
  31845. /**
  31846. * Compute the time lapsed since the previous beginMonitoring() call.
  31847. * @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
  31848. */
  31849. endMonitoring(newFrame?: boolean): void;
  31850. private _fetchResult;
  31851. private _startMonitoringTime;
  31852. private _min;
  31853. private _max;
  31854. private _average;
  31855. private _current;
  31856. private _totalValueCount;
  31857. private _totalAccumulated;
  31858. private _lastSecAverage;
  31859. private _lastSecAccumulated;
  31860. private _lastSecTime;
  31861. private _lastSecValueCount;
  31862. }
  31863. /**
  31864. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31865. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31866. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31867. * @param name The name of the class, case should be preserved
  31868. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31869. */
  31870. export function className(name: string, module?: string): (target: Object) => void;
  31871. /**
  31872. * An implementation of a loop for asynchronous functions.
  31873. */
  31874. export class AsyncLoop {
  31875. /**
  31876. * Defines the number of iterations for the loop
  31877. */
  31878. iterations: number;
  31879. /**
  31880. * Defines the current index of the loop.
  31881. */
  31882. index: number;
  31883. private _done;
  31884. private _fn;
  31885. private _successCallback;
  31886. /**
  31887. * Constructor.
  31888. * @param iterations the number of iterations.
  31889. * @param func the function to run each iteration
  31890. * @param successCallback the callback that will be called upon succesful execution
  31891. * @param offset starting offset.
  31892. */
  31893. constructor(
  31894. /**
  31895. * Defines the number of iterations for the loop
  31896. */
  31897. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31898. /**
  31899. * Execute the next iteration. Must be called after the last iteration was finished.
  31900. */
  31901. executeNext(): void;
  31902. /**
  31903. * Break the loop and run the success callback.
  31904. */
  31905. breakLoop(): void;
  31906. /**
  31907. * Create and run an async loop.
  31908. * @param iterations the number of iterations.
  31909. * @param fn the function to run each iteration
  31910. * @param successCallback the callback that will be called upon succesful execution
  31911. * @param offset starting offset.
  31912. * @returns the created async loop object
  31913. */
  31914. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31915. /**
  31916. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31917. * @param iterations total number of iterations
  31918. * @param syncedIterations number of synchronous iterations in each async iteration.
  31919. * @param fn the function to call each iteration.
  31920. * @param callback a success call back that will be called when iterating stops.
  31921. * @param breakFunction a break condition (optional)
  31922. * @param timeout timeout settings for the setTimeout function. default - 0.
  31923. * @returns the created async loop object
  31924. */
  31925. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31926. }
  31927. }
  31928. declare module BABYLON {
  31929. /** @hidden */
  31930. export interface ICollisionCoordinator {
  31931. createCollider(): Collider;
  31932. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31933. init(scene: Scene): void;
  31934. }
  31935. /** @hidden */
  31936. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31937. private _scene;
  31938. private _scaledPosition;
  31939. private _scaledVelocity;
  31940. private _finalPosition;
  31941. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31942. createCollider(): Collider;
  31943. init(scene: Scene): void;
  31944. private _collideWithWorld;
  31945. }
  31946. }
  31947. declare module BABYLON {
  31948. /**
  31949. * Class used to manage all inputs for the scene.
  31950. */
  31951. export class InputManager {
  31952. /** The distance in pixel that you have to move to prevent some events */
  31953. static DragMovementThreshold: number;
  31954. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31955. static LongPressDelay: number;
  31956. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31957. static DoubleClickDelay: number;
  31958. /** If you need to check double click without raising a single click at first click, enable this flag */
  31959. static ExclusiveDoubleClickMode: boolean;
  31960. private _wheelEventName;
  31961. private _onPointerMove;
  31962. private _onPointerDown;
  31963. private _onPointerUp;
  31964. private _initClickEvent;
  31965. private _initActionManager;
  31966. private _delayedSimpleClick;
  31967. private _delayedSimpleClickTimeout;
  31968. private _previousDelayedSimpleClickTimeout;
  31969. private _meshPickProceed;
  31970. private _previousButtonPressed;
  31971. private _currentPickResult;
  31972. private _previousPickResult;
  31973. private _totalPointersPressed;
  31974. private _doubleClickOccured;
  31975. private _pointerOverMesh;
  31976. private _pickedDownMesh;
  31977. private _pickedUpMesh;
  31978. private _pointerX;
  31979. private _pointerY;
  31980. private _unTranslatedPointerX;
  31981. private _unTranslatedPointerY;
  31982. private _startingPointerPosition;
  31983. private _previousStartingPointerPosition;
  31984. private _startingPointerTime;
  31985. private _previousStartingPointerTime;
  31986. private _pointerCaptures;
  31987. private _onKeyDown;
  31988. private _onKeyUp;
  31989. private _onCanvasFocusObserver;
  31990. private _onCanvasBlurObserver;
  31991. private _scene;
  31992. /**
  31993. * Creates a new InputManager
  31994. * @param scene defines the hosting scene
  31995. */
  31996. constructor(scene: Scene);
  31997. /**
  31998. * Gets the mesh that is currently under the pointer
  31999. */
  32000. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32001. /**
  32002. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32003. */
  32004. readonly unTranslatedPointer: Vector2;
  32005. /**
  32006. * Gets or sets the current on-screen X position of the pointer
  32007. */
  32008. pointerX: number;
  32009. /**
  32010. * Gets or sets the current on-screen Y position of the pointer
  32011. */
  32012. pointerY: number;
  32013. private _updatePointerPosition;
  32014. private _processPointerMove;
  32015. private _setRayOnPointerInfo;
  32016. private _checkPrePointerObservable;
  32017. /**
  32018. * Use this method to simulate a pointer move on a mesh
  32019. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32020. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32021. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32022. */
  32023. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32024. /**
  32025. * Use this method to simulate a pointer down on a mesh
  32026. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32027. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32028. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32029. */
  32030. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32031. private _processPointerDown;
  32032. /** @hidden */
  32033. _isPointerSwiping(): boolean;
  32034. /**
  32035. * Use this method to simulate a pointer up on a mesh
  32036. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32037. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32038. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32039. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32040. */
  32041. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32042. private _processPointerUp;
  32043. /**
  32044. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32045. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32046. * @returns true if the pointer was captured
  32047. */
  32048. isPointerCaptured(pointerId?: number): boolean;
  32049. /**
  32050. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32051. * @param attachUp defines if you want to attach events to pointerup
  32052. * @param attachDown defines if you want to attach events to pointerdown
  32053. * @param attachMove defines if you want to attach events to pointermove
  32054. */
  32055. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32056. /**
  32057. * Detaches all event handlers
  32058. */
  32059. detachControl(): void;
  32060. /**
  32061. * Force the value of meshUnderPointer
  32062. * @param mesh defines the mesh to use
  32063. */
  32064. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32065. /**
  32066. * Gets the mesh under the pointer
  32067. * @returns a Mesh or null if no mesh is under the pointer
  32068. */
  32069. getPointerOverMesh(): Nullable<AbstractMesh>;
  32070. }
  32071. }
  32072. declare module BABYLON {
  32073. /**
  32074. * This class defines the direct association between an animation and a target
  32075. */
  32076. export class TargetedAnimation {
  32077. /**
  32078. * Animation to perform
  32079. */
  32080. animation: Animation;
  32081. /**
  32082. * Target to animate
  32083. */
  32084. target: any;
  32085. /**
  32086. * Serialize the object
  32087. * @returns the JSON object representing the current entity
  32088. */
  32089. serialize(): any;
  32090. }
  32091. /**
  32092. * Use this class to create coordinated animations on multiple targets
  32093. */
  32094. export class AnimationGroup implements IDisposable {
  32095. /** The name of the animation group */
  32096. name: string;
  32097. private _scene;
  32098. private _targetedAnimations;
  32099. private _animatables;
  32100. private _from;
  32101. private _to;
  32102. private _isStarted;
  32103. private _isPaused;
  32104. private _speedRatio;
  32105. private _loopAnimation;
  32106. /**
  32107. * Gets or sets the unique id of the node
  32108. */
  32109. uniqueId: number;
  32110. /**
  32111. * This observable will notify when one animation have ended
  32112. */
  32113. onAnimationEndObservable: Observable<TargetedAnimation>;
  32114. /**
  32115. * Observer raised when one animation loops
  32116. */
  32117. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32118. /**
  32119. * This observable will notify when all animations have ended.
  32120. */
  32121. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32122. /**
  32123. * This observable will notify when all animations have paused.
  32124. */
  32125. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32126. /**
  32127. * This observable will notify when all animations are playing.
  32128. */
  32129. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32130. /**
  32131. * Gets the first frame
  32132. */
  32133. readonly from: number;
  32134. /**
  32135. * Gets the last frame
  32136. */
  32137. readonly to: number;
  32138. /**
  32139. * Define if the animations are started
  32140. */
  32141. readonly isStarted: boolean;
  32142. /**
  32143. * Gets a value indicating that the current group is playing
  32144. */
  32145. readonly isPlaying: boolean;
  32146. /**
  32147. * Gets or sets the speed ratio to use for all animations
  32148. */
  32149. /**
  32150. * Gets or sets the speed ratio to use for all animations
  32151. */
  32152. speedRatio: number;
  32153. /**
  32154. * Gets or sets if all animations should loop or not
  32155. */
  32156. loopAnimation: boolean;
  32157. /**
  32158. * Gets the targeted animations for this animation group
  32159. */
  32160. readonly targetedAnimations: Array<TargetedAnimation>;
  32161. /**
  32162. * returning the list of animatables controlled by this animation group.
  32163. */
  32164. readonly animatables: Array<Animatable>;
  32165. /**
  32166. * Instantiates a new Animation Group.
  32167. * This helps managing several animations at once.
  32168. * @see http://doc.babylonjs.com/how_to/group
  32169. * @param name Defines the name of the group
  32170. * @param scene Defines the scene the group belongs to
  32171. */
  32172. constructor(
  32173. /** The name of the animation group */
  32174. name: string, scene?: Nullable<Scene>);
  32175. /**
  32176. * Add an animation (with its target) in the group
  32177. * @param animation defines the animation we want to add
  32178. * @param target defines the target of the animation
  32179. * @returns the TargetedAnimation object
  32180. */
  32181. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32182. /**
  32183. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32184. * It can add constant keys at begin or end
  32185. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32186. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32187. * @returns the animation group
  32188. */
  32189. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32190. /**
  32191. * Start all animations on given targets
  32192. * @param loop defines if animations must loop
  32193. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32194. * @param from defines the from key (optional)
  32195. * @param to defines the to key (optional)
  32196. * @returns the current animation group
  32197. */
  32198. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32199. /**
  32200. * Pause all animations
  32201. * @returns the animation group
  32202. */
  32203. pause(): AnimationGroup;
  32204. /**
  32205. * Play all animations to initial state
  32206. * This function will start() the animations if they were not started or will restart() them if they were paused
  32207. * @param loop defines if animations must loop
  32208. * @returns the animation group
  32209. */
  32210. play(loop?: boolean): AnimationGroup;
  32211. /**
  32212. * Reset all animations to initial state
  32213. * @returns the animation group
  32214. */
  32215. reset(): AnimationGroup;
  32216. /**
  32217. * Restart animations from key 0
  32218. * @returns the animation group
  32219. */
  32220. restart(): AnimationGroup;
  32221. /**
  32222. * Stop all animations
  32223. * @returns the animation group
  32224. */
  32225. stop(): AnimationGroup;
  32226. /**
  32227. * Set animation weight for all animatables
  32228. * @param weight defines the weight to use
  32229. * @return the animationGroup
  32230. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32231. */
  32232. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32233. /**
  32234. * Synchronize and normalize all animatables with a source animatable
  32235. * @param root defines the root animatable to synchronize with
  32236. * @return the animationGroup
  32237. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32238. */
  32239. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32240. /**
  32241. * Goes to a specific frame in this animation group
  32242. * @param frame the frame number to go to
  32243. * @return the animationGroup
  32244. */
  32245. goToFrame(frame: number): AnimationGroup;
  32246. /**
  32247. * Dispose all associated resources
  32248. */
  32249. dispose(): void;
  32250. private _checkAnimationGroupEnded;
  32251. /**
  32252. * Clone the current animation group and returns a copy
  32253. * @param newName defines the name of the new group
  32254. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32255. * @returns the new aniamtion group
  32256. */
  32257. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32258. /**
  32259. * Serializes the animationGroup to an object
  32260. * @returns Serialized object
  32261. */
  32262. serialize(): any;
  32263. /**
  32264. * Returns a new AnimationGroup object parsed from the source provided.
  32265. * @param parsedAnimationGroup defines the source
  32266. * @param scene defines the scene that will receive the animationGroup
  32267. * @returns a new AnimationGroup
  32268. */
  32269. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32270. /**
  32271. * Returns the string "AnimationGroup"
  32272. * @returns "AnimationGroup"
  32273. */
  32274. getClassName(): string;
  32275. /**
  32276. * Creates a detailled string about the object
  32277. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32278. * @returns a string representing the object
  32279. */
  32280. toString(fullDetails?: boolean): string;
  32281. }
  32282. }
  32283. declare module BABYLON {
  32284. /**
  32285. * Define an interface for all classes that will hold resources
  32286. */
  32287. export interface IDisposable {
  32288. /**
  32289. * Releases all held resources
  32290. */
  32291. dispose(): void;
  32292. }
  32293. /** Interface defining initialization parameters for Scene class */
  32294. export interface SceneOptions {
  32295. /**
  32296. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32297. * It will improve performance when the number of geometries becomes important.
  32298. */
  32299. useGeometryUniqueIdsMap?: boolean;
  32300. /**
  32301. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32302. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32303. */
  32304. useMaterialMeshMap?: boolean;
  32305. /**
  32306. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32307. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32308. */
  32309. useClonedMeshhMap?: boolean;
  32310. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32311. virtual?: boolean;
  32312. }
  32313. /**
  32314. * Represents a scene to be rendered by the engine.
  32315. * @see http://doc.babylonjs.com/features/scene
  32316. */
  32317. export class Scene extends AbstractScene implements IAnimatable {
  32318. private static _uniqueIdCounter;
  32319. /** The fog is deactivated */
  32320. static readonly FOGMODE_NONE: number;
  32321. /** The fog density is following an exponential function */
  32322. static readonly FOGMODE_EXP: number;
  32323. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32324. static readonly FOGMODE_EXP2: number;
  32325. /** The fog density is following a linear function. */
  32326. static readonly FOGMODE_LINEAR: number;
  32327. /**
  32328. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32329. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32330. */
  32331. static MinDeltaTime: number;
  32332. /**
  32333. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32334. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32335. */
  32336. static MaxDeltaTime: number;
  32337. /**
  32338. * Factory used to create the default material.
  32339. * @param name The name of the material to create
  32340. * @param scene The scene to create the material for
  32341. * @returns The default material
  32342. */
  32343. static DefaultMaterialFactory(scene: Scene): Material;
  32344. /**
  32345. * Factory used to create the a collision coordinator.
  32346. * @returns The collision coordinator
  32347. */
  32348. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32349. /** @hidden */
  32350. _inputManager: InputManager;
  32351. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32352. cameraToUseForPointers: Nullable<Camera>;
  32353. /** @hidden */
  32354. readonly _isScene: boolean;
  32355. /**
  32356. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32357. */
  32358. autoClear: boolean;
  32359. /**
  32360. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32361. */
  32362. autoClearDepthAndStencil: boolean;
  32363. /**
  32364. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32365. */
  32366. clearColor: Color4;
  32367. /**
  32368. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32369. */
  32370. ambientColor: Color3;
  32371. /**
  32372. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32373. * It should only be one of the following (if not the default embedded one):
  32374. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32375. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32376. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32377. * The material properties need to be setup according to the type of texture in use.
  32378. */
  32379. environmentBRDFTexture: BaseTexture;
  32380. /** @hidden */
  32381. protected _environmentTexture: Nullable<BaseTexture>;
  32382. /**
  32383. * Texture used in all pbr material as the reflection texture.
  32384. * As in the majority of the scene they are the same (exception for multi room and so on),
  32385. * this is easier to reference from here than from all the materials.
  32386. */
  32387. /**
  32388. * Texture used in all pbr material as the reflection texture.
  32389. * As in the majority of the scene they are the same (exception for multi room and so on),
  32390. * this is easier to set here than in all the materials.
  32391. */
  32392. environmentTexture: Nullable<BaseTexture>;
  32393. /** @hidden */
  32394. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32395. /**
  32396. * Default image processing configuration used either in the rendering
  32397. * Forward main pass or through the imageProcessingPostProcess if present.
  32398. * As in the majority of the scene they are the same (exception for multi camera),
  32399. * this is easier to reference from here than from all the materials and post process.
  32400. *
  32401. * No setter as we it is a shared configuration, you can set the values instead.
  32402. */
  32403. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32404. private _forceWireframe;
  32405. /**
  32406. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32407. */
  32408. forceWireframe: boolean;
  32409. private _forcePointsCloud;
  32410. /**
  32411. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32412. */
  32413. forcePointsCloud: boolean;
  32414. /**
  32415. * Gets or sets the active clipplane 1
  32416. */
  32417. clipPlane: Nullable<Plane>;
  32418. /**
  32419. * Gets or sets the active clipplane 2
  32420. */
  32421. clipPlane2: Nullable<Plane>;
  32422. /**
  32423. * Gets or sets the active clipplane 3
  32424. */
  32425. clipPlane3: Nullable<Plane>;
  32426. /**
  32427. * Gets or sets the active clipplane 4
  32428. */
  32429. clipPlane4: Nullable<Plane>;
  32430. /**
  32431. * Gets or sets a boolean indicating if animations are enabled
  32432. */
  32433. animationsEnabled: boolean;
  32434. private _animationPropertiesOverride;
  32435. /**
  32436. * Gets or sets the animation properties override
  32437. */
  32438. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32439. /**
  32440. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32441. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32442. */
  32443. useConstantAnimationDeltaTime: boolean;
  32444. /**
  32445. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32446. * Please note that it requires to run a ray cast through the scene on every frame
  32447. */
  32448. constantlyUpdateMeshUnderPointer: boolean;
  32449. /**
  32450. * Defines the HTML cursor to use when hovering over interactive elements
  32451. */
  32452. hoverCursor: string;
  32453. /**
  32454. * Defines the HTML default cursor to use (empty by default)
  32455. */
  32456. defaultCursor: string;
  32457. /**
  32458. * This is used to call preventDefault() on pointer down
  32459. * in order to block unwanted artifacts like system double clicks
  32460. */
  32461. preventDefaultOnPointerDown: boolean;
  32462. /**
  32463. * This is used to call preventDefault() on pointer up
  32464. * in order to block unwanted artifacts like system double clicks
  32465. */
  32466. preventDefaultOnPointerUp: boolean;
  32467. /**
  32468. * Gets or sets user defined metadata
  32469. */
  32470. metadata: any;
  32471. /**
  32472. * For internal use only. Please do not use.
  32473. */
  32474. reservedDataStore: any;
  32475. /**
  32476. * Gets the name of the plugin used to load this scene (null by default)
  32477. */
  32478. loadingPluginName: string;
  32479. /**
  32480. * Use this array to add regular expressions used to disable offline support for specific urls
  32481. */
  32482. disableOfflineSupportExceptionRules: RegExp[];
  32483. /**
  32484. * An event triggered when the scene is disposed.
  32485. */
  32486. onDisposeObservable: Observable<Scene>;
  32487. private _onDisposeObserver;
  32488. /** Sets a function to be executed when this scene is disposed. */
  32489. onDispose: () => void;
  32490. /**
  32491. * An event triggered before rendering the scene (right after animations and physics)
  32492. */
  32493. onBeforeRenderObservable: Observable<Scene>;
  32494. private _onBeforeRenderObserver;
  32495. /** Sets a function to be executed before rendering this scene */
  32496. beforeRender: Nullable<() => void>;
  32497. /**
  32498. * An event triggered after rendering the scene
  32499. */
  32500. onAfterRenderObservable: Observable<Scene>;
  32501. /**
  32502. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32503. */
  32504. onAfterRenderCameraObservable: Observable<Camera>;
  32505. private _onAfterRenderObserver;
  32506. /** Sets a function to be executed after rendering this scene */
  32507. afterRender: Nullable<() => void>;
  32508. /**
  32509. * An event triggered before animating the scene
  32510. */
  32511. onBeforeAnimationsObservable: Observable<Scene>;
  32512. /**
  32513. * An event triggered after animations processing
  32514. */
  32515. onAfterAnimationsObservable: Observable<Scene>;
  32516. /**
  32517. * An event triggered before draw calls are ready to be sent
  32518. */
  32519. onBeforeDrawPhaseObservable: Observable<Scene>;
  32520. /**
  32521. * An event triggered after draw calls have been sent
  32522. */
  32523. onAfterDrawPhaseObservable: Observable<Scene>;
  32524. /**
  32525. * An event triggered when the scene is ready
  32526. */
  32527. onReadyObservable: Observable<Scene>;
  32528. /**
  32529. * An event triggered before rendering a camera
  32530. */
  32531. onBeforeCameraRenderObservable: Observable<Camera>;
  32532. private _onBeforeCameraRenderObserver;
  32533. /** Sets a function to be executed before rendering a camera*/
  32534. beforeCameraRender: () => void;
  32535. /**
  32536. * An event triggered after rendering a camera
  32537. */
  32538. onAfterCameraRenderObservable: Observable<Camera>;
  32539. private _onAfterCameraRenderObserver;
  32540. /** Sets a function to be executed after rendering a camera*/
  32541. afterCameraRender: () => void;
  32542. /**
  32543. * An event triggered when active meshes evaluation is about to start
  32544. */
  32545. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32546. /**
  32547. * An event triggered when active meshes evaluation is done
  32548. */
  32549. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32550. /**
  32551. * An event triggered when particles rendering is about to start
  32552. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32553. */
  32554. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32555. /**
  32556. * An event triggered when particles rendering is done
  32557. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32558. */
  32559. onAfterParticlesRenderingObservable: Observable<Scene>;
  32560. /**
  32561. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32562. */
  32563. onDataLoadedObservable: Observable<Scene>;
  32564. /**
  32565. * An event triggered when a camera is created
  32566. */
  32567. onNewCameraAddedObservable: Observable<Camera>;
  32568. /**
  32569. * An event triggered when a camera is removed
  32570. */
  32571. onCameraRemovedObservable: Observable<Camera>;
  32572. /**
  32573. * An event triggered when a light is created
  32574. */
  32575. onNewLightAddedObservable: Observable<Light>;
  32576. /**
  32577. * An event triggered when a light is removed
  32578. */
  32579. onLightRemovedObservable: Observable<Light>;
  32580. /**
  32581. * An event triggered when a geometry is created
  32582. */
  32583. onNewGeometryAddedObservable: Observable<Geometry>;
  32584. /**
  32585. * An event triggered when a geometry is removed
  32586. */
  32587. onGeometryRemovedObservable: Observable<Geometry>;
  32588. /**
  32589. * An event triggered when a transform node is created
  32590. */
  32591. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32592. /**
  32593. * An event triggered when a transform node is removed
  32594. */
  32595. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32596. /**
  32597. * An event triggered when a mesh is created
  32598. */
  32599. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32600. /**
  32601. * An event triggered when a mesh is removed
  32602. */
  32603. onMeshRemovedObservable: Observable<AbstractMesh>;
  32604. /**
  32605. * An event triggered when a skeleton is created
  32606. */
  32607. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32608. /**
  32609. * An event triggered when a skeleton is removed
  32610. */
  32611. onSkeletonRemovedObservable: Observable<Skeleton>;
  32612. /**
  32613. * An event triggered when a material is created
  32614. */
  32615. onNewMaterialAddedObservable: Observable<Material>;
  32616. /**
  32617. * An event triggered when a material is removed
  32618. */
  32619. onMaterialRemovedObservable: Observable<Material>;
  32620. /**
  32621. * An event triggered when a texture is created
  32622. */
  32623. onNewTextureAddedObservable: Observable<BaseTexture>;
  32624. /**
  32625. * An event triggered when a texture is removed
  32626. */
  32627. onTextureRemovedObservable: Observable<BaseTexture>;
  32628. /**
  32629. * An event triggered when render targets are about to be rendered
  32630. * Can happen multiple times per frame.
  32631. */
  32632. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32633. /**
  32634. * An event triggered when render targets were rendered.
  32635. * Can happen multiple times per frame.
  32636. */
  32637. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32638. /**
  32639. * An event triggered before calculating deterministic simulation step
  32640. */
  32641. onBeforeStepObservable: Observable<Scene>;
  32642. /**
  32643. * An event triggered after calculating deterministic simulation step
  32644. */
  32645. onAfterStepObservable: Observable<Scene>;
  32646. /**
  32647. * An event triggered when the activeCamera property is updated
  32648. */
  32649. onActiveCameraChanged: Observable<Scene>;
  32650. /**
  32651. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32652. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32653. * 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)
  32654. */
  32655. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32656. /**
  32657. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32658. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32659. * 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)
  32660. */
  32661. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32662. /**
  32663. * This Observable will when a mesh has been imported into the scene.
  32664. */
  32665. onMeshImportedObservable: Observable<AbstractMesh>;
  32666. /**
  32667. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32668. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32669. */
  32670. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32671. /** @hidden */
  32672. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32673. /**
  32674. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32675. */
  32676. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32677. /**
  32678. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32679. */
  32680. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32681. /**
  32682. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32683. */
  32684. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32685. /** Callback called when a pointer move is detected */
  32686. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32687. /** Callback called when a pointer down is detected */
  32688. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32689. /** Callback called when a pointer up is detected */
  32690. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32691. /** Callback called when a pointer pick is detected */
  32692. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32693. /**
  32694. * 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).
  32695. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32696. */
  32697. onPrePointerObservable: Observable<PointerInfoPre>;
  32698. /**
  32699. * Observable event triggered each time an input event is received from the rendering canvas
  32700. */
  32701. onPointerObservable: Observable<PointerInfo>;
  32702. /**
  32703. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32704. */
  32705. readonly unTranslatedPointer: Vector2;
  32706. /**
  32707. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32708. */
  32709. static DragMovementThreshold: number;
  32710. /**
  32711. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32712. */
  32713. static LongPressDelay: number;
  32714. /**
  32715. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32716. */
  32717. static DoubleClickDelay: number;
  32718. /** If you need to check double click without raising a single click at first click, enable this flag */
  32719. static ExclusiveDoubleClickMode: boolean;
  32720. /** @hidden */
  32721. _mirroredCameraPosition: Nullable<Vector3>;
  32722. /**
  32723. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32724. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32725. */
  32726. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32727. /**
  32728. * Observable event triggered each time an keyboard event is received from the hosting window
  32729. */
  32730. onKeyboardObservable: Observable<KeyboardInfo>;
  32731. private _useRightHandedSystem;
  32732. /**
  32733. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32734. */
  32735. useRightHandedSystem: boolean;
  32736. private _timeAccumulator;
  32737. private _currentStepId;
  32738. private _currentInternalStep;
  32739. /**
  32740. * Sets the step Id used by deterministic lock step
  32741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32742. * @param newStepId defines the step Id
  32743. */
  32744. setStepId(newStepId: number): void;
  32745. /**
  32746. * Gets the step Id used by deterministic lock step
  32747. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32748. * @returns the step Id
  32749. */
  32750. getStepId(): number;
  32751. /**
  32752. * Gets the internal step used by deterministic lock step
  32753. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32754. * @returns the internal step
  32755. */
  32756. getInternalStep(): number;
  32757. private _fogEnabled;
  32758. /**
  32759. * Gets or sets a boolean indicating if fog is enabled on this scene
  32760. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32761. * (Default is true)
  32762. */
  32763. fogEnabled: boolean;
  32764. private _fogMode;
  32765. /**
  32766. * Gets or sets the fog mode to use
  32767. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32768. * | mode | value |
  32769. * | --- | --- |
  32770. * | FOGMODE_NONE | 0 |
  32771. * | FOGMODE_EXP | 1 |
  32772. * | FOGMODE_EXP2 | 2 |
  32773. * | FOGMODE_LINEAR | 3 |
  32774. */
  32775. fogMode: number;
  32776. /**
  32777. * Gets or sets the fog color to use
  32778. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32779. * (Default is Color3(0.2, 0.2, 0.3))
  32780. */
  32781. fogColor: Color3;
  32782. /**
  32783. * Gets or sets the fog density to use
  32784. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32785. * (Default is 0.1)
  32786. */
  32787. fogDensity: number;
  32788. /**
  32789. * Gets or sets the fog start distance to use
  32790. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32791. * (Default is 0)
  32792. */
  32793. fogStart: number;
  32794. /**
  32795. * Gets or sets the fog end distance to use
  32796. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32797. * (Default is 1000)
  32798. */
  32799. fogEnd: number;
  32800. private _shadowsEnabled;
  32801. /**
  32802. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32803. */
  32804. shadowsEnabled: boolean;
  32805. private _lightsEnabled;
  32806. /**
  32807. * Gets or sets a boolean indicating if lights are enabled on this scene
  32808. */
  32809. lightsEnabled: boolean;
  32810. /** All of the active cameras added to this scene. */
  32811. activeCameras: Camera[];
  32812. /** @hidden */
  32813. _activeCamera: Nullable<Camera>;
  32814. /** Gets or sets the current active camera */
  32815. activeCamera: Nullable<Camera>;
  32816. private _defaultMaterial;
  32817. /** The default material used on meshes when no material is affected */
  32818. /** The default material used on meshes when no material is affected */
  32819. defaultMaterial: Material;
  32820. private _texturesEnabled;
  32821. /**
  32822. * Gets or sets a boolean indicating if textures are enabled on this scene
  32823. */
  32824. texturesEnabled: boolean;
  32825. /**
  32826. * Gets or sets a boolean indicating if particles are enabled on this scene
  32827. */
  32828. particlesEnabled: boolean;
  32829. /**
  32830. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32831. */
  32832. spritesEnabled: boolean;
  32833. private _skeletonsEnabled;
  32834. /**
  32835. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32836. */
  32837. skeletonsEnabled: boolean;
  32838. /**
  32839. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32840. */
  32841. lensFlaresEnabled: boolean;
  32842. /**
  32843. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32844. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32845. */
  32846. collisionsEnabled: boolean;
  32847. private _collisionCoordinator;
  32848. /** @hidden */
  32849. readonly collisionCoordinator: ICollisionCoordinator;
  32850. /**
  32851. * Defines the gravity applied to this scene (used only for collisions)
  32852. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32853. */
  32854. gravity: Vector3;
  32855. /**
  32856. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32857. */
  32858. postProcessesEnabled: boolean;
  32859. /**
  32860. * The list of postprocesses added to the scene
  32861. */
  32862. postProcesses: PostProcess[];
  32863. /**
  32864. * Gets the current postprocess manager
  32865. */
  32866. postProcessManager: PostProcessManager;
  32867. /**
  32868. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32869. */
  32870. renderTargetsEnabled: boolean;
  32871. /**
  32872. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32873. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32874. */
  32875. dumpNextRenderTargets: boolean;
  32876. /**
  32877. * The list of user defined render targets added to the scene
  32878. */
  32879. customRenderTargets: RenderTargetTexture[];
  32880. /**
  32881. * Defines if texture loading must be delayed
  32882. * If true, textures will only be loaded when they need to be rendered
  32883. */
  32884. useDelayedTextureLoading: boolean;
  32885. /**
  32886. * Gets the list of meshes imported to the scene through SceneLoader
  32887. */
  32888. importedMeshesFiles: String[];
  32889. /**
  32890. * Gets or sets a boolean indicating if probes are enabled on this scene
  32891. */
  32892. probesEnabled: boolean;
  32893. /**
  32894. * Gets or sets the current offline provider to use to store scene data
  32895. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32896. */
  32897. offlineProvider: IOfflineProvider;
  32898. /**
  32899. * Gets or sets the action manager associated with the scene
  32900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32901. */
  32902. actionManager: AbstractActionManager;
  32903. private _meshesForIntersections;
  32904. /**
  32905. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32906. */
  32907. proceduralTexturesEnabled: boolean;
  32908. private _engine;
  32909. private _totalVertices;
  32910. /** @hidden */
  32911. _activeIndices: PerfCounter;
  32912. /** @hidden */
  32913. _activeParticles: PerfCounter;
  32914. /** @hidden */
  32915. _activeBones: PerfCounter;
  32916. private _animationRatio;
  32917. /** @hidden */
  32918. _animationTimeLast: number;
  32919. /** @hidden */
  32920. _animationTime: number;
  32921. /**
  32922. * Gets or sets a general scale for animation speed
  32923. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32924. */
  32925. animationTimeScale: number;
  32926. /** @hidden */
  32927. _cachedMaterial: Nullable<Material>;
  32928. /** @hidden */
  32929. _cachedEffect: Nullable<Effect>;
  32930. /** @hidden */
  32931. _cachedVisibility: Nullable<number>;
  32932. private _renderId;
  32933. private _frameId;
  32934. private _executeWhenReadyTimeoutId;
  32935. private _intermediateRendering;
  32936. private _viewUpdateFlag;
  32937. private _projectionUpdateFlag;
  32938. /** @hidden */
  32939. _toBeDisposed: Nullable<IDisposable>[];
  32940. private _activeRequests;
  32941. /** @hidden */
  32942. _pendingData: any[];
  32943. private _isDisposed;
  32944. /**
  32945. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32946. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32947. */
  32948. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32949. private _activeMeshes;
  32950. private _processedMaterials;
  32951. private _renderTargets;
  32952. /** @hidden */
  32953. _activeParticleSystems: SmartArray<IParticleSystem>;
  32954. private _activeSkeletons;
  32955. private _softwareSkinnedMeshes;
  32956. private _renderingManager;
  32957. /** @hidden */
  32958. _activeAnimatables: Animatable[];
  32959. private _transformMatrix;
  32960. private _sceneUbo;
  32961. /** @hidden */
  32962. _viewMatrix: Matrix;
  32963. private _projectionMatrix;
  32964. /** @hidden */
  32965. _forcedViewPosition: Nullable<Vector3>;
  32966. /** @hidden */
  32967. _frustumPlanes: Plane[];
  32968. /**
  32969. * Gets the list of frustum planes (built from the active camera)
  32970. */
  32971. readonly frustumPlanes: Plane[];
  32972. /**
  32973. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32974. * This is useful if there are more lights that the maximum simulteanous authorized
  32975. */
  32976. requireLightSorting: boolean;
  32977. /** @hidden */
  32978. readonly useMaterialMeshMap: boolean;
  32979. /** @hidden */
  32980. readonly useClonedMeshhMap: boolean;
  32981. private _externalData;
  32982. private _uid;
  32983. /**
  32984. * @hidden
  32985. * Backing store of defined scene components.
  32986. */
  32987. _components: ISceneComponent[];
  32988. /**
  32989. * @hidden
  32990. * Backing store of defined scene components.
  32991. */
  32992. _serializableComponents: ISceneSerializableComponent[];
  32993. /**
  32994. * List of components to register on the next registration step.
  32995. */
  32996. private _transientComponents;
  32997. /**
  32998. * Registers the transient components if needed.
  32999. */
  33000. private _registerTransientComponents;
  33001. /**
  33002. * @hidden
  33003. * Add a component to the scene.
  33004. * Note that the ccomponent could be registered on th next frame if this is called after
  33005. * the register component stage.
  33006. * @param component Defines the component to add to the scene
  33007. */
  33008. _addComponent(component: ISceneComponent): void;
  33009. /**
  33010. * @hidden
  33011. * Gets a component from the scene.
  33012. * @param name defines the name of the component to retrieve
  33013. * @returns the component or null if not present
  33014. */
  33015. _getComponent(name: string): Nullable<ISceneComponent>;
  33016. /**
  33017. * @hidden
  33018. * Defines the actions happening before camera updates.
  33019. */
  33020. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33021. /**
  33022. * @hidden
  33023. * Defines the actions happening before clear the canvas.
  33024. */
  33025. _beforeClearStage: Stage<SimpleStageAction>;
  33026. /**
  33027. * @hidden
  33028. * Defines the actions when collecting render targets for the frame.
  33029. */
  33030. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33031. /**
  33032. * @hidden
  33033. * Defines the actions happening for one camera in the frame.
  33034. */
  33035. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33036. /**
  33037. * @hidden
  33038. * Defines the actions happening during the per mesh ready checks.
  33039. */
  33040. _isReadyForMeshStage: Stage<MeshStageAction>;
  33041. /**
  33042. * @hidden
  33043. * Defines the actions happening before evaluate active mesh checks.
  33044. */
  33045. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33046. /**
  33047. * @hidden
  33048. * Defines the actions happening during the evaluate sub mesh checks.
  33049. */
  33050. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33051. /**
  33052. * @hidden
  33053. * Defines the actions happening during the active mesh stage.
  33054. */
  33055. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33056. /**
  33057. * @hidden
  33058. * Defines the actions happening during the per camera render target step.
  33059. */
  33060. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33061. /**
  33062. * @hidden
  33063. * Defines the actions happening just before the active camera is drawing.
  33064. */
  33065. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33066. /**
  33067. * @hidden
  33068. * Defines the actions happening just before a render target is drawing.
  33069. */
  33070. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33071. /**
  33072. * @hidden
  33073. * Defines the actions happening just before a rendering group is drawing.
  33074. */
  33075. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33076. /**
  33077. * @hidden
  33078. * Defines the actions happening just before a mesh is drawing.
  33079. */
  33080. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33081. /**
  33082. * @hidden
  33083. * Defines the actions happening just after a mesh has been drawn.
  33084. */
  33085. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33086. /**
  33087. * @hidden
  33088. * Defines the actions happening just after a rendering group has been drawn.
  33089. */
  33090. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33091. /**
  33092. * @hidden
  33093. * Defines the actions happening just after the active camera has been drawn.
  33094. */
  33095. _afterCameraDrawStage: Stage<CameraStageAction>;
  33096. /**
  33097. * @hidden
  33098. * Defines the actions happening just after a render target has been drawn.
  33099. */
  33100. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33101. /**
  33102. * @hidden
  33103. * Defines the actions happening just after rendering all cameras and computing intersections.
  33104. */
  33105. _afterRenderStage: Stage<SimpleStageAction>;
  33106. /**
  33107. * @hidden
  33108. * Defines the actions happening when a pointer move event happens.
  33109. */
  33110. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33111. /**
  33112. * @hidden
  33113. * Defines the actions happening when a pointer down event happens.
  33114. */
  33115. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33116. /**
  33117. * @hidden
  33118. * Defines the actions happening when a pointer up event happens.
  33119. */
  33120. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33121. /**
  33122. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33123. */
  33124. private geometriesByUniqueId;
  33125. /**
  33126. * Creates a new Scene
  33127. * @param engine defines the engine to use to render this scene
  33128. * @param options defines the scene options
  33129. */
  33130. constructor(engine: Engine, options?: SceneOptions);
  33131. /**
  33132. * Gets a string idenfifying the name of the class
  33133. * @returns "Scene" string
  33134. */
  33135. getClassName(): string;
  33136. private _defaultMeshCandidates;
  33137. /**
  33138. * @hidden
  33139. */
  33140. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33141. private _defaultSubMeshCandidates;
  33142. /**
  33143. * @hidden
  33144. */
  33145. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33146. /**
  33147. * Sets the default candidate providers for the scene.
  33148. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33149. * and getCollidingSubMeshCandidates to their default function
  33150. */
  33151. setDefaultCandidateProviders(): void;
  33152. /**
  33153. * Gets the mesh that is currently under the pointer
  33154. */
  33155. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33156. /**
  33157. * Gets or sets the current on-screen X position of the pointer
  33158. */
  33159. pointerX: number;
  33160. /**
  33161. * Gets or sets the current on-screen Y position of the pointer
  33162. */
  33163. pointerY: number;
  33164. /**
  33165. * Gets the cached material (ie. the latest rendered one)
  33166. * @returns the cached material
  33167. */
  33168. getCachedMaterial(): Nullable<Material>;
  33169. /**
  33170. * Gets the cached effect (ie. the latest rendered one)
  33171. * @returns the cached effect
  33172. */
  33173. getCachedEffect(): Nullable<Effect>;
  33174. /**
  33175. * Gets the cached visibility state (ie. the latest rendered one)
  33176. * @returns the cached visibility state
  33177. */
  33178. getCachedVisibility(): Nullable<number>;
  33179. /**
  33180. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33181. * @param material defines the current material
  33182. * @param effect defines the current effect
  33183. * @param visibility defines the current visibility state
  33184. * @returns true if one parameter is not cached
  33185. */
  33186. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33187. /**
  33188. * Gets the engine associated with the scene
  33189. * @returns an Engine
  33190. */
  33191. getEngine(): Engine;
  33192. /**
  33193. * Gets the total number of vertices rendered per frame
  33194. * @returns the total number of vertices rendered per frame
  33195. */
  33196. getTotalVertices(): number;
  33197. /**
  33198. * Gets the performance counter for total vertices
  33199. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33200. */
  33201. readonly totalVerticesPerfCounter: PerfCounter;
  33202. /**
  33203. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33204. * @returns the total number of active indices rendered per frame
  33205. */
  33206. getActiveIndices(): number;
  33207. /**
  33208. * Gets the performance counter for active indices
  33209. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33210. */
  33211. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33212. /**
  33213. * Gets the total number of active particles rendered per frame
  33214. * @returns the total number of active particles rendered per frame
  33215. */
  33216. getActiveParticles(): number;
  33217. /**
  33218. * Gets the performance counter for active particles
  33219. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33220. */
  33221. readonly activeParticlesPerfCounter: PerfCounter;
  33222. /**
  33223. * Gets the total number of active bones rendered per frame
  33224. * @returns the total number of active bones rendered per frame
  33225. */
  33226. getActiveBones(): number;
  33227. /**
  33228. * Gets the performance counter for active bones
  33229. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33230. */
  33231. readonly activeBonesPerfCounter: PerfCounter;
  33232. /**
  33233. * Gets the array of active meshes
  33234. * @returns an array of AbstractMesh
  33235. */
  33236. getActiveMeshes(): SmartArray<AbstractMesh>;
  33237. /**
  33238. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33239. * @returns a number
  33240. */
  33241. getAnimationRatio(): number;
  33242. /**
  33243. * Gets an unique Id for the current render phase
  33244. * @returns a number
  33245. */
  33246. getRenderId(): number;
  33247. /**
  33248. * Gets an unique Id for the current frame
  33249. * @returns a number
  33250. */
  33251. getFrameId(): number;
  33252. /** Call this function if you want to manually increment the render Id*/
  33253. incrementRenderId(): void;
  33254. private _createUbo;
  33255. /**
  33256. * Use this method to simulate a pointer move on a mesh
  33257. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33258. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33259. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33260. * @returns the current scene
  33261. */
  33262. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33263. /**
  33264. * Use this method to simulate a pointer down on a mesh
  33265. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33266. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33267. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33268. * @returns the current scene
  33269. */
  33270. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33271. /**
  33272. * Use this method to simulate a pointer up on a mesh
  33273. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33274. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33275. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33276. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33277. * @returns the current scene
  33278. */
  33279. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33280. /**
  33281. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33282. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33283. * @returns true if the pointer was captured
  33284. */
  33285. isPointerCaptured(pointerId?: number): boolean;
  33286. /**
  33287. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33288. * @param attachUp defines if you want to attach events to pointerup
  33289. * @param attachDown defines if you want to attach events to pointerdown
  33290. * @param attachMove defines if you want to attach events to pointermove
  33291. */
  33292. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33293. /** Detaches all event handlers*/
  33294. detachControl(): void;
  33295. /**
  33296. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33297. * Delay loaded resources are not taking in account
  33298. * @return true if all required resources are ready
  33299. */
  33300. isReady(): boolean;
  33301. /** Resets all cached information relative to material (including effect and visibility) */
  33302. resetCachedMaterial(): void;
  33303. /**
  33304. * Registers a function to be called before every frame render
  33305. * @param func defines the function to register
  33306. */
  33307. registerBeforeRender(func: () => void): void;
  33308. /**
  33309. * Unregisters a function called before every frame render
  33310. * @param func defines the function to unregister
  33311. */
  33312. unregisterBeforeRender(func: () => void): void;
  33313. /**
  33314. * Registers a function to be called after every frame render
  33315. * @param func defines the function to register
  33316. */
  33317. registerAfterRender(func: () => void): void;
  33318. /**
  33319. * Unregisters a function called after every frame render
  33320. * @param func defines the function to unregister
  33321. */
  33322. unregisterAfterRender(func: () => void): void;
  33323. private _executeOnceBeforeRender;
  33324. /**
  33325. * The provided function will run before render once and will be disposed afterwards.
  33326. * A timeout delay can be provided so that the function will be executed in N ms.
  33327. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33328. * @param func The function to be executed.
  33329. * @param timeout optional delay in ms
  33330. */
  33331. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33332. /** @hidden */
  33333. _addPendingData(data: any): void;
  33334. /** @hidden */
  33335. _removePendingData(data: any): void;
  33336. /**
  33337. * Returns the number of items waiting to be loaded
  33338. * @returns the number of items waiting to be loaded
  33339. */
  33340. getWaitingItemsCount(): number;
  33341. /**
  33342. * Returns a boolean indicating if the scene is still loading data
  33343. */
  33344. readonly isLoading: boolean;
  33345. /**
  33346. * Registers a function to be executed when the scene is ready
  33347. * @param {Function} func - the function to be executed
  33348. */
  33349. executeWhenReady(func: () => void): void;
  33350. /**
  33351. * Returns a promise that resolves when the scene is ready
  33352. * @returns A promise that resolves when the scene is ready
  33353. */
  33354. whenReadyAsync(): Promise<void>;
  33355. /** @hidden */
  33356. _checkIsReady(): void;
  33357. /**
  33358. * Gets all animatable attached to the scene
  33359. */
  33360. readonly animatables: Animatable[];
  33361. /**
  33362. * Resets the last animation time frame.
  33363. * Useful to override when animations start running when loading a scene for the first time.
  33364. */
  33365. resetLastAnimationTimeFrame(): void;
  33366. /**
  33367. * Gets the current view matrix
  33368. * @returns a Matrix
  33369. */
  33370. getViewMatrix(): Matrix;
  33371. /**
  33372. * Gets the current projection matrix
  33373. * @returns a Matrix
  33374. */
  33375. getProjectionMatrix(): Matrix;
  33376. /**
  33377. * Gets the current transform matrix
  33378. * @returns a Matrix made of View * Projection
  33379. */
  33380. getTransformMatrix(): Matrix;
  33381. /**
  33382. * Sets the current transform matrix
  33383. * @param viewL defines the View matrix to use
  33384. * @param projectionL defines the Projection matrix to use
  33385. * @param viewR defines the right View matrix to use (if provided)
  33386. * @param projectionR defines the right Projection matrix to use (if provided)
  33387. */
  33388. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33389. /**
  33390. * Gets the uniform buffer used to store scene data
  33391. * @returns a UniformBuffer
  33392. */
  33393. getSceneUniformBuffer(): UniformBuffer;
  33394. /**
  33395. * Gets an unique (relatively to the current scene) Id
  33396. * @returns an unique number for the scene
  33397. */
  33398. getUniqueId(): number;
  33399. /**
  33400. * Add a mesh to the list of scene's meshes
  33401. * @param newMesh defines the mesh to add
  33402. * @param recursive if all child meshes should also be added to the scene
  33403. */
  33404. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33405. /**
  33406. * Remove a mesh for the list of scene's meshes
  33407. * @param toRemove defines the mesh to remove
  33408. * @param recursive if all child meshes should also be removed from the scene
  33409. * @returns the index where the mesh was in the mesh list
  33410. */
  33411. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33412. /**
  33413. * Add a transform node to the list of scene's transform nodes
  33414. * @param newTransformNode defines the transform node to add
  33415. */
  33416. addTransformNode(newTransformNode: TransformNode): void;
  33417. /**
  33418. * Remove a transform node for the list of scene's transform nodes
  33419. * @param toRemove defines the transform node to remove
  33420. * @returns the index where the transform node was in the transform node list
  33421. */
  33422. removeTransformNode(toRemove: TransformNode): number;
  33423. /**
  33424. * Remove a skeleton for the list of scene's skeletons
  33425. * @param toRemove defines the skeleton to remove
  33426. * @returns the index where the skeleton was in the skeleton list
  33427. */
  33428. removeSkeleton(toRemove: Skeleton): number;
  33429. /**
  33430. * Remove a morph target for the list of scene's morph targets
  33431. * @param toRemove defines the morph target to remove
  33432. * @returns the index where the morph target was in the morph target list
  33433. */
  33434. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33435. /**
  33436. * Remove a light for the list of scene's lights
  33437. * @param toRemove defines the light to remove
  33438. * @returns the index where the light was in the light list
  33439. */
  33440. removeLight(toRemove: Light): number;
  33441. /**
  33442. * Remove a camera for the list of scene's cameras
  33443. * @param toRemove defines the camera to remove
  33444. * @returns the index where the camera was in the camera list
  33445. */
  33446. removeCamera(toRemove: Camera): number;
  33447. /**
  33448. * Remove a particle system for the list of scene's particle systems
  33449. * @param toRemove defines the particle system to remove
  33450. * @returns the index where the particle system was in the particle system list
  33451. */
  33452. removeParticleSystem(toRemove: IParticleSystem): number;
  33453. /**
  33454. * Remove a animation for the list of scene's animations
  33455. * @param toRemove defines the animation to remove
  33456. * @returns the index where the animation was in the animation list
  33457. */
  33458. removeAnimation(toRemove: Animation): number;
  33459. /**
  33460. * Will stop the animation of the given target
  33461. * @param target - the target
  33462. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33463. * @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)
  33464. */
  33465. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33466. /**
  33467. * Removes the given animation group from this scene.
  33468. * @param toRemove The animation group to remove
  33469. * @returns The index of the removed animation group
  33470. */
  33471. removeAnimationGroup(toRemove: AnimationGroup): number;
  33472. /**
  33473. * Removes the given multi-material from this scene.
  33474. * @param toRemove The multi-material to remove
  33475. * @returns The index of the removed multi-material
  33476. */
  33477. removeMultiMaterial(toRemove: MultiMaterial): number;
  33478. /**
  33479. * Removes the given material from this scene.
  33480. * @param toRemove The material to remove
  33481. * @returns The index of the removed material
  33482. */
  33483. removeMaterial(toRemove: Material): number;
  33484. /**
  33485. * Removes the given action manager from this scene.
  33486. * @param toRemove The action manager to remove
  33487. * @returns The index of the removed action manager
  33488. */
  33489. removeActionManager(toRemove: AbstractActionManager): number;
  33490. /**
  33491. * Removes the given texture from this scene.
  33492. * @param toRemove The texture to remove
  33493. * @returns The index of the removed texture
  33494. */
  33495. removeTexture(toRemove: BaseTexture): number;
  33496. /**
  33497. * Adds the given light to this scene
  33498. * @param newLight The light to add
  33499. */
  33500. addLight(newLight: Light): void;
  33501. /**
  33502. * Sorts the list list based on light priorities
  33503. */
  33504. sortLightsByPriority(): void;
  33505. /**
  33506. * Adds the given camera to this scene
  33507. * @param newCamera The camera to add
  33508. */
  33509. addCamera(newCamera: Camera): void;
  33510. /**
  33511. * Adds the given skeleton to this scene
  33512. * @param newSkeleton The skeleton to add
  33513. */
  33514. addSkeleton(newSkeleton: Skeleton): void;
  33515. /**
  33516. * Adds the given particle system to this scene
  33517. * @param newParticleSystem The particle system to add
  33518. */
  33519. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33520. /**
  33521. * Adds the given animation to this scene
  33522. * @param newAnimation The animation to add
  33523. */
  33524. addAnimation(newAnimation: Animation): void;
  33525. /**
  33526. * Adds the given animation group to this scene.
  33527. * @param newAnimationGroup The animation group to add
  33528. */
  33529. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33530. /**
  33531. * Adds the given multi-material to this scene
  33532. * @param newMultiMaterial The multi-material to add
  33533. */
  33534. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33535. /**
  33536. * Adds the given material to this scene
  33537. * @param newMaterial The material to add
  33538. */
  33539. addMaterial(newMaterial: Material): void;
  33540. /**
  33541. * Adds the given morph target to this scene
  33542. * @param newMorphTargetManager The morph target to add
  33543. */
  33544. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33545. /**
  33546. * Adds the given geometry to this scene
  33547. * @param newGeometry The geometry to add
  33548. */
  33549. addGeometry(newGeometry: Geometry): void;
  33550. /**
  33551. * Adds the given action manager to this scene
  33552. * @param newActionManager The action manager to add
  33553. */
  33554. addActionManager(newActionManager: AbstractActionManager): void;
  33555. /**
  33556. * Adds the given texture to this scene.
  33557. * @param newTexture The texture to add
  33558. */
  33559. addTexture(newTexture: BaseTexture): void;
  33560. /**
  33561. * Switch active camera
  33562. * @param newCamera defines the new active camera
  33563. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33564. */
  33565. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33566. /**
  33567. * sets the active camera of the scene using its ID
  33568. * @param id defines the camera's ID
  33569. * @return the new active camera or null if none found.
  33570. */
  33571. setActiveCameraByID(id: string): Nullable<Camera>;
  33572. /**
  33573. * sets the active camera of the scene using its name
  33574. * @param name defines the camera's name
  33575. * @returns the new active camera or null if none found.
  33576. */
  33577. setActiveCameraByName(name: string): Nullable<Camera>;
  33578. /**
  33579. * get an animation group using its name
  33580. * @param name defines the material's name
  33581. * @return the animation group or null if none found.
  33582. */
  33583. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33584. /**
  33585. * Get a material using its unique id
  33586. * @param uniqueId defines the material's unique id
  33587. * @return the material or null if none found.
  33588. */
  33589. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33590. /**
  33591. * get a material using its id
  33592. * @param id defines the material's ID
  33593. * @return the material or null if none found.
  33594. */
  33595. getMaterialByID(id: string): Nullable<Material>;
  33596. /**
  33597. * Gets a the last added material using a given id
  33598. * @param id defines the material's ID
  33599. * @return the last material with the given id or null if none found.
  33600. */
  33601. getLastMaterialByID(id: string): Nullable<Material>;
  33602. /**
  33603. * Gets a material using its name
  33604. * @param name defines the material's name
  33605. * @return the material or null if none found.
  33606. */
  33607. getMaterialByName(name: string): Nullable<Material>;
  33608. /**
  33609. * Gets a camera using its id
  33610. * @param id defines the id to look for
  33611. * @returns the camera or null if not found
  33612. */
  33613. getCameraByID(id: string): Nullable<Camera>;
  33614. /**
  33615. * Gets a camera using its unique id
  33616. * @param uniqueId defines the unique id to look for
  33617. * @returns the camera or null if not found
  33618. */
  33619. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33620. /**
  33621. * Gets a camera using its name
  33622. * @param name defines the camera's name
  33623. * @return the camera or null if none found.
  33624. */
  33625. getCameraByName(name: string): Nullable<Camera>;
  33626. /**
  33627. * Gets a bone using its id
  33628. * @param id defines the bone's id
  33629. * @return the bone or null if not found
  33630. */
  33631. getBoneByID(id: string): Nullable<Bone>;
  33632. /**
  33633. * Gets a bone using its id
  33634. * @param name defines the bone's name
  33635. * @return the bone or null if not found
  33636. */
  33637. getBoneByName(name: string): Nullable<Bone>;
  33638. /**
  33639. * Gets a light node using its name
  33640. * @param name defines the the light's name
  33641. * @return the light or null if none found.
  33642. */
  33643. getLightByName(name: string): Nullable<Light>;
  33644. /**
  33645. * Gets a light node using its id
  33646. * @param id defines the light's id
  33647. * @return the light or null if none found.
  33648. */
  33649. getLightByID(id: string): Nullable<Light>;
  33650. /**
  33651. * Gets a light node using its scene-generated unique ID
  33652. * @param uniqueId defines the light's unique id
  33653. * @return the light or null if none found.
  33654. */
  33655. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33656. /**
  33657. * Gets a particle system by id
  33658. * @param id defines the particle system id
  33659. * @return the corresponding system or null if none found
  33660. */
  33661. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33662. /**
  33663. * Gets a geometry using its ID
  33664. * @param id defines the geometry's id
  33665. * @return the geometry or null if none found.
  33666. */
  33667. getGeometryByID(id: string): Nullable<Geometry>;
  33668. private _getGeometryByUniqueID;
  33669. /**
  33670. * Add a new geometry to this scene
  33671. * @param geometry defines the geometry to be added to the scene.
  33672. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33673. * @return a boolean defining if the geometry was added or not
  33674. */
  33675. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33676. /**
  33677. * Removes an existing geometry
  33678. * @param geometry defines the geometry to be removed from the scene
  33679. * @return a boolean defining if the geometry was removed or not
  33680. */
  33681. removeGeometry(geometry: Geometry): boolean;
  33682. /**
  33683. * Gets the list of geometries attached to the scene
  33684. * @returns an array of Geometry
  33685. */
  33686. getGeometries(): Geometry[];
  33687. /**
  33688. * Gets the first added mesh found of a given ID
  33689. * @param id defines the id to search for
  33690. * @return the mesh found or null if not found at all
  33691. */
  33692. getMeshByID(id: string): Nullable<AbstractMesh>;
  33693. /**
  33694. * Gets a list of meshes using their id
  33695. * @param id defines the id to search for
  33696. * @returns a list of meshes
  33697. */
  33698. getMeshesByID(id: string): Array<AbstractMesh>;
  33699. /**
  33700. * Gets the first added transform node found of a given ID
  33701. * @param id defines the id to search for
  33702. * @return the found transform node or null if not found at all.
  33703. */
  33704. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33705. /**
  33706. * Gets a transform node with its auto-generated unique id
  33707. * @param uniqueId efines the unique id to search for
  33708. * @return the found transform node or null if not found at all.
  33709. */
  33710. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33711. /**
  33712. * Gets a list of transform nodes using their id
  33713. * @param id defines the id to search for
  33714. * @returns a list of transform nodes
  33715. */
  33716. getTransformNodesByID(id: string): Array<TransformNode>;
  33717. /**
  33718. * Gets a mesh with its auto-generated unique id
  33719. * @param uniqueId defines the unique id to search for
  33720. * @return the found mesh or null if not found at all.
  33721. */
  33722. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33723. /**
  33724. * Gets a the last added mesh using a given id
  33725. * @param id defines the id to search for
  33726. * @return the found mesh or null if not found at all.
  33727. */
  33728. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33729. /**
  33730. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33731. * @param id defines the id to search for
  33732. * @return the found node or null if not found at all
  33733. */
  33734. getLastEntryByID(id: string): Nullable<Node>;
  33735. /**
  33736. * Gets a node (Mesh, Camera, Light) using a given id
  33737. * @param id defines the id to search for
  33738. * @return the found node or null if not found at all
  33739. */
  33740. getNodeByID(id: string): Nullable<Node>;
  33741. /**
  33742. * Gets a node (Mesh, Camera, Light) using a given name
  33743. * @param name defines the name to search for
  33744. * @return the found node or null if not found at all.
  33745. */
  33746. getNodeByName(name: string): Nullable<Node>;
  33747. /**
  33748. * Gets a mesh using a given name
  33749. * @param name defines the name to search for
  33750. * @return the found mesh or null if not found at all.
  33751. */
  33752. getMeshByName(name: string): Nullable<AbstractMesh>;
  33753. /**
  33754. * Gets a transform node using a given name
  33755. * @param name defines the name to search for
  33756. * @return the found transform node or null if not found at all.
  33757. */
  33758. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33759. /**
  33760. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33761. * @param id defines the id to search for
  33762. * @return the found skeleton or null if not found at all.
  33763. */
  33764. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33765. /**
  33766. * Gets a skeleton using a given auto generated unique id
  33767. * @param uniqueId defines the unique id to search for
  33768. * @return the found skeleton or null if not found at all.
  33769. */
  33770. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33771. /**
  33772. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33773. * @param id defines the id to search for
  33774. * @return the found skeleton or null if not found at all.
  33775. */
  33776. getSkeletonById(id: string): Nullable<Skeleton>;
  33777. /**
  33778. * Gets a skeleton using a given name
  33779. * @param name defines the name to search for
  33780. * @return the found skeleton or null if not found at all.
  33781. */
  33782. getSkeletonByName(name: string): Nullable<Skeleton>;
  33783. /**
  33784. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33785. * @param id defines the id to search for
  33786. * @return the found morph target manager or null if not found at all.
  33787. */
  33788. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33789. /**
  33790. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33791. * @param id defines the id to search for
  33792. * @return the found morph target or null if not found at all.
  33793. */
  33794. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33795. /**
  33796. * Gets a boolean indicating if the given mesh is active
  33797. * @param mesh defines the mesh to look for
  33798. * @returns true if the mesh is in the active list
  33799. */
  33800. isActiveMesh(mesh: AbstractMesh): boolean;
  33801. /**
  33802. * Return a unique id as a string which can serve as an identifier for the scene
  33803. */
  33804. readonly uid: string;
  33805. /**
  33806. * Add an externaly attached data from its key.
  33807. * This method call will fail and return false, if such key already exists.
  33808. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33809. * @param key the unique key that identifies the data
  33810. * @param data the data object to associate to the key for this Engine instance
  33811. * @return true if no such key were already present and the data was added successfully, false otherwise
  33812. */
  33813. addExternalData<T>(key: string, data: T): boolean;
  33814. /**
  33815. * Get an externaly attached data from its key
  33816. * @param key the unique key that identifies the data
  33817. * @return the associated data, if present (can be null), or undefined if not present
  33818. */
  33819. getExternalData<T>(key: string): Nullable<T>;
  33820. /**
  33821. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33822. * @param key the unique key that identifies the data
  33823. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33824. * @return the associated data, can be null if the factory returned null.
  33825. */
  33826. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33827. /**
  33828. * Remove an externaly attached data from the Engine instance
  33829. * @param key the unique key that identifies the data
  33830. * @return true if the data was successfully removed, false if it doesn't exist
  33831. */
  33832. removeExternalData(key: string): boolean;
  33833. private _evaluateSubMesh;
  33834. /**
  33835. * Clear the processed materials smart array preventing retention point in material dispose.
  33836. */
  33837. freeProcessedMaterials(): void;
  33838. private _preventFreeActiveMeshesAndRenderingGroups;
  33839. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33840. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33841. * when disposing several meshes in a row or a hierarchy of meshes.
  33842. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33843. */
  33844. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33845. /**
  33846. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33847. */
  33848. freeActiveMeshes(): void;
  33849. /**
  33850. * Clear the info related to rendering groups preventing retention points during dispose.
  33851. */
  33852. freeRenderingGroups(): void;
  33853. /** @hidden */
  33854. _isInIntermediateRendering(): boolean;
  33855. /**
  33856. * Lambda returning the list of potentially active meshes.
  33857. */
  33858. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33859. /**
  33860. * Lambda returning the list of potentially active sub meshes.
  33861. */
  33862. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33863. /**
  33864. * Lambda returning the list of potentially intersecting sub meshes.
  33865. */
  33866. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33867. /**
  33868. * Lambda returning the list of potentially colliding sub meshes.
  33869. */
  33870. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33871. private _activeMeshesFrozen;
  33872. /**
  33873. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33874. * @returns the current scene
  33875. */
  33876. freezeActiveMeshes(): Scene;
  33877. /**
  33878. * Use this function to restart evaluating active meshes on every frame
  33879. * @returns the current scene
  33880. */
  33881. unfreezeActiveMeshes(): Scene;
  33882. private _evaluateActiveMeshes;
  33883. private _activeMesh;
  33884. /**
  33885. * Update the transform matrix to update from the current active camera
  33886. * @param force defines a boolean used to force the update even if cache is up to date
  33887. */
  33888. updateTransformMatrix(force?: boolean): void;
  33889. private _bindFrameBuffer;
  33890. /** @hidden */
  33891. _allowPostProcessClearColor: boolean;
  33892. /** @hidden */
  33893. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33894. private _processSubCameras;
  33895. private _checkIntersections;
  33896. /** @hidden */
  33897. _advancePhysicsEngineStep(step: number): void;
  33898. /**
  33899. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33900. */
  33901. getDeterministicFrameTime: () => number;
  33902. /** @hidden */
  33903. _animate(): void;
  33904. /** Execute all animations (for a frame) */
  33905. animate(): void;
  33906. /**
  33907. * Render the scene
  33908. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33909. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33910. */
  33911. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33912. /**
  33913. * Freeze all materials
  33914. * A frozen material will not be updatable but should be faster to render
  33915. */
  33916. freezeMaterials(): void;
  33917. /**
  33918. * Unfreeze all materials
  33919. * A frozen material will not be updatable but should be faster to render
  33920. */
  33921. unfreezeMaterials(): void;
  33922. /**
  33923. * Releases all held ressources
  33924. */
  33925. dispose(): void;
  33926. /**
  33927. * Gets if the scene is already disposed
  33928. */
  33929. readonly isDisposed: boolean;
  33930. /**
  33931. * Call this function to reduce memory footprint of the scene.
  33932. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33933. */
  33934. clearCachedVertexData(): void;
  33935. /**
  33936. * This function will remove the local cached buffer data from texture.
  33937. * It will save memory but will prevent the texture from being rebuilt
  33938. */
  33939. cleanCachedTextureBuffer(): void;
  33940. /**
  33941. * Get the world extend vectors with an optional filter
  33942. *
  33943. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33944. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33945. */
  33946. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33947. min: Vector3;
  33948. max: Vector3;
  33949. };
  33950. /**
  33951. * Creates a ray that can be used to pick in the scene
  33952. * @param x defines the x coordinate of the origin (on-screen)
  33953. * @param y defines the y coordinate of the origin (on-screen)
  33954. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33955. * @param camera defines the camera to use for the picking
  33956. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33957. * @returns a Ray
  33958. */
  33959. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33960. /**
  33961. * Creates a ray that can be used to pick in the scene
  33962. * @param x defines the x coordinate of the origin (on-screen)
  33963. * @param y defines the y coordinate of the origin (on-screen)
  33964. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33965. * @param result defines the ray where to store the picking ray
  33966. * @param camera defines the camera to use for the picking
  33967. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33968. * @returns the current scene
  33969. */
  33970. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33971. /**
  33972. * Creates a ray that can be used to pick in the scene
  33973. * @param x defines the x coordinate of the origin (on-screen)
  33974. * @param y defines the y coordinate of the origin (on-screen)
  33975. * @param camera defines the camera to use for the picking
  33976. * @returns a Ray
  33977. */
  33978. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33979. /**
  33980. * Creates a ray that can be used to pick in the scene
  33981. * @param x defines the x coordinate of the origin (on-screen)
  33982. * @param y defines the y coordinate of the origin (on-screen)
  33983. * @param result defines the ray where to store the picking ray
  33984. * @param camera defines the camera to use for the picking
  33985. * @returns the current scene
  33986. */
  33987. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33988. /** Launch a ray to try to pick a mesh in the scene
  33989. * @param x position on screen
  33990. * @param y position on screen
  33991. * @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
  33992. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33993. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33994. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33995. * @returns a PickingInfo
  33996. */
  33997. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33998. /** Use the given ray to pick a mesh in the scene
  33999. * @param ray The ray to use to pick meshes
  34000. * @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
  34001. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34002. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34003. * @returns a PickingInfo
  34004. */
  34005. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34006. /**
  34007. * Launch a ray to try to pick a mesh in the scene
  34008. * @param x X position on screen
  34009. * @param y Y position on screen
  34010. * @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
  34011. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34012. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34013. * @returns an array of PickingInfo
  34014. */
  34015. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34016. /**
  34017. * Launch a ray to try to pick a mesh in the scene
  34018. * @param ray Ray to use
  34019. * @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
  34020. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34021. * @returns an array of PickingInfo
  34022. */
  34023. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34024. /**
  34025. * Force the value of meshUnderPointer
  34026. * @param mesh defines the mesh to use
  34027. */
  34028. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34029. /**
  34030. * Gets the mesh under the pointer
  34031. * @returns a Mesh or null if no mesh is under the pointer
  34032. */
  34033. getPointerOverMesh(): Nullable<AbstractMesh>;
  34034. /** @hidden */
  34035. _rebuildGeometries(): void;
  34036. /** @hidden */
  34037. _rebuildTextures(): void;
  34038. private _getByTags;
  34039. /**
  34040. * Get a list of meshes by tags
  34041. * @param tagsQuery defines the tags query to use
  34042. * @param forEach defines a predicate used to filter results
  34043. * @returns an array of Mesh
  34044. */
  34045. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34046. /**
  34047. * Get a list of cameras by tags
  34048. * @param tagsQuery defines the tags query to use
  34049. * @param forEach defines a predicate used to filter results
  34050. * @returns an array of Camera
  34051. */
  34052. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34053. /**
  34054. * Get a list of lights by tags
  34055. * @param tagsQuery defines the tags query to use
  34056. * @param forEach defines a predicate used to filter results
  34057. * @returns an array of Light
  34058. */
  34059. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34060. /**
  34061. * Get a list of materials by tags
  34062. * @param tagsQuery defines the tags query to use
  34063. * @param forEach defines a predicate used to filter results
  34064. * @returns an array of Material
  34065. */
  34066. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34067. /**
  34068. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34069. * This allowed control for front to back rendering or reversly depending of the special needs.
  34070. *
  34071. * @param renderingGroupId The rendering group id corresponding to its index
  34072. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34073. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34074. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34075. */
  34076. 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;
  34077. /**
  34078. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34079. *
  34080. * @param renderingGroupId The rendering group id corresponding to its index
  34081. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34082. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34083. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34084. */
  34085. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34086. /**
  34087. * Gets the current auto clear configuration for one rendering group of the rendering
  34088. * manager.
  34089. * @param index the rendering group index to get the information for
  34090. * @returns The auto clear setup for the requested rendering group
  34091. */
  34092. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34093. private _blockMaterialDirtyMechanism;
  34094. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34095. blockMaterialDirtyMechanism: boolean;
  34096. /**
  34097. * Will flag all materials as dirty to trigger new shader compilation
  34098. * @param flag defines the flag used to specify which material part must be marked as dirty
  34099. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34100. */
  34101. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34102. /** @hidden */
  34103. _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;
  34104. /** @hidden */
  34105. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34106. }
  34107. }
  34108. declare module BABYLON {
  34109. /**
  34110. * Set of assets to keep when moving a scene into an asset container.
  34111. */
  34112. export class KeepAssets extends AbstractScene {
  34113. }
  34114. /**
  34115. * Container with a set of assets that can be added or removed from a scene.
  34116. */
  34117. export class AssetContainer extends AbstractScene {
  34118. /**
  34119. * The scene the AssetContainer belongs to.
  34120. */
  34121. scene: Scene;
  34122. /**
  34123. * Instantiates an AssetContainer.
  34124. * @param scene The scene the AssetContainer belongs to.
  34125. */
  34126. constructor(scene: Scene);
  34127. /**
  34128. * Adds all the assets from the container to the scene.
  34129. */
  34130. addAllToScene(): void;
  34131. /**
  34132. * Removes all the assets in the container from the scene
  34133. */
  34134. removeAllFromScene(): void;
  34135. /**
  34136. * Disposes all the assets in the container
  34137. */
  34138. dispose(): void;
  34139. private _moveAssets;
  34140. /**
  34141. * Removes all the assets contained in the scene and adds them to the container.
  34142. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34143. */
  34144. moveAllFromScene(keepAssets?: KeepAssets): void;
  34145. /**
  34146. * 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.
  34147. * @returns the root mesh
  34148. */
  34149. createRootMesh(): Mesh;
  34150. }
  34151. }
  34152. declare module BABYLON {
  34153. /**
  34154. * Defines how the parser contract is defined.
  34155. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34156. */
  34157. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34158. /**
  34159. * Defines how the individual parser contract is defined.
  34160. * These parser can parse an individual asset
  34161. */
  34162. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34163. /**
  34164. * Base class of the scene acting as a container for the different elements composing a scene.
  34165. * This class is dynamically extended by the different components of the scene increasing
  34166. * flexibility and reducing coupling
  34167. */
  34168. export abstract class AbstractScene {
  34169. /**
  34170. * Stores the list of available parsers in the application.
  34171. */
  34172. private static _BabylonFileParsers;
  34173. /**
  34174. * Stores the list of available individual parsers in the application.
  34175. */
  34176. private static _IndividualBabylonFileParsers;
  34177. /**
  34178. * Adds a parser in the list of available ones
  34179. * @param name Defines the name of the parser
  34180. * @param parser Defines the parser to add
  34181. */
  34182. static AddParser(name: string, parser: BabylonFileParser): void;
  34183. /**
  34184. * Gets a general parser from the list of avaialble ones
  34185. * @param name Defines the name of the parser
  34186. * @returns the requested parser or null
  34187. */
  34188. static GetParser(name: string): Nullable<BabylonFileParser>;
  34189. /**
  34190. * Adds n individual parser in the list of available ones
  34191. * @param name Defines the name of the parser
  34192. * @param parser Defines the parser to add
  34193. */
  34194. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34195. /**
  34196. * Gets an individual parser from the list of avaialble ones
  34197. * @param name Defines the name of the parser
  34198. * @returns the requested parser or null
  34199. */
  34200. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34201. /**
  34202. * Parser json data and populate both a scene and its associated container object
  34203. * @param jsonData Defines the data to parse
  34204. * @param scene Defines the scene to parse the data for
  34205. * @param container Defines the container attached to the parsing sequence
  34206. * @param rootUrl Defines the root url of the data
  34207. */
  34208. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34209. /**
  34210. * Gets the list of root nodes (ie. nodes with no parent)
  34211. */
  34212. rootNodes: Node[];
  34213. /** All of the cameras added to this scene
  34214. * @see http://doc.babylonjs.com/babylon101/cameras
  34215. */
  34216. cameras: Camera[];
  34217. /**
  34218. * All of the lights added to this scene
  34219. * @see http://doc.babylonjs.com/babylon101/lights
  34220. */
  34221. lights: Light[];
  34222. /**
  34223. * All of the (abstract) meshes added to this scene
  34224. */
  34225. meshes: AbstractMesh[];
  34226. /**
  34227. * The list of skeletons added to the scene
  34228. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34229. */
  34230. skeletons: Skeleton[];
  34231. /**
  34232. * All of the particle systems added to this scene
  34233. * @see http://doc.babylonjs.com/babylon101/particles
  34234. */
  34235. particleSystems: IParticleSystem[];
  34236. /**
  34237. * Gets a list of Animations associated with the scene
  34238. */
  34239. animations: Animation[];
  34240. /**
  34241. * All of the animation groups added to this scene
  34242. * @see http://doc.babylonjs.com/how_to/group
  34243. */
  34244. animationGroups: AnimationGroup[];
  34245. /**
  34246. * All of the multi-materials added to this scene
  34247. * @see http://doc.babylonjs.com/how_to/multi_materials
  34248. */
  34249. multiMaterials: MultiMaterial[];
  34250. /**
  34251. * All of the materials added to this scene
  34252. * In the context of a Scene, it is not supposed to be modified manually.
  34253. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34254. * Note also that the order of the Material wihin the array is not significant and might change.
  34255. * @see http://doc.babylonjs.com/babylon101/materials
  34256. */
  34257. materials: Material[];
  34258. /**
  34259. * The list of morph target managers added to the scene
  34260. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34261. */
  34262. morphTargetManagers: MorphTargetManager[];
  34263. /**
  34264. * The list of geometries used in the scene.
  34265. */
  34266. geometries: Geometry[];
  34267. /**
  34268. * All of the tranform nodes added to this scene
  34269. * In the context of a Scene, it is not supposed to be modified manually.
  34270. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34271. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34272. * @see http://doc.babylonjs.com/how_to/transformnode
  34273. */
  34274. transformNodes: TransformNode[];
  34275. /**
  34276. * ActionManagers available on the scene.
  34277. */
  34278. actionManagers: AbstractActionManager[];
  34279. /**
  34280. * Textures to keep.
  34281. */
  34282. textures: BaseTexture[];
  34283. /**
  34284. * Environment texture for the scene
  34285. */
  34286. environmentTexture: Nullable<BaseTexture>;
  34287. }
  34288. }
  34289. declare module BABYLON {
  34290. /**
  34291. * Interface used to define options for Sound class
  34292. */
  34293. export interface ISoundOptions {
  34294. /**
  34295. * Does the sound autoplay once loaded.
  34296. */
  34297. autoplay?: boolean;
  34298. /**
  34299. * Does the sound loop after it finishes playing once.
  34300. */
  34301. loop?: boolean;
  34302. /**
  34303. * Sound's volume
  34304. */
  34305. volume?: number;
  34306. /**
  34307. * Is it a spatial sound?
  34308. */
  34309. spatialSound?: boolean;
  34310. /**
  34311. * Maximum distance to hear that sound
  34312. */
  34313. maxDistance?: number;
  34314. /**
  34315. * Uses user defined attenuation function
  34316. */
  34317. useCustomAttenuation?: boolean;
  34318. /**
  34319. * Define the roll off factor of spatial sounds.
  34320. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34321. */
  34322. rolloffFactor?: number;
  34323. /**
  34324. * Define the reference distance the sound should be heard perfectly.
  34325. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34326. */
  34327. refDistance?: number;
  34328. /**
  34329. * Define the distance attenuation model the sound will follow.
  34330. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34331. */
  34332. distanceModel?: string;
  34333. /**
  34334. * Defines the playback speed (1 by default)
  34335. */
  34336. playbackRate?: number;
  34337. /**
  34338. * Defines if the sound is from a streaming source
  34339. */
  34340. streaming?: boolean;
  34341. /**
  34342. * Defines an optional length (in seconds) inside the sound file
  34343. */
  34344. length?: number;
  34345. /**
  34346. * Defines an optional offset (in seconds) inside the sound file
  34347. */
  34348. offset?: number;
  34349. /**
  34350. * If true, URLs will not be required to state the audio file codec to use.
  34351. */
  34352. skipCodecCheck?: boolean;
  34353. }
  34354. /**
  34355. * Defines a sound that can be played in the application.
  34356. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34358. */
  34359. export class Sound {
  34360. /**
  34361. * The name of the sound in the scene.
  34362. */
  34363. name: string;
  34364. /**
  34365. * Does the sound autoplay once loaded.
  34366. */
  34367. autoplay: boolean;
  34368. /**
  34369. * Does the sound loop after it finishes playing once.
  34370. */
  34371. loop: boolean;
  34372. /**
  34373. * Does the sound use a custom attenuation curve to simulate the falloff
  34374. * happening when the source gets further away from the camera.
  34375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34376. */
  34377. useCustomAttenuation: boolean;
  34378. /**
  34379. * The sound track id this sound belongs to.
  34380. */
  34381. soundTrackId: number;
  34382. /**
  34383. * Is this sound currently played.
  34384. */
  34385. isPlaying: boolean;
  34386. /**
  34387. * Is this sound currently paused.
  34388. */
  34389. isPaused: boolean;
  34390. /**
  34391. * Does this sound enables spatial sound.
  34392. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34393. */
  34394. spatialSound: boolean;
  34395. /**
  34396. * Define the reference distance the sound should be heard perfectly.
  34397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34398. */
  34399. refDistance: number;
  34400. /**
  34401. * Define the roll off factor of spatial sounds.
  34402. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34403. */
  34404. rolloffFactor: number;
  34405. /**
  34406. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34408. */
  34409. maxDistance: number;
  34410. /**
  34411. * Define the distance attenuation model the sound will follow.
  34412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34413. */
  34414. distanceModel: string;
  34415. /**
  34416. * @hidden
  34417. * Back Compat
  34418. **/
  34419. onended: () => any;
  34420. /**
  34421. * Observable event when the current playing sound finishes.
  34422. */
  34423. onEndedObservable: Observable<Sound>;
  34424. private _panningModel;
  34425. private _playbackRate;
  34426. private _streaming;
  34427. private _startTime;
  34428. private _startOffset;
  34429. private _position;
  34430. /** @hidden */
  34431. _positionInEmitterSpace: boolean;
  34432. private _localDirection;
  34433. private _volume;
  34434. private _isReadyToPlay;
  34435. private _isDirectional;
  34436. private _readyToPlayCallback;
  34437. private _audioBuffer;
  34438. private _soundSource;
  34439. private _streamingSource;
  34440. private _soundPanner;
  34441. private _soundGain;
  34442. private _inputAudioNode;
  34443. private _outputAudioNode;
  34444. private _coneInnerAngle;
  34445. private _coneOuterAngle;
  34446. private _coneOuterGain;
  34447. private _scene;
  34448. private _connectedTransformNode;
  34449. private _customAttenuationFunction;
  34450. private _registerFunc;
  34451. private _isOutputConnected;
  34452. private _htmlAudioElement;
  34453. private _urlType;
  34454. private _length?;
  34455. private _offset?;
  34456. /** @hidden */
  34457. static _SceneComponentInitialization: (scene: Scene) => void;
  34458. /**
  34459. * Create a sound and attach it to a scene
  34460. * @param name Name of your sound
  34461. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34462. * @param scene defines the scene the sound belongs to
  34463. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34464. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34465. */
  34466. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34467. /**
  34468. * Release the sound and its associated resources
  34469. */
  34470. dispose(): void;
  34471. /**
  34472. * Gets if the sounds is ready to be played or not.
  34473. * @returns true if ready, otherwise false
  34474. */
  34475. isReady(): boolean;
  34476. private _soundLoaded;
  34477. /**
  34478. * Sets the data of the sound from an audiobuffer
  34479. * @param audioBuffer The audioBuffer containing the data
  34480. */
  34481. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34482. /**
  34483. * Updates the current sounds options such as maxdistance, loop...
  34484. * @param options A JSON object containing values named as the object properties
  34485. */
  34486. updateOptions(options: ISoundOptions): void;
  34487. private _createSpatialParameters;
  34488. private _updateSpatialParameters;
  34489. /**
  34490. * Switch the panning model to HRTF:
  34491. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34493. */
  34494. switchPanningModelToHRTF(): void;
  34495. /**
  34496. * Switch the panning model to Equal Power:
  34497. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34499. */
  34500. switchPanningModelToEqualPower(): void;
  34501. private _switchPanningModel;
  34502. /**
  34503. * Connect this sound to a sound track audio node like gain...
  34504. * @param soundTrackAudioNode the sound track audio node to connect to
  34505. */
  34506. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34507. /**
  34508. * Transform this sound into a directional source
  34509. * @param coneInnerAngle Size of the inner cone in degree
  34510. * @param coneOuterAngle Size of the outer cone in degree
  34511. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34512. */
  34513. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34514. /**
  34515. * Gets or sets the inner angle for the directional cone.
  34516. */
  34517. /**
  34518. * Gets or sets the inner angle for the directional cone.
  34519. */
  34520. directionalConeInnerAngle: number;
  34521. /**
  34522. * Gets or sets the outer angle for the directional cone.
  34523. */
  34524. /**
  34525. * Gets or sets the outer angle for the directional cone.
  34526. */
  34527. directionalConeOuterAngle: number;
  34528. /**
  34529. * Sets the position of the emitter if spatial sound is enabled
  34530. * @param newPosition Defines the new posisiton
  34531. */
  34532. setPosition(newPosition: Vector3): void;
  34533. /**
  34534. * Sets the local direction of the emitter if spatial sound is enabled
  34535. * @param newLocalDirection Defines the new local direction
  34536. */
  34537. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34538. private _updateDirection;
  34539. /** @hidden */
  34540. updateDistanceFromListener(): void;
  34541. /**
  34542. * Sets a new custom attenuation function for the sound.
  34543. * @param callback Defines the function used for the attenuation
  34544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34545. */
  34546. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34547. /**
  34548. * Play the sound
  34549. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34550. * @param offset (optional) Start the sound at a specific time in seconds
  34551. * @param length (optional) Sound duration (in seconds)
  34552. */
  34553. play(time?: number, offset?: number, length?: number): void;
  34554. private _onended;
  34555. /**
  34556. * Stop the sound
  34557. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34558. */
  34559. stop(time?: number): void;
  34560. /**
  34561. * Put the sound in pause
  34562. */
  34563. pause(): void;
  34564. /**
  34565. * Sets a dedicated volume for this sounds
  34566. * @param newVolume Define the new volume of the sound
  34567. * @param time Define time for gradual change to new volume
  34568. */
  34569. setVolume(newVolume: number, time?: number): void;
  34570. /**
  34571. * Set the sound play back rate
  34572. * @param newPlaybackRate Define the playback rate the sound should be played at
  34573. */
  34574. setPlaybackRate(newPlaybackRate: number): void;
  34575. /**
  34576. * Gets the volume of the sound.
  34577. * @returns the volume of the sound
  34578. */
  34579. getVolume(): number;
  34580. /**
  34581. * Attach the sound to a dedicated mesh
  34582. * @param transformNode The transform node to connect the sound with
  34583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34584. */
  34585. attachToMesh(transformNode: TransformNode): void;
  34586. /**
  34587. * Detach the sound from the previously attached mesh
  34588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34589. */
  34590. detachFromMesh(): void;
  34591. private _onRegisterAfterWorldMatrixUpdate;
  34592. /**
  34593. * Clone the current sound in the scene.
  34594. * @returns the new sound clone
  34595. */
  34596. clone(): Nullable<Sound>;
  34597. /**
  34598. * Gets the current underlying audio buffer containing the data
  34599. * @returns the audio buffer
  34600. */
  34601. getAudioBuffer(): Nullable<AudioBuffer>;
  34602. /**
  34603. * Serializes the Sound in a JSON representation
  34604. * @returns the JSON representation of the sound
  34605. */
  34606. serialize(): any;
  34607. /**
  34608. * Parse a JSON representation of a sound to innstantiate in a given scene
  34609. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34610. * @param scene Define the scene the new parsed sound should be created in
  34611. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34612. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34613. * @returns the newly parsed sound
  34614. */
  34615. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34616. }
  34617. }
  34618. declare module BABYLON {
  34619. /**
  34620. * This defines an action helpful to play a defined sound on a triggered action.
  34621. */
  34622. export class PlaySoundAction extends Action {
  34623. private _sound;
  34624. /**
  34625. * Instantiate the action
  34626. * @param triggerOptions defines the trigger options
  34627. * @param sound defines the sound to play
  34628. * @param condition defines the trigger related conditions
  34629. */
  34630. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34631. /** @hidden */
  34632. _prepare(): void;
  34633. /**
  34634. * Execute the action and play the sound.
  34635. */
  34636. execute(): void;
  34637. /**
  34638. * Serializes the actions and its related information.
  34639. * @param parent defines the object to serialize in
  34640. * @returns the serialized object
  34641. */
  34642. serialize(parent: any): any;
  34643. }
  34644. /**
  34645. * This defines an action helpful to stop a defined sound on a triggered action.
  34646. */
  34647. export class StopSoundAction extends Action {
  34648. private _sound;
  34649. /**
  34650. * Instantiate the action
  34651. * @param triggerOptions defines the trigger options
  34652. * @param sound defines the sound to stop
  34653. * @param condition defines the trigger related conditions
  34654. */
  34655. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34656. /** @hidden */
  34657. _prepare(): void;
  34658. /**
  34659. * Execute the action and stop the sound.
  34660. */
  34661. execute(): void;
  34662. /**
  34663. * Serializes the actions and its related information.
  34664. * @param parent defines the object to serialize in
  34665. * @returns the serialized object
  34666. */
  34667. serialize(parent: any): any;
  34668. }
  34669. }
  34670. declare module BABYLON {
  34671. /**
  34672. * This defines an action responsible to change the value of a property
  34673. * by interpolating between its current value and the newly set one once triggered.
  34674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34675. */
  34676. export class InterpolateValueAction extends Action {
  34677. /**
  34678. * Defines the path of the property where the value should be interpolated
  34679. */
  34680. propertyPath: string;
  34681. /**
  34682. * Defines the target value at the end of the interpolation.
  34683. */
  34684. value: any;
  34685. /**
  34686. * Defines the time it will take for the property to interpolate to the value.
  34687. */
  34688. duration: number;
  34689. /**
  34690. * Defines if the other scene animations should be stopped when the action has been triggered
  34691. */
  34692. stopOtherAnimations?: boolean;
  34693. /**
  34694. * Defines a callback raised once the interpolation animation has been done.
  34695. */
  34696. onInterpolationDone?: () => void;
  34697. /**
  34698. * Observable triggered once the interpolation animation has been done.
  34699. */
  34700. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34701. private _target;
  34702. private _effectiveTarget;
  34703. private _property;
  34704. /**
  34705. * Instantiate the action
  34706. * @param triggerOptions defines the trigger options
  34707. * @param target defines the object containing the value to interpolate
  34708. * @param propertyPath defines the path to the property in the target object
  34709. * @param value defines the target value at the end of the interpolation
  34710. * @param duration deines the time it will take for the property to interpolate to the value.
  34711. * @param condition defines the trigger related conditions
  34712. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34713. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34714. */
  34715. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34716. /** @hidden */
  34717. _prepare(): void;
  34718. /**
  34719. * Execute the action starts the value interpolation.
  34720. */
  34721. execute(): void;
  34722. /**
  34723. * Serializes the actions and its related information.
  34724. * @param parent defines the object to serialize in
  34725. * @returns the serialized object
  34726. */
  34727. serialize(parent: any): any;
  34728. }
  34729. }
  34730. declare module BABYLON {
  34731. /**
  34732. * Options allowed during the creation of a sound track.
  34733. */
  34734. export interface ISoundTrackOptions {
  34735. /**
  34736. * The volume the sound track should take during creation
  34737. */
  34738. volume?: number;
  34739. /**
  34740. * Define if the sound track is the main sound track of the scene
  34741. */
  34742. mainTrack?: boolean;
  34743. }
  34744. /**
  34745. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34746. * It will be also used in a future release to apply effects on a specific track.
  34747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34748. */
  34749. export class SoundTrack {
  34750. /**
  34751. * The unique identifier of the sound track in the scene.
  34752. */
  34753. id: number;
  34754. /**
  34755. * The list of sounds included in the sound track.
  34756. */
  34757. soundCollection: Array<Sound>;
  34758. private _outputAudioNode;
  34759. private _scene;
  34760. private _isMainTrack;
  34761. private _connectedAnalyser;
  34762. private _options;
  34763. private _isInitialized;
  34764. /**
  34765. * Creates a new sound track.
  34766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34767. * @param scene Define the scene the sound track belongs to
  34768. * @param options
  34769. */
  34770. constructor(scene: Scene, options?: ISoundTrackOptions);
  34771. private _initializeSoundTrackAudioGraph;
  34772. /**
  34773. * Release the sound track and its associated resources
  34774. */
  34775. dispose(): void;
  34776. /**
  34777. * Adds a sound to this sound track
  34778. * @param sound define the cound to add
  34779. * @ignoreNaming
  34780. */
  34781. AddSound(sound: Sound): void;
  34782. /**
  34783. * Removes a sound to this sound track
  34784. * @param sound define the cound to remove
  34785. * @ignoreNaming
  34786. */
  34787. RemoveSound(sound: Sound): void;
  34788. /**
  34789. * Set a global volume for the full sound track.
  34790. * @param newVolume Define the new volume of the sound track
  34791. */
  34792. setVolume(newVolume: number): void;
  34793. /**
  34794. * Switch the panning model to HRTF:
  34795. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34797. */
  34798. switchPanningModelToHRTF(): void;
  34799. /**
  34800. * Switch the panning model to Equal Power:
  34801. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34803. */
  34804. switchPanningModelToEqualPower(): void;
  34805. /**
  34806. * Connect the sound track to an audio analyser allowing some amazing
  34807. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34809. * @param analyser The analyser to connect to the engine
  34810. */
  34811. connectToAnalyser(analyser: Analyser): void;
  34812. }
  34813. }
  34814. declare module BABYLON {
  34815. interface AbstractScene {
  34816. /**
  34817. * The list of sounds used in the scene.
  34818. */
  34819. sounds: Nullable<Array<Sound>>;
  34820. }
  34821. interface Scene {
  34822. /**
  34823. * @hidden
  34824. * Backing field
  34825. */
  34826. _mainSoundTrack: SoundTrack;
  34827. /**
  34828. * The main sound track played by the scene.
  34829. * It cotains your primary collection of sounds.
  34830. */
  34831. mainSoundTrack: SoundTrack;
  34832. /**
  34833. * The list of sound tracks added to the scene
  34834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34835. */
  34836. soundTracks: Nullable<Array<SoundTrack>>;
  34837. /**
  34838. * Gets a sound using a given name
  34839. * @param name defines the name to search for
  34840. * @return the found sound or null if not found at all.
  34841. */
  34842. getSoundByName(name: string): Nullable<Sound>;
  34843. /**
  34844. * Gets or sets if audio support is enabled
  34845. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34846. */
  34847. audioEnabled: boolean;
  34848. /**
  34849. * Gets or sets if audio will be output to headphones
  34850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34851. */
  34852. headphone: boolean;
  34853. }
  34854. /**
  34855. * Defines the sound scene component responsible to manage any sounds
  34856. * in a given scene.
  34857. */
  34858. export class AudioSceneComponent implements ISceneSerializableComponent {
  34859. /**
  34860. * The component name helpfull to identify the component in the list of scene components.
  34861. */
  34862. readonly name: string;
  34863. /**
  34864. * The scene the component belongs to.
  34865. */
  34866. scene: Scene;
  34867. private _audioEnabled;
  34868. /**
  34869. * Gets whether audio is enabled or not.
  34870. * Please use related enable/disable method to switch state.
  34871. */
  34872. readonly audioEnabled: boolean;
  34873. private _headphone;
  34874. /**
  34875. * Gets whether audio is outputing to headphone or not.
  34876. * Please use the according Switch methods to change output.
  34877. */
  34878. readonly headphone: boolean;
  34879. /**
  34880. * Creates a new instance of the component for the given scene
  34881. * @param scene Defines the scene to register the component in
  34882. */
  34883. constructor(scene: Scene);
  34884. /**
  34885. * Registers the component in a given scene
  34886. */
  34887. register(): void;
  34888. /**
  34889. * Rebuilds the elements related to this component in case of
  34890. * context lost for instance.
  34891. */
  34892. rebuild(): void;
  34893. /**
  34894. * Serializes the component data to the specified json object
  34895. * @param serializationObject The object to serialize to
  34896. */
  34897. serialize(serializationObject: any): void;
  34898. /**
  34899. * Adds all the elements from the container to the scene
  34900. * @param container the container holding the elements
  34901. */
  34902. addFromContainer(container: AbstractScene): void;
  34903. /**
  34904. * Removes all the elements in the container from the scene
  34905. * @param container contains the elements to remove
  34906. * @param dispose if the removed element should be disposed (default: false)
  34907. */
  34908. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34909. /**
  34910. * Disposes the component and the associated ressources.
  34911. */
  34912. dispose(): void;
  34913. /**
  34914. * Disables audio in the associated scene.
  34915. */
  34916. disableAudio(): void;
  34917. /**
  34918. * Enables audio in the associated scene.
  34919. */
  34920. enableAudio(): void;
  34921. /**
  34922. * Switch audio to headphone output.
  34923. */
  34924. switchAudioModeForHeadphones(): void;
  34925. /**
  34926. * Switch audio to normal speakers.
  34927. */
  34928. switchAudioModeForNormalSpeakers(): void;
  34929. private _afterRender;
  34930. }
  34931. }
  34932. declare module BABYLON {
  34933. /**
  34934. * Wraps one or more Sound objects and selects one with random weight for playback.
  34935. */
  34936. export class WeightedSound {
  34937. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34938. loop: boolean;
  34939. private _coneInnerAngle;
  34940. private _coneOuterAngle;
  34941. private _volume;
  34942. /** A Sound is currently playing. */
  34943. isPlaying: boolean;
  34944. /** A Sound is currently paused. */
  34945. isPaused: boolean;
  34946. private _sounds;
  34947. private _weights;
  34948. private _currentIndex?;
  34949. /**
  34950. * Creates a new WeightedSound from the list of sounds given.
  34951. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34952. * @param sounds Array of Sounds that will be selected from.
  34953. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34954. */
  34955. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34956. /**
  34957. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34958. */
  34959. /**
  34960. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34961. */
  34962. directionalConeInnerAngle: number;
  34963. /**
  34964. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34965. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34966. */
  34967. /**
  34968. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34969. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34970. */
  34971. directionalConeOuterAngle: number;
  34972. /**
  34973. * Playback volume.
  34974. */
  34975. /**
  34976. * Playback volume.
  34977. */
  34978. volume: number;
  34979. private _onended;
  34980. /**
  34981. * Suspend playback
  34982. */
  34983. pause(): void;
  34984. /**
  34985. * Stop playback
  34986. */
  34987. stop(): void;
  34988. /**
  34989. * Start playback.
  34990. * @param startOffset Position the clip head at a specific time in seconds.
  34991. */
  34992. play(startOffset?: number): void;
  34993. }
  34994. }
  34995. declare module BABYLON {
  34996. /**
  34997. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34998. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34999. */
  35000. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35001. /**
  35002. * Gets the name of the behavior.
  35003. */
  35004. readonly name: string;
  35005. /**
  35006. * The easing function used by animations
  35007. */
  35008. static EasingFunction: BackEase;
  35009. /**
  35010. * The easing mode used by animations
  35011. */
  35012. static EasingMode: number;
  35013. /**
  35014. * The duration of the animation, in milliseconds
  35015. */
  35016. transitionDuration: number;
  35017. /**
  35018. * Length of the distance animated by the transition when lower radius is reached
  35019. */
  35020. lowerRadiusTransitionRange: number;
  35021. /**
  35022. * Length of the distance animated by the transition when upper radius is reached
  35023. */
  35024. upperRadiusTransitionRange: number;
  35025. private _autoTransitionRange;
  35026. /**
  35027. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35028. */
  35029. /**
  35030. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35031. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35032. */
  35033. autoTransitionRange: boolean;
  35034. private _attachedCamera;
  35035. private _onAfterCheckInputsObserver;
  35036. private _onMeshTargetChangedObserver;
  35037. /**
  35038. * Initializes the behavior.
  35039. */
  35040. init(): void;
  35041. /**
  35042. * Attaches the behavior to its arc rotate camera.
  35043. * @param camera Defines the camera to attach the behavior to
  35044. */
  35045. attach(camera: ArcRotateCamera): void;
  35046. /**
  35047. * Detaches the behavior from its current arc rotate camera.
  35048. */
  35049. detach(): void;
  35050. private _radiusIsAnimating;
  35051. private _radiusBounceTransition;
  35052. private _animatables;
  35053. private _cachedWheelPrecision;
  35054. /**
  35055. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35056. * @param radiusLimit The limit to check against.
  35057. * @return Bool to indicate if at limit.
  35058. */
  35059. private _isRadiusAtLimit;
  35060. /**
  35061. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35062. * @param radiusDelta The delta by which to animate to. Can be negative.
  35063. */
  35064. private _applyBoundRadiusAnimation;
  35065. /**
  35066. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35067. */
  35068. protected _clearAnimationLocks(): void;
  35069. /**
  35070. * Stops and removes all animations that have been applied to the camera
  35071. */
  35072. stopAllAnimations(): void;
  35073. }
  35074. }
  35075. declare module BABYLON {
  35076. /**
  35077. * 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.
  35078. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35079. */
  35080. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35081. /**
  35082. * Gets the name of the behavior.
  35083. */
  35084. readonly name: string;
  35085. private _mode;
  35086. private _radiusScale;
  35087. private _positionScale;
  35088. private _defaultElevation;
  35089. private _elevationReturnTime;
  35090. private _elevationReturnWaitTime;
  35091. private _zoomStopsAnimation;
  35092. private _framingTime;
  35093. /**
  35094. * The easing function used by animations
  35095. */
  35096. static EasingFunction: ExponentialEase;
  35097. /**
  35098. * The easing mode used by animations
  35099. */
  35100. static EasingMode: number;
  35101. /**
  35102. * Sets the current mode used by the behavior
  35103. */
  35104. /**
  35105. * Gets current mode used by the behavior.
  35106. */
  35107. mode: number;
  35108. /**
  35109. * Sets the scale applied to the radius (1 by default)
  35110. */
  35111. /**
  35112. * Gets the scale applied to the radius
  35113. */
  35114. radiusScale: number;
  35115. /**
  35116. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35117. */
  35118. /**
  35119. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35120. */
  35121. positionScale: number;
  35122. /**
  35123. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35124. * behaviour is triggered, in radians.
  35125. */
  35126. /**
  35127. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35128. * behaviour is triggered, in radians.
  35129. */
  35130. defaultElevation: number;
  35131. /**
  35132. * Sets the time (in milliseconds) taken to return to the default beta position.
  35133. * Negative value indicates camera should not return to default.
  35134. */
  35135. /**
  35136. * Gets the time (in milliseconds) taken to return to the default beta position.
  35137. * Negative value indicates camera should not return to default.
  35138. */
  35139. elevationReturnTime: number;
  35140. /**
  35141. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35142. */
  35143. /**
  35144. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35145. */
  35146. elevationReturnWaitTime: number;
  35147. /**
  35148. * Sets the flag that indicates if user zooming should stop animation.
  35149. */
  35150. /**
  35151. * Gets the flag that indicates if user zooming should stop animation.
  35152. */
  35153. zoomStopsAnimation: boolean;
  35154. /**
  35155. * Sets the transition time when framing the mesh, in milliseconds
  35156. */
  35157. /**
  35158. * Gets the transition time when framing the mesh, in milliseconds
  35159. */
  35160. framingTime: number;
  35161. /**
  35162. * Define if the behavior should automatically change the configured
  35163. * camera limits and sensibilities.
  35164. */
  35165. autoCorrectCameraLimitsAndSensibility: boolean;
  35166. private _onPrePointerObservableObserver;
  35167. private _onAfterCheckInputsObserver;
  35168. private _onMeshTargetChangedObserver;
  35169. private _attachedCamera;
  35170. private _isPointerDown;
  35171. private _lastInteractionTime;
  35172. /**
  35173. * Initializes the behavior.
  35174. */
  35175. init(): void;
  35176. /**
  35177. * Attaches the behavior to its arc rotate camera.
  35178. * @param camera Defines the camera to attach the behavior to
  35179. */
  35180. attach(camera: ArcRotateCamera): void;
  35181. /**
  35182. * Detaches the behavior from its current arc rotate camera.
  35183. */
  35184. detach(): void;
  35185. private _animatables;
  35186. private _betaIsAnimating;
  35187. private _betaTransition;
  35188. private _radiusTransition;
  35189. private _vectorTransition;
  35190. /**
  35191. * Targets the given mesh and updates zoom level accordingly.
  35192. * @param mesh The mesh to target.
  35193. * @param radius Optional. If a cached radius position already exists, overrides default.
  35194. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35195. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35196. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35197. */
  35198. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35199. /**
  35200. * Targets the given mesh with its children and updates zoom level accordingly.
  35201. * @param mesh The mesh to target.
  35202. * @param radius Optional. If a cached radius position already exists, overrides default.
  35203. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35204. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35205. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35206. */
  35207. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35208. /**
  35209. * Targets the given meshes with their children and updates zoom level accordingly.
  35210. * @param meshes The mesh to target.
  35211. * @param radius Optional. If a cached radius position already exists, overrides default.
  35212. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35213. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35214. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35215. */
  35216. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35217. /**
  35218. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35219. * @param minimumWorld Determines the smaller position of the bounding box extend
  35220. * @param maximumWorld Determines the bigger position of the bounding box extend
  35221. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35222. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35223. */
  35224. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35225. /**
  35226. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35227. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35228. * frustum width.
  35229. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35230. * to fully enclose the mesh in the viewing frustum.
  35231. */
  35232. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35233. /**
  35234. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35235. * is automatically returned to its default position (expected to be above ground plane).
  35236. */
  35237. private _maintainCameraAboveGround;
  35238. /**
  35239. * Returns the frustum slope based on the canvas ratio and camera FOV
  35240. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35241. */
  35242. private _getFrustumSlope;
  35243. /**
  35244. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35245. */
  35246. private _clearAnimationLocks;
  35247. /**
  35248. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35249. */
  35250. private _applyUserInteraction;
  35251. /**
  35252. * Stops and removes all animations that have been applied to the camera
  35253. */
  35254. stopAllAnimations(): void;
  35255. /**
  35256. * Gets a value indicating if the user is moving the camera
  35257. */
  35258. readonly isUserIsMoving: boolean;
  35259. /**
  35260. * The camera can move all the way towards the mesh.
  35261. */
  35262. static IgnoreBoundsSizeMode: number;
  35263. /**
  35264. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35265. */
  35266. static FitFrustumSidesMode: number;
  35267. }
  35268. }
  35269. declare module BABYLON {
  35270. /**
  35271. * Base class for Camera Pointer Inputs.
  35272. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35273. * for example usage.
  35274. */
  35275. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35276. /**
  35277. * Defines the camera the input is attached to.
  35278. */
  35279. abstract camera: Camera;
  35280. /**
  35281. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35282. */
  35283. protected _altKey: boolean;
  35284. protected _ctrlKey: boolean;
  35285. protected _metaKey: boolean;
  35286. protected _shiftKey: boolean;
  35287. /**
  35288. * Which mouse buttons were pressed at time of last mouse event.
  35289. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35290. */
  35291. protected _buttonsPressed: number;
  35292. /**
  35293. * Defines the buttons associated with the input to handle camera move.
  35294. */
  35295. buttons: number[];
  35296. /**
  35297. * Attach the input controls to a specific dom element to get the input from.
  35298. * @param element Defines the element the controls should be listened from
  35299. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35300. */
  35301. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35302. /**
  35303. * Detach the current controls from the specified dom element.
  35304. * @param element Defines the element to stop listening the inputs from
  35305. */
  35306. detachControl(element: Nullable<HTMLElement>): void;
  35307. /**
  35308. * Gets the class name of the current input.
  35309. * @returns the class name
  35310. */
  35311. getClassName(): string;
  35312. /**
  35313. * Get the friendly name associated with the input class.
  35314. * @returns the input friendly name
  35315. */
  35316. getSimpleName(): string;
  35317. /**
  35318. * Called on pointer POINTERDOUBLETAP event.
  35319. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35320. */
  35321. protected onDoubleTap(type: string): void;
  35322. /**
  35323. * Called on pointer POINTERMOVE event if only a single touch is active.
  35324. * Override this method to provide functionality.
  35325. */
  35326. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35327. /**
  35328. * Called on pointer POINTERMOVE event if multiple touches are active.
  35329. * Override this method to provide functionality.
  35330. */
  35331. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35332. /**
  35333. * Called on JS contextmenu event.
  35334. * Override this method to provide functionality.
  35335. */
  35336. protected onContextMenu(evt: PointerEvent): void;
  35337. /**
  35338. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35339. * press.
  35340. * Override this method to provide functionality.
  35341. */
  35342. protected onButtonDown(evt: PointerEvent): void;
  35343. /**
  35344. * Called each time a new POINTERUP event occurs. Ie, for each button
  35345. * release.
  35346. * Override this method to provide functionality.
  35347. */
  35348. protected onButtonUp(evt: PointerEvent): void;
  35349. /**
  35350. * Called when window becomes inactive.
  35351. * Override this method to provide functionality.
  35352. */
  35353. protected onLostFocus(): void;
  35354. private _pointerInput;
  35355. private _observer;
  35356. private _onLostFocus;
  35357. private pointA;
  35358. private pointB;
  35359. }
  35360. }
  35361. declare module BABYLON {
  35362. /**
  35363. * Manage the pointers inputs to control an arc rotate camera.
  35364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35365. */
  35366. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35367. /**
  35368. * Defines the camera the input is attached to.
  35369. */
  35370. camera: ArcRotateCamera;
  35371. /**
  35372. * Gets the class name of the current input.
  35373. * @returns the class name
  35374. */
  35375. getClassName(): string;
  35376. /**
  35377. * Defines the buttons associated with the input to handle camera move.
  35378. */
  35379. buttons: number[];
  35380. /**
  35381. * Defines the pointer angular sensibility along the X axis or how fast is
  35382. * the camera rotating.
  35383. */
  35384. angularSensibilityX: number;
  35385. /**
  35386. * Defines the pointer angular sensibility along the Y axis or how fast is
  35387. * the camera rotating.
  35388. */
  35389. angularSensibilityY: number;
  35390. /**
  35391. * Defines the pointer pinch precision or how fast is the camera zooming.
  35392. */
  35393. pinchPrecision: number;
  35394. /**
  35395. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35396. * from 0.
  35397. * It defines the percentage of current camera.radius to use as delta when
  35398. * pinch zoom is used.
  35399. */
  35400. pinchDeltaPercentage: number;
  35401. /**
  35402. * Defines the pointer panning sensibility or how fast is the camera moving.
  35403. */
  35404. panningSensibility: number;
  35405. /**
  35406. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35407. */
  35408. multiTouchPanning: boolean;
  35409. /**
  35410. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35411. * zoom (pinch) through multitouch.
  35412. */
  35413. multiTouchPanAndZoom: boolean;
  35414. /**
  35415. * Revers pinch action direction.
  35416. */
  35417. pinchInwards: boolean;
  35418. private _isPanClick;
  35419. private _twoFingerActivityCount;
  35420. private _isPinching;
  35421. /**
  35422. * Called on pointer POINTERMOVE event if only a single touch is active.
  35423. */
  35424. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35425. /**
  35426. * Called on pointer POINTERDOUBLETAP event.
  35427. */
  35428. protected onDoubleTap(type: string): void;
  35429. /**
  35430. * Called on pointer POINTERMOVE event if multiple touches are active.
  35431. */
  35432. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35433. /**
  35434. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35435. * press.
  35436. */
  35437. protected onButtonDown(evt: PointerEvent): void;
  35438. /**
  35439. * Called each time a new POINTERUP event occurs. Ie, for each button
  35440. * release.
  35441. */
  35442. protected onButtonUp(evt: PointerEvent): void;
  35443. /**
  35444. * Called when window becomes inactive.
  35445. */
  35446. protected onLostFocus(): void;
  35447. }
  35448. }
  35449. declare module BABYLON {
  35450. /**
  35451. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35453. */
  35454. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35455. /**
  35456. * Defines the camera the input is attached to.
  35457. */
  35458. camera: ArcRotateCamera;
  35459. /**
  35460. * Defines the list of key codes associated with the up action (increase alpha)
  35461. */
  35462. keysUp: number[];
  35463. /**
  35464. * Defines the list of key codes associated with the down action (decrease alpha)
  35465. */
  35466. keysDown: number[];
  35467. /**
  35468. * Defines the list of key codes associated with the left action (increase beta)
  35469. */
  35470. keysLeft: number[];
  35471. /**
  35472. * Defines the list of key codes associated with the right action (decrease beta)
  35473. */
  35474. keysRight: number[];
  35475. /**
  35476. * Defines the list of key codes associated with the reset action.
  35477. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35478. */
  35479. keysReset: number[];
  35480. /**
  35481. * Defines the panning sensibility of the inputs.
  35482. * (How fast is the camera paning)
  35483. */
  35484. panningSensibility: number;
  35485. /**
  35486. * Defines the zooming sensibility of the inputs.
  35487. * (How fast is the camera zooming)
  35488. */
  35489. zoomingSensibility: number;
  35490. /**
  35491. * Defines wether maintaining the alt key down switch the movement mode from
  35492. * orientation to zoom.
  35493. */
  35494. useAltToZoom: boolean;
  35495. /**
  35496. * Rotation speed of the camera
  35497. */
  35498. angularSpeed: number;
  35499. private _keys;
  35500. private _ctrlPressed;
  35501. private _altPressed;
  35502. private _onCanvasBlurObserver;
  35503. private _onKeyboardObserver;
  35504. private _engine;
  35505. private _scene;
  35506. /**
  35507. * Attach the input controls to a specific dom element to get the input from.
  35508. * @param element Defines the element the controls should be listened from
  35509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35510. */
  35511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35512. /**
  35513. * Detach the current controls from the specified dom element.
  35514. * @param element Defines the element to stop listening the inputs from
  35515. */
  35516. detachControl(element: Nullable<HTMLElement>): void;
  35517. /**
  35518. * Update the current camera state depending on the inputs that have been used this frame.
  35519. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35520. */
  35521. checkInputs(): void;
  35522. /**
  35523. * Gets the class name of the current intput.
  35524. * @returns the class name
  35525. */
  35526. getClassName(): string;
  35527. /**
  35528. * Get the friendly name associated with the input class.
  35529. * @returns the input friendly name
  35530. */
  35531. getSimpleName(): string;
  35532. }
  35533. }
  35534. declare module BABYLON {
  35535. /**
  35536. * Manage the mouse wheel inputs to control an arc rotate camera.
  35537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35538. */
  35539. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35540. /**
  35541. * Defines the camera the input is attached to.
  35542. */
  35543. camera: ArcRotateCamera;
  35544. /**
  35545. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35546. */
  35547. wheelPrecision: number;
  35548. /**
  35549. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35550. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35551. */
  35552. wheelDeltaPercentage: number;
  35553. private _wheel;
  35554. private _observer;
  35555. private computeDeltaFromMouseWheelLegacyEvent;
  35556. /**
  35557. * Attach the input controls to a specific dom element to get the input from.
  35558. * @param element Defines the element the controls should be listened from
  35559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35560. */
  35561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35562. /**
  35563. * Detach the current controls from the specified dom element.
  35564. * @param element Defines the element to stop listening the inputs from
  35565. */
  35566. detachControl(element: Nullable<HTMLElement>): void;
  35567. /**
  35568. * Gets the class name of the current intput.
  35569. * @returns the class name
  35570. */
  35571. getClassName(): string;
  35572. /**
  35573. * Get the friendly name associated with the input class.
  35574. * @returns the input friendly name
  35575. */
  35576. getSimpleName(): string;
  35577. }
  35578. }
  35579. declare module BABYLON {
  35580. /**
  35581. * Default Inputs manager for the ArcRotateCamera.
  35582. * It groups all the default supported inputs for ease of use.
  35583. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35584. */
  35585. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35586. /**
  35587. * Instantiates a new ArcRotateCameraInputsManager.
  35588. * @param camera Defines the camera the inputs belong to
  35589. */
  35590. constructor(camera: ArcRotateCamera);
  35591. /**
  35592. * Add mouse wheel input support to the input manager.
  35593. * @returns the current input manager
  35594. */
  35595. addMouseWheel(): ArcRotateCameraInputsManager;
  35596. /**
  35597. * Add pointers input support to the input manager.
  35598. * @returns the current input manager
  35599. */
  35600. addPointers(): ArcRotateCameraInputsManager;
  35601. /**
  35602. * Add keyboard input support to the input manager.
  35603. * @returns the current input manager
  35604. */
  35605. addKeyboard(): ArcRotateCameraInputsManager;
  35606. }
  35607. }
  35608. declare module BABYLON {
  35609. /**
  35610. * This represents an orbital type of camera.
  35611. *
  35612. * 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.
  35613. * 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.
  35614. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35615. */
  35616. export class ArcRotateCamera extends TargetCamera {
  35617. /**
  35618. * Defines the rotation angle of the camera along the longitudinal axis.
  35619. */
  35620. alpha: number;
  35621. /**
  35622. * Defines the rotation angle of the camera along the latitudinal axis.
  35623. */
  35624. beta: number;
  35625. /**
  35626. * Defines the radius of the camera from it s target point.
  35627. */
  35628. radius: number;
  35629. protected _target: Vector3;
  35630. protected _targetHost: Nullable<AbstractMesh>;
  35631. /**
  35632. * Defines the target point of the camera.
  35633. * The camera looks towards it form the radius distance.
  35634. */
  35635. target: Vector3;
  35636. /**
  35637. * Define the current local position of the camera in the scene
  35638. */
  35639. position: Vector3;
  35640. protected _upVector: Vector3;
  35641. protected _upToYMatrix: Matrix;
  35642. protected _YToUpMatrix: Matrix;
  35643. /**
  35644. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35645. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35646. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35647. */
  35648. upVector: Vector3;
  35649. /**
  35650. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35651. */
  35652. setMatUp(): void;
  35653. /**
  35654. * Current inertia value on the longitudinal axis.
  35655. * The bigger this number the longer it will take for the camera to stop.
  35656. */
  35657. inertialAlphaOffset: number;
  35658. /**
  35659. * Current inertia value on the latitudinal axis.
  35660. * The bigger this number the longer it will take for the camera to stop.
  35661. */
  35662. inertialBetaOffset: number;
  35663. /**
  35664. * Current inertia value on the radius axis.
  35665. * The bigger this number the longer it will take for the camera to stop.
  35666. */
  35667. inertialRadiusOffset: number;
  35668. /**
  35669. * Minimum allowed angle on the longitudinal axis.
  35670. * This can help limiting how the Camera is able to move in the scene.
  35671. */
  35672. lowerAlphaLimit: Nullable<number>;
  35673. /**
  35674. * Maximum allowed angle on the longitudinal axis.
  35675. * This can help limiting how the Camera is able to move in the scene.
  35676. */
  35677. upperAlphaLimit: Nullable<number>;
  35678. /**
  35679. * Minimum allowed angle on the latitudinal axis.
  35680. * This can help limiting how the Camera is able to move in the scene.
  35681. */
  35682. lowerBetaLimit: number;
  35683. /**
  35684. * Maximum allowed angle on the latitudinal axis.
  35685. * This can help limiting how the Camera is able to move in the scene.
  35686. */
  35687. upperBetaLimit: number;
  35688. /**
  35689. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35690. * This can help limiting how the Camera is able to move in the scene.
  35691. */
  35692. lowerRadiusLimit: Nullable<number>;
  35693. /**
  35694. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35695. * This can help limiting how the Camera is able to move in the scene.
  35696. */
  35697. upperRadiusLimit: Nullable<number>;
  35698. /**
  35699. * Defines the current inertia value used during panning of the camera along the X axis.
  35700. */
  35701. inertialPanningX: number;
  35702. /**
  35703. * Defines the current inertia value used during panning of the camera along the Y axis.
  35704. */
  35705. inertialPanningY: number;
  35706. /**
  35707. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35708. * Basically if your fingers moves away from more than this distance you will be considered
  35709. * in pinch mode.
  35710. */
  35711. pinchToPanMaxDistance: number;
  35712. /**
  35713. * Defines the maximum distance the camera can pan.
  35714. * This could help keeping the cammera always in your scene.
  35715. */
  35716. panningDistanceLimit: Nullable<number>;
  35717. /**
  35718. * Defines the target of the camera before paning.
  35719. */
  35720. panningOriginTarget: Vector3;
  35721. /**
  35722. * Defines the value of the inertia used during panning.
  35723. * 0 would mean stop inertia and one would mean no decelleration at all.
  35724. */
  35725. panningInertia: number;
  35726. /**
  35727. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35728. */
  35729. angularSensibilityX: number;
  35730. /**
  35731. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35732. */
  35733. angularSensibilityY: number;
  35734. /**
  35735. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35736. */
  35737. pinchPrecision: number;
  35738. /**
  35739. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35740. * It will be used instead of pinchDeltaPrecision if different from 0.
  35741. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35742. */
  35743. pinchDeltaPercentage: number;
  35744. /**
  35745. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35746. */
  35747. panningSensibility: number;
  35748. /**
  35749. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35750. */
  35751. keysUp: number[];
  35752. /**
  35753. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35754. */
  35755. keysDown: number[];
  35756. /**
  35757. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35758. */
  35759. keysLeft: number[];
  35760. /**
  35761. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35762. */
  35763. keysRight: number[];
  35764. /**
  35765. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35766. */
  35767. wheelPrecision: number;
  35768. /**
  35769. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35770. * It will be used instead of pinchDeltaPrecision if different from 0.
  35771. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35772. */
  35773. wheelDeltaPercentage: number;
  35774. /**
  35775. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35776. */
  35777. zoomOnFactor: number;
  35778. /**
  35779. * Defines a screen offset for the camera position.
  35780. */
  35781. targetScreenOffset: Vector2;
  35782. /**
  35783. * Allows the camera to be completely reversed.
  35784. * If false the camera can not arrive upside down.
  35785. */
  35786. allowUpsideDown: boolean;
  35787. /**
  35788. * Define if double tap/click is used to restore the previously saved state of the camera.
  35789. */
  35790. useInputToRestoreState: boolean;
  35791. /** @hidden */
  35792. _viewMatrix: Matrix;
  35793. /** @hidden */
  35794. _useCtrlForPanning: boolean;
  35795. /** @hidden */
  35796. _panningMouseButton: number;
  35797. /**
  35798. * Defines the input associated to the camera.
  35799. */
  35800. inputs: ArcRotateCameraInputsManager;
  35801. /** @hidden */
  35802. _reset: () => void;
  35803. /**
  35804. * Defines the allowed panning axis.
  35805. */
  35806. panningAxis: Vector3;
  35807. protected _localDirection: Vector3;
  35808. protected _transformedDirection: Vector3;
  35809. private _bouncingBehavior;
  35810. /**
  35811. * Gets the bouncing behavior of the camera if it has been enabled.
  35812. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35813. */
  35814. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35815. /**
  35816. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35817. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35818. */
  35819. useBouncingBehavior: boolean;
  35820. private _framingBehavior;
  35821. /**
  35822. * Gets the framing behavior of the camera if it has been enabled.
  35823. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35824. */
  35825. readonly framingBehavior: Nullable<FramingBehavior>;
  35826. /**
  35827. * Defines if the framing behavior of the camera is enabled on the camera.
  35828. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35829. */
  35830. useFramingBehavior: boolean;
  35831. private _autoRotationBehavior;
  35832. /**
  35833. * Gets the auto rotation behavior of the camera if it has been enabled.
  35834. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35835. */
  35836. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35837. /**
  35838. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35839. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35840. */
  35841. useAutoRotationBehavior: boolean;
  35842. /**
  35843. * Observable triggered when the mesh target has been changed on the camera.
  35844. */
  35845. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35846. /**
  35847. * Event raised when the camera is colliding with a mesh.
  35848. */
  35849. onCollide: (collidedMesh: AbstractMesh) => void;
  35850. /**
  35851. * Defines whether the camera should check collision with the objects oh the scene.
  35852. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35853. */
  35854. checkCollisions: boolean;
  35855. /**
  35856. * Defines the collision radius of the camera.
  35857. * This simulates a sphere around the camera.
  35858. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35859. */
  35860. collisionRadius: Vector3;
  35861. protected _collider: Collider;
  35862. protected _previousPosition: Vector3;
  35863. protected _collisionVelocity: Vector3;
  35864. protected _newPosition: Vector3;
  35865. protected _previousAlpha: number;
  35866. protected _previousBeta: number;
  35867. protected _previousRadius: number;
  35868. protected _collisionTriggered: boolean;
  35869. protected _targetBoundingCenter: Nullable<Vector3>;
  35870. private _computationVector;
  35871. /**
  35872. * Instantiates a new ArcRotateCamera in a given scene
  35873. * @param name Defines the name of the camera
  35874. * @param alpha Defines the camera rotation along the logitudinal axis
  35875. * @param beta Defines the camera rotation along the latitudinal axis
  35876. * @param radius Defines the camera distance from its target
  35877. * @param target Defines the camera target
  35878. * @param scene Defines the scene the camera belongs to
  35879. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35880. */
  35881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35882. /** @hidden */
  35883. _initCache(): void;
  35884. /** @hidden */
  35885. _updateCache(ignoreParentClass?: boolean): void;
  35886. protected _getTargetPosition(): Vector3;
  35887. private _storedAlpha;
  35888. private _storedBeta;
  35889. private _storedRadius;
  35890. private _storedTarget;
  35891. /**
  35892. * Stores the current state of the camera (alpha, beta, radius and target)
  35893. * @returns the camera itself
  35894. */
  35895. storeState(): Camera;
  35896. /**
  35897. * @hidden
  35898. * Restored camera state. You must call storeState() first
  35899. */
  35900. _restoreStateValues(): boolean;
  35901. /** @hidden */
  35902. _isSynchronizedViewMatrix(): boolean;
  35903. /**
  35904. * Attached controls to the current camera.
  35905. * @param element Defines the element the controls should be listened from
  35906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35907. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35908. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35909. */
  35910. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35911. /**
  35912. * Detach the current controls from the camera.
  35913. * The camera will stop reacting to inputs.
  35914. * @param element Defines the element to stop listening the inputs from
  35915. */
  35916. detachControl(element: HTMLElement): void;
  35917. /** @hidden */
  35918. _checkInputs(): void;
  35919. protected _checkLimits(): void;
  35920. /**
  35921. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35922. */
  35923. rebuildAnglesAndRadius(): void;
  35924. /**
  35925. * Use a position to define the current camera related information like aplha, beta and radius
  35926. * @param position Defines the position to set the camera at
  35927. */
  35928. setPosition(position: Vector3): void;
  35929. /**
  35930. * Defines the target the camera should look at.
  35931. * This will automatically adapt alpha beta and radius to fit within the new target.
  35932. * @param target Defines the new target as a Vector or a mesh
  35933. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35934. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35935. */
  35936. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35937. /** @hidden */
  35938. _getViewMatrix(): Matrix;
  35939. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35940. /**
  35941. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35942. * @param meshes Defines the mesh to zoom on
  35943. * @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)
  35944. */
  35945. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35946. /**
  35947. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35948. * The target will be changed but the radius
  35949. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35950. * @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)
  35951. */
  35952. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35953. min: Vector3;
  35954. max: Vector3;
  35955. distance: number;
  35956. }, doNotUpdateMaxZ?: boolean): void;
  35957. /**
  35958. * @override
  35959. * Override Camera.createRigCamera
  35960. */
  35961. createRigCamera(name: string, cameraIndex: number): Camera;
  35962. /**
  35963. * @hidden
  35964. * @override
  35965. * Override Camera._updateRigCameras
  35966. */
  35967. _updateRigCameras(): void;
  35968. /**
  35969. * Destroy the camera and release the current resources hold by it.
  35970. */
  35971. dispose(): void;
  35972. /**
  35973. * Gets the current object class name.
  35974. * @return the class name
  35975. */
  35976. getClassName(): string;
  35977. }
  35978. }
  35979. declare module BABYLON {
  35980. /**
  35981. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35982. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35983. */
  35984. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35985. /**
  35986. * Gets the name of the behavior.
  35987. */
  35988. readonly name: string;
  35989. private _zoomStopsAnimation;
  35990. private _idleRotationSpeed;
  35991. private _idleRotationWaitTime;
  35992. private _idleRotationSpinupTime;
  35993. /**
  35994. * Sets the flag that indicates if user zooming should stop animation.
  35995. */
  35996. /**
  35997. * Gets the flag that indicates if user zooming should stop animation.
  35998. */
  35999. zoomStopsAnimation: boolean;
  36000. /**
  36001. * Sets the default speed at which the camera rotates around the model.
  36002. */
  36003. /**
  36004. * Gets the default speed at which the camera rotates around the model.
  36005. */
  36006. idleRotationSpeed: number;
  36007. /**
  36008. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36009. */
  36010. /**
  36011. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36012. */
  36013. idleRotationWaitTime: number;
  36014. /**
  36015. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36016. */
  36017. /**
  36018. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36019. */
  36020. idleRotationSpinupTime: number;
  36021. /**
  36022. * Gets a value indicating if the camera is currently rotating because of this behavior
  36023. */
  36024. readonly rotationInProgress: boolean;
  36025. private _onPrePointerObservableObserver;
  36026. private _onAfterCheckInputsObserver;
  36027. private _attachedCamera;
  36028. private _isPointerDown;
  36029. private _lastFrameTime;
  36030. private _lastInteractionTime;
  36031. private _cameraRotationSpeed;
  36032. /**
  36033. * Initializes the behavior.
  36034. */
  36035. init(): void;
  36036. /**
  36037. * Attaches the behavior to its arc rotate camera.
  36038. * @param camera Defines the camera to attach the behavior to
  36039. */
  36040. attach(camera: ArcRotateCamera): void;
  36041. /**
  36042. * Detaches the behavior from its current arc rotate camera.
  36043. */
  36044. detach(): void;
  36045. /**
  36046. * Returns true if user is scrolling.
  36047. * @return true if user is scrolling.
  36048. */
  36049. private _userIsZooming;
  36050. private _lastFrameRadius;
  36051. private _shouldAnimationStopForInteraction;
  36052. /**
  36053. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36054. */
  36055. private _applyUserInteraction;
  36056. private _userIsMoving;
  36057. }
  36058. }
  36059. declare module BABYLON {
  36060. /**
  36061. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36062. */
  36063. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36064. private ui;
  36065. /**
  36066. * The name of the behavior
  36067. */
  36068. name: string;
  36069. /**
  36070. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36071. */
  36072. distanceAwayFromFace: number;
  36073. /**
  36074. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36075. */
  36076. distanceAwayFromBottomOfFace: number;
  36077. private _faceVectors;
  36078. private _target;
  36079. private _scene;
  36080. private _onRenderObserver;
  36081. private _tmpMatrix;
  36082. private _tmpVector;
  36083. /**
  36084. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36085. * @param ui The transform node that should be attched to the mesh
  36086. */
  36087. constructor(ui: TransformNode);
  36088. /**
  36089. * Initializes the behavior
  36090. */
  36091. init(): void;
  36092. private _closestFace;
  36093. private _zeroVector;
  36094. private _lookAtTmpMatrix;
  36095. private _lookAtToRef;
  36096. /**
  36097. * Attaches the AttachToBoxBehavior to the passed in mesh
  36098. * @param target The mesh that the specified node will be attached to
  36099. */
  36100. attach(target: Mesh): void;
  36101. /**
  36102. * Detaches the behavior from the mesh
  36103. */
  36104. detach(): void;
  36105. }
  36106. }
  36107. declare module BABYLON {
  36108. /**
  36109. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36110. */
  36111. export class FadeInOutBehavior implements Behavior<Mesh> {
  36112. /**
  36113. * Time in milliseconds to delay before fading in (Default: 0)
  36114. */
  36115. delay: number;
  36116. /**
  36117. * Time in milliseconds for the mesh to fade in (Default: 300)
  36118. */
  36119. fadeInTime: number;
  36120. private _millisecondsPerFrame;
  36121. private _hovered;
  36122. private _hoverValue;
  36123. private _ownerNode;
  36124. /**
  36125. * Instatiates the FadeInOutBehavior
  36126. */
  36127. constructor();
  36128. /**
  36129. * The name of the behavior
  36130. */
  36131. readonly name: string;
  36132. /**
  36133. * Initializes the behavior
  36134. */
  36135. init(): void;
  36136. /**
  36137. * Attaches the fade behavior on the passed in mesh
  36138. * @param ownerNode The mesh that will be faded in/out once attached
  36139. */
  36140. attach(ownerNode: Mesh): void;
  36141. /**
  36142. * Detaches the behavior from the mesh
  36143. */
  36144. detach(): void;
  36145. /**
  36146. * Triggers the mesh to begin fading in or out
  36147. * @param value if the object should fade in or out (true to fade in)
  36148. */
  36149. fadeIn(value: boolean): void;
  36150. private _update;
  36151. private _setAllVisibility;
  36152. }
  36153. }
  36154. declare module BABYLON {
  36155. /**
  36156. * Class containing a set of static utilities functions for managing Pivots
  36157. * @hidden
  36158. */
  36159. export class PivotTools {
  36160. private static _PivotCached;
  36161. private static _OldPivotPoint;
  36162. private static _PivotTranslation;
  36163. private static _PivotTmpVector;
  36164. /** @hidden */
  36165. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36166. /** @hidden */
  36167. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36168. }
  36169. }
  36170. declare module BABYLON {
  36171. /**
  36172. * Class containing static functions to help procedurally build meshes
  36173. */
  36174. export class PlaneBuilder {
  36175. /**
  36176. * Creates a plane mesh
  36177. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36178. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36179. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36181. * * 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
  36182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36183. * @param name defines the name of the mesh
  36184. * @param options defines the options used to create the mesh
  36185. * @param scene defines the hosting scene
  36186. * @returns the plane mesh
  36187. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36188. */
  36189. static CreatePlane(name: string, options: {
  36190. size?: number;
  36191. width?: number;
  36192. height?: number;
  36193. sideOrientation?: number;
  36194. frontUVs?: Vector4;
  36195. backUVs?: Vector4;
  36196. updatable?: boolean;
  36197. sourcePlane?: Plane;
  36198. }, scene?: Nullable<Scene>): Mesh;
  36199. }
  36200. }
  36201. declare module BABYLON {
  36202. /**
  36203. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36204. */
  36205. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36206. private static _AnyMouseID;
  36207. /**
  36208. * Abstract mesh the behavior is set on
  36209. */
  36210. attachedNode: AbstractMesh;
  36211. private _dragPlane;
  36212. private _scene;
  36213. private _pointerObserver;
  36214. private _beforeRenderObserver;
  36215. private static _planeScene;
  36216. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36217. /**
  36218. * 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)
  36219. */
  36220. maxDragAngle: number;
  36221. /**
  36222. * @hidden
  36223. */
  36224. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36225. /**
  36226. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36227. */
  36228. currentDraggingPointerID: number;
  36229. /**
  36230. * The last position where the pointer hit the drag plane in world space
  36231. */
  36232. lastDragPosition: Vector3;
  36233. /**
  36234. * If the behavior is currently in a dragging state
  36235. */
  36236. dragging: boolean;
  36237. /**
  36238. * 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)
  36239. */
  36240. dragDeltaRatio: number;
  36241. /**
  36242. * If the drag plane orientation should be updated during the dragging (Default: true)
  36243. */
  36244. updateDragPlane: boolean;
  36245. private _debugMode;
  36246. private _moving;
  36247. /**
  36248. * Fires each time the attached mesh is dragged with the pointer
  36249. * * delta between last drag position and current drag position in world space
  36250. * * dragDistance along the drag axis
  36251. * * dragPlaneNormal normal of the current drag plane used during the drag
  36252. * * dragPlanePoint in world space where the drag intersects the drag plane
  36253. */
  36254. onDragObservable: Observable<{
  36255. delta: Vector3;
  36256. dragPlanePoint: Vector3;
  36257. dragPlaneNormal: Vector3;
  36258. dragDistance: number;
  36259. pointerId: number;
  36260. }>;
  36261. /**
  36262. * Fires each time a drag begins (eg. mouse down on mesh)
  36263. */
  36264. onDragStartObservable: Observable<{
  36265. dragPlanePoint: Vector3;
  36266. pointerId: number;
  36267. }>;
  36268. /**
  36269. * Fires each time a drag ends (eg. mouse release after drag)
  36270. */
  36271. onDragEndObservable: Observable<{
  36272. dragPlanePoint: Vector3;
  36273. pointerId: number;
  36274. }>;
  36275. /**
  36276. * If the attached mesh should be moved when dragged
  36277. */
  36278. moveAttached: boolean;
  36279. /**
  36280. * If the drag behavior will react to drag events (Default: true)
  36281. */
  36282. enabled: boolean;
  36283. /**
  36284. * If pointer events should start and release the drag (Default: true)
  36285. */
  36286. startAndReleaseDragOnPointerEvents: boolean;
  36287. /**
  36288. * If camera controls should be detached during the drag
  36289. */
  36290. detachCameraControls: boolean;
  36291. /**
  36292. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36293. */
  36294. useObjectOrienationForDragging: boolean;
  36295. private _options;
  36296. /**
  36297. * Creates a pointer drag behavior that can be attached to a mesh
  36298. * @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)
  36299. */
  36300. constructor(options?: {
  36301. dragAxis?: Vector3;
  36302. dragPlaneNormal?: Vector3;
  36303. });
  36304. /**
  36305. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36306. */
  36307. validateDrag: (targetPosition: Vector3) => boolean;
  36308. /**
  36309. * The name of the behavior
  36310. */
  36311. readonly name: string;
  36312. /**
  36313. * Initializes the behavior
  36314. */
  36315. init(): void;
  36316. private _tmpVector;
  36317. private _alternatePickedPoint;
  36318. private _worldDragAxis;
  36319. private _targetPosition;
  36320. private _attachedElement;
  36321. /**
  36322. * Attaches the drag behavior the passed in mesh
  36323. * @param ownerNode The mesh that will be dragged around once attached
  36324. */
  36325. attach(ownerNode: AbstractMesh): void;
  36326. /**
  36327. * Force relase the drag action by code.
  36328. */
  36329. releaseDrag(): void;
  36330. private _startDragRay;
  36331. private _lastPointerRay;
  36332. /**
  36333. * Simulates the start of a pointer drag event on the behavior
  36334. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36335. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36336. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36337. */
  36338. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36339. private _startDrag;
  36340. private _dragDelta;
  36341. private _moveDrag;
  36342. private _pickWithRayOnDragPlane;
  36343. private _pointA;
  36344. private _pointB;
  36345. private _pointC;
  36346. private _lineA;
  36347. private _lineB;
  36348. private _localAxis;
  36349. private _lookAt;
  36350. private _updateDragPlanePosition;
  36351. /**
  36352. * Detaches the behavior from the mesh
  36353. */
  36354. detach(): void;
  36355. }
  36356. }
  36357. declare module BABYLON {
  36358. /**
  36359. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36360. */
  36361. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36362. private _dragBehaviorA;
  36363. private _dragBehaviorB;
  36364. private _startDistance;
  36365. private _initialScale;
  36366. private _targetScale;
  36367. private _ownerNode;
  36368. private _sceneRenderObserver;
  36369. /**
  36370. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36371. */
  36372. constructor();
  36373. /**
  36374. * The name of the behavior
  36375. */
  36376. readonly name: string;
  36377. /**
  36378. * Initializes the behavior
  36379. */
  36380. init(): void;
  36381. private _getCurrentDistance;
  36382. /**
  36383. * Attaches the scale behavior the passed in mesh
  36384. * @param ownerNode The mesh that will be scaled around once attached
  36385. */
  36386. attach(ownerNode: Mesh): void;
  36387. /**
  36388. * Detaches the behavior from the mesh
  36389. */
  36390. detach(): void;
  36391. }
  36392. }
  36393. declare module BABYLON {
  36394. /**
  36395. * 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
  36396. */
  36397. export class SixDofDragBehavior implements Behavior<Mesh> {
  36398. private static _virtualScene;
  36399. private _ownerNode;
  36400. private _sceneRenderObserver;
  36401. private _scene;
  36402. private _targetPosition;
  36403. private _virtualOriginMesh;
  36404. private _virtualDragMesh;
  36405. private _pointerObserver;
  36406. private _moving;
  36407. private _startingOrientation;
  36408. /**
  36409. * 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)
  36410. */
  36411. private zDragFactor;
  36412. /**
  36413. * If the object should rotate to face the drag origin
  36414. */
  36415. rotateDraggedObject: boolean;
  36416. /**
  36417. * If the behavior is currently in a dragging state
  36418. */
  36419. dragging: boolean;
  36420. /**
  36421. * 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)
  36422. */
  36423. dragDeltaRatio: number;
  36424. /**
  36425. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36426. */
  36427. currentDraggingPointerID: number;
  36428. /**
  36429. * If camera controls should be detached during the drag
  36430. */
  36431. detachCameraControls: boolean;
  36432. /**
  36433. * Fires each time a drag starts
  36434. */
  36435. onDragStartObservable: Observable<{}>;
  36436. /**
  36437. * Fires each time a drag ends (eg. mouse release after drag)
  36438. */
  36439. onDragEndObservable: Observable<{}>;
  36440. /**
  36441. * 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
  36442. */
  36443. constructor();
  36444. /**
  36445. * The name of the behavior
  36446. */
  36447. readonly name: string;
  36448. /**
  36449. * Initializes the behavior
  36450. */
  36451. init(): void;
  36452. /**
  36453. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36454. */
  36455. private readonly _pointerCamera;
  36456. /**
  36457. * Attaches the scale behavior the passed in mesh
  36458. * @param ownerNode The mesh that will be scaled around once attached
  36459. */
  36460. attach(ownerNode: Mesh): void;
  36461. /**
  36462. * Detaches the behavior from the mesh
  36463. */
  36464. detach(): void;
  36465. }
  36466. }
  36467. declare module BABYLON {
  36468. /**
  36469. * Class used to apply inverse kinematics to bones
  36470. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36471. */
  36472. export class BoneIKController {
  36473. private static _tmpVecs;
  36474. private static _tmpQuat;
  36475. private static _tmpMats;
  36476. /**
  36477. * Gets or sets the target mesh
  36478. */
  36479. targetMesh: AbstractMesh;
  36480. /** Gets or sets the mesh used as pole */
  36481. poleTargetMesh: AbstractMesh;
  36482. /**
  36483. * Gets or sets the bone used as pole
  36484. */
  36485. poleTargetBone: Nullable<Bone>;
  36486. /**
  36487. * Gets or sets the target position
  36488. */
  36489. targetPosition: Vector3;
  36490. /**
  36491. * Gets or sets the pole target position
  36492. */
  36493. poleTargetPosition: Vector3;
  36494. /**
  36495. * Gets or sets the pole target local offset
  36496. */
  36497. poleTargetLocalOffset: Vector3;
  36498. /**
  36499. * Gets or sets the pole angle
  36500. */
  36501. poleAngle: number;
  36502. /**
  36503. * Gets or sets the mesh associated with the controller
  36504. */
  36505. mesh: AbstractMesh;
  36506. /**
  36507. * 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)
  36508. */
  36509. slerpAmount: number;
  36510. private _bone1Quat;
  36511. private _bone1Mat;
  36512. private _bone2Ang;
  36513. private _bone1;
  36514. private _bone2;
  36515. private _bone1Length;
  36516. private _bone2Length;
  36517. private _maxAngle;
  36518. private _maxReach;
  36519. private _rightHandedSystem;
  36520. private _bendAxis;
  36521. private _slerping;
  36522. private _adjustRoll;
  36523. /**
  36524. * Gets or sets maximum allowed angle
  36525. */
  36526. maxAngle: number;
  36527. /**
  36528. * Creates a new BoneIKController
  36529. * @param mesh defines the mesh to control
  36530. * @param bone defines the bone to control
  36531. * @param options defines options to set up the controller
  36532. */
  36533. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36534. targetMesh?: AbstractMesh;
  36535. poleTargetMesh?: AbstractMesh;
  36536. poleTargetBone?: Bone;
  36537. poleTargetLocalOffset?: Vector3;
  36538. poleAngle?: number;
  36539. bendAxis?: Vector3;
  36540. maxAngle?: number;
  36541. slerpAmount?: number;
  36542. });
  36543. private _setMaxAngle;
  36544. /**
  36545. * Force the controller to update the bones
  36546. */
  36547. update(): void;
  36548. }
  36549. }
  36550. declare module BABYLON {
  36551. /**
  36552. * Class used to make a bone look toward a point in space
  36553. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36554. */
  36555. export class BoneLookController {
  36556. private static _tmpVecs;
  36557. private static _tmpQuat;
  36558. private static _tmpMats;
  36559. /**
  36560. * The target Vector3 that the bone will look at
  36561. */
  36562. target: Vector3;
  36563. /**
  36564. * The mesh that the bone is attached to
  36565. */
  36566. mesh: AbstractMesh;
  36567. /**
  36568. * The bone that will be looking to the target
  36569. */
  36570. bone: Bone;
  36571. /**
  36572. * The up axis of the coordinate system that is used when the bone is rotated
  36573. */
  36574. upAxis: Vector3;
  36575. /**
  36576. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36577. */
  36578. upAxisSpace: Space;
  36579. /**
  36580. * Used to make an adjustment to the yaw of the bone
  36581. */
  36582. adjustYaw: number;
  36583. /**
  36584. * Used to make an adjustment to the pitch of the bone
  36585. */
  36586. adjustPitch: number;
  36587. /**
  36588. * Used to make an adjustment to the roll of the bone
  36589. */
  36590. adjustRoll: number;
  36591. /**
  36592. * 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)
  36593. */
  36594. slerpAmount: number;
  36595. private _minYaw;
  36596. private _maxYaw;
  36597. private _minPitch;
  36598. private _maxPitch;
  36599. private _minYawSin;
  36600. private _minYawCos;
  36601. private _maxYawSin;
  36602. private _maxYawCos;
  36603. private _midYawConstraint;
  36604. private _minPitchTan;
  36605. private _maxPitchTan;
  36606. private _boneQuat;
  36607. private _slerping;
  36608. private _transformYawPitch;
  36609. private _transformYawPitchInv;
  36610. private _firstFrameSkipped;
  36611. private _yawRange;
  36612. private _fowardAxis;
  36613. /**
  36614. * Gets or sets the minimum yaw angle that the bone can look to
  36615. */
  36616. minYaw: number;
  36617. /**
  36618. * Gets or sets the maximum yaw angle that the bone can look to
  36619. */
  36620. maxYaw: number;
  36621. /**
  36622. * Gets or sets the minimum pitch angle that the bone can look to
  36623. */
  36624. minPitch: number;
  36625. /**
  36626. * Gets or sets the maximum pitch angle that the bone can look to
  36627. */
  36628. maxPitch: number;
  36629. /**
  36630. * Create a BoneLookController
  36631. * @param mesh the mesh that the bone belongs to
  36632. * @param bone the bone that will be looking to the target
  36633. * @param target the target Vector3 to look at
  36634. * @param options optional settings:
  36635. * * maxYaw: the maximum angle the bone will yaw to
  36636. * * minYaw: the minimum angle the bone will yaw to
  36637. * * maxPitch: the maximum angle the bone will pitch to
  36638. * * minPitch: the minimum angle the bone will yaw to
  36639. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36640. * * upAxis: the up axis of the coordinate system
  36641. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36642. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36643. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36644. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36645. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36646. * * adjustRoll: used to make an adjustment to the roll of the bone
  36647. **/
  36648. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36649. maxYaw?: number;
  36650. minYaw?: number;
  36651. maxPitch?: number;
  36652. minPitch?: number;
  36653. slerpAmount?: number;
  36654. upAxis?: Vector3;
  36655. upAxisSpace?: Space;
  36656. yawAxis?: Vector3;
  36657. pitchAxis?: Vector3;
  36658. adjustYaw?: number;
  36659. adjustPitch?: number;
  36660. adjustRoll?: number;
  36661. });
  36662. /**
  36663. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36664. */
  36665. update(): void;
  36666. private _getAngleDiff;
  36667. private _getAngleBetween;
  36668. private _isAngleBetween;
  36669. }
  36670. }
  36671. declare module BABYLON {
  36672. /**
  36673. * Manage the gamepad inputs to control an arc rotate camera.
  36674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36675. */
  36676. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36677. /**
  36678. * Defines the camera the input is attached to.
  36679. */
  36680. camera: ArcRotateCamera;
  36681. /**
  36682. * Defines the gamepad the input is gathering event from.
  36683. */
  36684. gamepad: Nullable<Gamepad>;
  36685. /**
  36686. * Defines the gamepad rotation sensiblity.
  36687. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36688. */
  36689. gamepadRotationSensibility: number;
  36690. /**
  36691. * Defines the gamepad move sensiblity.
  36692. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36693. */
  36694. gamepadMoveSensibility: number;
  36695. private _onGamepadConnectedObserver;
  36696. private _onGamepadDisconnectedObserver;
  36697. /**
  36698. * Attach the input controls to a specific dom element to get the input from.
  36699. * @param element Defines the element the controls should be listened from
  36700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36701. */
  36702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36703. /**
  36704. * Detach the current controls from the specified dom element.
  36705. * @param element Defines the element to stop listening the inputs from
  36706. */
  36707. detachControl(element: Nullable<HTMLElement>): void;
  36708. /**
  36709. * Update the current camera state depending on the inputs that have been used this frame.
  36710. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36711. */
  36712. checkInputs(): void;
  36713. /**
  36714. * Gets the class name of the current intput.
  36715. * @returns the class name
  36716. */
  36717. getClassName(): string;
  36718. /**
  36719. * Get the friendly name associated with the input class.
  36720. * @returns the input friendly name
  36721. */
  36722. getSimpleName(): string;
  36723. }
  36724. }
  36725. declare module BABYLON {
  36726. interface ArcRotateCameraInputsManager {
  36727. /**
  36728. * Add orientation input support to the input manager.
  36729. * @returns the current input manager
  36730. */
  36731. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36732. }
  36733. /**
  36734. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36736. */
  36737. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36738. /**
  36739. * Defines the camera the input is attached to.
  36740. */
  36741. camera: ArcRotateCamera;
  36742. /**
  36743. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36744. */
  36745. alphaCorrection: number;
  36746. /**
  36747. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36748. */
  36749. gammaCorrection: number;
  36750. private _alpha;
  36751. private _gamma;
  36752. private _dirty;
  36753. private _deviceOrientationHandler;
  36754. /**
  36755. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36756. */
  36757. constructor();
  36758. /**
  36759. * Attach the input controls to a specific dom element to get the input from.
  36760. * @param element Defines the element the controls should be listened from
  36761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36762. */
  36763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36764. /** @hidden */
  36765. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36766. /**
  36767. * Update the current camera state depending on the inputs that have been used this frame.
  36768. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36769. */
  36770. checkInputs(): void;
  36771. /**
  36772. * Detach the current controls from the specified dom element.
  36773. * @param element Defines the element to stop listening the inputs from
  36774. */
  36775. detachControl(element: Nullable<HTMLElement>): void;
  36776. /**
  36777. * Gets the class name of the current intput.
  36778. * @returns the class name
  36779. */
  36780. getClassName(): string;
  36781. /**
  36782. * Get the friendly name associated with the input class.
  36783. * @returns the input friendly name
  36784. */
  36785. getSimpleName(): string;
  36786. }
  36787. }
  36788. declare module BABYLON {
  36789. /**
  36790. * Listen to mouse events to control the camera.
  36791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36792. */
  36793. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36794. /**
  36795. * Defines the camera the input is attached to.
  36796. */
  36797. camera: FlyCamera;
  36798. /**
  36799. * Defines if touch is enabled. (Default is true.)
  36800. */
  36801. touchEnabled: boolean;
  36802. /**
  36803. * Defines the buttons associated with the input to handle camera rotation.
  36804. */
  36805. buttons: number[];
  36806. /**
  36807. * Assign buttons for Yaw control.
  36808. */
  36809. buttonsYaw: number[];
  36810. /**
  36811. * Assign buttons for Pitch control.
  36812. */
  36813. buttonsPitch: number[];
  36814. /**
  36815. * Assign buttons for Roll control.
  36816. */
  36817. buttonsRoll: number[];
  36818. /**
  36819. * Detect if any button is being pressed while mouse is moved.
  36820. * -1 = Mouse locked.
  36821. * 0 = Left button.
  36822. * 1 = Middle Button.
  36823. * 2 = Right Button.
  36824. */
  36825. activeButton: number;
  36826. /**
  36827. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36828. * Higher values reduce its sensitivity.
  36829. */
  36830. angularSensibility: number;
  36831. private _mousemoveCallback;
  36832. private _observer;
  36833. private _rollObserver;
  36834. private previousPosition;
  36835. private noPreventDefault;
  36836. private element;
  36837. /**
  36838. * Listen to mouse events to control the camera.
  36839. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36841. */
  36842. constructor(touchEnabled?: boolean);
  36843. /**
  36844. * Attach the mouse control to the HTML DOM element.
  36845. * @param element Defines the element that listens to the input events.
  36846. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36847. */
  36848. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36849. /**
  36850. * Detach the current controls from the specified dom element.
  36851. * @param element Defines the element to stop listening the inputs from
  36852. */
  36853. detachControl(element: Nullable<HTMLElement>): void;
  36854. /**
  36855. * Gets the class name of the current input.
  36856. * @returns the class name.
  36857. */
  36858. getClassName(): string;
  36859. /**
  36860. * Get the friendly name associated with the input class.
  36861. * @returns the input's friendly name.
  36862. */
  36863. getSimpleName(): string;
  36864. private _pointerInput;
  36865. private _onMouseMove;
  36866. /**
  36867. * Rotate camera by mouse offset.
  36868. */
  36869. private rotateCamera;
  36870. }
  36871. }
  36872. declare module BABYLON {
  36873. /**
  36874. * Default Inputs manager for the FlyCamera.
  36875. * It groups all the default supported inputs for ease of use.
  36876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36877. */
  36878. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36879. /**
  36880. * Instantiates a new FlyCameraInputsManager.
  36881. * @param camera Defines the camera the inputs belong to.
  36882. */
  36883. constructor(camera: FlyCamera);
  36884. /**
  36885. * Add keyboard input support to the input manager.
  36886. * @returns the new FlyCameraKeyboardMoveInput().
  36887. */
  36888. addKeyboard(): FlyCameraInputsManager;
  36889. /**
  36890. * Add mouse input support to the input manager.
  36891. * @param touchEnabled Enable touch screen support.
  36892. * @returns the new FlyCameraMouseInput().
  36893. */
  36894. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36895. }
  36896. }
  36897. declare module BABYLON {
  36898. /**
  36899. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36900. * such as in a 3D Space Shooter or a Flight Simulator.
  36901. */
  36902. export class FlyCamera extends TargetCamera {
  36903. /**
  36904. * Define the collision ellipsoid of the camera.
  36905. * This is helpful for simulating a camera body, like a player's body.
  36906. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36907. */
  36908. ellipsoid: Vector3;
  36909. /**
  36910. * Define an offset for the position of the ellipsoid around the camera.
  36911. * This can be helpful if the camera is attached away from the player's body center,
  36912. * such as at its head.
  36913. */
  36914. ellipsoidOffset: Vector3;
  36915. /**
  36916. * Enable or disable collisions of the camera with the rest of the scene objects.
  36917. */
  36918. checkCollisions: boolean;
  36919. /**
  36920. * Enable or disable gravity on the camera.
  36921. */
  36922. applyGravity: boolean;
  36923. /**
  36924. * Define the current direction the camera is moving to.
  36925. */
  36926. cameraDirection: Vector3;
  36927. /**
  36928. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36929. * This overrides and empties cameraRotation.
  36930. */
  36931. rotationQuaternion: Quaternion;
  36932. /**
  36933. * Track Roll to maintain the wanted Rolling when looking around.
  36934. */
  36935. _trackRoll: number;
  36936. /**
  36937. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36938. */
  36939. rollCorrect: number;
  36940. /**
  36941. * Mimic a banked turn, Rolling the camera when Yawing.
  36942. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36943. */
  36944. bankedTurn: boolean;
  36945. /**
  36946. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36947. */
  36948. bankedTurnLimit: number;
  36949. /**
  36950. * Value of 0 disables the banked Roll.
  36951. * Value of 1 is equal to the Yaw angle in radians.
  36952. */
  36953. bankedTurnMultiplier: number;
  36954. /**
  36955. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36956. */
  36957. inputs: FlyCameraInputsManager;
  36958. /**
  36959. * Gets the input sensibility for mouse input.
  36960. * Higher values reduce sensitivity.
  36961. */
  36962. /**
  36963. * Sets the input sensibility for a mouse input.
  36964. * Higher values reduce sensitivity.
  36965. */
  36966. angularSensibility: number;
  36967. /**
  36968. * Get the keys for camera movement forward.
  36969. */
  36970. /**
  36971. * Set the keys for camera movement forward.
  36972. */
  36973. keysForward: number[];
  36974. /**
  36975. * Get the keys for camera movement backward.
  36976. */
  36977. keysBackward: number[];
  36978. /**
  36979. * Get the keys for camera movement up.
  36980. */
  36981. /**
  36982. * Set the keys for camera movement up.
  36983. */
  36984. keysUp: number[];
  36985. /**
  36986. * Get the keys for camera movement down.
  36987. */
  36988. /**
  36989. * Set the keys for camera movement down.
  36990. */
  36991. keysDown: number[];
  36992. /**
  36993. * Get the keys for camera movement left.
  36994. */
  36995. /**
  36996. * Set the keys for camera movement left.
  36997. */
  36998. keysLeft: number[];
  36999. /**
  37000. * Set the keys for camera movement right.
  37001. */
  37002. /**
  37003. * Set the keys for camera movement right.
  37004. */
  37005. keysRight: number[];
  37006. /**
  37007. * Event raised when the camera collides with a mesh in the scene.
  37008. */
  37009. onCollide: (collidedMesh: AbstractMesh) => void;
  37010. private _collider;
  37011. private _needMoveForGravity;
  37012. private _oldPosition;
  37013. private _diffPosition;
  37014. private _newPosition;
  37015. /** @hidden */
  37016. _localDirection: Vector3;
  37017. /** @hidden */
  37018. _transformedDirection: Vector3;
  37019. /**
  37020. * Instantiates a FlyCamera.
  37021. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37022. * such as in a 3D Space Shooter or a Flight Simulator.
  37023. * @param name Define the name of the camera in the scene.
  37024. * @param position Define the starting position of the camera in the scene.
  37025. * @param scene Define the scene the camera belongs to.
  37026. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37027. */
  37028. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37029. /**
  37030. * Attach a control to the HTML DOM element.
  37031. * @param element Defines the element that listens to the input events.
  37032. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37033. */
  37034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37035. /**
  37036. * Detach a control from the HTML DOM element.
  37037. * The camera will stop reacting to that input.
  37038. * @param element Defines the element that listens to the input events.
  37039. */
  37040. detachControl(element: HTMLElement): void;
  37041. private _collisionMask;
  37042. /**
  37043. * Get the mask that the camera ignores in collision events.
  37044. */
  37045. /**
  37046. * Set the mask that the camera ignores in collision events.
  37047. */
  37048. collisionMask: number;
  37049. /** @hidden */
  37050. _collideWithWorld(displacement: Vector3): void;
  37051. /** @hidden */
  37052. private _onCollisionPositionChange;
  37053. /** @hidden */
  37054. _checkInputs(): void;
  37055. /** @hidden */
  37056. _decideIfNeedsToMove(): boolean;
  37057. /** @hidden */
  37058. _updatePosition(): void;
  37059. /**
  37060. * Restore the Roll to its target value at the rate specified.
  37061. * @param rate - Higher means slower restoring.
  37062. * @hidden
  37063. */
  37064. restoreRoll(rate: number): void;
  37065. /**
  37066. * Destroy the camera and release the current resources held by it.
  37067. */
  37068. dispose(): void;
  37069. /**
  37070. * Get the current object class name.
  37071. * @returns the class name.
  37072. */
  37073. getClassName(): string;
  37074. }
  37075. }
  37076. declare module BABYLON {
  37077. /**
  37078. * Listen to keyboard events to control the camera.
  37079. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37080. */
  37081. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37082. /**
  37083. * Defines the camera the input is attached to.
  37084. */
  37085. camera: FlyCamera;
  37086. /**
  37087. * The list of keyboard keys used to control the forward move of the camera.
  37088. */
  37089. keysForward: number[];
  37090. /**
  37091. * The list of keyboard keys used to control the backward move of the camera.
  37092. */
  37093. keysBackward: number[];
  37094. /**
  37095. * The list of keyboard keys used to control the forward move of the camera.
  37096. */
  37097. keysUp: number[];
  37098. /**
  37099. * The list of keyboard keys used to control the backward move of the camera.
  37100. */
  37101. keysDown: number[];
  37102. /**
  37103. * The list of keyboard keys used to control the right strafe move of the camera.
  37104. */
  37105. keysRight: number[];
  37106. /**
  37107. * The list of keyboard keys used to control the left strafe move of the camera.
  37108. */
  37109. keysLeft: number[];
  37110. private _keys;
  37111. private _onCanvasBlurObserver;
  37112. private _onKeyboardObserver;
  37113. private _engine;
  37114. private _scene;
  37115. /**
  37116. * Attach the input controls to a specific dom element to get the input from.
  37117. * @param element Defines the element the controls should be listened from
  37118. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37119. */
  37120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37121. /**
  37122. * Detach the current controls from the specified dom element.
  37123. * @param element Defines the element to stop listening the inputs from
  37124. */
  37125. detachControl(element: Nullable<HTMLElement>): void;
  37126. /**
  37127. * Gets the class name of the current intput.
  37128. * @returns the class name
  37129. */
  37130. getClassName(): string;
  37131. /** @hidden */
  37132. _onLostFocus(e: FocusEvent): void;
  37133. /**
  37134. * Get the friendly name associated with the input class.
  37135. * @returns the input friendly name
  37136. */
  37137. getSimpleName(): string;
  37138. /**
  37139. * Update the current camera state depending on the inputs that have been used this frame.
  37140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37141. */
  37142. checkInputs(): void;
  37143. }
  37144. }
  37145. declare module BABYLON {
  37146. /**
  37147. * Manage the mouse wheel inputs to control a follow camera.
  37148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37149. */
  37150. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37151. /**
  37152. * Defines the camera the input is attached to.
  37153. */
  37154. camera: FollowCamera;
  37155. /**
  37156. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37157. */
  37158. axisControlRadius: boolean;
  37159. /**
  37160. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37161. */
  37162. axisControlHeight: boolean;
  37163. /**
  37164. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37165. */
  37166. axisControlRotation: boolean;
  37167. /**
  37168. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37169. * relation to mouseWheel events.
  37170. */
  37171. wheelPrecision: number;
  37172. /**
  37173. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37174. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37175. */
  37176. wheelDeltaPercentage: number;
  37177. private _wheel;
  37178. private _observer;
  37179. /**
  37180. * Attach the input controls to a specific dom element to get the input from.
  37181. * @param element Defines the element the controls should be listened from
  37182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37183. */
  37184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37185. /**
  37186. * Detach the current controls from the specified dom element.
  37187. * @param element Defines the element to stop listening the inputs from
  37188. */
  37189. detachControl(element: Nullable<HTMLElement>): void;
  37190. /**
  37191. * Gets the class name of the current intput.
  37192. * @returns the class name
  37193. */
  37194. getClassName(): string;
  37195. /**
  37196. * Get the friendly name associated with the input class.
  37197. * @returns the input friendly name
  37198. */
  37199. getSimpleName(): string;
  37200. }
  37201. }
  37202. declare module BABYLON {
  37203. /**
  37204. * Manage the pointers inputs to control an follow camera.
  37205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37206. */
  37207. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37208. /**
  37209. * Defines the camera the input is attached to.
  37210. */
  37211. camera: FollowCamera;
  37212. /**
  37213. * Gets the class name of the current input.
  37214. * @returns the class name
  37215. */
  37216. getClassName(): string;
  37217. /**
  37218. * Defines the pointer angular sensibility along the X axis or how fast is
  37219. * the camera rotating.
  37220. * A negative number will reverse the axis direction.
  37221. */
  37222. angularSensibilityX: number;
  37223. /**
  37224. * Defines the pointer angular sensibility along the Y axis or how fast is
  37225. * the camera rotating.
  37226. * A negative number will reverse the axis direction.
  37227. */
  37228. angularSensibilityY: number;
  37229. /**
  37230. * Defines the pointer pinch precision or how fast is the camera zooming.
  37231. * A negative number will reverse the axis direction.
  37232. */
  37233. pinchPrecision: number;
  37234. /**
  37235. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37236. * from 0.
  37237. * It defines the percentage of current camera.radius to use as delta when
  37238. * pinch zoom is used.
  37239. */
  37240. pinchDeltaPercentage: number;
  37241. /**
  37242. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37243. */
  37244. axisXControlRadius: boolean;
  37245. /**
  37246. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37247. */
  37248. axisXControlHeight: boolean;
  37249. /**
  37250. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37251. */
  37252. axisXControlRotation: boolean;
  37253. /**
  37254. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37255. */
  37256. axisYControlRadius: boolean;
  37257. /**
  37258. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37259. */
  37260. axisYControlHeight: boolean;
  37261. /**
  37262. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37263. */
  37264. axisYControlRotation: boolean;
  37265. /**
  37266. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37267. */
  37268. axisPinchControlRadius: boolean;
  37269. /**
  37270. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37271. */
  37272. axisPinchControlHeight: boolean;
  37273. /**
  37274. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37275. */
  37276. axisPinchControlRotation: boolean;
  37277. /**
  37278. * Log error messages if basic misconfiguration has occurred.
  37279. */
  37280. warningEnable: boolean;
  37281. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37282. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37283. private _warningCounter;
  37284. private _warning;
  37285. }
  37286. }
  37287. declare module BABYLON {
  37288. /**
  37289. * Default Inputs manager for the FollowCamera.
  37290. * It groups all the default supported inputs for ease of use.
  37291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37292. */
  37293. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37294. /**
  37295. * Instantiates a new FollowCameraInputsManager.
  37296. * @param camera Defines the camera the inputs belong to
  37297. */
  37298. constructor(camera: FollowCamera);
  37299. /**
  37300. * Add keyboard input support to the input manager.
  37301. * @returns the current input manager
  37302. */
  37303. addKeyboard(): FollowCameraInputsManager;
  37304. /**
  37305. * Add mouse wheel input support to the input manager.
  37306. * @returns the current input manager
  37307. */
  37308. addMouseWheel(): FollowCameraInputsManager;
  37309. /**
  37310. * Add pointers input support to the input manager.
  37311. * @returns the current input manager
  37312. */
  37313. addPointers(): FollowCameraInputsManager;
  37314. /**
  37315. * Add orientation input support to the input manager.
  37316. * @returns the current input manager
  37317. */
  37318. addVRDeviceOrientation(): FollowCameraInputsManager;
  37319. }
  37320. }
  37321. declare module BABYLON {
  37322. /**
  37323. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37324. * an arc rotate version arcFollowCamera are available.
  37325. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37326. */
  37327. export class FollowCamera extends TargetCamera {
  37328. /**
  37329. * Distance the follow camera should follow an object at
  37330. */
  37331. radius: number;
  37332. /**
  37333. * Minimum allowed distance of the camera to the axis of rotation
  37334. * (The camera can not get closer).
  37335. * This can help limiting how the Camera is able to move in the scene.
  37336. */
  37337. lowerRadiusLimit: Nullable<number>;
  37338. /**
  37339. * Maximum allowed distance of the camera to the axis of rotation
  37340. * (The camera can not get further).
  37341. * This can help limiting how the Camera is able to move in the scene.
  37342. */
  37343. upperRadiusLimit: Nullable<number>;
  37344. /**
  37345. * Define a rotation offset between the camera and the object it follows
  37346. */
  37347. rotationOffset: number;
  37348. /**
  37349. * Minimum allowed angle to camera position relative to target object.
  37350. * This can help limiting how the Camera is able to move in the scene.
  37351. */
  37352. lowerRotationOffsetLimit: Nullable<number>;
  37353. /**
  37354. * Maximum allowed angle to camera position relative to target object.
  37355. * This can help limiting how the Camera is able to move in the scene.
  37356. */
  37357. upperRotationOffsetLimit: Nullable<number>;
  37358. /**
  37359. * Define a height offset between the camera and the object it follows.
  37360. * It can help following an object from the top (like a car chaing a plane)
  37361. */
  37362. heightOffset: number;
  37363. /**
  37364. * Minimum allowed height of camera position relative to target object.
  37365. * This can help limiting how the Camera is able to move in the scene.
  37366. */
  37367. lowerHeightOffsetLimit: Nullable<number>;
  37368. /**
  37369. * Maximum allowed height of camera position relative to target object.
  37370. * This can help limiting how the Camera is able to move in the scene.
  37371. */
  37372. upperHeightOffsetLimit: Nullable<number>;
  37373. /**
  37374. * Define how fast the camera can accelerate to follow it s target.
  37375. */
  37376. cameraAcceleration: number;
  37377. /**
  37378. * Define the speed limit of the camera following an object.
  37379. */
  37380. maxCameraSpeed: number;
  37381. /**
  37382. * Define the target of the camera.
  37383. */
  37384. lockedTarget: Nullable<AbstractMesh>;
  37385. /**
  37386. * Defines the input associated with the camera.
  37387. */
  37388. inputs: FollowCameraInputsManager;
  37389. /**
  37390. * Instantiates the follow camera.
  37391. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37392. * @param name Define the name of the camera in the scene
  37393. * @param position Define the position of the camera
  37394. * @param scene Define the scene the camera belong to
  37395. * @param lockedTarget Define the target of the camera
  37396. */
  37397. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37398. private _follow;
  37399. /**
  37400. * Attached controls to the current camera.
  37401. * @param element Defines the element the controls should be listened from
  37402. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37403. */
  37404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37405. /**
  37406. * Detach the current controls from the camera.
  37407. * The camera will stop reacting to inputs.
  37408. * @param element Defines the element to stop listening the inputs from
  37409. */
  37410. detachControl(element: HTMLElement): void;
  37411. /** @hidden */
  37412. _checkInputs(): void;
  37413. private _checkLimits;
  37414. /**
  37415. * Gets the camera class name.
  37416. * @returns the class name
  37417. */
  37418. getClassName(): string;
  37419. }
  37420. /**
  37421. * Arc Rotate version of the follow camera.
  37422. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37423. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37424. */
  37425. export class ArcFollowCamera extends TargetCamera {
  37426. /** The longitudinal angle of the camera */
  37427. alpha: number;
  37428. /** The latitudinal angle of the camera */
  37429. beta: number;
  37430. /** The radius of the camera from its target */
  37431. radius: number;
  37432. /** Define the camera target (the messh it should follow) */
  37433. target: Nullable<AbstractMesh>;
  37434. private _cartesianCoordinates;
  37435. /**
  37436. * Instantiates a new ArcFollowCamera
  37437. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37438. * @param name Define the name of the camera
  37439. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37440. * @param beta Define the rotation angle of the camera around the elevation axis
  37441. * @param radius Define the radius of the camera from its target point
  37442. * @param target Define the target of the camera
  37443. * @param scene Define the scene the camera belongs to
  37444. */
  37445. constructor(name: string,
  37446. /** The longitudinal angle of the camera */
  37447. alpha: number,
  37448. /** The latitudinal angle of the camera */
  37449. beta: number,
  37450. /** The radius of the camera from its target */
  37451. radius: number,
  37452. /** Define the camera target (the messh it should follow) */
  37453. target: Nullable<AbstractMesh>, scene: Scene);
  37454. private _follow;
  37455. /** @hidden */
  37456. _checkInputs(): void;
  37457. /**
  37458. * Returns the class name of the object.
  37459. * It is mostly used internally for serialization purposes.
  37460. */
  37461. getClassName(): string;
  37462. }
  37463. }
  37464. declare module BABYLON {
  37465. /**
  37466. * Manage the keyboard inputs to control the movement of a follow camera.
  37467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37468. */
  37469. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37470. /**
  37471. * Defines the camera the input is attached to.
  37472. */
  37473. camera: FollowCamera;
  37474. /**
  37475. * Defines the list of key codes associated with the up action (increase heightOffset)
  37476. */
  37477. keysHeightOffsetIncr: number[];
  37478. /**
  37479. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37480. */
  37481. keysHeightOffsetDecr: number[];
  37482. /**
  37483. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37484. */
  37485. keysHeightOffsetModifierAlt: boolean;
  37486. /**
  37487. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37488. */
  37489. keysHeightOffsetModifierCtrl: boolean;
  37490. /**
  37491. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37492. */
  37493. keysHeightOffsetModifierShift: boolean;
  37494. /**
  37495. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37496. */
  37497. keysRotationOffsetIncr: number[];
  37498. /**
  37499. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37500. */
  37501. keysRotationOffsetDecr: number[];
  37502. /**
  37503. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37504. */
  37505. keysRotationOffsetModifierAlt: boolean;
  37506. /**
  37507. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37508. */
  37509. keysRotationOffsetModifierCtrl: boolean;
  37510. /**
  37511. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37512. */
  37513. keysRotationOffsetModifierShift: boolean;
  37514. /**
  37515. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37516. */
  37517. keysRadiusIncr: number[];
  37518. /**
  37519. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37520. */
  37521. keysRadiusDecr: number[];
  37522. /**
  37523. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37524. */
  37525. keysRadiusModifierAlt: boolean;
  37526. /**
  37527. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37528. */
  37529. keysRadiusModifierCtrl: boolean;
  37530. /**
  37531. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37532. */
  37533. keysRadiusModifierShift: boolean;
  37534. /**
  37535. * Defines the rate of change of heightOffset.
  37536. */
  37537. heightSensibility: number;
  37538. /**
  37539. * Defines the rate of change of rotationOffset.
  37540. */
  37541. rotationSensibility: number;
  37542. /**
  37543. * Defines the rate of change of radius.
  37544. */
  37545. radiusSensibility: number;
  37546. private _keys;
  37547. private _ctrlPressed;
  37548. private _altPressed;
  37549. private _shiftPressed;
  37550. private _onCanvasBlurObserver;
  37551. private _onKeyboardObserver;
  37552. private _engine;
  37553. private _scene;
  37554. /**
  37555. * Attach the input controls to a specific dom element to get the input from.
  37556. * @param element Defines the element the controls should be listened from
  37557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37558. */
  37559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37560. /**
  37561. * Detach the current controls from the specified dom element.
  37562. * @param element Defines the element to stop listening the inputs from
  37563. */
  37564. detachControl(element: Nullable<HTMLElement>): void;
  37565. /**
  37566. * Update the current camera state depending on the inputs that have been used this frame.
  37567. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37568. */
  37569. checkInputs(): void;
  37570. /**
  37571. * Gets the class name of the current input.
  37572. * @returns the class name
  37573. */
  37574. getClassName(): string;
  37575. /**
  37576. * Get the friendly name associated with the input class.
  37577. * @returns the input friendly name
  37578. */
  37579. getSimpleName(): string;
  37580. /**
  37581. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37582. * allow modification of the heightOffset value.
  37583. */
  37584. private _modifierHeightOffset;
  37585. /**
  37586. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37587. * allow modification of the rotationOffset value.
  37588. */
  37589. private _modifierRotationOffset;
  37590. /**
  37591. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37592. * allow modification of the radius value.
  37593. */
  37594. private _modifierRadius;
  37595. }
  37596. }
  37597. declare module BABYLON {
  37598. interface FreeCameraInputsManager {
  37599. /**
  37600. * @hidden
  37601. */
  37602. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37603. /**
  37604. * Add orientation input support to the input manager.
  37605. * @returns the current input manager
  37606. */
  37607. addDeviceOrientation(): FreeCameraInputsManager;
  37608. }
  37609. /**
  37610. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37611. * Screen rotation is taken into account.
  37612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37613. */
  37614. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37615. private _camera;
  37616. private _screenOrientationAngle;
  37617. private _constantTranform;
  37618. private _screenQuaternion;
  37619. private _alpha;
  37620. private _beta;
  37621. private _gamma;
  37622. /**
  37623. * Can be used to detect if a device orientation sensor is availible on a device
  37624. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37625. * @returns a promise that will resolve on orientation change
  37626. */
  37627. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37628. /**
  37629. * @hidden
  37630. */
  37631. _onDeviceOrientationChangedObservable: Observable<void>;
  37632. /**
  37633. * Instantiates a new input
  37634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37635. */
  37636. constructor();
  37637. /**
  37638. * Define the camera controlled by the input.
  37639. */
  37640. camera: FreeCamera;
  37641. /**
  37642. * Attach the input controls to a specific dom element to get the input from.
  37643. * @param element Defines the element the controls should be listened from
  37644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37645. */
  37646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37647. private _orientationChanged;
  37648. private _deviceOrientation;
  37649. /**
  37650. * Detach the current controls from the specified dom element.
  37651. * @param element Defines the element to stop listening the inputs from
  37652. */
  37653. detachControl(element: Nullable<HTMLElement>): void;
  37654. /**
  37655. * Update the current camera state depending on the inputs that have been used this frame.
  37656. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37657. */
  37658. checkInputs(): void;
  37659. /**
  37660. * Gets the class name of the current intput.
  37661. * @returns the class name
  37662. */
  37663. getClassName(): string;
  37664. /**
  37665. * Get the friendly name associated with the input class.
  37666. * @returns the input friendly name
  37667. */
  37668. getSimpleName(): string;
  37669. }
  37670. }
  37671. declare module BABYLON {
  37672. /**
  37673. * Manage the gamepad inputs to control a free camera.
  37674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37675. */
  37676. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37677. /**
  37678. * Define the camera the input is attached to.
  37679. */
  37680. camera: FreeCamera;
  37681. /**
  37682. * Define the Gamepad controlling the input
  37683. */
  37684. gamepad: Nullable<Gamepad>;
  37685. /**
  37686. * Defines the gamepad rotation sensiblity.
  37687. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37688. */
  37689. gamepadAngularSensibility: number;
  37690. /**
  37691. * Defines the gamepad move sensiblity.
  37692. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37693. */
  37694. gamepadMoveSensibility: number;
  37695. private _onGamepadConnectedObserver;
  37696. private _onGamepadDisconnectedObserver;
  37697. private _cameraTransform;
  37698. private _deltaTransform;
  37699. private _vector3;
  37700. private _vector2;
  37701. /**
  37702. * Attach the input controls to a specific dom element to get the input from.
  37703. * @param element Defines the element the controls should be listened from
  37704. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37705. */
  37706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37707. /**
  37708. * Detach the current controls from the specified dom element.
  37709. * @param element Defines the element to stop listening the inputs from
  37710. */
  37711. detachControl(element: Nullable<HTMLElement>): void;
  37712. /**
  37713. * Update the current camera state depending on the inputs that have been used this frame.
  37714. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37715. */
  37716. checkInputs(): void;
  37717. /**
  37718. * Gets the class name of the current intput.
  37719. * @returns the class name
  37720. */
  37721. getClassName(): string;
  37722. /**
  37723. * Get the friendly name associated with the input class.
  37724. * @returns the input friendly name
  37725. */
  37726. getSimpleName(): string;
  37727. }
  37728. }
  37729. declare module BABYLON {
  37730. /**
  37731. * Defines the potential axis of a Joystick
  37732. */
  37733. export enum JoystickAxis {
  37734. /** X axis */
  37735. X = 0,
  37736. /** Y axis */
  37737. Y = 1,
  37738. /** Z axis */
  37739. Z = 2
  37740. }
  37741. /**
  37742. * Class used to define virtual joystick (used in touch mode)
  37743. */
  37744. export class VirtualJoystick {
  37745. /**
  37746. * Gets or sets a boolean indicating that left and right values must be inverted
  37747. */
  37748. reverseLeftRight: boolean;
  37749. /**
  37750. * Gets or sets a boolean indicating that up and down values must be inverted
  37751. */
  37752. reverseUpDown: boolean;
  37753. /**
  37754. * Gets the offset value for the position (ie. the change of the position value)
  37755. */
  37756. deltaPosition: Vector3;
  37757. /**
  37758. * Gets a boolean indicating if the virtual joystick was pressed
  37759. */
  37760. pressed: boolean;
  37761. /**
  37762. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37763. */
  37764. static Canvas: Nullable<HTMLCanvasElement>;
  37765. private static _globalJoystickIndex;
  37766. private static vjCanvasContext;
  37767. private static vjCanvasWidth;
  37768. private static vjCanvasHeight;
  37769. private static halfWidth;
  37770. private _action;
  37771. private _axisTargetedByLeftAndRight;
  37772. private _axisTargetedByUpAndDown;
  37773. private _joystickSensibility;
  37774. private _inversedSensibility;
  37775. private _joystickPointerID;
  37776. private _joystickColor;
  37777. private _joystickPointerPos;
  37778. private _joystickPreviousPointerPos;
  37779. private _joystickPointerStartPos;
  37780. private _deltaJoystickVector;
  37781. private _leftJoystick;
  37782. private _touches;
  37783. private _onPointerDownHandlerRef;
  37784. private _onPointerMoveHandlerRef;
  37785. private _onPointerUpHandlerRef;
  37786. private _onResize;
  37787. /**
  37788. * Creates a new virtual joystick
  37789. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37790. */
  37791. constructor(leftJoystick?: boolean);
  37792. /**
  37793. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37794. * @param newJoystickSensibility defines the new sensibility
  37795. */
  37796. setJoystickSensibility(newJoystickSensibility: number): void;
  37797. private _onPointerDown;
  37798. private _onPointerMove;
  37799. private _onPointerUp;
  37800. /**
  37801. * Change the color of the virtual joystick
  37802. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37803. */
  37804. setJoystickColor(newColor: string): void;
  37805. /**
  37806. * Defines a callback to call when the joystick is touched
  37807. * @param action defines the callback
  37808. */
  37809. setActionOnTouch(action: () => any): void;
  37810. /**
  37811. * Defines which axis you'd like to control for left & right
  37812. * @param axis defines the axis to use
  37813. */
  37814. setAxisForLeftRight(axis: JoystickAxis): void;
  37815. /**
  37816. * Defines which axis you'd like to control for up & down
  37817. * @param axis defines the axis to use
  37818. */
  37819. setAxisForUpDown(axis: JoystickAxis): void;
  37820. private _drawVirtualJoystick;
  37821. /**
  37822. * Release internal HTML canvas
  37823. */
  37824. releaseCanvas(): void;
  37825. }
  37826. }
  37827. declare module BABYLON {
  37828. interface FreeCameraInputsManager {
  37829. /**
  37830. * Add virtual joystick input support to the input manager.
  37831. * @returns the current input manager
  37832. */
  37833. addVirtualJoystick(): FreeCameraInputsManager;
  37834. }
  37835. /**
  37836. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37837. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37838. */
  37839. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37840. /**
  37841. * Defines the camera the input is attached to.
  37842. */
  37843. camera: FreeCamera;
  37844. private _leftjoystick;
  37845. private _rightjoystick;
  37846. /**
  37847. * Gets the left stick of the virtual joystick.
  37848. * @returns The virtual Joystick
  37849. */
  37850. getLeftJoystick(): VirtualJoystick;
  37851. /**
  37852. * Gets the right stick of the virtual joystick.
  37853. * @returns The virtual Joystick
  37854. */
  37855. getRightJoystick(): VirtualJoystick;
  37856. /**
  37857. * Update the current camera state depending on the inputs that have been used this frame.
  37858. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37859. */
  37860. checkInputs(): void;
  37861. /**
  37862. * Attach the input controls to a specific dom element to get the input from.
  37863. * @param element Defines the element the controls should be listened from
  37864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37865. */
  37866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37867. /**
  37868. * Detach the current controls from the specified dom element.
  37869. * @param element Defines the element to stop listening the inputs from
  37870. */
  37871. detachControl(element: Nullable<HTMLElement>): void;
  37872. /**
  37873. * Gets the class name of the current intput.
  37874. * @returns the class name
  37875. */
  37876. getClassName(): string;
  37877. /**
  37878. * Get the friendly name associated with the input class.
  37879. * @returns the input friendly name
  37880. */
  37881. getSimpleName(): string;
  37882. }
  37883. }
  37884. declare module BABYLON {
  37885. /**
  37886. * This represents a FPS type of camera controlled by touch.
  37887. * This is like a universal camera minus the Gamepad controls.
  37888. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37889. */
  37890. export class TouchCamera extends FreeCamera {
  37891. /**
  37892. * Defines the touch sensibility for rotation.
  37893. * The higher the faster.
  37894. */
  37895. touchAngularSensibility: number;
  37896. /**
  37897. * Defines the touch sensibility for move.
  37898. * The higher the faster.
  37899. */
  37900. touchMoveSensibility: number;
  37901. /**
  37902. * Instantiates a new touch camera.
  37903. * This represents a FPS type of camera controlled by touch.
  37904. * This is like a universal camera minus the Gamepad controls.
  37905. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37906. * @param name Define the name of the camera in the scene
  37907. * @param position Define the start position of the camera in the scene
  37908. * @param scene Define the scene the camera belongs to
  37909. */
  37910. constructor(name: string, position: Vector3, scene: Scene);
  37911. /**
  37912. * Gets the current object class name.
  37913. * @return the class name
  37914. */
  37915. getClassName(): string;
  37916. /** @hidden */
  37917. _setupInputs(): void;
  37918. }
  37919. }
  37920. declare module BABYLON {
  37921. /**
  37922. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37923. * being tilted forward or back and left or right.
  37924. */
  37925. export class DeviceOrientationCamera extends FreeCamera {
  37926. private _initialQuaternion;
  37927. private _quaternionCache;
  37928. private _tmpDragQuaternion;
  37929. /**
  37930. * Creates a new device orientation camera
  37931. * @param name The name of the camera
  37932. * @param position The start position camera
  37933. * @param scene The scene the camera belongs to
  37934. */
  37935. constructor(name: string, position: Vector3, scene: Scene);
  37936. /**
  37937. * @hidden
  37938. * Disabled pointer input on first orientation sensor update (Default: true)
  37939. */
  37940. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37941. private _dragFactor;
  37942. /**
  37943. * Enabled turning on the y axis when the orientation sensor is active
  37944. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37945. */
  37946. enableHorizontalDragging(dragFactor?: number): void;
  37947. /**
  37948. * Gets the current instance class name ("DeviceOrientationCamera").
  37949. * This helps avoiding instanceof at run time.
  37950. * @returns the class name
  37951. */
  37952. getClassName(): string;
  37953. /**
  37954. * @hidden
  37955. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37956. */
  37957. _checkInputs(): void;
  37958. /**
  37959. * Reset the camera to its default orientation on the specified axis only.
  37960. * @param axis The axis to reset
  37961. */
  37962. resetToCurrentRotation(axis?: Axis): void;
  37963. }
  37964. }
  37965. declare module BABYLON {
  37966. /**
  37967. * Defines supported buttons for XBox360 compatible gamepads
  37968. */
  37969. export enum Xbox360Button {
  37970. /** A */
  37971. A = 0,
  37972. /** B */
  37973. B = 1,
  37974. /** X */
  37975. X = 2,
  37976. /** Y */
  37977. Y = 3,
  37978. /** Start */
  37979. Start = 4,
  37980. /** Back */
  37981. Back = 5,
  37982. /** Left button */
  37983. LB = 6,
  37984. /** Right button */
  37985. RB = 7,
  37986. /** Left stick */
  37987. LeftStick = 8,
  37988. /** Right stick */
  37989. RightStick = 9
  37990. }
  37991. /** Defines values for XBox360 DPad */
  37992. export enum Xbox360Dpad {
  37993. /** Up */
  37994. Up = 0,
  37995. /** Down */
  37996. Down = 1,
  37997. /** Left */
  37998. Left = 2,
  37999. /** Right */
  38000. Right = 3
  38001. }
  38002. /**
  38003. * Defines a XBox360 gamepad
  38004. */
  38005. export class Xbox360Pad extends Gamepad {
  38006. private _leftTrigger;
  38007. private _rightTrigger;
  38008. private _onlefttriggerchanged;
  38009. private _onrighttriggerchanged;
  38010. private _onbuttondown;
  38011. private _onbuttonup;
  38012. private _ondpaddown;
  38013. private _ondpadup;
  38014. /** Observable raised when a button is pressed */
  38015. onButtonDownObservable: Observable<Xbox360Button>;
  38016. /** Observable raised when a button is released */
  38017. onButtonUpObservable: Observable<Xbox360Button>;
  38018. /** Observable raised when a pad is pressed */
  38019. onPadDownObservable: Observable<Xbox360Dpad>;
  38020. /** Observable raised when a pad is released */
  38021. onPadUpObservable: Observable<Xbox360Dpad>;
  38022. private _buttonA;
  38023. private _buttonB;
  38024. private _buttonX;
  38025. private _buttonY;
  38026. private _buttonBack;
  38027. private _buttonStart;
  38028. private _buttonLB;
  38029. private _buttonRB;
  38030. private _buttonLeftStick;
  38031. private _buttonRightStick;
  38032. private _dPadUp;
  38033. private _dPadDown;
  38034. private _dPadLeft;
  38035. private _dPadRight;
  38036. private _isXboxOnePad;
  38037. /**
  38038. * Creates a new XBox360 gamepad object
  38039. * @param id defines the id of this gamepad
  38040. * @param index defines its index
  38041. * @param gamepad defines the internal HTML gamepad object
  38042. * @param xboxOne defines if it is a XBox One gamepad
  38043. */
  38044. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38045. /**
  38046. * Defines the callback to call when left trigger is pressed
  38047. * @param callback defines the callback to use
  38048. */
  38049. onlefttriggerchanged(callback: (value: number) => void): void;
  38050. /**
  38051. * Defines the callback to call when right trigger is pressed
  38052. * @param callback defines the callback to use
  38053. */
  38054. onrighttriggerchanged(callback: (value: number) => void): void;
  38055. /**
  38056. * Gets the left trigger value
  38057. */
  38058. /**
  38059. * Sets the left trigger value
  38060. */
  38061. leftTrigger: number;
  38062. /**
  38063. * Gets the right trigger value
  38064. */
  38065. /**
  38066. * Sets the right trigger value
  38067. */
  38068. rightTrigger: number;
  38069. /**
  38070. * Defines the callback to call when a button is pressed
  38071. * @param callback defines the callback to use
  38072. */
  38073. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38074. /**
  38075. * Defines the callback to call when a button is released
  38076. * @param callback defines the callback to use
  38077. */
  38078. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38079. /**
  38080. * Defines the callback to call when a pad is pressed
  38081. * @param callback defines the callback to use
  38082. */
  38083. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38084. /**
  38085. * Defines the callback to call when a pad is released
  38086. * @param callback defines the callback to use
  38087. */
  38088. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38089. private _setButtonValue;
  38090. private _setDPadValue;
  38091. /**
  38092. * Gets the value of the `A` button
  38093. */
  38094. /**
  38095. * Sets the value of the `A` button
  38096. */
  38097. buttonA: number;
  38098. /**
  38099. * Gets the value of the `B` button
  38100. */
  38101. /**
  38102. * Sets the value of the `B` button
  38103. */
  38104. buttonB: number;
  38105. /**
  38106. * Gets the value of the `X` button
  38107. */
  38108. /**
  38109. * Sets the value of the `X` button
  38110. */
  38111. buttonX: number;
  38112. /**
  38113. * Gets the value of the `Y` button
  38114. */
  38115. /**
  38116. * Sets the value of the `Y` button
  38117. */
  38118. buttonY: number;
  38119. /**
  38120. * Gets the value of the `Start` button
  38121. */
  38122. /**
  38123. * Sets the value of the `Start` button
  38124. */
  38125. buttonStart: number;
  38126. /**
  38127. * Gets the value of the `Back` button
  38128. */
  38129. /**
  38130. * Sets the value of the `Back` button
  38131. */
  38132. buttonBack: number;
  38133. /**
  38134. * Gets the value of the `Left` button
  38135. */
  38136. /**
  38137. * Sets the value of the `Left` button
  38138. */
  38139. buttonLB: number;
  38140. /**
  38141. * Gets the value of the `Right` button
  38142. */
  38143. /**
  38144. * Sets the value of the `Right` button
  38145. */
  38146. buttonRB: number;
  38147. /**
  38148. * Gets the value of the Left joystick
  38149. */
  38150. /**
  38151. * Sets the value of the Left joystick
  38152. */
  38153. buttonLeftStick: number;
  38154. /**
  38155. * Gets the value of the Right joystick
  38156. */
  38157. /**
  38158. * Sets the value of the Right joystick
  38159. */
  38160. buttonRightStick: number;
  38161. /**
  38162. * Gets the value of D-pad up
  38163. */
  38164. /**
  38165. * Sets the value of D-pad up
  38166. */
  38167. dPadUp: number;
  38168. /**
  38169. * Gets the value of D-pad down
  38170. */
  38171. /**
  38172. * Sets the value of D-pad down
  38173. */
  38174. dPadDown: number;
  38175. /**
  38176. * Gets the value of D-pad left
  38177. */
  38178. /**
  38179. * Sets the value of D-pad left
  38180. */
  38181. dPadLeft: number;
  38182. /**
  38183. * Gets the value of D-pad right
  38184. */
  38185. /**
  38186. * Sets the value of D-pad right
  38187. */
  38188. dPadRight: number;
  38189. /**
  38190. * Force the gamepad to synchronize with device values
  38191. */
  38192. update(): void;
  38193. /**
  38194. * Disposes the gamepad
  38195. */
  38196. dispose(): void;
  38197. }
  38198. }
  38199. declare module BABYLON {
  38200. /**
  38201. * Manager for handling gamepads
  38202. */
  38203. export class GamepadManager {
  38204. private _scene?;
  38205. private _babylonGamepads;
  38206. private _oneGamepadConnected;
  38207. /** @hidden */
  38208. _isMonitoring: boolean;
  38209. private _gamepadEventSupported;
  38210. private _gamepadSupport;
  38211. /**
  38212. * observable to be triggered when the gamepad controller has been connected
  38213. */
  38214. onGamepadConnectedObservable: Observable<Gamepad>;
  38215. /**
  38216. * observable to be triggered when the gamepad controller has been disconnected
  38217. */
  38218. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38219. private _onGamepadConnectedEvent;
  38220. private _onGamepadDisconnectedEvent;
  38221. /**
  38222. * Initializes the gamepad manager
  38223. * @param _scene BabylonJS scene
  38224. */
  38225. constructor(_scene?: Scene | undefined);
  38226. /**
  38227. * The gamepads in the game pad manager
  38228. */
  38229. readonly gamepads: Gamepad[];
  38230. /**
  38231. * Get the gamepad controllers based on type
  38232. * @param type The type of gamepad controller
  38233. * @returns Nullable gamepad
  38234. */
  38235. getGamepadByType(type?: number): Nullable<Gamepad>;
  38236. /**
  38237. * Disposes the gamepad manager
  38238. */
  38239. dispose(): void;
  38240. private _addNewGamepad;
  38241. private _startMonitoringGamepads;
  38242. private _stopMonitoringGamepads;
  38243. /** @hidden */
  38244. _checkGamepadsStatus(): void;
  38245. private _updateGamepadObjects;
  38246. }
  38247. }
  38248. declare module BABYLON {
  38249. interface Scene {
  38250. /** @hidden */
  38251. _gamepadManager: Nullable<GamepadManager>;
  38252. /**
  38253. * Gets the gamepad manager associated with the scene
  38254. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38255. */
  38256. gamepadManager: GamepadManager;
  38257. }
  38258. /**
  38259. * Interface representing a free camera inputs manager
  38260. */
  38261. interface FreeCameraInputsManager {
  38262. /**
  38263. * Adds gamepad input support to the FreeCameraInputsManager.
  38264. * @returns the FreeCameraInputsManager
  38265. */
  38266. addGamepad(): FreeCameraInputsManager;
  38267. }
  38268. /**
  38269. * Interface representing an arc rotate camera inputs manager
  38270. */
  38271. interface ArcRotateCameraInputsManager {
  38272. /**
  38273. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38274. * @returns the camera inputs manager
  38275. */
  38276. addGamepad(): ArcRotateCameraInputsManager;
  38277. }
  38278. /**
  38279. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38280. */
  38281. export class GamepadSystemSceneComponent implements ISceneComponent {
  38282. /**
  38283. * The component name helpfull to identify the component in the list of scene components.
  38284. */
  38285. readonly name: string;
  38286. /**
  38287. * The scene the component belongs to.
  38288. */
  38289. scene: Scene;
  38290. /**
  38291. * Creates a new instance of the component for the given scene
  38292. * @param scene Defines the scene to register the component in
  38293. */
  38294. constructor(scene: Scene);
  38295. /**
  38296. * Registers the component in a given scene
  38297. */
  38298. register(): void;
  38299. /**
  38300. * Rebuilds the elements related to this component in case of
  38301. * context lost for instance.
  38302. */
  38303. rebuild(): void;
  38304. /**
  38305. * Disposes the component and the associated ressources
  38306. */
  38307. dispose(): void;
  38308. private _beforeCameraUpdate;
  38309. }
  38310. }
  38311. declare module BABYLON {
  38312. /**
  38313. * 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,
  38314. * which still works and will still be found in many Playgrounds.
  38315. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38316. */
  38317. export class UniversalCamera extends TouchCamera {
  38318. /**
  38319. * Defines the gamepad rotation sensiblity.
  38320. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38321. */
  38322. gamepadAngularSensibility: number;
  38323. /**
  38324. * Defines the gamepad move sensiblity.
  38325. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38326. */
  38327. gamepadMoveSensibility: number;
  38328. /**
  38329. * 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,
  38330. * which still works and will still be found in many Playgrounds.
  38331. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38332. * @param name Define the name of the camera in the scene
  38333. * @param position Define the start position of the camera in the scene
  38334. * @param scene Define the scene the camera belongs to
  38335. */
  38336. constructor(name: string, position: Vector3, scene: Scene);
  38337. /**
  38338. * Gets the current object class name.
  38339. * @return the class name
  38340. */
  38341. getClassName(): string;
  38342. }
  38343. }
  38344. declare module BABYLON {
  38345. /**
  38346. * This represents a FPS type of camera. This is only here for back compat purpose.
  38347. * Please use the UniversalCamera instead as both are identical.
  38348. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38349. */
  38350. export class GamepadCamera extends UniversalCamera {
  38351. /**
  38352. * Instantiates a new Gamepad Camera
  38353. * This represents a FPS type of camera. This is only here for back compat purpose.
  38354. * Please use the UniversalCamera instead as both are identical.
  38355. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38356. * @param name Define the name of the camera in the scene
  38357. * @param position Define the start position of the camera in the scene
  38358. * @param scene Define the scene the camera belongs to
  38359. */
  38360. constructor(name: string, position: Vector3, scene: Scene);
  38361. /**
  38362. * Gets the current object class name.
  38363. * @return the class name
  38364. */
  38365. getClassName(): string;
  38366. }
  38367. }
  38368. declare module BABYLON {
  38369. /** @hidden */
  38370. export var passPixelShader: {
  38371. name: string;
  38372. shader: string;
  38373. };
  38374. }
  38375. declare module BABYLON {
  38376. /** @hidden */
  38377. export var passCubePixelShader: {
  38378. name: string;
  38379. shader: string;
  38380. };
  38381. }
  38382. declare module BABYLON {
  38383. /**
  38384. * PassPostProcess which produces an output the same as it's input
  38385. */
  38386. export class PassPostProcess extends PostProcess {
  38387. /**
  38388. * Creates the PassPostProcess
  38389. * @param name The name of the effect.
  38390. * @param options The required width/height ratio to downsize to before computing the render pass.
  38391. * @param camera The camera to apply the render pass to.
  38392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38393. * @param engine The engine which the post process will be applied. (default: current engine)
  38394. * @param reusable If the post process can be reused on the same frame. (default: false)
  38395. * @param textureType The type of texture to be used when performing the post processing.
  38396. * @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)
  38397. */
  38398. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38399. }
  38400. /**
  38401. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38402. */
  38403. export class PassCubePostProcess extends PostProcess {
  38404. private _face;
  38405. /**
  38406. * Gets or sets the cube face to display.
  38407. * * 0 is +X
  38408. * * 1 is -X
  38409. * * 2 is +Y
  38410. * * 3 is -Y
  38411. * * 4 is +Z
  38412. * * 5 is -Z
  38413. */
  38414. face: number;
  38415. /**
  38416. * Creates the PassCubePostProcess
  38417. * @param name The name of the effect.
  38418. * @param options The required width/height ratio to downsize to before computing the render pass.
  38419. * @param camera The camera to apply the render pass to.
  38420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38421. * @param engine The engine which the post process will be applied. (default: current engine)
  38422. * @param reusable If the post process can be reused on the same frame. (default: false)
  38423. * @param textureType The type of texture to be used when performing the post processing.
  38424. * @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)
  38425. */
  38426. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38427. }
  38428. }
  38429. declare module BABYLON {
  38430. /** @hidden */
  38431. export var anaglyphPixelShader: {
  38432. name: string;
  38433. shader: string;
  38434. };
  38435. }
  38436. declare module BABYLON {
  38437. /**
  38438. * Postprocess used to generate anaglyphic rendering
  38439. */
  38440. export class AnaglyphPostProcess extends PostProcess {
  38441. private _passedProcess;
  38442. /**
  38443. * Creates a new AnaglyphPostProcess
  38444. * @param name defines postprocess name
  38445. * @param options defines creation options or target ratio scale
  38446. * @param rigCameras defines cameras using this postprocess
  38447. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38448. * @param engine defines hosting engine
  38449. * @param reusable defines if the postprocess will be reused multiple times per frame
  38450. */
  38451. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38452. }
  38453. }
  38454. declare module BABYLON {
  38455. /**
  38456. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38457. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38458. */
  38459. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38460. /**
  38461. * Creates a new AnaglyphArcRotateCamera
  38462. * @param name defines camera name
  38463. * @param alpha defines alpha angle (in radians)
  38464. * @param beta defines beta angle (in radians)
  38465. * @param radius defines radius
  38466. * @param target defines camera target
  38467. * @param interaxialDistance defines distance between each color axis
  38468. * @param scene defines the hosting scene
  38469. */
  38470. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38471. /**
  38472. * Gets camera class name
  38473. * @returns AnaglyphArcRotateCamera
  38474. */
  38475. getClassName(): string;
  38476. }
  38477. }
  38478. declare module BABYLON {
  38479. /**
  38480. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38481. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38482. */
  38483. export class AnaglyphFreeCamera extends FreeCamera {
  38484. /**
  38485. * Creates a new AnaglyphFreeCamera
  38486. * @param name defines camera name
  38487. * @param position defines initial position
  38488. * @param interaxialDistance defines distance between each color axis
  38489. * @param scene defines the hosting scene
  38490. */
  38491. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38492. /**
  38493. * Gets camera class name
  38494. * @returns AnaglyphFreeCamera
  38495. */
  38496. getClassName(): string;
  38497. }
  38498. }
  38499. declare module BABYLON {
  38500. /**
  38501. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38502. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38503. */
  38504. export class AnaglyphGamepadCamera extends GamepadCamera {
  38505. /**
  38506. * Creates a new AnaglyphGamepadCamera
  38507. * @param name defines camera name
  38508. * @param position defines initial position
  38509. * @param interaxialDistance defines distance between each color axis
  38510. * @param scene defines the hosting scene
  38511. */
  38512. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38513. /**
  38514. * Gets camera class name
  38515. * @returns AnaglyphGamepadCamera
  38516. */
  38517. getClassName(): string;
  38518. }
  38519. }
  38520. declare module BABYLON {
  38521. /**
  38522. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38523. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38524. */
  38525. export class AnaglyphUniversalCamera extends UniversalCamera {
  38526. /**
  38527. * Creates a new AnaglyphUniversalCamera
  38528. * @param name defines camera name
  38529. * @param position defines initial position
  38530. * @param interaxialDistance defines distance between each color axis
  38531. * @param scene defines the hosting scene
  38532. */
  38533. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38534. /**
  38535. * Gets camera class name
  38536. * @returns AnaglyphUniversalCamera
  38537. */
  38538. getClassName(): string;
  38539. }
  38540. }
  38541. declare module BABYLON {
  38542. /** @hidden */
  38543. export var stereoscopicInterlacePixelShader: {
  38544. name: string;
  38545. shader: string;
  38546. };
  38547. }
  38548. declare module BABYLON {
  38549. /**
  38550. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38551. */
  38552. export class StereoscopicInterlacePostProcess extends PostProcess {
  38553. private _stepSize;
  38554. private _passedProcess;
  38555. /**
  38556. * Initializes a StereoscopicInterlacePostProcess
  38557. * @param name The name of the effect.
  38558. * @param rigCameras The rig cameras to be appled to the post process
  38559. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38561. * @param engine The engine which the post process will be applied. (default: current engine)
  38562. * @param reusable If the post process can be reused on the same frame. (default: false)
  38563. */
  38564. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38565. }
  38566. }
  38567. declare module BABYLON {
  38568. /**
  38569. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38570. * @see http://doc.babylonjs.com/features/cameras
  38571. */
  38572. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38573. /**
  38574. * Creates a new StereoscopicArcRotateCamera
  38575. * @param name defines camera name
  38576. * @param alpha defines alpha angle (in radians)
  38577. * @param beta defines beta angle (in radians)
  38578. * @param radius defines radius
  38579. * @param target defines camera target
  38580. * @param interaxialDistance defines distance between each color axis
  38581. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38582. * @param scene defines the hosting scene
  38583. */
  38584. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38585. /**
  38586. * Gets camera class name
  38587. * @returns StereoscopicArcRotateCamera
  38588. */
  38589. getClassName(): string;
  38590. }
  38591. }
  38592. declare module BABYLON {
  38593. /**
  38594. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38595. * @see http://doc.babylonjs.com/features/cameras
  38596. */
  38597. export class StereoscopicFreeCamera extends FreeCamera {
  38598. /**
  38599. * Creates a new StereoscopicFreeCamera
  38600. * @param name defines camera name
  38601. * @param position defines initial position
  38602. * @param interaxialDistance defines distance between each color axis
  38603. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38604. * @param scene defines the hosting scene
  38605. */
  38606. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38607. /**
  38608. * Gets camera class name
  38609. * @returns StereoscopicFreeCamera
  38610. */
  38611. getClassName(): string;
  38612. }
  38613. }
  38614. declare module BABYLON {
  38615. /**
  38616. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38617. * @see http://doc.babylonjs.com/features/cameras
  38618. */
  38619. export class StereoscopicGamepadCamera extends GamepadCamera {
  38620. /**
  38621. * Creates a new StereoscopicGamepadCamera
  38622. * @param name defines camera name
  38623. * @param position defines initial position
  38624. * @param interaxialDistance defines distance between each color axis
  38625. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38626. * @param scene defines the hosting scene
  38627. */
  38628. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38629. /**
  38630. * Gets camera class name
  38631. * @returns StereoscopicGamepadCamera
  38632. */
  38633. getClassName(): string;
  38634. }
  38635. }
  38636. declare module BABYLON {
  38637. /**
  38638. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38639. * @see http://doc.babylonjs.com/features/cameras
  38640. */
  38641. export class StereoscopicUniversalCamera extends UniversalCamera {
  38642. /**
  38643. * Creates a new StereoscopicUniversalCamera
  38644. * @param name defines camera name
  38645. * @param position defines initial position
  38646. * @param interaxialDistance defines distance between each color axis
  38647. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38648. * @param scene defines the hosting scene
  38649. */
  38650. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38651. /**
  38652. * Gets camera class name
  38653. * @returns StereoscopicUniversalCamera
  38654. */
  38655. getClassName(): string;
  38656. }
  38657. }
  38658. declare module BABYLON {
  38659. /**
  38660. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38661. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38662. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38663. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38664. */
  38665. export class VirtualJoysticksCamera extends FreeCamera {
  38666. /**
  38667. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38668. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38669. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38670. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38671. * @param name Define the name of the camera in the scene
  38672. * @param position Define the start position of the camera in the scene
  38673. * @param scene Define the scene the camera belongs to
  38674. */
  38675. constructor(name: string, position: Vector3, scene: Scene);
  38676. /**
  38677. * Gets the current object class name.
  38678. * @return the class name
  38679. */
  38680. getClassName(): string;
  38681. }
  38682. }
  38683. declare module BABYLON {
  38684. /**
  38685. * This represents all the required metrics to create a VR camera.
  38686. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38687. */
  38688. export class VRCameraMetrics {
  38689. /**
  38690. * Define the horizontal resolution off the screen.
  38691. */
  38692. hResolution: number;
  38693. /**
  38694. * Define the vertical resolution off the screen.
  38695. */
  38696. vResolution: number;
  38697. /**
  38698. * Define the horizontal screen size.
  38699. */
  38700. hScreenSize: number;
  38701. /**
  38702. * Define the vertical screen size.
  38703. */
  38704. vScreenSize: number;
  38705. /**
  38706. * Define the vertical screen center position.
  38707. */
  38708. vScreenCenter: number;
  38709. /**
  38710. * Define the distance of the eyes to the screen.
  38711. */
  38712. eyeToScreenDistance: number;
  38713. /**
  38714. * Define the distance between both lenses
  38715. */
  38716. lensSeparationDistance: number;
  38717. /**
  38718. * Define the distance between both viewer's eyes.
  38719. */
  38720. interpupillaryDistance: number;
  38721. /**
  38722. * Define the distortion factor of the VR postprocess.
  38723. * Please, touch with care.
  38724. */
  38725. distortionK: number[];
  38726. /**
  38727. * Define the chromatic aberration correction factors for the VR post process.
  38728. */
  38729. chromaAbCorrection: number[];
  38730. /**
  38731. * Define the scale factor of the post process.
  38732. * The smaller the better but the slower.
  38733. */
  38734. postProcessScaleFactor: number;
  38735. /**
  38736. * Define an offset for the lens center.
  38737. */
  38738. lensCenterOffset: number;
  38739. /**
  38740. * Define if the current vr camera should compensate the distortion of the lense or not.
  38741. */
  38742. compensateDistortion: boolean;
  38743. /**
  38744. * Defines if multiview should be enabled when rendering (Default: false)
  38745. */
  38746. multiviewEnabled: boolean;
  38747. /**
  38748. * Gets the rendering aspect ratio based on the provided resolutions.
  38749. */
  38750. readonly aspectRatio: number;
  38751. /**
  38752. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38753. */
  38754. readonly aspectRatioFov: number;
  38755. /**
  38756. * @hidden
  38757. */
  38758. readonly leftHMatrix: Matrix;
  38759. /**
  38760. * @hidden
  38761. */
  38762. readonly rightHMatrix: Matrix;
  38763. /**
  38764. * @hidden
  38765. */
  38766. readonly leftPreViewMatrix: Matrix;
  38767. /**
  38768. * @hidden
  38769. */
  38770. readonly rightPreViewMatrix: Matrix;
  38771. /**
  38772. * Get the default VRMetrics based on the most generic setup.
  38773. * @returns the default vr metrics
  38774. */
  38775. static GetDefault(): VRCameraMetrics;
  38776. }
  38777. }
  38778. declare module BABYLON {
  38779. /** @hidden */
  38780. export var vrDistortionCorrectionPixelShader: {
  38781. name: string;
  38782. shader: string;
  38783. };
  38784. }
  38785. declare module BABYLON {
  38786. /**
  38787. * VRDistortionCorrectionPostProcess used for mobile VR
  38788. */
  38789. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38790. private _isRightEye;
  38791. private _distortionFactors;
  38792. private _postProcessScaleFactor;
  38793. private _lensCenterOffset;
  38794. private _scaleIn;
  38795. private _scaleFactor;
  38796. private _lensCenter;
  38797. /**
  38798. * Initializes the VRDistortionCorrectionPostProcess
  38799. * @param name The name of the effect.
  38800. * @param camera The camera to apply the render pass to.
  38801. * @param isRightEye If this is for the right eye distortion
  38802. * @param vrMetrics All the required metrics for the VR camera
  38803. */
  38804. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38805. }
  38806. }
  38807. declare module BABYLON {
  38808. /**
  38809. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38810. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38811. */
  38812. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38813. /**
  38814. * Creates a new VRDeviceOrientationArcRotateCamera
  38815. * @param name defines camera name
  38816. * @param alpha defines the camera rotation along the logitudinal axis
  38817. * @param beta defines the camera rotation along the latitudinal axis
  38818. * @param radius defines the camera distance from its target
  38819. * @param target defines the camera target
  38820. * @param scene defines the scene the camera belongs to
  38821. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38822. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38823. */
  38824. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38825. /**
  38826. * Gets camera class name
  38827. * @returns VRDeviceOrientationArcRotateCamera
  38828. */
  38829. getClassName(): string;
  38830. }
  38831. }
  38832. declare module BABYLON {
  38833. /**
  38834. * Camera used to simulate VR rendering (based on FreeCamera)
  38835. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38836. */
  38837. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38838. /**
  38839. * Creates a new VRDeviceOrientationFreeCamera
  38840. * @param name defines camera name
  38841. * @param position defines the start position of the camera
  38842. * @param scene defines the scene the camera belongs to
  38843. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38844. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38845. */
  38846. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38847. /**
  38848. * Gets camera class name
  38849. * @returns VRDeviceOrientationFreeCamera
  38850. */
  38851. getClassName(): string;
  38852. }
  38853. }
  38854. declare module BABYLON {
  38855. /**
  38856. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38857. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38858. */
  38859. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38860. /**
  38861. * Creates a new VRDeviceOrientationGamepadCamera
  38862. * @param name defines camera name
  38863. * @param position defines the start position of the camera
  38864. * @param scene defines the scene the camera belongs to
  38865. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38866. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38867. */
  38868. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38869. /**
  38870. * Gets camera class name
  38871. * @returns VRDeviceOrientationGamepadCamera
  38872. */
  38873. getClassName(): string;
  38874. }
  38875. }
  38876. declare module BABYLON {
  38877. /**
  38878. * Base class of materials working in push mode in babylon JS
  38879. * @hidden
  38880. */
  38881. export class PushMaterial extends Material {
  38882. protected _activeEffect: Effect;
  38883. protected _normalMatrix: Matrix;
  38884. /**
  38885. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38886. * This means that the material can keep using a previous shader while a new one is being compiled.
  38887. * This is mostly used when shader parallel compilation is supported (true by default)
  38888. */
  38889. allowShaderHotSwapping: boolean;
  38890. constructor(name: string, scene: Scene);
  38891. getEffect(): Effect;
  38892. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38893. /**
  38894. * Binds the given world matrix to the active effect
  38895. *
  38896. * @param world the matrix to bind
  38897. */
  38898. bindOnlyWorldMatrix(world: Matrix): void;
  38899. /**
  38900. * Binds the given normal matrix to the active effect
  38901. *
  38902. * @param normalMatrix the matrix to bind
  38903. */
  38904. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38905. bind(world: Matrix, mesh?: Mesh): void;
  38906. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38907. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38908. }
  38909. }
  38910. declare module BABYLON {
  38911. /**
  38912. * This groups all the flags used to control the materials channel.
  38913. */
  38914. export class MaterialFlags {
  38915. private static _DiffuseTextureEnabled;
  38916. /**
  38917. * Are diffuse textures enabled in the application.
  38918. */
  38919. static DiffuseTextureEnabled: boolean;
  38920. private static _AmbientTextureEnabled;
  38921. /**
  38922. * Are ambient textures enabled in the application.
  38923. */
  38924. static AmbientTextureEnabled: boolean;
  38925. private static _OpacityTextureEnabled;
  38926. /**
  38927. * Are opacity textures enabled in the application.
  38928. */
  38929. static OpacityTextureEnabled: boolean;
  38930. private static _ReflectionTextureEnabled;
  38931. /**
  38932. * Are reflection textures enabled in the application.
  38933. */
  38934. static ReflectionTextureEnabled: boolean;
  38935. private static _EmissiveTextureEnabled;
  38936. /**
  38937. * Are emissive textures enabled in the application.
  38938. */
  38939. static EmissiveTextureEnabled: boolean;
  38940. private static _SpecularTextureEnabled;
  38941. /**
  38942. * Are specular textures enabled in the application.
  38943. */
  38944. static SpecularTextureEnabled: boolean;
  38945. private static _BumpTextureEnabled;
  38946. /**
  38947. * Are bump textures enabled in the application.
  38948. */
  38949. static BumpTextureEnabled: boolean;
  38950. private static _LightmapTextureEnabled;
  38951. /**
  38952. * Are lightmap textures enabled in the application.
  38953. */
  38954. static LightmapTextureEnabled: boolean;
  38955. private static _RefractionTextureEnabled;
  38956. /**
  38957. * Are refraction textures enabled in the application.
  38958. */
  38959. static RefractionTextureEnabled: boolean;
  38960. private static _ColorGradingTextureEnabled;
  38961. /**
  38962. * Are color grading textures enabled in the application.
  38963. */
  38964. static ColorGradingTextureEnabled: boolean;
  38965. private static _FresnelEnabled;
  38966. /**
  38967. * Are fresnels enabled in the application.
  38968. */
  38969. static FresnelEnabled: boolean;
  38970. private static _ClearCoatTextureEnabled;
  38971. /**
  38972. * Are clear coat textures enabled in the application.
  38973. */
  38974. static ClearCoatTextureEnabled: boolean;
  38975. private static _ClearCoatBumpTextureEnabled;
  38976. /**
  38977. * Are clear coat bump textures enabled in the application.
  38978. */
  38979. static ClearCoatBumpTextureEnabled: boolean;
  38980. private static _ClearCoatTintTextureEnabled;
  38981. /**
  38982. * Are clear coat tint textures enabled in the application.
  38983. */
  38984. static ClearCoatTintTextureEnabled: boolean;
  38985. private static _SheenTextureEnabled;
  38986. /**
  38987. * Are sheen textures enabled in the application.
  38988. */
  38989. static SheenTextureEnabled: boolean;
  38990. private static _AnisotropicTextureEnabled;
  38991. /**
  38992. * Are anisotropic textures enabled in the application.
  38993. */
  38994. static AnisotropicTextureEnabled: boolean;
  38995. private static _ThicknessTextureEnabled;
  38996. /**
  38997. * Are thickness textures enabled in the application.
  38998. */
  38999. static ThicknessTextureEnabled: boolean;
  39000. }
  39001. }
  39002. declare module BABYLON {
  39003. /** @hidden */
  39004. export var defaultFragmentDeclaration: {
  39005. name: string;
  39006. shader: string;
  39007. };
  39008. }
  39009. declare module BABYLON {
  39010. /** @hidden */
  39011. export var defaultUboDeclaration: {
  39012. name: string;
  39013. shader: string;
  39014. };
  39015. }
  39016. declare module BABYLON {
  39017. /** @hidden */
  39018. export var lightFragmentDeclaration: {
  39019. name: string;
  39020. shader: string;
  39021. };
  39022. }
  39023. declare module BABYLON {
  39024. /** @hidden */
  39025. export var lightUboDeclaration: {
  39026. name: string;
  39027. shader: string;
  39028. };
  39029. }
  39030. declare module BABYLON {
  39031. /** @hidden */
  39032. export var lightsFragmentFunctions: {
  39033. name: string;
  39034. shader: string;
  39035. };
  39036. }
  39037. declare module BABYLON {
  39038. /** @hidden */
  39039. export var shadowsFragmentFunctions: {
  39040. name: string;
  39041. shader: string;
  39042. };
  39043. }
  39044. declare module BABYLON {
  39045. /** @hidden */
  39046. export var fresnelFunction: {
  39047. name: string;
  39048. shader: string;
  39049. };
  39050. }
  39051. declare module BABYLON {
  39052. /** @hidden */
  39053. export var reflectionFunction: {
  39054. name: string;
  39055. shader: string;
  39056. };
  39057. }
  39058. declare module BABYLON {
  39059. /** @hidden */
  39060. export var bumpFragmentFunctions: {
  39061. name: string;
  39062. shader: string;
  39063. };
  39064. }
  39065. declare module BABYLON {
  39066. /** @hidden */
  39067. export var logDepthDeclaration: {
  39068. name: string;
  39069. shader: string;
  39070. };
  39071. }
  39072. declare module BABYLON {
  39073. /** @hidden */
  39074. export var bumpFragment: {
  39075. name: string;
  39076. shader: string;
  39077. };
  39078. }
  39079. declare module BABYLON {
  39080. /** @hidden */
  39081. export var depthPrePass: {
  39082. name: string;
  39083. shader: string;
  39084. };
  39085. }
  39086. declare module BABYLON {
  39087. /** @hidden */
  39088. export var lightFragment: {
  39089. name: string;
  39090. shader: string;
  39091. };
  39092. }
  39093. declare module BABYLON {
  39094. /** @hidden */
  39095. export var logDepthFragment: {
  39096. name: string;
  39097. shader: string;
  39098. };
  39099. }
  39100. declare module BABYLON {
  39101. /** @hidden */
  39102. export var defaultPixelShader: {
  39103. name: string;
  39104. shader: string;
  39105. };
  39106. }
  39107. declare module BABYLON {
  39108. /** @hidden */
  39109. export var defaultVertexDeclaration: {
  39110. name: string;
  39111. shader: string;
  39112. };
  39113. }
  39114. declare module BABYLON {
  39115. /** @hidden */
  39116. export var bumpVertexDeclaration: {
  39117. name: string;
  39118. shader: string;
  39119. };
  39120. }
  39121. declare module BABYLON {
  39122. /** @hidden */
  39123. export var bumpVertex: {
  39124. name: string;
  39125. shader: string;
  39126. };
  39127. }
  39128. declare module BABYLON {
  39129. /** @hidden */
  39130. export var fogVertex: {
  39131. name: string;
  39132. shader: string;
  39133. };
  39134. }
  39135. declare module BABYLON {
  39136. /** @hidden */
  39137. export var shadowsVertex: {
  39138. name: string;
  39139. shader: string;
  39140. };
  39141. }
  39142. declare module BABYLON {
  39143. /** @hidden */
  39144. export var pointCloudVertex: {
  39145. name: string;
  39146. shader: string;
  39147. };
  39148. }
  39149. declare module BABYLON {
  39150. /** @hidden */
  39151. export var logDepthVertex: {
  39152. name: string;
  39153. shader: string;
  39154. };
  39155. }
  39156. declare module BABYLON {
  39157. /** @hidden */
  39158. export var defaultVertexShader: {
  39159. name: string;
  39160. shader: string;
  39161. };
  39162. }
  39163. declare module BABYLON {
  39164. /** @hidden */
  39165. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39166. MAINUV1: boolean;
  39167. MAINUV2: boolean;
  39168. DIFFUSE: boolean;
  39169. DIFFUSEDIRECTUV: number;
  39170. AMBIENT: boolean;
  39171. AMBIENTDIRECTUV: number;
  39172. OPACITY: boolean;
  39173. OPACITYDIRECTUV: number;
  39174. OPACITYRGB: boolean;
  39175. REFLECTION: boolean;
  39176. EMISSIVE: boolean;
  39177. EMISSIVEDIRECTUV: number;
  39178. SPECULAR: boolean;
  39179. SPECULARDIRECTUV: number;
  39180. BUMP: boolean;
  39181. BUMPDIRECTUV: number;
  39182. PARALLAX: boolean;
  39183. PARALLAXOCCLUSION: boolean;
  39184. SPECULAROVERALPHA: boolean;
  39185. CLIPPLANE: boolean;
  39186. CLIPPLANE2: boolean;
  39187. CLIPPLANE3: boolean;
  39188. CLIPPLANE4: boolean;
  39189. ALPHATEST: boolean;
  39190. DEPTHPREPASS: boolean;
  39191. ALPHAFROMDIFFUSE: boolean;
  39192. POINTSIZE: boolean;
  39193. FOG: boolean;
  39194. SPECULARTERM: boolean;
  39195. DIFFUSEFRESNEL: boolean;
  39196. OPACITYFRESNEL: boolean;
  39197. REFLECTIONFRESNEL: boolean;
  39198. REFRACTIONFRESNEL: boolean;
  39199. EMISSIVEFRESNEL: boolean;
  39200. FRESNEL: boolean;
  39201. NORMAL: boolean;
  39202. UV1: boolean;
  39203. UV2: boolean;
  39204. VERTEXCOLOR: boolean;
  39205. VERTEXALPHA: boolean;
  39206. NUM_BONE_INFLUENCERS: number;
  39207. BonesPerMesh: number;
  39208. BONETEXTURE: boolean;
  39209. INSTANCES: boolean;
  39210. GLOSSINESS: boolean;
  39211. ROUGHNESS: boolean;
  39212. EMISSIVEASILLUMINATION: boolean;
  39213. LINKEMISSIVEWITHDIFFUSE: boolean;
  39214. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39215. LIGHTMAP: boolean;
  39216. LIGHTMAPDIRECTUV: number;
  39217. OBJECTSPACE_NORMALMAP: boolean;
  39218. USELIGHTMAPASSHADOWMAP: boolean;
  39219. REFLECTIONMAP_3D: boolean;
  39220. REFLECTIONMAP_SPHERICAL: boolean;
  39221. REFLECTIONMAP_PLANAR: boolean;
  39222. REFLECTIONMAP_CUBIC: boolean;
  39223. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39224. REFLECTIONMAP_PROJECTION: boolean;
  39225. REFLECTIONMAP_SKYBOX: boolean;
  39226. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39227. REFLECTIONMAP_EXPLICIT: boolean;
  39228. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39229. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39230. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39231. INVERTCUBICMAP: boolean;
  39232. LOGARITHMICDEPTH: boolean;
  39233. REFRACTION: boolean;
  39234. REFRACTIONMAP_3D: boolean;
  39235. REFLECTIONOVERALPHA: boolean;
  39236. TWOSIDEDLIGHTING: boolean;
  39237. SHADOWFLOAT: boolean;
  39238. MORPHTARGETS: boolean;
  39239. MORPHTARGETS_NORMAL: boolean;
  39240. MORPHTARGETS_TANGENT: boolean;
  39241. MORPHTARGETS_UV: boolean;
  39242. NUM_MORPH_INFLUENCERS: number;
  39243. NONUNIFORMSCALING: boolean;
  39244. PREMULTIPLYALPHA: boolean;
  39245. IMAGEPROCESSING: boolean;
  39246. VIGNETTE: boolean;
  39247. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39248. VIGNETTEBLENDMODEOPAQUE: boolean;
  39249. TONEMAPPING: boolean;
  39250. TONEMAPPING_ACES: boolean;
  39251. CONTRAST: boolean;
  39252. COLORCURVES: boolean;
  39253. COLORGRADING: boolean;
  39254. COLORGRADING3D: boolean;
  39255. SAMPLER3DGREENDEPTH: boolean;
  39256. SAMPLER3DBGRMAP: boolean;
  39257. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39258. MULTIVIEW: boolean;
  39259. /**
  39260. * If the reflection texture on this material is in linear color space
  39261. * @hidden
  39262. */
  39263. IS_REFLECTION_LINEAR: boolean;
  39264. /**
  39265. * If the refraction texture on this material is in linear color space
  39266. * @hidden
  39267. */
  39268. IS_REFRACTION_LINEAR: boolean;
  39269. EXPOSURE: boolean;
  39270. constructor();
  39271. setReflectionMode(modeToEnable: string): void;
  39272. }
  39273. /**
  39274. * This is the default material used in Babylon. It is the best trade off between quality
  39275. * and performances.
  39276. * @see http://doc.babylonjs.com/babylon101/materials
  39277. */
  39278. export class StandardMaterial extends PushMaterial {
  39279. private _diffuseTexture;
  39280. /**
  39281. * The basic texture of the material as viewed under a light.
  39282. */
  39283. diffuseTexture: Nullable<BaseTexture>;
  39284. private _ambientTexture;
  39285. /**
  39286. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39287. */
  39288. ambientTexture: Nullable<BaseTexture>;
  39289. private _opacityTexture;
  39290. /**
  39291. * Define the transparency of the material from a texture.
  39292. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39293. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39294. */
  39295. opacityTexture: Nullable<BaseTexture>;
  39296. private _reflectionTexture;
  39297. /**
  39298. * Define the texture used to display the reflection.
  39299. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39300. */
  39301. reflectionTexture: Nullable<BaseTexture>;
  39302. private _emissiveTexture;
  39303. /**
  39304. * Define texture of the material as if self lit.
  39305. * This will be mixed in the final result even in the absence of light.
  39306. */
  39307. emissiveTexture: Nullable<BaseTexture>;
  39308. private _specularTexture;
  39309. /**
  39310. * Define how the color and intensity of the highlight given by the light in the material.
  39311. */
  39312. specularTexture: Nullable<BaseTexture>;
  39313. private _bumpTexture;
  39314. /**
  39315. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39316. * 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.
  39317. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39318. */
  39319. bumpTexture: Nullable<BaseTexture>;
  39320. private _lightmapTexture;
  39321. /**
  39322. * Complex lighting can be computationally expensive to compute at runtime.
  39323. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39324. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39325. */
  39326. lightmapTexture: Nullable<BaseTexture>;
  39327. private _refractionTexture;
  39328. /**
  39329. * Define the texture used to display the refraction.
  39330. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39331. */
  39332. refractionTexture: Nullable<BaseTexture>;
  39333. /**
  39334. * The color of the material lit by the environmental background lighting.
  39335. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39336. */
  39337. ambientColor: Color3;
  39338. /**
  39339. * The basic color of the material as viewed under a light.
  39340. */
  39341. diffuseColor: Color3;
  39342. /**
  39343. * Define how the color and intensity of the highlight given by the light in the material.
  39344. */
  39345. specularColor: Color3;
  39346. /**
  39347. * Define the color of the material as if self lit.
  39348. * This will be mixed in the final result even in the absence of light.
  39349. */
  39350. emissiveColor: Color3;
  39351. /**
  39352. * Defines how sharp are the highlights in the material.
  39353. * The bigger the value the sharper giving a more glossy feeling to the result.
  39354. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39355. */
  39356. specularPower: number;
  39357. private _useAlphaFromDiffuseTexture;
  39358. /**
  39359. * Does the transparency come from the diffuse texture alpha channel.
  39360. */
  39361. useAlphaFromDiffuseTexture: boolean;
  39362. private _useEmissiveAsIllumination;
  39363. /**
  39364. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39365. */
  39366. useEmissiveAsIllumination: boolean;
  39367. private _linkEmissiveWithDiffuse;
  39368. /**
  39369. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39370. * the emissive level when the final color is close to one.
  39371. */
  39372. linkEmissiveWithDiffuse: boolean;
  39373. private _useSpecularOverAlpha;
  39374. /**
  39375. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39376. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39377. */
  39378. useSpecularOverAlpha: boolean;
  39379. private _useReflectionOverAlpha;
  39380. /**
  39381. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39382. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39383. */
  39384. useReflectionOverAlpha: boolean;
  39385. private _disableLighting;
  39386. /**
  39387. * Does lights from the scene impacts this material.
  39388. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39389. */
  39390. disableLighting: boolean;
  39391. private _useObjectSpaceNormalMap;
  39392. /**
  39393. * Allows using an object space normal map (instead of tangent space).
  39394. */
  39395. useObjectSpaceNormalMap: boolean;
  39396. private _useParallax;
  39397. /**
  39398. * Is parallax enabled or not.
  39399. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39400. */
  39401. useParallax: boolean;
  39402. private _useParallaxOcclusion;
  39403. /**
  39404. * Is parallax occlusion enabled or not.
  39405. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39406. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39407. */
  39408. useParallaxOcclusion: boolean;
  39409. /**
  39410. * 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.
  39411. */
  39412. parallaxScaleBias: number;
  39413. private _roughness;
  39414. /**
  39415. * Helps to define how blurry the reflections should appears in the material.
  39416. */
  39417. roughness: number;
  39418. /**
  39419. * In case of refraction, define the value of the index of refraction.
  39420. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39421. */
  39422. indexOfRefraction: number;
  39423. /**
  39424. * Invert the refraction texture alongside the y axis.
  39425. * It can be useful with procedural textures or probe for instance.
  39426. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39427. */
  39428. invertRefractionY: boolean;
  39429. /**
  39430. * Defines the alpha limits in alpha test mode.
  39431. */
  39432. alphaCutOff: number;
  39433. private _useLightmapAsShadowmap;
  39434. /**
  39435. * In case of light mapping, define whether the map contains light or shadow informations.
  39436. */
  39437. useLightmapAsShadowmap: boolean;
  39438. private _diffuseFresnelParameters;
  39439. /**
  39440. * Define the diffuse fresnel parameters of the material.
  39441. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39442. */
  39443. diffuseFresnelParameters: FresnelParameters;
  39444. private _opacityFresnelParameters;
  39445. /**
  39446. * Define the opacity fresnel parameters of the material.
  39447. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39448. */
  39449. opacityFresnelParameters: FresnelParameters;
  39450. private _reflectionFresnelParameters;
  39451. /**
  39452. * Define the reflection fresnel parameters of the material.
  39453. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39454. */
  39455. reflectionFresnelParameters: FresnelParameters;
  39456. private _refractionFresnelParameters;
  39457. /**
  39458. * Define the refraction fresnel parameters of the material.
  39459. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39460. */
  39461. refractionFresnelParameters: FresnelParameters;
  39462. private _emissiveFresnelParameters;
  39463. /**
  39464. * Define the emissive fresnel parameters of the material.
  39465. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39466. */
  39467. emissiveFresnelParameters: FresnelParameters;
  39468. private _useReflectionFresnelFromSpecular;
  39469. /**
  39470. * If true automatically deducts the fresnels values from the material specularity.
  39471. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39472. */
  39473. useReflectionFresnelFromSpecular: boolean;
  39474. private _useGlossinessFromSpecularMapAlpha;
  39475. /**
  39476. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39477. */
  39478. useGlossinessFromSpecularMapAlpha: boolean;
  39479. private _maxSimultaneousLights;
  39480. /**
  39481. * Defines the maximum number of lights that can be used in the material
  39482. */
  39483. maxSimultaneousLights: number;
  39484. private _invertNormalMapX;
  39485. /**
  39486. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39487. */
  39488. invertNormalMapX: boolean;
  39489. private _invertNormalMapY;
  39490. /**
  39491. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39492. */
  39493. invertNormalMapY: boolean;
  39494. private _twoSidedLighting;
  39495. /**
  39496. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39497. */
  39498. twoSidedLighting: boolean;
  39499. /**
  39500. * Default configuration related to image processing available in the standard Material.
  39501. */
  39502. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39503. /**
  39504. * Gets the image processing configuration used either in this material.
  39505. */
  39506. /**
  39507. * Sets the Default image processing configuration used either in the this material.
  39508. *
  39509. * If sets to null, the scene one is in use.
  39510. */
  39511. imageProcessingConfiguration: ImageProcessingConfiguration;
  39512. /**
  39513. * Keep track of the image processing observer to allow dispose and replace.
  39514. */
  39515. private _imageProcessingObserver;
  39516. /**
  39517. * Attaches a new image processing configuration to the Standard Material.
  39518. * @param configuration
  39519. */
  39520. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39521. /**
  39522. * Gets wether the color curves effect is enabled.
  39523. */
  39524. /**
  39525. * Sets wether the color curves effect is enabled.
  39526. */
  39527. cameraColorCurvesEnabled: boolean;
  39528. /**
  39529. * Gets wether the color grading effect is enabled.
  39530. */
  39531. /**
  39532. * Gets wether the color grading effect is enabled.
  39533. */
  39534. cameraColorGradingEnabled: boolean;
  39535. /**
  39536. * Gets wether tonemapping is enabled or not.
  39537. */
  39538. /**
  39539. * Sets wether tonemapping is enabled or not
  39540. */
  39541. cameraToneMappingEnabled: boolean;
  39542. /**
  39543. * The camera exposure used on this material.
  39544. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39545. * This corresponds to a photographic exposure.
  39546. */
  39547. /**
  39548. * The camera exposure used on this material.
  39549. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39550. * This corresponds to a photographic exposure.
  39551. */
  39552. cameraExposure: number;
  39553. /**
  39554. * Gets The camera contrast used on this material.
  39555. */
  39556. /**
  39557. * Sets The camera contrast used on this material.
  39558. */
  39559. cameraContrast: number;
  39560. /**
  39561. * Gets the Color Grading 2D Lookup Texture.
  39562. */
  39563. /**
  39564. * Sets the Color Grading 2D Lookup Texture.
  39565. */
  39566. cameraColorGradingTexture: Nullable<BaseTexture>;
  39567. /**
  39568. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39569. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39570. * 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;
  39571. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39572. */
  39573. /**
  39574. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39575. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39576. * 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;
  39577. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39578. */
  39579. cameraColorCurves: Nullable<ColorCurves>;
  39580. /**
  39581. * Custom callback helping to override the default shader used in the material.
  39582. */
  39583. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39584. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39585. protected _worldViewProjectionMatrix: Matrix;
  39586. protected _globalAmbientColor: Color3;
  39587. protected _useLogarithmicDepth: boolean;
  39588. /**
  39589. * Instantiates a new standard material.
  39590. * This is the default material used in Babylon. It is the best trade off between quality
  39591. * and performances.
  39592. * @see http://doc.babylonjs.com/babylon101/materials
  39593. * @param name Define the name of the material in the scene
  39594. * @param scene Define the scene the material belong to
  39595. */
  39596. constructor(name: string, scene: Scene);
  39597. /**
  39598. * Gets a boolean indicating that current material needs to register RTT
  39599. */
  39600. readonly hasRenderTargetTextures: boolean;
  39601. /**
  39602. * Gets the current class name of the material e.g. "StandardMaterial"
  39603. * Mainly use in serialization.
  39604. * @returns the class name
  39605. */
  39606. getClassName(): string;
  39607. /**
  39608. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39609. * You can try switching to logarithmic depth.
  39610. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39611. */
  39612. useLogarithmicDepth: boolean;
  39613. /**
  39614. * Specifies if the material will require alpha blending
  39615. * @returns a boolean specifying if alpha blending is needed
  39616. */
  39617. needAlphaBlending(): boolean;
  39618. /**
  39619. * Specifies if this material should be rendered in alpha test mode
  39620. * @returns a boolean specifying if an alpha test is needed.
  39621. */
  39622. needAlphaTesting(): boolean;
  39623. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39624. /**
  39625. * Get the texture used for alpha test purpose.
  39626. * @returns the diffuse texture in case of the standard material.
  39627. */
  39628. getAlphaTestTexture(): Nullable<BaseTexture>;
  39629. /**
  39630. * Get if the submesh is ready to be used and all its information available.
  39631. * Child classes can use it to update shaders
  39632. * @param mesh defines the mesh to check
  39633. * @param subMesh defines which submesh to check
  39634. * @param useInstances specifies that instances should be used
  39635. * @returns a boolean indicating that the submesh is ready or not
  39636. */
  39637. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39638. /**
  39639. * Builds the material UBO layouts.
  39640. * Used internally during the effect preparation.
  39641. */
  39642. buildUniformLayout(): void;
  39643. /**
  39644. * Unbinds the material from the mesh
  39645. */
  39646. unbind(): void;
  39647. /**
  39648. * Binds the submesh to this material by preparing the effect and shader to draw
  39649. * @param world defines the world transformation matrix
  39650. * @param mesh defines the mesh containing the submesh
  39651. * @param subMesh defines the submesh to bind the material to
  39652. */
  39653. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39654. /**
  39655. * Get the list of animatables in the material.
  39656. * @returns the list of animatables object used in the material
  39657. */
  39658. getAnimatables(): IAnimatable[];
  39659. /**
  39660. * Gets the active textures from the material
  39661. * @returns an array of textures
  39662. */
  39663. getActiveTextures(): BaseTexture[];
  39664. /**
  39665. * Specifies if the material uses a texture
  39666. * @param texture defines the texture to check against the material
  39667. * @returns a boolean specifying if the material uses the texture
  39668. */
  39669. hasTexture(texture: BaseTexture): boolean;
  39670. /**
  39671. * Disposes the material
  39672. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39673. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39674. */
  39675. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39676. /**
  39677. * Makes a duplicate of the material, and gives it a new name
  39678. * @param name defines the new name for the duplicated material
  39679. * @returns the cloned material
  39680. */
  39681. clone(name: string): StandardMaterial;
  39682. /**
  39683. * Serializes this material in a JSON representation
  39684. * @returns the serialized material object
  39685. */
  39686. serialize(): any;
  39687. /**
  39688. * Creates a standard material from parsed material data
  39689. * @param source defines the JSON representation of the material
  39690. * @param scene defines the hosting scene
  39691. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39692. * @returns a new standard material
  39693. */
  39694. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39695. /**
  39696. * Are diffuse textures enabled in the application.
  39697. */
  39698. static DiffuseTextureEnabled: boolean;
  39699. /**
  39700. * Are ambient textures enabled in the application.
  39701. */
  39702. static AmbientTextureEnabled: boolean;
  39703. /**
  39704. * Are opacity textures enabled in the application.
  39705. */
  39706. static OpacityTextureEnabled: boolean;
  39707. /**
  39708. * Are reflection textures enabled in the application.
  39709. */
  39710. static ReflectionTextureEnabled: boolean;
  39711. /**
  39712. * Are emissive textures enabled in the application.
  39713. */
  39714. static EmissiveTextureEnabled: boolean;
  39715. /**
  39716. * Are specular textures enabled in the application.
  39717. */
  39718. static SpecularTextureEnabled: boolean;
  39719. /**
  39720. * Are bump textures enabled in the application.
  39721. */
  39722. static BumpTextureEnabled: boolean;
  39723. /**
  39724. * Are lightmap textures enabled in the application.
  39725. */
  39726. static LightmapTextureEnabled: boolean;
  39727. /**
  39728. * Are refraction textures enabled in the application.
  39729. */
  39730. static RefractionTextureEnabled: boolean;
  39731. /**
  39732. * Are color grading textures enabled in the application.
  39733. */
  39734. static ColorGradingTextureEnabled: boolean;
  39735. /**
  39736. * Are fresnels enabled in the application.
  39737. */
  39738. static FresnelEnabled: boolean;
  39739. }
  39740. }
  39741. declare module BABYLON {
  39742. /**
  39743. * A class extending Texture allowing drawing on a texture
  39744. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39745. */
  39746. export class DynamicTexture extends Texture {
  39747. private _generateMipMaps;
  39748. private _canvas;
  39749. private _context;
  39750. private _engine;
  39751. /**
  39752. * Creates a DynamicTexture
  39753. * @param name defines the name of the texture
  39754. * @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
  39755. * @param scene defines the scene where you want the texture
  39756. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39757. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39758. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39759. */
  39760. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39761. /**
  39762. * Get the current class name of the texture useful for serialization or dynamic coding.
  39763. * @returns "DynamicTexture"
  39764. */
  39765. getClassName(): string;
  39766. /**
  39767. * Gets the current state of canRescale
  39768. */
  39769. readonly canRescale: boolean;
  39770. private _recreate;
  39771. /**
  39772. * Scales the texture
  39773. * @param ratio the scale factor to apply to both width and height
  39774. */
  39775. scale(ratio: number): void;
  39776. /**
  39777. * Resizes the texture
  39778. * @param width the new width
  39779. * @param height the new height
  39780. */
  39781. scaleTo(width: number, height: number): void;
  39782. /**
  39783. * Gets the context of the canvas used by the texture
  39784. * @returns the canvas context of the dynamic texture
  39785. */
  39786. getContext(): CanvasRenderingContext2D;
  39787. /**
  39788. * Clears the texture
  39789. */
  39790. clear(): void;
  39791. /**
  39792. * Updates the texture
  39793. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39794. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39795. */
  39796. update(invertY?: boolean, premulAlpha?: boolean): void;
  39797. /**
  39798. * Draws text onto the texture
  39799. * @param text defines the text to be drawn
  39800. * @param x defines the placement of the text from the left
  39801. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39802. * @param font defines the font to be used with font-style, font-size, font-name
  39803. * @param color defines the color used for the text
  39804. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39805. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39806. * @param update defines whether texture is immediately update (default is true)
  39807. */
  39808. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39809. /**
  39810. * Clones the texture
  39811. * @returns the clone of the texture.
  39812. */
  39813. clone(): DynamicTexture;
  39814. /**
  39815. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39816. * @returns a serialized dynamic texture object
  39817. */
  39818. serialize(): any;
  39819. /** @hidden */
  39820. _rebuild(): void;
  39821. }
  39822. }
  39823. declare module BABYLON {
  39824. /** @hidden */
  39825. export var imageProcessingPixelShader: {
  39826. name: string;
  39827. shader: string;
  39828. };
  39829. }
  39830. declare module BABYLON {
  39831. /**
  39832. * ImageProcessingPostProcess
  39833. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39834. */
  39835. export class ImageProcessingPostProcess extends PostProcess {
  39836. /**
  39837. * Default configuration related to image processing available in the PBR Material.
  39838. */
  39839. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39840. /**
  39841. * Gets the image processing configuration used either in this material.
  39842. */
  39843. /**
  39844. * Sets the Default image processing configuration used either in the this material.
  39845. *
  39846. * If sets to null, the scene one is in use.
  39847. */
  39848. imageProcessingConfiguration: ImageProcessingConfiguration;
  39849. /**
  39850. * Keep track of the image processing observer to allow dispose and replace.
  39851. */
  39852. private _imageProcessingObserver;
  39853. /**
  39854. * Attaches a new image processing configuration to the PBR Material.
  39855. * @param configuration
  39856. */
  39857. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39858. /**
  39859. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39860. */
  39861. /**
  39862. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39863. */
  39864. colorCurves: Nullable<ColorCurves>;
  39865. /**
  39866. * Gets wether the color curves effect is enabled.
  39867. */
  39868. /**
  39869. * Sets wether the color curves effect is enabled.
  39870. */
  39871. colorCurvesEnabled: boolean;
  39872. /**
  39873. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39874. */
  39875. /**
  39876. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39877. */
  39878. colorGradingTexture: Nullable<BaseTexture>;
  39879. /**
  39880. * Gets wether the color grading effect is enabled.
  39881. */
  39882. /**
  39883. * Gets wether the color grading effect is enabled.
  39884. */
  39885. colorGradingEnabled: boolean;
  39886. /**
  39887. * Gets exposure used in the effect.
  39888. */
  39889. /**
  39890. * Sets exposure used in the effect.
  39891. */
  39892. exposure: number;
  39893. /**
  39894. * Gets wether tonemapping is enabled or not.
  39895. */
  39896. /**
  39897. * Sets wether tonemapping is enabled or not
  39898. */
  39899. toneMappingEnabled: boolean;
  39900. /**
  39901. * Gets the type of tone mapping effect.
  39902. */
  39903. /**
  39904. * Sets the type of tone mapping effect.
  39905. */
  39906. toneMappingType: number;
  39907. /**
  39908. * Gets contrast used in the effect.
  39909. */
  39910. /**
  39911. * Sets contrast used in the effect.
  39912. */
  39913. contrast: number;
  39914. /**
  39915. * Gets Vignette stretch size.
  39916. */
  39917. /**
  39918. * Sets Vignette stretch size.
  39919. */
  39920. vignetteStretch: number;
  39921. /**
  39922. * Gets Vignette centre X Offset.
  39923. */
  39924. /**
  39925. * Sets Vignette centre X Offset.
  39926. */
  39927. vignetteCentreX: number;
  39928. /**
  39929. * Gets Vignette centre Y Offset.
  39930. */
  39931. /**
  39932. * Sets Vignette centre Y Offset.
  39933. */
  39934. vignetteCentreY: number;
  39935. /**
  39936. * Gets Vignette weight or intensity of the vignette effect.
  39937. */
  39938. /**
  39939. * Sets Vignette weight or intensity of the vignette effect.
  39940. */
  39941. vignetteWeight: number;
  39942. /**
  39943. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39944. * if vignetteEnabled is set to true.
  39945. */
  39946. /**
  39947. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39948. * if vignetteEnabled is set to true.
  39949. */
  39950. vignetteColor: Color4;
  39951. /**
  39952. * Gets Camera field of view used by the Vignette effect.
  39953. */
  39954. /**
  39955. * Sets Camera field of view used by the Vignette effect.
  39956. */
  39957. vignetteCameraFov: number;
  39958. /**
  39959. * Gets the vignette blend mode allowing different kind of effect.
  39960. */
  39961. /**
  39962. * Sets the vignette blend mode allowing different kind of effect.
  39963. */
  39964. vignetteBlendMode: number;
  39965. /**
  39966. * Gets wether the vignette effect is enabled.
  39967. */
  39968. /**
  39969. * Sets wether the vignette effect is enabled.
  39970. */
  39971. vignetteEnabled: boolean;
  39972. private _fromLinearSpace;
  39973. /**
  39974. * Gets wether the input of the processing is in Gamma or Linear Space.
  39975. */
  39976. /**
  39977. * Sets wether the input of the processing is in Gamma or Linear Space.
  39978. */
  39979. fromLinearSpace: boolean;
  39980. /**
  39981. * Defines cache preventing GC.
  39982. */
  39983. private _defines;
  39984. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39985. /**
  39986. * "ImageProcessingPostProcess"
  39987. * @returns "ImageProcessingPostProcess"
  39988. */
  39989. getClassName(): string;
  39990. protected _updateParameters(): void;
  39991. dispose(camera?: Camera): void;
  39992. }
  39993. }
  39994. declare module BABYLON {
  39995. /**
  39996. * Class containing static functions to help procedurally build meshes
  39997. */
  39998. export class GroundBuilder {
  39999. /**
  40000. * Creates a ground mesh
  40001. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40002. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40004. * @param name defines the name of the mesh
  40005. * @param options defines the options used to create the mesh
  40006. * @param scene defines the hosting scene
  40007. * @returns the ground mesh
  40008. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40009. */
  40010. static CreateGround(name: string, options: {
  40011. width?: number;
  40012. height?: number;
  40013. subdivisions?: number;
  40014. subdivisionsX?: number;
  40015. subdivisionsY?: number;
  40016. updatable?: boolean;
  40017. }, scene: any): Mesh;
  40018. /**
  40019. * Creates a tiled ground mesh
  40020. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40021. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40022. * * 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
  40023. * * 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
  40024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40025. * @param name defines the name of the mesh
  40026. * @param options defines the options used to create the mesh
  40027. * @param scene defines the hosting scene
  40028. * @returns the tiled ground mesh
  40029. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40030. */
  40031. static CreateTiledGround(name: string, options: {
  40032. xmin: number;
  40033. zmin: number;
  40034. xmax: number;
  40035. zmax: number;
  40036. subdivisions?: {
  40037. w: number;
  40038. h: number;
  40039. };
  40040. precision?: {
  40041. w: number;
  40042. h: number;
  40043. };
  40044. updatable?: boolean;
  40045. }, scene?: Nullable<Scene>): Mesh;
  40046. /**
  40047. * Creates a ground mesh from a height map
  40048. * * The parameter `url` sets the URL of the height map image resource.
  40049. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40050. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40051. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40052. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40053. * * 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.
  40054. * * 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).
  40055. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40057. * @param name defines the name of the mesh
  40058. * @param url defines the url to the height map
  40059. * @param options defines the options used to create the mesh
  40060. * @param scene defines the hosting scene
  40061. * @returns the ground mesh
  40062. * @see https://doc.babylonjs.com/babylon101/height_map
  40063. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40064. */
  40065. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40066. width?: number;
  40067. height?: number;
  40068. subdivisions?: number;
  40069. minHeight?: number;
  40070. maxHeight?: number;
  40071. colorFilter?: Color3;
  40072. alphaFilter?: number;
  40073. updatable?: boolean;
  40074. onReady?: (mesh: GroundMesh) => void;
  40075. }, scene?: Nullable<Scene>): GroundMesh;
  40076. }
  40077. }
  40078. declare module BABYLON {
  40079. /**
  40080. * Class containing static functions to help procedurally build meshes
  40081. */
  40082. export class TorusBuilder {
  40083. /**
  40084. * Creates a torus mesh
  40085. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40086. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40087. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40089. * * 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
  40090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40091. * @param name defines the name of the mesh
  40092. * @param options defines the options used to create the mesh
  40093. * @param scene defines the hosting scene
  40094. * @returns the torus mesh
  40095. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40096. */
  40097. static CreateTorus(name: string, options: {
  40098. diameter?: number;
  40099. thickness?: number;
  40100. tessellation?: number;
  40101. updatable?: boolean;
  40102. sideOrientation?: number;
  40103. frontUVs?: Vector4;
  40104. backUVs?: Vector4;
  40105. }, scene: any): Mesh;
  40106. }
  40107. }
  40108. declare module BABYLON {
  40109. /**
  40110. * Class containing static functions to help procedurally build meshes
  40111. */
  40112. export class CylinderBuilder {
  40113. /**
  40114. * Creates a cylinder or a cone mesh
  40115. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40116. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40117. * * 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.
  40118. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40119. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40120. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40121. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40122. * * 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).
  40123. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40124. * * 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).
  40125. * * 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
  40126. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40127. * * 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
  40128. * * 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.
  40129. * * If `enclose` is false, a ring surface is one element.
  40130. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40131. * * 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
  40132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40133. * * 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
  40134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40135. * @param name defines the name of the mesh
  40136. * @param options defines the options used to create the mesh
  40137. * @param scene defines the hosting scene
  40138. * @returns the cylinder mesh
  40139. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40140. */
  40141. static CreateCylinder(name: string, options: {
  40142. height?: number;
  40143. diameterTop?: number;
  40144. diameterBottom?: number;
  40145. diameter?: number;
  40146. tessellation?: number;
  40147. subdivisions?: number;
  40148. arc?: number;
  40149. faceColors?: Color4[];
  40150. faceUV?: Vector4[];
  40151. updatable?: boolean;
  40152. hasRings?: boolean;
  40153. enclose?: boolean;
  40154. cap?: number;
  40155. sideOrientation?: number;
  40156. frontUVs?: Vector4;
  40157. backUVs?: Vector4;
  40158. }, scene: any): Mesh;
  40159. }
  40160. }
  40161. declare module BABYLON {
  40162. /**
  40163. * Options to modify the vr teleportation behavior.
  40164. */
  40165. export interface VRTeleportationOptions {
  40166. /**
  40167. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40168. */
  40169. floorMeshName?: string;
  40170. /**
  40171. * A list of meshes to be used as the teleportation floor. (default: empty)
  40172. */
  40173. floorMeshes?: Mesh[];
  40174. }
  40175. /**
  40176. * Options to modify the vr experience helper's behavior.
  40177. */
  40178. export interface VRExperienceHelperOptions extends WebVROptions {
  40179. /**
  40180. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40181. */
  40182. createDeviceOrientationCamera?: boolean;
  40183. /**
  40184. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40185. */
  40186. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40187. /**
  40188. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40189. */
  40190. laserToggle?: boolean;
  40191. /**
  40192. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40193. */
  40194. floorMeshes?: Mesh[];
  40195. /**
  40196. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40197. */
  40198. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40199. }
  40200. /**
  40201. * Event containing information after VR has been entered
  40202. */
  40203. export class OnAfterEnteringVRObservableEvent {
  40204. /**
  40205. * If entering vr was successful
  40206. */
  40207. success: boolean;
  40208. }
  40209. /**
  40210. * Helps to quickly add VR support to an existing scene.
  40211. * See http://doc.babylonjs.com/how_to/webvr_helper
  40212. */
  40213. export class VRExperienceHelper {
  40214. /** Options to modify the vr experience helper's behavior. */
  40215. webVROptions: VRExperienceHelperOptions;
  40216. private _scene;
  40217. private _position;
  40218. private _btnVR;
  40219. private _btnVRDisplayed;
  40220. private _webVRsupported;
  40221. private _webVRready;
  40222. private _webVRrequesting;
  40223. private _webVRpresenting;
  40224. private _hasEnteredVR;
  40225. private _fullscreenVRpresenting;
  40226. private _canvas;
  40227. private _webVRCamera;
  40228. private _vrDeviceOrientationCamera;
  40229. private _deviceOrientationCamera;
  40230. private _existingCamera;
  40231. private _onKeyDown;
  40232. private _onVrDisplayPresentChange;
  40233. private _onVRDisplayChanged;
  40234. private _onVRRequestPresentStart;
  40235. private _onVRRequestPresentComplete;
  40236. /**
  40237. * Observable raised right before entering VR.
  40238. */
  40239. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40240. /**
  40241. * Observable raised when entering VR has completed.
  40242. */
  40243. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40244. /**
  40245. * Observable raised when exiting VR.
  40246. */
  40247. onExitingVRObservable: Observable<VRExperienceHelper>;
  40248. /**
  40249. * Observable raised when controller mesh is loaded.
  40250. */
  40251. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40252. /** Return this.onEnteringVRObservable
  40253. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40254. */
  40255. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40256. /** Return this.onExitingVRObservable
  40257. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40258. */
  40259. readonly onExitingVR: Observable<VRExperienceHelper>;
  40260. /** Return this.onControllerMeshLoadedObservable
  40261. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40262. */
  40263. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40264. private _rayLength;
  40265. private _useCustomVRButton;
  40266. private _teleportationRequested;
  40267. private _teleportActive;
  40268. private _floorMeshName;
  40269. private _floorMeshesCollection;
  40270. private _rotationAllowed;
  40271. private _teleportBackwardsVector;
  40272. private _teleportationTarget;
  40273. private _isDefaultTeleportationTarget;
  40274. private _postProcessMove;
  40275. private _teleportationFillColor;
  40276. private _teleportationBorderColor;
  40277. private _rotationAngle;
  40278. private _haloCenter;
  40279. private _cameraGazer;
  40280. private _padSensibilityUp;
  40281. private _padSensibilityDown;
  40282. private _leftController;
  40283. private _rightController;
  40284. /**
  40285. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40286. */
  40287. onNewMeshSelected: Observable<AbstractMesh>;
  40288. /**
  40289. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40290. */
  40291. onNewMeshPicked: Observable<PickingInfo>;
  40292. private _circleEase;
  40293. /**
  40294. * Observable raised before camera teleportation
  40295. */
  40296. onBeforeCameraTeleport: Observable<Vector3>;
  40297. /**
  40298. * Observable raised after camera teleportation
  40299. */
  40300. onAfterCameraTeleport: Observable<Vector3>;
  40301. /**
  40302. * Observable raised when current selected mesh gets unselected
  40303. */
  40304. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40305. private _raySelectionPredicate;
  40306. /**
  40307. * To be optionaly changed by user to define custom ray selection
  40308. */
  40309. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40310. /**
  40311. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40312. */
  40313. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40314. /**
  40315. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40316. */
  40317. teleportationEnabled: boolean;
  40318. private _defaultHeight;
  40319. private _teleportationInitialized;
  40320. private _interactionsEnabled;
  40321. private _interactionsRequested;
  40322. private _displayGaze;
  40323. private _displayLaserPointer;
  40324. /**
  40325. * The mesh used to display where the user is going to teleport.
  40326. */
  40327. /**
  40328. * Sets the mesh to be used to display where the user is going to teleport.
  40329. */
  40330. teleportationTarget: Mesh;
  40331. /**
  40332. * 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
  40333. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40334. * See http://doc.babylonjs.com/resources/baking_transformations
  40335. */
  40336. gazeTrackerMesh: Mesh;
  40337. /**
  40338. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40339. */
  40340. updateGazeTrackerScale: boolean;
  40341. /**
  40342. * If the gaze trackers color should be updated when selecting meshes
  40343. */
  40344. updateGazeTrackerColor: boolean;
  40345. /**
  40346. * The gaze tracking mesh corresponding to the left controller
  40347. */
  40348. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40349. /**
  40350. * The gaze tracking mesh corresponding to the right controller
  40351. */
  40352. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40353. /**
  40354. * If the ray of the gaze should be displayed.
  40355. */
  40356. /**
  40357. * Sets if the ray of the gaze should be displayed.
  40358. */
  40359. displayGaze: boolean;
  40360. /**
  40361. * If the ray of the LaserPointer should be displayed.
  40362. */
  40363. /**
  40364. * Sets if the ray of the LaserPointer should be displayed.
  40365. */
  40366. displayLaserPointer: boolean;
  40367. /**
  40368. * The deviceOrientationCamera used as the camera when not in VR.
  40369. */
  40370. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40371. /**
  40372. * Based on the current WebVR support, returns the current VR camera used.
  40373. */
  40374. readonly currentVRCamera: Nullable<Camera>;
  40375. /**
  40376. * The webVRCamera which is used when in VR.
  40377. */
  40378. readonly webVRCamera: WebVRFreeCamera;
  40379. /**
  40380. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40381. */
  40382. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40383. private readonly _teleportationRequestInitiated;
  40384. /**
  40385. * Defines wether or not Pointer lock should be requested when switching to
  40386. * full screen.
  40387. */
  40388. requestPointerLockOnFullScreen: boolean;
  40389. /**
  40390. * Instantiates a VRExperienceHelper.
  40391. * Helps to quickly add VR support to an existing scene.
  40392. * @param scene The scene the VRExperienceHelper belongs to.
  40393. * @param webVROptions Options to modify the vr experience helper's behavior.
  40394. */
  40395. constructor(scene: Scene,
  40396. /** Options to modify the vr experience helper's behavior. */
  40397. webVROptions?: VRExperienceHelperOptions);
  40398. private _onDefaultMeshLoaded;
  40399. private _onResize;
  40400. private _onFullscreenChange;
  40401. /**
  40402. * Gets a value indicating if we are currently in VR mode.
  40403. */
  40404. readonly isInVRMode: boolean;
  40405. private onVrDisplayPresentChange;
  40406. private onVRDisplayChanged;
  40407. private moveButtonToBottomRight;
  40408. private displayVRButton;
  40409. private updateButtonVisibility;
  40410. private _cachedAngularSensibility;
  40411. /**
  40412. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40413. * Otherwise, will use the fullscreen API.
  40414. */
  40415. enterVR(): void;
  40416. /**
  40417. * Attempt to exit VR, or fullscreen.
  40418. */
  40419. exitVR(): void;
  40420. /**
  40421. * The position of the vr experience helper.
  40422. */
  40423. /**
  40424. * Sets the position of the vr experience helper.
  40425. */
  40426. position: Vector3;
  40427. /**
  40428. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40429. */
  40430. enableInteractions(): void;
  40431. private readonly _noControllerIsActive;
  40432. private beforeRender;
  40433. private _isTeleportationFloor;
  40434. /**
  40435. * Adds a floor mesh to be used for teleportation.
  40436. * @param floorMesh the mesh to be used for teleportation.
  40437. */
  40438. addFloorMesh(floorMesh: Mesh): void;
  40439. /**
  40440. * Removes a floor mesh from being used for teleportation.
  40441. * @param floorMesh the mesh to be removed.
  40442. */
  40443. removeFloorMesh(floorMesh: Mesh): void;
  40444. /**
  40445. * Enables interactions and teleportation using the VR controllers and gaze.
  40446. * @param vrTeleportationOptions options to modify teleportation behavior.
  40447. */
  40448. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40449. private _onNewGamepadConnected;
  40450. private _tryEnableInteractionOnController;
  40451. private _onNewGamepadDisconnected;
  40452. private _enableInteractionOnController;
  40453. private _checkTeleportWithRay;
  40454. private _checkRotate;
  40455. private _checkTeleportBackwards;
  40456. private _enableTeleportationOnController;
  40457. private _createTeleportationCircles;
  40458. private _displayTeleportationTarget;
  40459. private _hideTeleportationTarget;
  40460. private _rotateCamera;
  40461. private _moveTeleportationSelectorTo;
  40462. private _workingVector;
  40463. private _workingQuaternion;
  40464. private _workingMatrix;
  40465. /**
  40466. * Teleports the users feet to the desired location
  40467. * @param location The location where the user's feet should be placed
  40468. */
  40469. teleportCamera(location: Vector3): void;
  40470. private _convertNormalToDirectionOfRay;
  40471. private _castRayAndSelectObject;
  40472. private _notifySelectedMeshUnselected;
  40473. /**
  40474. * Sets the color of the laser ray from the vr controllers.
  40475. * @param color new color for the ray.
  40476. */
  40477. changeLaserColor(color: Color3): void;
  40478. /**
  40479. * Sets the color of the ray from the vr headsets gaze.
  40480. * @param color new color for the ray.
  40481. */
  40482. changeGazeColor(color: Color3): void;
  40483. /**
  40484. * Exits VR and disposes of the vr experience helper
  40485. */
  40486. dispose(): void;
  40487. /**
  40488. * Gets the name of the VRExperienceHelper class
  40489. * @returns "VRExperienceHelper"
  40490. */
  40491. getClassName(): string;
  40492. }
  40493. }
  40494. declare module BABYLON {
  40495. /**
  40496. * Manages an XRSession to work with Babylon's engine
  40497. * @see https://doc.babylonjs.com/how_to/webxr
  40498. */
  40499. export class WebXRSessionManager implements IDisposable {
  40500. private scene;
  40501. /**
  40502. * Fires every time a new xrFrame arrives which can be used to update the camera
  40503. */
  40504. onXRFrameObservable: Observable<any>;
  40505. /**
  40506. * Fires when the xr session is ended either by the device or manually done
  40507. */
  40508. onXRSessionEnded: Observable<any>;
  40509. /**
  40510. * Underlying xr session
  40511. */
  40512. session: XRSession;
  40513. /**
  40514. * Type of reference space used when creating the session
  40515. */
  40516. referenceSpace: XRReferenceSpace;
  40517. /** @hidden */
  40518. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40519. /**
  40520. * Current XR frame
  40521. */
  40522. currentFrame: Nullable<XRFrame>;
  40523. private _xrNavigator;
  40524. private baseLayer;
  40525. /**
  40526. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40527. * @param scene The scene which the session should be created for
  40528. */
  40529. constructor(scene: Scene);
  40530. /**
  40531. * Initializes the manager
  40532. * After initialization enterXR can be called to start an XR session
  40533. * @returns Promise which resolves after it is initialized
  40534. */
  40535. initializeAsync(): Promise<void>;
  40536. /**
  40537. * Initializes an xr session
  40538. * @param xrSessionMode mode to initialize
  40539. * @returns a promise which will resolve once the session has been initialized
  40540. */
  40541. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40542. /**
  40543. * Sets the reference space on the xr session
  40544. * @param referenceSpace space to set
  40545. * @returns a promise that will resolve once the reference space has been set
  40546. */
  40547. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40548. /**
  40549. * Updates the render state of the session
  40550. * @param state state to set
  40551. * @returns a promise that resolves once the render state has been updated
  40552. */
  40553. updateRenderStateAsync(state: any): Promise<void>;
  40554. /**
  40555. * Starts rendering to the xr layer
  40556. * @returns a promise that will resolve once rendering has started
  40557. */
  40558. startRenderingToXRAsync(): Promise<void>;
  40559. /**
  40560. * Stops the xrSession and restores the renderloop
  40561. * @returns Promise which resolves after it exits XR
  40562. */
  40563. exitXRAsync(): Promise<unknown>;
  40564. /**
  40565. * Checks if a session would be supported for the creation options specified
  40566. * @param sessionMode session mode to check if supported eg. immersive-vr
  40567. * @returns true if supported
  40568. */
  40569. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40570. /**
  40571. * @hidden
  40572. * Converts the render layer of xrSession to a render target
  40573. * @param session session to create render target for
  40574. * @param scene scene the new render target should be created for
  40575. */
  40576. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40577. /**
  40578. * Disposes of the session manager
  40579. */
  40580. dispose(): void;
  40581. }
  40582. }
  40583. declare module BABYLON {
  40584. /**
  40585. * WebXR Camera which holds the views for the xrSession
  40586. * @see https://doc.babylonjs.com/how_to/webxr
  40587. */
  40588. export class WebXRCamera extends FreeCamera {
  40589. private static _TmpMatrix;
  40590. /**
  40591. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40592. * @param name the name of the camera
  40593. * @param scene the scene to add the camera to
  40594. */
  40595. constructor(name: string, scene: Scene);
  40596. private _updateNumberOfRigCameras;
  40597. /** @hidden */
  40598. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40599. /**
  40600. * Updates the cameras position from the current pose information of the XR session
  40601. * @param xrSessionManager the session containing pose information
  40602. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40603. */
  40604. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40605. }
  40606. }
  40607. declare module BABYLON {
  40608. /**
  40609. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40610. */
  40611. export class WebXRManagedOutputCanvas implements IDisposable {
  40612. private helper;
  40613. private _canvas;
  40614. /**
  40615. * xrpresent context of the canvas which can be used to display/mirror xr content
  40616. */
  40617. canvasContext: WebGLRenderingContext;
  40618. /**
  40619. * xr layer for the canvas
  40620. */
  40621. xrLayer: Nullable<XRWebGLLayer>;
  40622. /**
  40623. * Initializes the xr layer for the session
  40624. * @param xrSession xr session
  40625. * @returns a promise that will resolve once the XR Layer has been created
  40626. */
  40627. initializeXRLayerAsync(xrSession: any): any;
  40628. /**
  40629. * Initializes the canvas to be added/removed upon entering/exiting xr
  40630. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40631. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40632. */
  40633. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40634. /**
  40635. * Disposes of the object
  40636. */
  40637. dispose(): void;
  40638. private _setManagedOutputCanvas;
  40639. private _addCanvas;
  40640. private _removeCanvas;
  40641. }
  40642. }
  40643. declare module BABYLON {
  40644. /**
  40645. * States of the webXR experience
  40646. */
  40647. export enum WebXRState {
  40648. /**
  40649. * Transitioning to being in XR mode
  40650. */
  40651. ENTERING_XR = 0,
  40652. /**
  40653. * Transitioning to non XR mode
  40654. */
  40655. EXITING_XR = 1,
  40656. /**
  40657. * In XR mode and presenting
  40658. */
  40659. IN_XR = 2,
  40660. /**
  40661. * Not entered XR mode
  40662. */
  40663. NOT_IN_XR = 3
  40664. }
  40665. /**
  40666. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40667. * @see https://doc.babylonjs.com/how_to/webxr
  40668. */
  40669. export class WebXRExperienceHelper implements IDisposable {
  40670. private scene;
  40671. /**
  40672. * 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
  40673. */
  40674. container: AbstractMesh;
  40675. /**
  40676. * Camera used to render xr content
  40677. */
  40678. camera: WebXRCamera;
  40679. /**
  40680. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40681. */
  40682. state: WebXRState;
  40683. private _setState;
  40684. private static _TmpVector;
  40685. /**
  40686. * Fires when the state of the experience helper has changed
  40687. */
  40688. onStateChangedObservable: Observable<WebXRState>;
  40689. /** Session manager used to keep track of xr session */
  40690. sessionManager: WebXRSessionManager;
  40691. private _nonVRCamera;
  40692. private _originalSceneAutoClear;
  40693. private _supported;
  40694. /**
  40695. * Creates the experience helper
  40696. * @param scene the scene to attach the experience helper to
  40697. * @returns a promise for the experience helper
  40698. */
  40699. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40700. /**
  40701. * Creates a WebXRExperienceHelper
  40702. * @param scene The scene the helper should be created in
  40703. */
  40704. private constructor();
  40705. /**
  40706. * Exits XR mode and returns the scene to its original state
  40707. * @returns promise that resolves after xr mode has exited
  40708. */
  40709. exitXRAsync(): Promise<unknown>;
  40710. /**
  40711. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40712. * @param sessionCreationOptions options for the XR session
  40713. * @param referenceSpaceType frame of reference of the XR session
  40714. * @param outputCanvas the output canvas that will be used to enter XR mode
  40715. * @returns promise that resolves after xr mode has entered
  40716. */
  40717. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40718. /**
  40719. * Updates the global position of the camera by moving the camera's container
  40720. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40721. * @param position The desired global position of the camera
  40722. */
  40723. setPositionOfCameraUsingContainer(position: Vector3): void;
  40724. /**
  40725. * Rotates the xr camera by rotating the camera's container around the camera's position
  40726. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40727. * @param rotation the desired quaternion rotation to apply to the camera
  40728. */
  40729. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40730. /**
  40731. * Disposes of the experience helper
  40732. */
  40733. dispose(): void;
  40734. }
  40735. }
  40736. declare module BABYLON {
  40737. /**
  40738. * Button which can be used to enter a different mode of XR
  40739. */
  40740. export class WebXREnterExitUIButton {
  40741. /** button element */
  40742. element: HTMLElement;
  40743. /** XR initialization options for the button */
  40744. sessionMode: XRSessionMode;
  40745. /** Reference space type */
  40746. referenceSpaceType: XRReferenceSpaceType;
  40747. /**
  40748. * Creates a WebXREnterExitUIButton
  40749. * @param element button element
  40750. * @param sessionMode XR initialization session mode
  40751. * @param referenceSpaceType the type of reference space to be used
  40752. */
  40753. constructor(
  40754. /** button element */
  40755. element: HTMLElement,
  40756. /** XR initialization options for the button */
  40757. sessionMode: XRSessionMode,
  40758. /** Reference space type */
  40759. referenceSpaceType: XRReferenceSpaceType);
  40760. /**
  40761. * Overwritable function which can be used to update the button's visuals when the state changes
  40762. * @param activeButton the current active button in the UI
  40763. */
  40764. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40765. }
  40766. /**
  40767. * Options to create the webXR UI
  40768. */
  40769. export class WebXREnterExitUIOptions {
  40770. /**
  40771. * Context to enter xr with
  40772. */
  40773. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40774. /**
  40775. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40776. */
  40777. customButtons?: Array<WebXREnterExitUIButton>;
  40778. }
  40779. /**
  40780. * UI to allow the user to enter/exit XR mode
  40781. */
  40782. export class WebXREnterExitUI implements IDisposable {
  40783. private scene;
  40784. private _overlay;
  40785. private _buttons;
  40786. private _activeButton;
  40787. /**
  40788. * Fired every time the active button is changed.
  40789. *
  40790. * When xr is entered via a button that launches xr that button will be the callback parameter
  40791. *
  40792. * When exiting xr the callback parameter will be null)
  40793. */
  40794. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40795. /**
  40796. * Creates UI to allow the user to enter/exit XR mode
  40797. * @param scene the scene to add the ui to
  40798. * @param helper the xr experience helper to enter/exit xr with
  40799. * @param options options to configure the UI
  40800. * @returns the created ui
  40801. */
  40802. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40803. private constructor();
  40804. private _updateButtons;
  40805. /**
  40806. * Disposes of the object
  40807. */
  40808. dispose(): void;
  40809. }
  40810. }
  40811. declare module BABYLON {
  40812. /**
  40813. * Represents an XR input
  40814. */
  40815. export class WebXRController {
  40816. private scene;
  40817. /** The underlying input source for the controller */
  40818. inputSource: XRInputSource;
  40819. private parentContainer;
  40820. /**
  40821. * 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
  40822. */
  40823. grip?: AbstractMesh;
  40824. /**
  40825. * Pointer which can be used to select objects or attach a visible laser to
  40826. */
  40827. pointer: AbstractMesh;
  40828. /**
  40829. * Event that fires when the controller is removed/disposed
  40830. */
  40831. onDisposeObservable: Observable<{}>;
  40832. private _tmpMatrix;
  40833. private _tmpQuaternion;
  40834. private _tmpVector;
  40835. /**
  40836. * Creates the controller
  40837. * @see https://doc.babylonjs.com/how_to/webxr
  40838. * @param scene the scene which the controller should be associated to
  40839. * @param inputSource the underlying input source for the controller
  40840. * @param parentContainer parent that the controller meshes should be children of
  40841. */
  40842. constructor(scene: Scene,
  40843. /** The underlying input source for the controller */
  40844. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  40845. /**
  40846. * Updates the controller pose based on the given XRFrame
  40847. * @param xrFrame xr frame to update the pose with
  40848. * @param referenceSpace reference space to use
  40849. */
  40850. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  40851. /**
  40852. * Gets a world space ray coming from the controller
  40853. * @param result the resulting ray
  40854. */
  40855. getWorldPointerRayToRef(result: Ray): void;
  40856. /**
  40857. * Disposes of the object
  40858. */
  40859. dispose(): void;
  40860. }
  40861. }
  40862. declare module BABYLON {
  40863. /**
  40864. * XR input used to track XR inputs such as controllers/rays
  40865. */
  40866. export class WebXRInput implements IDisposable {
  40867. /**
  40868. * Base experience the input listens to
  40869. */
  40870. baseExperience: WebXRExperienceHelper;
  40871. /**
  40872. * XR controllers being tracked
  40873. */
  40874. controllers: Array<WebXRController>;
  40875. private _frameObserver;
  40876. private _stateObserver;
  40877. /**
  40878. * Event when a controller has been connected/added
  40879. */
  40880. onControllerAddedObservable: Observable<WebXRController>;
  40881. /**
  40882. * Event when a controller has been removed/disconnected
  40883. */
  40884. onControllerRemovedObservable: Observable<WebXRController>;
  40885. /**
  40886. * Initializes the WebXRInput
  40887. * @param baseExperience experience helper which the input should be created for
  40888. */
  40889. constructor(
  40890. /**
  40891. * Base experience the input listens to
  40892. */
  40893. baseExperience: WebXRExperienceHelper);
  40894. private _onInputSourcesChange;
  40895. private _addAndRemoveControllers;
  40896. /**
  40897. * Disposes of the object
  40898. */
  40899. dispose(): void;
  40900. }
  40901. }
  40902. declare module BABYLON {
  40903. /**
  40904. * Enables teleportation
  40905. */
  40906. export class WebXRControllerTeleportation {
  40907. private _teleportationFillColor;
  40908. private _teleportationBorderColor;
  40909. private _tmpRay;
  40910. private _tmpVector;
  40911. /**
  40912. * Creates a WebXRControllerTeleportation
  40913. * @param input input manager to add teleportation to
  40914. * @param floorMeshes floormeshes which can be teleported to
  40915. */
  40916. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  40917. }
  40918. }
  40919. declare module BABYLON {
  40920. /**
  40921. * Handles pointer input automatically for the pointer of XR controllers
  40922. */
  40923. export class WebXRControllerPointerSelection {
  40924. private static _idCounter;
  40925. private _tmpRay;
  40926. /**
  40927. * Creates a WebXRControllerPointerSelection
  40928. * @param input input manager to setup pointer selection
  40929. */
  40930. constructor(input: WebXRInput);
  40931. private _convertNormalToDirectionOfRay;
  40932. private _updatePointerDistance;
  40933. }
  40934. }
  40935. declare module BABYLON {
  40936. /**
  40937. * Class used to represent data loading progression
  40938. */
  40939. export class SceneLoaderProgressEvent {
  40940. /** defines if data length to load can be evaluated */
  40941. readonly lengthComputable: boolean;
  40942. /** defines the loaded data length */
  40943. readonly loaded: number;
  40944. /** defines the data length to load */
  40945. readonly total: number;
  40946. /**
  40947. * Create a new progress event
  40948. * @param lengthComputable defines if data length to load can be evaluated
  40949. * @param loaded defines the loaded data length
  40950. * @param total defines the data length to load
  40951. */
  40952. constructor(
  40953. /** defines if data length to load can be evaluated */
  40954. lengthComputable: boolean,
  40955. /** defines the loaded data length */
  40956. loaded: number,
  40957. /** defines the data length to load */
  40958. total: number);
  40959. /**
  40960. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40961. * @param event defines the source event
  40962. * @returns a new SceneLoaderProgressEvent
  40963. */
  40964. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40965. }
  40966. /**
  40967. * Interface used by SceneLoader plugins to define supported file extensions
  40968. */
  40969. export interface ISceneLoaderPluginExtensions {
  40970. /**
  40971. * Defines the list of supported extensions
  40972. */
  40973. [extension: string]: {
  40974. isBinary: boolean;
  40975. };
  40976. }
  40977. /**
  40978. * Interface used by SceneLoader plugin factory
  40979. */
  40980. export interface ISceneLoaderPluginFactory {
  40981. /**
  40982. * Defines the name of the factory
  40983. */
  40984. name: string;
  40985. /**
  40986. * Function called to create a new plugin
  40987. * @return the new plugin
  40988. */
  40989. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40990. /**
  40991. * Boolean indicating if the plugin can direct load specific data
  40992. */
  40993. canDirectLoad?: (data: string) => boolean;
  40994. }
  40995. /**
  40996. * Interface used to define a SceneLoader plugin
  40997. */
  40998. export interface ISceneLoaderPlugin {
  40999. /**
  41000. * The friendly name of this plugin.
  41001. */
  41002. name: string;
  41003. /**
  41004. * The file extensions supported by this plugin.
  41005. */
  41006. extensions: string | ISceneLoaderPluginExtensions;
  41007. /**
  41008. * Import meshes into a scene.
  41009. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41010. * @param scene The scene to import into
  41011. * @param data The data to import
  41012. * @param rootUrl The root url for scene and resources
  41013. * @param meshes The meshes array to import into
  41014. * @param particleSystems The particle systems array to import into
  41015. * @param skeletons The skeletons array to import into
  41016. * @param onError The callback when import fails
  41017. * @returns True if successful or false otherwise
  41018. */
  41019. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41020. /**
  41021. * Load into a scene.
  41022. * @param scene The scene to load into
  41023. * @param data The data to import
  41024. * @param rootUrl The root url for scene and resources
  41025. * @param onError The callback when import fails
  41026. * @returns true if successful or false otherwise
  41027. */
  41028. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41029. /**
  41030. * The callback that returns true if the data can be directly loaded.
  41031. */
  41032. canDirectLoad?: (data: string) => boolean;
  41033. /**
  41034. * The callback that allows custom handling of the root url based on the response url.
  41035. */
  41036. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41037. /**
  41038. * Load into an asset container.
  41039. * @param scene The scene to load into
  41040. * @param data The data to import
  41041. * @param rootUrl The root url for scene and resources
  41042. * @param onError The callback when import fails
  41043. * @returns The loaded asset container
  41044. */
  41045. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41046. }
  41047. /**
  41048. * Interface used to define an async SceneLoader plugin
  41049. */
  41050. export interface ISceneLoaderPluginAsync {
  41051. /**
  41052. * The friendly name of this plugin.
  41053. */
  41054. name: string;
  41055. /**
  41056. * The file extensions supported by this plugin.
  41057. */
  41058. extensions: string | ISceneLoaderPluginExtensions;
  41059. /**
  41060. * Import meshes into a scene.
  41061. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41062. * @param scene The scene to import into
  41063. * @param data The data to import
  41064. * @param rootUrl The root url for scene and resources
  41065. * @param onProgress The callback when the load progresses
  41066. * @param fileName Defines the name of the file to load
  41067. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41068. */
  41069. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41070. meshes: AbstractMesh[];
  41071. particleSystems: IParticleSystem[];
  41072. skeletons: Skeleton[];
  41073. animationGroups: AnimationGroup[];
  41074. }>;
  41075. /**
  41076. * Load into a scene.
  41077. * @param scene The scene to load into
  41078. * @param data The data to import
  41079. * @param rootUrl The root url for scene and resources
  41080. * @param onProgress The callback when the load progresses
  41081. * @param fileName Defines the name of the file to load
  41082. * @returns Nothing
  41083. */
  41084. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41085. /**
  41086. * The callback that returns true if the data can be directly loaded.
  41087. */
  41088. canDirectLoad?: (data: string) => boolean;
  41089. /**
  41090. * The callback that allows custom handling of the root url based on the response url.
  41091. */
  41092. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41093. /**
  41094. * Load into an asset container.
  41095. * @param scene The scene to load into
  41096. * @param data The data to import
  41097. * @param rootUrl The root url for scene and resources
  41098. * @param onProgress The callback when the load progresses
  41099. * @param fileName Defines the name of the file to load
  41100. * @returns The loaded asset container
  41101. */
  41102. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41103. }
  41104. /**
  41105. * Class used to load scene from various file formats using registered plugins
  41106. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41107. */
  41108. export class SceneLoader {
  41109. /**
  41110. * No logging while loading
  41111. */
  41112. static readonly NO_LOGGING: number;
  41113. /**
  41114. * Minimal logging while loading
  41115. */
  41116. static readonly MINIMAL_LOGGING: number;
  41117. /**
  41118. * Summary logging while loading
  41119. */
  41120. static readonly SUMMARY_LOGGING: number;
  41121. /**
  41122. * Detailled logging while loading
  41123. */
  41124. static readonly DETAILED_LOGGING: number;
  41125. /**
  41126. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41127. */
  41128. static ForceFullSceneLoadingForIncremental: boolean;
  41129. /**
  41130. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41131. */
  41132. static ShowLoadingScreen: boolean;
  41133. /**
  41134. * Defines the current logging level (while loading the scene)
  41135. * @ignorenaming
  41136. */
  41137. static loggingLevel: number;
  41138. /**
  41139. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41140. */
  41141. static CleanBoneMatrixWeights: boolean;
  41142. /**
  41143. * Event raised when a plugin is used to load a scene
  41144. */
  41145. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41146. private static _registeredPlugins;
  41147. private static _getDefaultPlugin;
  41148. private static _getPluginForExtension;
  41149. private static _getPluginForDirectLoad;
  41150. private static _getPluginForFilename;
  41151. private static _getDirectLoad;
  41152. private static _loadData;
  41153. private static _getFileInfo;
  41154. /**
  41155. * Gets a plugin that can load the given extension
  41156. * @param extension defines the extension to load
  41157. * @returns a plugin or null if none works
  41158. */
  41159. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41160. /**
  41161. * Gets a boolean indicating that the given extension can be loaded
  41162. * @param extension defines the extension to load
  41163. * @returns true if the extension is supported
  41164. */
  41165. static IsPluginForExtensionAvailable(extension: string): boolean;
  41166. /**
  41167. * Adds a new plugin to the list of registered plugins
  41168. * @param plugin defines the plugin to add
  41169. */
  41170. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41171. /**
  41172. * Import meshes into a scene
  41173. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41174. * @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)
  41175. * @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)
  41176. * @param scene the instance of BABYLON.Scene to append to
  41177. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41178. * @param onProgress a callback with a progress event for each file being loaded
  41179. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41180. * @param pluginExtension the extension used to determine the plugin
  41181. * @returns The loaded plugin
  41182. */
  41183. 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>;
  41184. /**
  41185. * Import meshes into a scene
  41186. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41187. * @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)
  41188. * @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)
  41189. * @param scene the instance of BABYLON.Scene to append to
  41190. * @param onProgress a callback with a progress event for each file being loaded
  41191. * @param pluginExtension the extension used to determine the plugin
  41192. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41193. */
  41194. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41195. meshes: AbstractMesh[];
  41196. particleSystems: IParticleSystem[];
  41197. skeletons: Skeleton[];
  41198. animationGroups: AnimationGroup[];
  41199. }>;
  41200. /**
  41201. * Load a scene
  41202. * @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)
  41203. * @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)
  41204. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41205. * @param onSuccess a callback with the scene when import succeeds
  41206. * @param onProgress a callback with a progress event for each file being loaded
  41207. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41208. * @param pluginExtension the extension used to determine the plugin
  41209. * @returns The loaded plugin
  41210. */
  41211. 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>;
  41212. /**
  41213. * Load a scene
  41214. * @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)
  41215. * @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)
  41216. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41217. * @param onProgress a callback with a progress event for each file being loaded
  41218. * @param pluginExtension the extension used to determine the plugin
  41219. * @returns The loaded scene
  41220. */
  41221. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41222. /**
  41223. * Append a scene
  41224. * @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)
  41225. * @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)
  41226. * @param scene is the instance of BABYLON.Scene to append to
  41227. * @param onSuccess a callback with the scene when import succeeds
  41228. * @param onProgress a callback with a progress event for each file being loaded
  41229. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41230. * @param pluginExtension the extension used to determine the plugin
  41231. * @returns The loaded plugin
  41232. */
  41233. 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>;
  41234. /**
  41235. * Append a scene
  41236. * @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)
  41237. * @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)
  41238. * @param scene is the instance of BABYLON.Scene to append to
  41239. * @param onProgress a callback with a progress event for each file being loaded
  41240. * @param pluginExtension the extension used to determine the plugin
  41241. * @returns The given scene
  41242. */
  41243. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41244. /**
  41245. * Load a scene into an asset container
  41246. * @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)
  41247. * @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)
  41248. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41249. * @param onSuccess a callback with the scene when import succeeds
  41250. * @param onProgress a callback with a progress event for each file being loaded
  41251. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41252. * @param pluginExtension the extension used to determine the plugin
  41253. * @returns The loaded plugin
  41254. */
  41255. 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>;
  41256. /**
  41257. * Load a scene into an asset container
  41258. * @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)
  41259. * @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)
  41260. * @param scene is the instance of Scene to append to
  41261. * @param onProgress a callback with a progress event for each file being loaded
  41262. * @param pluginExtension the extension used to determine the plugin
  41263. * @returns The loaded asset container
  41264. */
  41265. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41266. }
  41267. }
  41268. declare module BABYLON {
  41269. /**
  41270. * Generic Controller
  41271. */
  41272. export class GenericController extends WebVRController {
  41273. /**
  41274. * Base Url for the controller model.
  41275. */
  41276. static readonly MODEL_BASE_URL: string;
  41277. /**
  41278. * File name for the controller model.
  41279. */
  41280. static readonly MODEL_FILENAME: string;
  41281. /**
  41282. * Creates a new GenericController from a gamepad
  41283. * @param vrGamepad the gamepad that the controller should be created from
  41284. */
  41285. constructor(vrGamepad: any);
  41286. /**
  41287. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41288. * @param scene scene in which to add meshes
  41289. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41290. */
  41291. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41292. /**
  41293. * Called once for each button that changed state since the last frame
  41294. * @param buttonIdx Which button index changed
  41295. * @param state New state of the button
  41296. * @param changes Which properties on the state changed since last frame
  41297. */
  41298. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41299. }
  41300. }
  41301. declare module BABYLON {
  41302. /**
  41303. * Defines the WindowsMotionController object that the state of the windows motion controller
  41304. */
  41305. export class WindowsMotionController extends WebVRController {
  41306. /**
  41307. * The base url used to load the left and right controller models
  41308. */
  41309. static MODEL_BASE_URL: string;
  41310. /**
  41311. * The name of the left controller model file
  41312. */
  41313. static MODEL_LEFT_FILENAME: string;
  41314. /**
  41315. * The name of the right controller model file
  41316. */
  41317. static MODEL_RIGHT_FILENAME: string;
  41318. /**
  41319. * The controller name prefix for this controller type
  41320. */
  41321. static readonly GAMEPAD_ID_PREFIX: string;
  41322. /**
  41323. * The controller id pattern for this controller type
  41324. */
  41325. private static readonly GAMEPAD_ID_PATTERN;
  41326. private _loadedMeshInfo;
  41327. private readonly _mapping;
  41328. /**
  41329. * Fired when the trackpad on this controller is clicked
  41330. */
  41331. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41332. /**
  41333. * Fired when the trackpad on this controller is modified
  41334. */
  41335. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41336. /**
  41337. * The current x and y values of this controller's trackpad
  41338. */
  41339. trackpad: StickValues;
  41340. /**
  41341. * Creates a new WindowsMotionController from a gamepad
  41342. * @param vrGamepad the gamepad that the controller should be created from
  41343. */
  41344. constructor(vrGamepad: any);
  41345. /**
  41346. * Fired when the trigger on this controller is modified
  41347. */
  41348. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41349. /**
  41350. * Fired when the menu button on this controller is modified
  41351. */
  41352. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41353. /**
  41354. * Fired when the grip button on this controller is modified
  41355. */
  41356. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41357. /**
  41358. * Fired when the thumbstick button on this controller is modified
  41359. */
  41360. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41361. /**
  41362. * Fired when the touchpad button on this controller is modified
  41363. */
  41364. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41365. /**
  41366. * Fired when the touchpad values on this controller are modified
  41367. */
  41368. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41369. private _updateTrackpad;
  41370. /**
  41371. * Called once per frame by the engine.
  41372. */
  41373. update(): void;
  41374. /**
  41375. * Called once for each button that changed state since the last frame
  41376. * @param buttonIdx Which button index changed
  41377. * @param state New state of the button
  41378. * @param changes Which properties on the state changed since last frame
  41379. */
  41380. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41381. /**
  41382. * Moves the buttons on the controller mesh based on their current state
  41383. * @param buttonName the name of the button to move
  41384. * @param buttonValue the value of the button which determines the buttons new position
  41385. */
  41386. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41387. /**
  41388. * Moves the axis on the controller mesh based on its current state
  41389. * @param axis the index of the axis
  41390. * @param axisValue the value of the axis which determines the meshes new position
  41391. * @hidden
  41392. */
  41393. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41394. /**
  41395. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41396. * @param scene scene in which to add meshes
  41397. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41398. */
  41399. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41400. /**
  41401. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41402. * can be transformed by button presses and axes values, based on this._mapping.
  41403. *
  41404. * @param scene scene in which the meshes exist
  41405. * @param meshes list of meshes that make up the controller model to process
  41406. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41407. */
  41408. private processModel;
  41409. private createMeshInfo;
  41410. /**
  41411. * Gets the ray of the controller in the direction the controller is pointing
  41412. * @param length the length the resulting ray should be
  41413. * @returns a ray in the direction the controller is pointing
  41414. */
  41415. getForwardRay(length?: number): Ray;
  41416. /**
  41417. * Disposes of the controller
  41418. */
  41419. dispose(): void;
  41420. }
  41421. }
  41422. declare module BABYLON {
  41423. /**
  41424. * Oculus Touch Controller
  41425. */
  41426. export class OculusTouchController extends WebVRController {
  41427. /**
  41428. * Base Url for the controller model.
  41429. */
  41430. static MODEL_BASE_URL: string;
  41431. /**
  41432. * File name for the left controller model.
  41433. */
  41434. static MODEL_LEFT_FILENAME: string;
  41435. /**
  41436. * File name for the right controller model.
  41437. */
  41438. static MODEL_RIGHT_FILENAME: string;
  41439. /**
  41440. * Base Url for the Quest controller model.
  41441. */
  41442. static QUEST_MODEL_BASE_URL: string;
  41443. /**
  41444. * @hidden
  41445. * If the controllers are running on a device that needs the updated Quest controller models
  41446. */
  41447. static _IsQuest: boolean;
  41448. /**
  41449. * Fired when the secondary trigger on this controller is modified
  41450. */
  41451. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41452. /**
  41453. * Fired when the thumb rest on this controller is modified
  41454. */
  41455. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41456. /**
  41457. * Creates a new OculusTouchController from a gamepad
  41458. * @param vrGamepad the gamepad that the controller should be created from
  41459. */
  41460. constructor(vrGamepad: any);
  41461. /**
  41462. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41463. * @param scene scene in which to add meshes
  41464. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41465. */
  41466. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41467. /**
  41468. * Fired when the A button on this controller is modified
  41469. */
  41470. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41471. /**
  41472. * Fired when the B button on this controller is modified
  41473. */
  41474. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41475. /**
  41476. * Fired when the X button on this controller is modified
  41477. */
  41478. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41479. /**
  41480. * Fired when the Y button on this controller is modified
  41481. */
  41482. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41483. /**
  41484. * Called once for each button that changed state since the last frame
  41485. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41486. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41487. * 2) secondary trigger (same)
  41488. * 3) A (right) X (left), touch, pressed = value
  41489. * 4) B / Y
  41490. * 5) thumb rest
  41491. * @param buttonIdx Which button index changed
  41492. * @param state New state of the button
  41493. * @param changes Which properties on the state changed since last frame
  41494. */
  41495. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41496. }
  41497. }
  41498. declare module BABYLON {
  41499. /**
  41500. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41501. */
  41502. export class WebXRControllerModelLoader {
  41503. /**
  41504. * Creates the WebXRControllerModelLoader
  41505. * @param input xr input that creates the controllers
  41506. */
  41507. constructor(input: WebXRInput);
  41508. }
  41509. }
  41510. declare module BABYLON {
  41511. /**
  41512. * Contains an array of blocks representing the octree
  41513. */
  41514. export interface IOctreeContainer<T> {
  41515. /**
  41516. * Blocks within the octree
  41517. */
  41518. blocks: Array<OctreeBlock<T>>;
  41519. }
  41520. /**
  41521. * Class used to store a cell in an octree
  41522. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41523. */
  41524. export class OctreeBlock<T> {
  41525. /**
  41526. * Gets the content of the current block
  41527. */
  41528. entries: T[];
  41529. /**
  41530. * Gets the list of block children
  41531. */
  41532. blocks: Array<OctreeBlock<T>>;
  41533. private _depth;
  41534. private _maxDepth;
  41535. private _capacity;
  41536. private _minPoint;
  41537. private _maxPoint;
  41538. private _boundingVectors;
  41539. private _creationFunc;
  41540. /**
  41541. * Creates a new block
  41542. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41543. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41544. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41545. * @param depth defines the current depth of this block in the octree
  41546. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41547. * @param creationFunc defines a callback to call when an element is added to the block
  41548. */
  41549. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41550. /**
  41551. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41552. */
  41553. readonly capacity: number;
  41554. /**
  41555. * Gets the minimum vector (in world space) of the block's bounding box
  41556. */
  41557. readonly minPoint: Vector3;
  41558. /**
  41559. * Gets the maximum vector (in world space) of the block's bounding box
  41560. */
  41561. readonly maxPoint: Vector3;
  41562. /**
  41563. * Add a new element to this block
  41564. * @param entry defines the element to add
  41565. */
  41566. addEntry(entry: T): void;
  41567. /**
  41568. * Remove an element from this block
  41569. * @param entry defines the element to remove
  41570. */
  41571. removeEntry(entry: T): void;
  41572. /**
  41573. * Add an array of elements to this block
  41574. * @param entries defines the array of elements to add
  41575. */
  41576. addEntries(entries: T[]): void;
  41577. /**
  41578. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41579. * @param frustumPlanes defines the frustum planes to test
  41580. * @param selection defines the array to store current content if selection is positive
  41581. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41582. */
  41583. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41584. /**
  41585. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41586. * @param sphereCenter defines the bounding sphere center
  41587. * @param sphereRadius defines the bounding sphere radius
  41588. * @param selection defines the array to store current content if selection is positive
  41589. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41590. */
  41591. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41592. /**
  41593. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41594. * @param ray defines the ray to test with
  41595. * @param selection defines the array to store current content if selection is positive
  41596. */
  41597. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41598. /**
  41599. * Subdivide the content into child blocks (this block will then be empty)
  41600. */
  41601. createInnerBlocks(): void;
  41602. /**
  41603. * @hidden
  41604. */
  41605. 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;
  41606. }
  41607. }
  41608. declare module BABYLON {
  41609. /**
  41610. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41611. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41612. */
  41613. export class Octree<T> {
  41614. /** 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.) */
  41615. maxDepth: number;
  41616. /**
  41617. * Blocks within the octree containing objects
  41618. */
  41619. blocks: Array<OctreeBlock<T>>;
  41620. /**
  41621. * Content stored in the octree
  41622. */
  41623. dynamicContent: T[];
  41624. private _maxBlockCapacity;
  41625. private _selectionContent;
  41626. private _creationFunc;
  41627. /**
  41628. * Creates a octree
  41629. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41630. * @param creationFunc function to be used to instatiate the octree
  41631. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41632. * @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.)
  41633. */
  41634. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41635. /** 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.) */
  41636. maxDepth?: number);
  41637. /**
  41638. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41639. * @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);
  41640. * @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);
  41641. * @param entries meshes to be added to the octree blocks
  41642. */
  41643. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41644. /**
  41645. * Adds a mesh to the octree
  41646. * @param entry Mesh to add to the octree
  41647. */
  41648. addMesh(entry: T): void;
  41649. /**
  41650. * Remove an element from the octree
  41651. * @param entry defines the element to remove
  41652. */
  41653. removeMesh(entry: T): void;
  41654. /**
  41655. * Selects an array of meshes within the frustum
  41656. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41657. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41658. * @returns array of meshes within the frustum
  41659. */
  41660. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41661. /**
  41662. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41663. * @param sphereCenter defines the bounding sphere center
  41664. * @param sphereRadius defines the bounding sphere radius
  41665. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41666. * @returns an array of objects that intersect the sphere
  41667. */
  41668. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41669. /**
  41670. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41671. * @param ray defines the ray to test with
  41672. * @returns array of intersected objects
  41673. */
  41674. intersectsRay(ray: Ray): SmartArray<T>;
  41675. /**
  41676. * Adds a mesh into the octree block if it intersects the block
  41677. */
  41678. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41679. /**
  41680. * Adds a submesh into the octree block if it intersects the block
  41681. */
  41682. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41683. }
  41684. }
  41685. declare module BABYLON {
  41686. interface Scene {
  41687. /**
  41688. * @hidden
  41689. * Backing Filed
  41690. */
  41691. _selectionOctree: Octree<AbstractMesh>;
  41692. /**
  41693. * Gets the octree used to boost mesh selection (picking)
  41694. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41695. */
  41696. selectionOctree: Octree<AbstractMesh>;
  41697. /**
  41698. * Creates or updates the octree used to boost selection (picking)
  41699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41700. * @param maxCapacity defines the maximum capacity per leaf
  41701. * @param maxDepth defines the maximum depth of the octree
  41702. * @returns an octree of AbstractMesh
  41703. */
  41704. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41705. }
  41706. interface AbstractMesh {
  41707. /**
  41708. * @hidden
  41709. * Backing Field
  41710. */
  41711. _submeshesOctree: Octree<SubMesh>;
  41712. /**
  41713. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41714. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41715. * @param maxCapacity defines the maximum size of each block (64 by default)
  41716. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41717. * @returns the new octree
  41718. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41719. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41720. */
  41721. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41722. }
  41723. /**
  41724. * Defines the octree scene component responsible to manage any octrees
  41725. * in a given scene.
  41726. */
  41727. export class OctreeSceneComponent {
  41728. /**
  41729. * The component name help to identify the component in the list of scene components.
  41730. */
  41731. readonly name: string;
  41732. /**
  41733. * The scene the component belongs to.
  41734. */
  41735. scene: Scene;
  41736. /**
  41737. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41738. */
  41739. readonly checksIsEnabled: boolean;
  41740. /**
  41741. * Creates a new instance of the component for the given scene
  41742. * @param scene Defines the scene to register the component in
  41743. */
  41744. constructor(scene: Scene);
  41745. /**
  41746. * Registers the component in a given scene
  41747. */
  41748. register(): void;
  41749. /**
  41750. * Return the list of active meshes
  41751. * @returns the list of active meshes
  41752. */
  41753. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41754. /**
  41755. * Return the list of active sub meshes
  41756. * @param mesh The mesh to get the candidates sub meshes from
  41757. * @returns the list of active sub meshes
  41758. */
  41759. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41760. private _tempRay;
  41761. /**
  41762. * Return the list of sub meshes intersecting with a given local ray
  41763. * @param mesh defines the mesh to find the submesh for
  41764. * @param localRay defines the ray in local space
  41765. * @returns the list of intersecting sub meshes
  41766. */
  41767. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41768. /**
  41769. * Return the list of sub meshes colliding with a collider
  41770. * @param mesh defines the mesh to find the submesh for
  41771. * @param collider defines the collider to evaluate the collision against
  41772. * @returns the list of colliding sub meshes
  41773. */
  41774. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41775. /**
  41776. * Rebuilds the elements related to this component in case of
  41777. * context lost for instance.
  41778. */
  41779. rebuild(): void;
  41780. /**
  41781. * Disposes the component and the associated ressources.
  41782. */
  41783. dispose(): void;
  41784. }
  41785. }
  41786. declare module BABYLON {
  41787. /**
  41788. * Renders a layer on top of an existing scene
  41789. */
  41790. export class UtilityLayerRenderer implements IDisposable {
  41791. /** the original scene that will be rendered on top of */
  41792. originalScene: Scene;
  41793. private _pointerCaptures;
  41794. private _lastPointerEvents;
  41795. private static _DefaultUtilityLayer;
  41796. private static _DefaultKeepDepthUtilityLayer;
  41797. private _sharedGizmoLight;
  41798. private _renderCamera;
  41799. /**
  41800. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41801. * @returns the camera that is used when rendering the utility layer
  41802. */
  41803. getRenderCamera(): Nullable<Camera>;
  41804. /**
  41805. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41806. * @param cam the camera that should be used when rendering the utility layer
  41807. */
  41808. setRenderCamera(cam: Nullable<Camera>): void;
  41809. /**
  41810. * @hidden
  41811. * Light which used by gizmos to get light shading
  41812. */
  41813. _getSharedGizmoLight(): HemisphericLight;
  41814. /**
  41815. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41816. */
  41817. pickUtilitySceneFirst: boolean;
  41818. /**
  41819. * 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)
  41820. */
  41821. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41822. /**
  41823. * 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)
  41824. */
  41825. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41826. /**
  41827. * The scene that is rendered on top of the original scene
  41828. */
  41829. utilityLayerScene: Scene;
  41830. /**
  41831. * If the utility layer should automatically be rendered on top of existing scene
  41832. */
  41833. shouldRender: boolean;
  41834. /**
  41835. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41836. */
  41837. onlyCheckPointerDownEvents: boolean;
  41838. /**
  41839. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41840. */
  41841. processAllEvents: boolean;
  41842. /**
  41843. * Observable raised when the pointer move from the utility layer scene to the main scene
  41844. */
  41845. onPointerOutObservable: Observable<number>;
  41846. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41847. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41848. private _afterRenderObserver;
  41849. private _sceneDisposeObserver;
  41850. private _originalPointerObserver;
  41851. /**
  41852. * Instantiates a UtilityLayerRenderer
  41853. * @param originalScene the original scene that will be rendered on top of
  41854. * @param handleEvents boolean indicating if the utility layer should handle events
  41855. */
  41856. constructor(
  41857. /** the original scene that will be rendered on top of */
  41858. originalScene: Scene, handleEvents?: boolean);
  41859. private _notifyObservers;
  41860. /**
  41861. * Renders the utility layers scene on top of the original scene
  41862. */
  41863. render(): void;
  41864. /**
  41865. * Disposes of the renderer
  41866. */
  41867. dispose(): void;
  41868. private _updateCamera;
  41869. }
  41870. }
  41871. declare module BABYLON {
  41872. /**
  41873. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41874. */
  41875. export class Gizmo implements IDisposable {
  41876. /** The utility layer the gizmo will be added to */
  41877. gizmoLayer: UtilityLayerRenderer;
  41878. /**
  41879. * The root mesh of the gizmo
  41880. */
  41881. _rootMesh: Mesh;
  41882. private _attachedMesh;
  41883. /**
  41884. * Ratio for the scale of the gizmo (Default: 1)
  41885. */
  41886. scaleRatio: number;
  41887. /**
  41888. * If a custom mesh has been set (Default: false)
  41889. */
  41890. protected _customMeshSet: boolean;
  41891. /**
  41892. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41893. * * When set, interactions will be enabled
  41894. */
  41895. attachedMesh: Nullable<AbstractMesh>;
  41896. /**
  41897. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41898. * @param mesh The mesh to replace the default mesh of the gizmo
  41899. */
  41900. setCustomMesh(mesh: Mesh): void;
  41901. /**
  41902. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41903. */
  41904. updateGizmoRotationToMatchAttachedMesh: boolean;
  41905. /**
  41906. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41907. */
  41908. updateGizmoPositionToMatchAttachedMesh: boolean;
  41909. /**
  41910. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41911. */
  41912. protected _updateScale: boolean;
  41913. protected _interactionsEnabled: boolean;
  41914. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41915. private _beforeRenderObserver;
  41916. private _tempVector;
  41917. /**
  41918. * Creates a gizmo
  41919. * @param gizmoLayer The utility layer the gizmo will be added to
  41920. */
  41921. constructor(
  41922. /** The utility layer the gizmo will be added to */
  41923. gizmoLayer?: UtilityLayerRenderer);
  41924. /**
  41925. * Updates the gizmo to match the attached mesh's position/rotation
  41926. */
  41927. protected _update(): void;
  41928. /**
  41929. * Disposes of the gizmo
  41930. */
  41931. dispose(): void;
  41932. }
  41933. }
  41934. declare module BABYLON {
  41935. /**
  41936. * Single plane drag gizmo
  41937. */
  41938. export class PlaneDragGizmo extends Gizmo {
  41939. /**
  41940. * Drag behavior responsible for the gizmos dragging interactions
  41941. */
  41942. dragBehavior: PointerDragBehavior;
  41943. private _pointerObserver;
  41944. /**
  41945. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41946. */
  41947. snapDistance: number;
  41948. /**
  41949. * Event that fires each time the gizmo snaps to a new location.
  41950. * * snapDistance is the the change in distance
  41951. */
  41952. onSnapObservable: Observable<{
  41953. snapDistance: number;
  41954. }>;
  41955. private _plane;
  41956. private _coloredMaterial;
  41957. private _hoverMaterial;
  41958. private _isEnabled;
  41959. private _parent;
  41960. /** @hidden */
  41961. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41962. /** @hidden */
  41963. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41964. /**
  41965. * Creates a PlaneDragGizmo
  41966. * @param gizmoLayer The utility layer the gizmo will be added to
  41967. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41968. * @param color The color of the gizmo
  41969. */
  41970. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41971. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41972. /**
  41973. * If the gizmo is enabled
  41974. */
  41975. isEnabled: boolean;
  41976. /**
  41977. * Disposes of the gizmo
  41978. */
  41979. dispose(): void;
  41980. }
  41981. }
  41982. declare module BABYLON {
  41983. /**
  41984. * Gizmo that enables dragging a mesh along 3 axis
  41985. */
  41986. export class PositionGizmo extends Gizmo {
  41987. /**
  41988. * Internal gizmo used for interactions on the x axis
  41989. */
  41990. xGizmo: AxisDragGizmo;
  41991. /**
  41992. * Internal gizmo used for interactions on the y axis
  41993. */
  41994. yGizmo: AxisDragGizmo;
  41995. /**
  41996. * Internal gizmo used for interactions on the z axis
  41997. */
  41998. zGizmo: AxisDragGizmo;
  41999. /**
  42000. * Internal gizmo used for interactions on the yz plane
  42001. */
  42002. xPlaneGizmo: PlaneDragGizmo;
  42003. /**
  42004. * Internal gizmo used for interactions on the xz plane
  42005. */
  42006. yPlaneGizmo: PlaneDragGizmo;
  42007. /**
  42008. * Internal gizmo used for interactions on the xy plane
  42009. */
  42010. zPlaneGizmo: PlaneDragGizmo;
  42011. /**
  42012. * private variables
  42013. */
  42014. private _meshAttached;
  42015. private _updateGizmoRotationToMatchAttachedMesh;
  42016. private _snapDistance;
  42017. private _scaleRatio;
  42018. /** Fires an event when any of it's sub gizmos are dragged */
  42019. onDragStartObservable: Observable<unknown>;
  42020. /** Fires an event when any of it's sub gizmos are released from dragging */
  42021. onDragEndObservable: Observable<unknown>;
  42022. /**
  42023. * If set to true, planar drag is enabled
  42024. */
  42025. private _planarGizmoEnabled;
  42026. attachedMesh: Nullable<AbstractMesh>;
  42027. /**
  42028. * Creates a PositionGizmo
  42029. * @param gizmoLayer The utility layer the gizmo will be added to
  42030. */
  42031. constructor(gizmoLayer?: UtilityLayerRenderer);
  42032. /**
  42033. * If the planar drag gizmo is enabled
  42034. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42035. */
  42036. planarGizmoEnabled: boolean;
  42037. updateGizmoRotationToMatchAttachedMesh: boolean;
  42038. /**
  42039. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42040. */
  42041. snapDistance: number;
  42042. /**
  42043. * Ratio for the scale of the gizmo (Default: 1)
  42044. */
  42045. scaleRatio: number;
  42046. /**
  42047. * Disposes of the gizmo
  42048. */
  42049. dispose(): void;
  42050. /**
  42051. * CustomMeshes are not supported by this gizmo
  42052. * @param mesh The mesh to replace the default mesh of the gizmo
  42053. */
  42054. setCustomMesh(mesh: Mesh): void;
  42055. }
  42056. }
  42057. declare module BABYLON {
  42058. /**
  42059. * Single axis drag gizmo
  42060. */
  42061. export class AxisDragGizmo extends Gizmo {
  42062. /**
  42063. * Drag behavior responsible for the gizmos dragging interactions
  42064. */
  42065. dragBehavior: PointerDragBehavior;
  42066. private _pointerObserver;
  42067. /**
  42068. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42069. */
  42070. snapDistance: number;
  42071. /**
  42072. * Event that fires each time the gizmo snaps to a new location.
  42073. * * snapDistance is the the change in distance
  42074. */
  42075. onSnapObservable: Observable<{
  42076. snapDistance: number;
  42077. }>;
  42078. private _isEnabled;
  42079. private _parent;
  42080. private _arrow;
  42081. private _coloredMaterial;
  42082. private _hoverMaterial;
  42083. /** @hidden */
  42084. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42085. /** @hidden */
  42086. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42087. /**
  42088. * Creates an AxisDragGizmo
  42089. * @param gizmoLayer The utility layer the gizmo will be added to
  42090. * @param dragAxis The axis which the gizmo will be able to drag on
  42091. * @param color The color of the gizmo
  42092. */
  42093. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42094. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42095. /**
  42096. * If the gizmo is enabled
  42097. */
  42098. isEnabled: boolean;
  42099. /**
  42100. * Disposes of the gizmo
  42101. */
  42102. dispose(): void;
  42103. }
  42104. }
  42105. declare module BABYLON.Debug {
  42106. /**
  42107. * The Axes viewer will show 3 axes in a specific point in space
  42108. */
  42109. export class AxesViewer {
  42110. private _xAxis;
  42111. private _yAxis;
  42112. private _zAxis;
  42113. private _scaleLinesFactor;
  42114. private _instanced;
  42115. /**
  42116. * Gets the hosting scene
  42117. */
  42118. scene: Scene;
  42119. /**
  42120. * Gets or sets a number used to scale line length
  42121. */
  42122. scaleLines: number;
  42123. /** Gets the node hierarchy used to render x-axis */
  42124. readonly xAxis: TransformNode;
  42125. /** Gets the node hierarchy used to render y-axis */
  42126. readonly yAxis: TransformNode;
  42127. /** Gets the node hierarchy used to render z-axis */
  42128. readonly zAxis: TransformNode;
  42129. /**
  42130. * Creates a new AxesViewer
  42131. * @param scene defines the hosting scene
  42132. * @param scaleLines defines a number used to scale line length (1 by default)
  42133. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42134. * @param xAxis defines the node hierarchy used to render the x-axis
  42135. * @param yAxis defines the node hierarchy used to render the y-axis
  42136. * @param zAxis defines the node hierarchy used to render the z-axis
  42137. */
  42138. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42139. /**
  42140. * Force the viewer to update
  42141. * @param position defines the position of the viewer
  42142. * @param xaxis defines the x axis of the viewer
  42143. * @param yaxis defines the y axis of the viewer
  42144. * @param zaxis defines the z axis of the viewer
  42145. */
  42146. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42147. /**
  42148. * Creates an instance of this axes viewer.
  42149. * @returns a new axes viewer with instanced meshes
  42150. */
  42151. createInstance(): AxesViewer;
  42152. /** Releases resources */
  42153. dispose(): void;
  42154. private static _SetRenderingGroupId;
  42155. }
  42156. }
  42157. declare module BABYLON.Debug {
  42158. /**
  42159. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42160. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42161. */
  42162. export class BoneAxesViewer extends AxesViewer {
  42163. /**
  42164. * Gets or sets the target mesh where to display the axes viewer
  42165. */
  42166. mesh: Nullable<Mesh>;
  42167. /**
  42168. * Gets or sets the target bone where to display the axes viewer
  42169. */
  42170. bone: Nullable<Bone>;
  42171. /** Gets current position */
  42172. pos: Vector3;
  42173. /** Gets direction of X axis */
  42174. xaxis: Vector3;
  42175. /** Gets direction of Y axis */
  42176. yaxis: Vector3;
  42177. /** Gets direction of Z axis */
  42178. zaxis: Vector3;
  42179. /**
  42180. * Creates a new BoneAxesViewer
  42181. * @param scene defines the hosting scene
  42182. * @param bone defines the target bone
  42183. * @param mesh defines the target mesh
  42184. * @param scaleLines defines a scaling factor for line length (1 by default)
  42185. */
  42186. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42187. /**
  42188. * Force the viewer to update
  42189. */
  42190. update(): void;
  42191. /** Releases resources */
  42192. dispose(): void;
  42193. }
  42194. }
  42195. declare module BABYLON {
  42196. /**
  42197. * Interface used to define scene explorer extensibility option
  42198. */
  42199. export interface IExplorerExtensibilityOption {
  42200. /**
  42201. * Define the option label
  42202. */
  42203. label: string;
  42204. /**
  42205. * Defines the action to execute on click
  42206. */
  42207. action: (entity: any) => void;
  42208. }
  42209. /**
  42210. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42211. */
  42212. export interface IExplorerExtensibilityGroup {
  42213. /**
  42214. * Defines a predicate to test if a given type mut be extended
  42215. */
  42216. predicate: (entity: any) => boolean;
  42217. /**
  42218. * Gets the list of options added to a type
  42219. */
  42220. entries: IExplorerExtensibilityOption[];
  42221. }
  42222. /**
  42223. * Interface used to define the options to use to create the Inspector
  42224. */
  42225. export interface IInspectorOptions {
  42226. /**
  42227. * Display in overlay mode (default: false)
  42228. */
  42229. overlay?: boolean;
  42230. /**
  42231. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42232. */
  42233. globalRoot?: HTMLElement;
  42234. /**
  42235. * Display the Scene explorer
  42236. */
  42237. showExplorer?: boolean;
  42238. /**
  42239. * Display the property inspector
  42240. */
  42241. showInspector?: boolean;
  42242. /**
  42243. * Display in embed mode (both panes on the right)
  42244. */
  42245. embedMode?: boolean;
  42246. /**
  42247. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42248. */
  42249. handleResize?: boolean;
  42250. /**
  42251. * Allow the panes to popup (default: true)
  42252. */
  42253. enablePopup?: boolean;
  42254. /**
  42255. * Allow the panes to be closed by users (default: true)
  42256. */
  42257. enableClose?: boolean;
  42258. /**
  42259. * Optional list of extensibility entries
  42260. */
  42261. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42262. /**
  42263. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42264. */
  42265. inspectorURL?: string;
  42266. }
  42267. interface Scene {
  42268. /**
  42269. * @hidden
  42270. * Backing field
  42271. */
  42272. _debugLayer: DebugLayer;
  42273. /**
  42274. * Gets the debug layer (aka Inspector) associated with the scene
  42275. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42276. */
  42277. debugLayer: DebugLayer;
  42278. }
  42279. /**
  42280. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42281. * what is happening in your scene
  42282. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42283. */
  42284. export class DebugLayer {
  42285. /**
  42286. * Define the url to get the inspector script from.
  42287. * By default it uses the babylonjs CDN.
  42288. * @ignoreNaming
  42289. */
  42290. static InspectorURL: string;
  42291. private _scene;
  42292. private BJSINSPECTOR;
  42293. private _onPropertyChangedObservable?;
  42294. /**
  42295. * Observable triggered when a property is changed through the inspector.
  42296. */
  42297. readonly onPropertyChangedObservable: any;
  42298. /**
  42299. * Instantiates a new debug layer.
  42300. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42301. * what is happening in your scene
  42302. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42303. * @param scene Defines the scene to inspect
  42304. */
  42305. constructor(scene: Scene);
  42306. /** Creates the inspector window. */
  42307. private _createInspector;
  42308. /**
  42309. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42310. * @param entity defines the entity to select
  42311. * @param lineContainerTitle defines the specific block to highlight
  42312. */
  42313. select(entity: any, lineContainerTitle?: string): void;
  42314. /** Get the inspector from bundle or global */
  42315. private _getGlobalInspector;
  42316. /**
  42317. * Get if the inspector is visible or not.
  42318. * @returns true if visible otherwise, false
  42319. */
  42320. isVisible(): boolean;
  42321. /**
  42322. * Hide the inspector and close its window.
  42323. */
  42324. hide(): void;
  42325. /**
  42326. * Launch the debugLayer.
  42327. * @param config Define the configuration of the inspector
  42328. * @return a promise fulfilled when the debug layer is visible
  42329. */
  42330. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42331. }
  42332. }
  42333. declare module BABYLON {
  42334. /**
  42335. * Class containing static functions to help procedurally build meshes
  42336. */
  42337. export class BoxBuilder {
  42338. /**
  42339. * Creates a box mesh
  42340. * * The parameter `size` sets the size (float) of each box side (default 1)
  42341. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42342. * * 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)
  42343. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42345. * * 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
  42346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42347. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42348. * @param name defines the name of the mesh
  42349. * @param options defines the options used to create the mesh
  42350. * @param scene defines the hosting scene
  42351. * @returns the box mesh
  42352. */
  42353. static CreateBox(name: string, options: {
  42354. size?: number;
  42355. width?: number;
  42356. height?: number;
  42357. depth?: number;
  42358. faceUV?: Vector4[];
  42359. faceColors?: Color4[];
  42360. sideOrientation?: number;
  42361. frontUVs?: Vector4;
  42362. backUVs?: Vector4;
  42363. wrap?: boolean;
  42364. topBaseAt?: number;
  42365. bottomBaseAt?: number;
  42366. updatable?: boolean;
  42367. }, scene?: Nullable<Scene>): Mesh;
  42368. }
  42369. }
  42370. declare module BABYLON {
  42371. /**
  42372. * Class containing static functions to help procedurally build meshes
  42373. */
  42374. export class SphereBuilder {
  42375. /**
  42376. * Creates a sphere mesh
  42377. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42378. * * 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`)
  42379. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42380. * * 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
  42381. * * 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)
  42382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42383. * * 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
  42384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42385. * @param name defines the name of the mesh
  42386. * @param options defines the options used to create the mesh
  42387. * @param scene defines the hosting scene
  42388. * @returns the sphere mesh
  42389. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42390. */
  42391. static CreateSphere(name: string, options: {
  42392. segments?: number;
  42393. diameter?: number;
  42394. diameterX?: number;
  42395. diameterY?: number;
  42396. diameterZ?: number;
  42397. arc?: number;
  42398. slice?: number;
  42399. sideOrientation?: number;
  42400. frontUVs?: Vector4;
  42401. backUVs?: Vector4;
  42402. updatable?: boolean;
  42403. }, scene: any): Mesh;
  42404. }
  42405. }
  42406. declare module BABYLON.Debug {
  42407. /**
  42408. * Used to show the physics impostor around the specific mesh
  42409. */
  42410. export class PhysicsViewer {
  42411. /** @hidden */
  42412. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42413. /** @hidden */
  42414. protected _meshes: Array<Nullable<AbstractMesh>>;
  42415. /** @hidden */
  42416. protected _scene: Nullable<Scene>;
  42417. /** @hidden */
  42418. protected _numMeshes: number;
  42419. /** @hidden */
  42420. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42421. private _renderFunction;
  42422. private _utilityLayer;
  42423. private _debugBoxMesh;
  42424. private _debugSphereMesh;
  42425. private _debugCylinderMesh;
  42426. private _debugMaterial;
  42427. private _debugMeshMeshes;
  42428. /**
  42429. * Creates a new PhysicsViewer
  42430. * @param scene defines the hosting scene
  42431. */
  42432. constructor(scene: Scene);
  42433. /** @hidden */
  42434. protected _updateDebugMeshes(): void;
  42435. /**
  42436. * Renders a specified physic impostor
  42437. * @param impostor defines the impostor to render
  42438. * @param targetMesh defines the mesh represented by the impostor
  42439. * @returns the new debug mesh used to render the impostor
  42440. */
  42441. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42442. /**
  42443. * Hides a specified physic impostor
  42444. * @param impostor defines the impostor to hide
  42445. */
  42446. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42447. private _getDebugMaterial;
  42448. private _getDebugBoxMesh;
  42449. private _getDebugSphereMesh;
  42450. private _getDebugCylinderMesh;
  42451. private _getDebugMeshMesh;
  42452. private _getDebugMesh;
  42453. /** Releases all resources */
  42454. dispose(): void;
  42455. }
  42456. }
  42457. declare module BABYLON {
  42458. /**
  42459. * Class containing static functions to help procedurally build meshes
  42460. */
  42461. export class LinesBuilder {
  42462. /**
  42463. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42464. * * 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
  42465. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42466. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42467. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42468. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42469. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42470. * * 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
  42471. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42474. * @param name defines the name of the new line system
  42475. * @param options defines the options used to create the line system
  42476. * @param scene defines the hosting scene
  42477. * @returns a new line system mesh
  42478. */
  42479. static CreateLineSystem(name: string, options: {
  42480. lines: Vector3[][];
  42481. updatable?: boolean;
  42482. instance?: Nullable<LinesMesh>;
  42483. colors?: Nullable<Color4[][]>;
  42484. useVertexAlpha?: boolean;
  42485. }, scene: Nullable<Scene>): LinesMesh;
  42486. /**
  42487. * Creates a line mesh
  42488. * 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
  42489. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42490. * * The parameter `points` is an array successive Vector3
  42491. * * 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
  42492. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42493. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42494. * * When updating an instance, remember that only point positions can change, not the number of points
  42495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42496. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42497. * @param name defines the name of the new line system
  42498. * @param options defines the options used to create the line system
  42499. * @param scene defines the hosting scene
  42500. * @returns a new line mesh
  42501. */
  42502. static CreateLines(name: string, options: {
  42503. points: Vector3[];
  42504. updatable?: boolean;
  42505. instance?: Nullable<LinesMesh>;
  42506. colors?: Color4[];
  42507. useVertexAlpha?: boolean;
  42508. }, scene?: Nullable<Scene>): LinesMesh;
  42509. /**
  42510. * Creates a dashed line mesh
  42511. * * 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
  42512. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42513. * * The parameter `points` is an array successive Vector3
  42514. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42515. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42516. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42517. * * 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
  42518. * * When updating an instance, remember that only point positions can change, not the number of points
  42519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42520. * @param name defines the name of the mesh
  42521. * @param options defines the options used to create the mesh
  42522. * @param scene defines the hosting scene
  42523. * @returns the dashed line mesh
  42524. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42525. */
  42526. static CreateDashedLines(name: string, options: {
  42527. points: Vector3[];
  42528. dashSize?: number;
  42529. gapSize?: number;
  42530. dashNb?: number;
  42531. updatable?: boolean;
  42532. instance?: LinesMesh;
  42533. }, scene?: Nullable<Scene>): LinesMesh;
  42534. }
  42535. }
  42536. declare module BABYLON {
  42537. /**
  42538. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42539. * in order to better appreciate the issue one might have.
  42540. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42541. */
  42542. export class RayHelper {
  42543. /**
  42544. * Defines the ray we are currently tryin to visualize.
  42545. */
  42546. ray: Nullable<Ray>;
  42547. private _renderPoints;
  42548. private _renderLine;
  42549. private _renderFunction;
  42550. private _scene;
  42551. private _updateToMeshFunction;
  42552. private _attachedToMesh;
  42553. private _meshSpaceDirection;
  42554. private _meshSpaceOrigin;
  42555. /**
  42556. * Helper function to create a colored helper in a scene in one line.
  42557. * @param ray Defines the ray we are currently tryin to visualize
  42558. * @param scene Defines the scene the ray is used in
  42559. * @param color Defines the color we want to see the ray in
  42560. * @returns The newly created ray helper.
  42561. */
  42562. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42563. /**
  42564. * Instantiate a new ray helper.
  42565. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42566. * in order to better appreciate the issue one might have.
  42567. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42568. * @param ray Defines the ray we are currently tryin to visualize
  42569. */
  42570. constructor(ray: Ray);
  42571. /**
  42572. * Shows the ray we are willing to debug.
  42573. * @param scene Defines the scene the ray needs to be rendered in
  42574. * @param color Defines the color the ray needs to be rendered in
  42575. */
  42576. show(scene: Scene, color?: Color3): void;
  42577. /**
  42578. * Hides the ray we are debugging.
  42579. */
  42580. hide(): void;
  42581. private _render;
  42582. /**
  42583. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42584. * @param mesh Defines the mesh we want the helper attached to
  42585. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42586. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42587. * @param length Defines the length of the ray
  42588. */
  42589. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42590. /**
  42591. * Detach the ray helper from the mesh it has previously been attached to.
  42592. */
  42593. detachFromMesh(): void;
  42594. private _updateToMesh;
  42595. /**
  42596. * Dispose the helper and release its associated resources.
  42597. */
  42598. dispose(): void;
  42599. }
  42600. }
  42601. declare module BABYLON.Debug {
  42602. /**
  42603. * Class used to render a debug view of a given skeleton
  42604. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42605. */
  42606. export class SkeletonViewer {
  42607. /** defines the skeleton to render */
  42608. skeleton: Skeleton;
  42609. /** defines the mesh attached to the skeleton */
  42610. mesh: AbstractMesh;
  42611. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42612. autoUpdateBonesMatrices: boolean;
  42613. /** defines the rendering group id to use with the viewer */
  42614. renderingGroupId: number;
  42615. /** Gets or sets the color used to render the skeleton */
  42616. color: Color3;
  42617. private _scene;
  42618. private _debugLines;
  42619. private _debugMesh;
  42620. private _isEnabled;
  42621. private _renderFunction;
  42622. private _utilityLayer;
  42623. /**
  42624. * Returns the mesh used to render the bones
  42625. */
  42626. readonly debugMesh: Nullable<LinesMesh>;
  42627. /**
  42628. * Creates a new SkeletonViewer
  42629. * @param skeleton defines the skeleton to render
  42630. * @param mesh defines the mesh attached to the skeleton
  42631. * @param scene defines the hosting scene
  42632. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42633. * @param renderingGroupId defines the rendering group id to use with the viewer
  42634. */
  42635. constructor(
  42636. /** defines the skeleton to render */
  42637. skeleton: Skeleton,
  42638. /** defines the mesh attached to the skeleton */
  42639. mesh: AbstractMesh, scene: Scene,
  42640. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42641. autoUpdateBonesMatrices?: boolean,
  42642. /** defines the rendering group id to use with the viewer */
  42643. renderingGroupId?: number);
  42644. /** Gets or sets a boolean indicating if the viewer is enabled */
  42645. isEnabled: boolean;
  42646. private _getBonePosition;
  42647. private _getLinesForBonesWithLength;
  42648. private _getLinesForBonesNoLength;
  42649. /** Update the viewer to sync with current skeleton state */
  42650. update(): void;
  42651. /** Release associated resources */
  42652. dispose(): void;
  42653. }
  42654. }
  42655. declare module BABYLON {
  42656. /**
  42657. * Options to create the null engine
  42658. */
  42659. export class NullEngineOptions {
  42660. /**
  42661. * Render width (Default: 512)
  42662. */
  42663. renderWidth: number;
  42664. /**
  42665. * Render height (Default: 256)
  42666. */
  42667. renderHeight: number;
  42668. /**
  42669. * Texture size (Default: 512)
  42670. */
  42671. textureSize: number;
  42672. /**
  42673. * If delta time between frames should be constant
  42674. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42675. */
  42676. deterministicLockstep: boolean;
  42677. /**
  42678. * Maximum about of steps between frames (Default: 4)
  42679. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42680. */
  42681. lockstepMaxSteps: number;
  42682. }
  42683. /**
  42684. * The null engine class provides support for headless version of babylon.js.
  42685. * This can be used in server side scenario or for testing purposes
  42686. */
  42687. export class NullEngine extends Engine {
  42688. private _options;
  42689. /**
  42690. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42691. */
  42692. isDeterministicLockStep(): boolean;
  42693. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42694. getLockstepMaxSteps(): number;
  42695. /**
  42696. * Sets hardware scaling, used to save performance if needed
  42697. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42698. */
  42699. getHardwareScalingLevel(): number;
  42700. constructor(options?: NullEngineOptions);
  42701. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42702. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42703. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42704. getRenderWidth(useScreen?: boolean): number;
  42705. getRenderHeight(useScreen?: boolean): number;
  42706. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42707. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42708. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42709. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42710. bindSamplers(effect: Effect): void;
  42711. enableEffect(effect: Effect): void;
  42712. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42713. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42714. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42715. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42716. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42717. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42718. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42719. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42720. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42721. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42722. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42723. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42724. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42725. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42726. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42727. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42728. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42729. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42730. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42731. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42732. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42733. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42734. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42735. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42736. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42737. bindBuffers(vertexBuffers: {
  42738. [key: string]: VertexBuffer;
  42739. }, indexBuffer: DataBuffer, effect: Effect): void;
  42740. wipeCaches(bruteForce?: boolean): void;
  42741. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42742. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42743. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42744. /** @hidden */
  42745. _createTexture(): WebGLTexture;
  42746. /** @hidden */
  42747. _releaseTexture(texture: InternalTexture): void;
  42748. 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;
  42749. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42750. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42751. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42752. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42753. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42754. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42755. areAllEffectsReady(): boolean;
  42756. /**
  42757. * @hidden
  42758. * Get the current error code of the webGL context
  42759. * @returns the error code
  42760. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42761. */
  42762. getError(): number;
  42763. /** @hidden */
  42764. _getUnpackAlignement(): number;
  42765. /** @hidden */
  42766. _unpackFlipY(value: boolean): void;
  42767. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42768. /**
  42769. * Updates a dynamic vertex buffer.
  42770. * @param vertexBuffer the vertex buffer to update
  42771. * @param data the data used to update the vertex buffer
  42772. * @param byteOffset the byte offset of the data (optional)
  42773. * @param byteLength the byte length of the data (optional)
  42774. */
  42775. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42776. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42777. /** @hidden */
  42778. _bindTexture(channel: number, texture: InternalTexture): void;
  42779. /** @hidden */
  42780. _releaseBuffer(buffer: DataBuffer): boolean;
  42781. releaseEffects(): void;
  42782. displayLoadingUI(): void;
  42783. hideLoadingUI(): void;
  42784. /** @hidden */
  42785. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42786. /** @hidden */
  42787. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42788. /** @hidden */
  42789. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42790. /** @hidden */
  42791. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42792. }
  42793. }
  42794. declare module BABYLON {
  42795. /** @hidden */
  42796. export class _OcclusionDataStorage {
  42797. /** @hidden */
  42798. occlusionInternalRetryCounter: number;
  42799. /** @hidden */
  42800. isOcclusionQueryInProgress: boolean;
  42801. /** @hidden */
  42802. isOccluded: boolean;
  42803. /** @hidden */
  42804. occlusionRetryCount: number;
  42805. /** @hidden */
  42806. occlusionType: number;
  42807. /** @hidden */
  42808. occlusionQueryAlgorithmType: number;
  42809. }
  42810. interface Engine {
  42811. /**
  42812. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42813. * @return the new query
  42814. */
  42815. createQuery(): WebGLQuery;
  42816. /**
  42817. * Delete and release a webGL query
  42818. * @param query defines the query to delete
  42819. * @return the current engine
  42820. */
  42821. deleteQuery(query: WebGLQuery): Engine;
  42822. /**
  42823. * Check if a given query has resolved and got its value
  42824. * @param query defines the query to check
  42825. * @returns true if the query got its value
  42826. */
  42827. isQueryResultAvailable(query: WebGLQuery): boolean;
  42828. /**
  42829. * Gets the value of a given query
  42830. * @param query defines the query to check
  42831. * @returns the value of the query
  42832. */
  42833. getQueryResult(query: WebGLQuery): number;
  42834. /**
  42835. * Initiates an occlusion query
  42836. * @param algorithmType defines the algorithm to use
  42837. * @param query defines the query to use
  42838. * @returns the current engine
  42839. * @see http://doc.babylonjs.com/features/occlusionquery
  42840. */
  42841. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42842. /**
  42843. * Ends an occlusion query
  42844. * @see http://doc.babylonjs.com/features/occlusionquery
  42845. * @param algorithmType defines the algorithm to use
  42846. * @returns the current engine
  42847. */
  42848. endOcclusionQuery(algorithmType: number): Engine;
  42849. /**
  42850. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42851. * Please note that only one query can be issued at a time
  42852. * @returns a time token used to track the time span
  42853. */
  42854. startTimeQuery(): Nullable<_TimeToken>;
  42855. /**
  42856. * Ends a time query
  42857. * @param token defines the token used to measure the time span
  42858. * @returns the time spent (in ns)
  42859. */
  42860. endTimeQuery(token: _TimeToken): int;
  42861. /** @hidden */
  42862. _currentNonTimestampToken: Nullable<_TimeToken>;
  42863. /** @hidden */
  42864. _createTimeQuery(): WebGLQuery;
  42865. /** @hidden */
  42866. _deleteTimeQuery(query: WebGLQuery): void;
  42867. /** @hidden */
  42868. _getGlAlgorithmType(algorithmType: number): number;
  42869. /** @hidden */
  42870. _getTimeQueryResult(query: WebGLQuery): any;
  42871. /** @hidden */
  42872. _getTimeQueryAvailability(query: WebGLQuery): any;
  42873. }
  42874. interface AbstractMesh {
  42875. /**
  42876. * Backing filed
  42877. * @hidden
  42878. */
  42879. __occlusionDataStorage: _OcclusionDataStorage;
  42880. /**
  42881. * Access property
  42882. * @hidden
  42883. */
  42884. _occlusionDataStorage: _OcclusionDataStorage;
  42885. /**
  42886. * 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.
  42887. * The default value is -1 which means don't break the query and wait till the result
  42888. * @see http://doc.babylonjs.com/features/occlusionquery
  42889. */
  42890. occlusionRetryCount: number;
  42891. /**
  42892. * 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:
  42893. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42894. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42895. * * 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.
  42896. * @see http://doc.babylonjs.com/features/occlusionquery
  42897. */
  42898. occlusionType: number;
  42899. /**
  42900. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42901. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42902. * * 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.
  42903. * @see http://doc.babylonjs.com/features/occlusionquery
  42904. */
  42905. occlusionQueryAlgorithmType: number;
  42906. /**
  42907. * 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
  42908. * @see http://doc.babylonjs.com/features/occlusionquery
  42909. */
  42910. isOccluded: boolean;
  42911. /**
  42912. * Flag to check the progress status of the query
  42913. * @see http://doc.babylonjs.com/features/occlusionquery
  42914. */
  42915. isOcclusionQueryInProgress: boolean;
  42916. }
  42917. }
  42918. declare module BABYLON {
  42919. /** @hidden */
  42920. export var _forceTransformFeedbackToBundle: boolean;
  42921. interface Engine {
  42922. /**
  42923. * Creates a webGL transform feedback object
  42924. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42925. * @returns the webGL transform feedback object
  42926. */
  42927. createTransformFeedback(): WebGLTransformFeedback;
  42928. /**
  42929. * Delete a webGL transform feedback object
  42930. * @param value defines the webGL transform feedback object to delete
  42931. */
  42932. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42933. /**
  42934. * Bind a webGL transform feedback object to the webgl context
  42935. * @param value defines the webGL transform feedback object to bind
  42936. */
  42937. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42938. /**
  42939. * Begins a transform feedback operation
  42940. * @param usePoints defines if points or triangles must be used
  42941. */
  42942. beginTransformFeedback(usePoints: boolean): void;
  42943. /**
  42944. * Ends a transform feedback operation
  42945. */
  42946. endTransformFeedback(): void;
  42947. /**
  42948. * Specify the varyings to use with transform feedback
  42949. * @param program defines the associated webGL program
  42950. * @param value defines the list of strings representing the varying names
  42951. */
  42952. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42953. /**
  42954. * Bind a webGL buffer for a transform feedback operation
  42955. * @param value defines the webGL buffer to bind
  42956. */
  42957. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42958. }
  42959. }
  42960. declare module BABYLON {
  42961. /**
  42962. * Creation options of the multi render target texture.
  42963. */
  42964. export interface IMultiRenderTargetOptions {
  42965. /**
  42966. * Define if the texture needs to create mip maps after render.
  42967. */
  42968. generateMipMaps?: boolean;
  42969. /**
  42970. * Define the types of all the draw buffers we want to create
  42971. */
  42972. types?: number[];
  42973. /**
  42974. * Define the sampling modes of all the draw buffers we want to create
  42975. */
  42976. samplingModes?: number[];
  42977. /**
  42978. * Define if a depth buffer is required
  42979. */
  42980. generateDepthBuffer?: boolean;
  42981. /**
  42982. * Define if a stencil buffer is required
  42983. */
  42984. generateStencilBuffer?: boolean;
  42985. /**
  42986. * Define if a depth texture is required instead of a depth buffer
  42987. */
  42988. generateDepthTexture?: boolean;
  42989. /**
  42990. * Define the number of desired draw buffers
  42991. */
  42992. textureCount?: number;
  42993. /**
  42994. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42995. */
  42996. doNotChangeAspectRatio?: boolean;
  42997. /**
  42998. * Define the default type of the buffers we are creating
  42999. */
  43000. defaultType?: number;
  43001. }
  43002. /**
  43003. * A multi render target, like a render target provides the ability to render to a texture.
  43004. * Unlike the render target, it can render to several draw buffers in one draw.
  43005. * This is specially interesting in deferred rendering or for any effects requiring more than
  43006. * just one color from a single pass.
  43007. */
  43008. export class MultiRenderTarget extends RenderTargetTexture {
  43009. private _internalTextures;
  43010. private _textures;
  43011. private _multiRenderTargetOptions;
  43012. /**
  43013. * Get if draw buffers are currently supported by the used hardware and browser.
  43014. */
  43015. readonly isSupported: boolean;
  43016. /**
  43017. * Get the list of textures generated by the multi render target.
  43018. */
  43019. readonly textures: Texture[];
  43020. /**
  43021. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43022. */
  43023. readonly depthTexture: Texture;
  43024. /**
  43025. * Set the wrapping mode on U of all the textures we are rendering to.
  43026. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43027. */
  43028. wrapU: number;
  43029. /**
  43030. * Set the wrapping mode on V of all the textures we are rendering to.
  43031. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43032. */
  43033. wrapV: number;
  43034. /**
  43035. * Instantiate a new multi render target texture.
  43036. * A multi render target, like a render target provides the ability to render to a texture.
  43037. * Unlike the render target, it can render to several draw buffers in one draw.
  43038. * This is specially interesting in deferred rendering or for any effects requiring more than
  43039. * just one color from a single pass.
  43040. * @param name Define the name of the texture
  43041. * @param size Define the size of the buffers to render to
  43042. * @param count Define the number of target we are rendering into
  43043. * @param scene Define the scene the texture belongs to
  43044. * @param options Define the options used to create the multi render target
  43045. */
  43046. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43047. /** @hidden */
  43048. _rebuild(): void;
  43049. private _createInternalTextures;
  43050. private _createTextures;
  43051. /**
  43052. * Define the number of samples used if MSAA is enabled.
  43053. */
  43054. samples: number;
  43055. /**
  43056. * Resize all the textures in the multi render target.
  43057. * Be carrefull as it will recreate all the data in the new texture.
  43058. * @param size Define the new size
  43059. */
  43060. resize(size: any): void;
  43061. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43062. /**
  43063. * Dispose the render targets and their associated resources
  43064. */
  43065. dispose(): void;
  43066. /**
  43067. * Release all the underlying texture used as draw buffers.
  43068. */
  43069. releaseInternalTextures(): void;
  43070. }
  43071. }
  43072. declare module BABYLON {
  43073. interface Engine {
  43074. /**
  43075. * Unbind a list of render target textures from the webGL context
  43076. * This is used only when drawBuffer extension or webGL2 are active
  43077. * @param textures defines the render target textures to unbind
  43078. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43079. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43080. */
  43081. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43082. /**
  43083. * Create a multi render target texture
  43084. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43085. * @param size defines the size of the texture
  43086. * @param options defines the creation options
  43087. * @returns the cube texture as an InternalTexture
  43088. */
  43089. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43090. /**
  43091. * Update the sample count for a given multiple render target texture
  43092. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43093. * @param textures defines the textures to update
  43094. * @param samples defines the sample count to set
  43095. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43096. */
  43097. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43098. }
  43099. }
  43100. declare module BABYLON {
  43101. /**
  43102. * Gather the list of clipboard event types as constants.
  43103. */
  43104. export class ClipboardEventTypes {
  43105. /**
  43106. * The clipboard event is fired when a copy command is active (pressed).
  43107. */
  43108. static readonly COPY: number;
  43109. /**
  43110. * The clipboard event is fired when a cut command is active (pressed).
  43111. */
  43112. static readonly CUT: number;
  43113. /**
  43114. * The clipboard event is fired when a paste command is active (pressed).
  43115. */
  43116. static readonly PASTE: number;
  43117. }
  43118. /**
  43119. * This class is used to store clipboard related info for the onClipboardObservable event.
  43120. */
  43121. export class ClipboardInfo {
  43122. /**
  43123. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43124. */
  43125. type: number;
  43126. /**
  43127. * Defines the related dom event
  43128. */
  43129. event: ClipboardEvent;
  43130. /**
  43131. *Creates an instance of ClipboardInfo.
  43132. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43133. * @param event Defines the related dom event
  43134. */
  43135. constructor(
  43136. /**
  43137. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43138. */
  43139. type: number,
  43140. /**
  43141. * Defines the related dom event
  43142. */
  43143. event: ClipboardEvent);
  43144. /**
  43145. * Get the clipboard event's type from the keycode.
  43146. * @param keyCode Defines the keyCode for the current keyboard event.
  43147. * @return {number}
  43148. */
  43149. static GetTypeFromCharacter(keyCode: number): number;
  43150. }
  43151. }
  43152. declare module BABYLON {
  43153. /**
  43154. * Google Daydream controller
  43155. */
  43156. export class DaydreamController extends WebVRController {
  43157. /**
  43158. * Base Url for the controller model.
  43159. */
  43160. static MODEL_BASE_URL: string;
  43161. /**
  43162. * File name for the controller model.
  43163. */
  43164. static MODEL_FILENAME: string;
  43165. /**
  43166. * Gamepad Id prefix used to identify Daydream Controller.
  43167. */
  43168. static readonly GAMEPAD_ID_PREFIX: string;
  43169. /**
  43170. * Creates a new DaydreamController from a gamepad
  43171. * @param vrGamepad the gamepad that the controller should be created from
  43172. */
  43173. constructor(vrGamepad: any);
  43174. /**
  43175. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43176. * @param scene scene in which to add meshes
  43177. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43178. */
  43179. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43180. /**
  43181. * Called once for each button that changed state since the last frame
  43182. * @param buttonIdx Which button index changed
  43183. * @param state New state of the button
  43184. * @param changes Which properties on the state changed since last frame
  43185. */
  43186. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43187. }
  43188. }
  43189. declare module BABYLON {
  43190. /**
  43191. * Gear VR Controller
  43192. */
  43193. export class GearVRController extends WebVRController {
  43194. /**
  43195. * Base Url for the controller model.
  43196. */
  43197. static MODEL_BASE_URL: string;
  43198. /**
  43199. * File name for the controller model.
  43200. */
  43201. static MODEL_FILENAME: string;
  43202. /**
  43203. * Gamepad Id prefix used to identify this controller.
  43204. */
  43205. static readonly GAMEPAD_ID_PREFIX: string;
  43206. private readonly _buttonIndexToObservableNameMap;
  43207. /**
  43208. * Creates a new GearVRController from a gamepad
  43209. * @param vrGamepad the gamepad that the controller should be created from
  43210. */
  43211. constructor(vrGamepad: any);
  43212. /**
  43213. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43214. * @param scene scene in which to add meshes
  43215. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43216. */
  43217. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43218. /**
  43219. * Called once for each button that changed state since the last frame
  43220. * @param buttonIdx Which button index changed
  43221. * @param state New state of the button
  43222. * @param changes Which properties on the state changed since last frame
  43223. */
  43224. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43225. }
  43226. }
  43227. declare module BABYLON {
  43228. /**
  43229. * Vive Controller
  43230. */
  43231. export class ViveController extends WebVRController {
  43232. /**
  43233. * Base Url for the controller model.
  43234. */
  43235. static MODEL_BASE_URL: string;
  43236. /**
  43237. * File name for the controller model.
  43238. */
  43239. static MODEL_FILENAME: string;
  43240. /**
  43241. * Creates a new ViveController from a gamepad
  43242. * @param vrGamepad the gamepad that the controller should be created from
  43243. */
  43244. constructor(vrGamepad: any);
  43245. /**
  43246. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43247. * @param scene scene in which to add meshes
  43248. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43249. */
  43250. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43251. /**
  43252. * Fired when the left button on this controller is modified
  43253. */
  43254. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43255. /**
  43256. * Fired when the right button on this controller is modified
  43257. */
  43258. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43259. /**
  43260. * Fired when the menu button on this controller is modified
  43261. */
  43262. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43263. /**
  43264. * Called once for each button that changed state since the last frame
  43265. * Vive mapping:
  43266. * 0: touchpad
  43267. * 1: trigger
  43268. * 2: left AND right buttons
  43269. * 3: menu button
  43270. * @param buttonIdx Which button index changed
  43271. * @param state New state of the button
  43272. * @param changes Which properties on the state changed since last frame
  43273. */
  43274. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43275. }
  43276. }
  43277. declare module BABYLON {
  43278. /**
  43279. * Class containing static functions to help procedurally build meshes
  43280. */
  43281. export class PolyhedronBuilder {
  43282. /**
  43283. * Creates a polyhedron mesh
  43284. * * 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
  43285. * * The parameter `size` (positive float, default 1) sets the polygon size
  43286. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43287. * * 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`
  43288. * * 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
  43289. * * 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)`)
  43290. * * 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
  43291. * * 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
  43292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43293. * * 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
  43294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43295. * @param name defines the name of the mesh
  43296. * @param options defines the options used to create the mesh
  43297. * @param scene defines the hosting scene
  43298. * @returns the polyhedron mesh
  43299. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43300. */
  43301. static CreatePolyhedron(name: string, options: {
  43302. type?: number;
  43303. size?: number;
  43304. sizeX?: number;
  43305. sizeY?: number;
  43306. sizeZ?: number;
  43307. custom?: any;
  43308. faceUV?: Vector4[];
  43309. faceColors?: Color4[];
  43310. flat?: boolean;
  43311. updatable?: boolean;
  43312. sideOrientation?: number;
  43313. frontUVs?: Vector4;
  43314. backUVs?: Vector4;
  43315. }, scene?: Nullable<Scene>): Mesh;
  43316. }
  43317. }
  43318. declare module BABYLON {
  43319. /**
  43320. * Gizmo that enables scaling a mesh along 3 axis
  43321. */
  43322. export class ScaleGizmo extends Gizmo {
  43323. /**
  43324. * Internal gizmo used for interactions on the x axis
  43325. */
  43326. xGizmo: AxisScaleGizmo;
  43327. /**
  43328. * Internal gizmo used for interactions on the y axis
  43329. */
  43330. yGizmo: AxisScaleGizmo;
  43331. /**
  43332. * Internal gizmo used for interactions on the z axis
  43333. */
  43334. zGizmo: AxisScaleGizmo;
  43335. /**
  43336. * Internal gizmo used to scale all axis equally
  43337. */
  43338. uniformScaleGizmo: AxisScaleGizmo;
  43339. private _meshAttached;
  43340. private _updateGizmoRotationToMatchAttachedMesh;
  43341. private _snapDistance;
  43342. private _scaleRatio;
  43343. private _uniformScalingMesh;
  43344. private _octahedron;
  43345. /** Fires an event when any of it's sub gizmos are dragged */
  43346. onDragStartObservable: Observable<unknown>;
  43347. /** Fires an event when any of it's sub gizmos are released from dragging */
  43348. onDragEndObservable: Observable<unknown>;
  43349. attachedMesh: Nullable<AbstractMesh>;
  43350. /**
  43351. * Creates a ScaleGizmo
  43352. * @param gizmoLayer The utility layer the gizmo will be added to
  43353. */
  43354. constructor(gizmoLayer?: UtilityLayerRenderer);
  43355. updateGizmoRotationToMatchAttachedMesh: boolean;
  43356. /**
  43357. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43358. */
  43359. snapDistance: number;
  43360. /**
  43361. * Ratio for the scale of the gizmo (Default: 1)
  43362. */
  43363. scaleRatio: number;
  43364. /**
  43365. * Disposes of the gizmo
  43366. */
  43367. dispose(): void;
  43368. }
  43369. }
  43370. declare module BABYLON {
  43371. /**
  43372. * Single axis scale gizmo
  43373. */
  43374. export class AxisScaleGizmo extends Gizmo {
  43375. /**
  43376. * Drag behavior responsible for the gizmos dragging interactions
  43377. */
  43378. dragBehavior: PointerDragBehavior;
  43379. private _pointerObserver;
  43380. /**
  43381. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43382. */
  43383. snapDistance: number;
  43384. /**
  43385. * Event that fires each time the gizmo snaps to a new location.
  43386. * * snapDistance is the the change in distance
  43387. */
  43388. onSnapObservable: Observable<{
  43389. snapDistance: number;
  43390. }>;
  43391. /**
  43392. * If the scaling operation should be done on all axis (default: false)
  43393. */
  43394. uniformScaling: boolean;
  43395. private _isEnabled;
  43396. private _parent;
  43397. private _arrow;
  43398. private _coloredMaterial;
  43399. private _hoverMaterial;
  43400. /**
  43401. * Creates an AxisScaleGizmo
  43402. * @param gizmoLayer The utility layer the gizmo will be added to
  43403. * @param dragAxis The axis which the gizmo will be able to scale on
  43404. * @param color The color of the gizmo
  43405. */
  43406. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43407. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43408. /**
  43409. * If the gizmo is enabled
  43410. */
  43411. isEnabled: boolean;
  43412. /**
  43413. * Disposes of the gizmo
  43414. */
  43415. dispose(): void;
  43416. /**
  43417. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43418. * @param mesh The mesh to replace the default mesh of the gizmo
  43419. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43420. */
  43421. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43422. }
  43423. }
  43424. declare module BABYLON {
  43425. /**
  43426. * Bounding box gizmo
  43427. */
  43428. export class BoundingBoxGizmo extends Gizmo {
  43429. private _lineBoundingBox;
  43430. private _rotateSpheresParent;
  43431. private _scaleBoxesParent;
  43432. private _boundingDimensions;
  43433. private _renderObserver;
  43434. private _pointerObserver;
  43435. private _scaleDragSpeed;
  43436. private _tmpQuaternion;
  43437. private _tmpVector;
  43438. private _tmpRotationMatrix;
  43439. /**
  43440. * 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)
  43441. */
  43442. ignoreChildren: boolean;
  43443. /**
  43444. * 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)
  43445. */
  43446. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43447. /**
  43448. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43449. */
  43450. rotationSphereSize: number;
  43451. /**
  43452. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43453. */
  43454. scaleBoxSize: number;
  43455. /**
  43456. * 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)
  43457. */
  43458. fixedDragMeshScreenSize: boolean;
  43459. /**
  43460. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43461. */
  43462. fixedDragMeshScreenSizeDistanceFactor: number;
  43463. /**
  43464. * Fired when a rotation sphere or scale box is dragged
  43465. */
  43466. onDragStartObservable: Observable<{}>;
  43467. /**
  43468. * Fired when a scale box is dragged
  43469. */
  43470. onScaleBoxDragObservable: Observable<{}>;
  43471. /**
  43472. * Fired when a scale box drag is ended
  43473. */
  43474. onScaleBoxDragEndObservable: Observable<{}>;
  43475. /**
  43476. * Fired when a rotation sphere is dragged
  43477. */
  43478. onRotationSphereDragObservable: Observable<{}>;
  43479. /**
  43480. * Fired when a rotation sphere drag is ended
  43481. */
  43482. onRotationSphereDragEndObservable: Observable<{}>;
  43483. /**
  43484. * 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)
  43485. */
  43486. scalePivot: Nullable<Vector3>;
  43487. /**
  43488. * Mesh used as a pivot to rotate the attached mesh
  43489. */
  43490. private _anchorMesh;
  43491. private _existingMeshScale;
  43492. private _dragMesh;
  43493. private pointerDragBehavior;
  43494. private coloredMaterial;
  43495. private hoverColoredMaterial;
  43496. /**
  43497. * Sets the color of the bounding box gizmo
  43498. * @param color the color to set
  43499. */
  43500. setColor(color: Color3): void;
  43501. /**
  43502. * Creates an BoundingBoxGizmo
  43503. * @param gizmoLayer The utility layer the gizmo will be added to
  43504. * @param color The color of the gizmo
  43505. */
  43506. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43507. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43508. private _selectNode;
  43509. /**
  43510. * Updates the bounding box information for the Gizmo
  43511. */
  43512. updateBoundingBox(): void;
  43513. private _updateRotationSpheres;
  43514. private _updateScaleBoxes;
  43515. /**
  43516. * Enables rotation on the specified axis and disables rotation on the others
  43517. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43518. */
  43519. setEnabledRotationAxis(axis: string): void;
  43520. /**
  43521. * Enables/disables scaling
  43522. * @param enable if scaling should be enabled
  43523. */
  43524. setEnabledScaling(enable: boolean): void;
  43525. private _updateDummy;
  43526. /**
  43527. * Enables a pointer drag behavior on the bounding box of the gizmo
  43528. */
  43529. enableDragBehavior(): void;
  43530. /**
  43531. * Disposes of the gizmo
  43532. */
  43533. dispose(): void;
  43534. /**
  43535. * 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)
  43536. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43537. * @returns the bounding box mesh with the passed in mesh as a child
  43538. */
  43539. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43540. /**
  43541. * CustomMeshes are not supported by this gizmo
  43542. * @param mesh The mesh to replace the default mesh of the gizmo
  43543. */
  43544. setCustomMesh(mesh: Mesh): void;
  43545. }
  43546. }
  43547. declare module BABYLON {
  43548. /**
  43549. * Single plane rotation gizmo
  43550. */
  43551. export class PlaneRotationGizmo extends Gizmo {
  43552. /**
  43553. * Drag behavior responsible for the gizmos dragging interactions
  43554. */
  43555. dragBehavior: PointerDragBehavior;
  43556. private _pointerObserver;
  43557. /**
  43558. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43559. */
  43560. snapDistance: number;
  43561. /**
  43562. * Event that fires each time the gizmo snaps to a new location.
  43563. * * snapDistance is the the change in distance
  43564. */
  43565. onSnapObservable: Observable<{
  43566. snapDistance: number;
  43567. }>;
  43568. private _isEnabled;
  43569. private _parent;
  43570. /**
  43571. * Creates a PlaneRotationGizmo
  43572. * @param gizmoLayer The utility layer the gizmo will be added to
  43573. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43574. * @param color The color of the gizmo
  43575. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43576. */
  43577. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43578. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43579. /**
  43580. * If the gizmo is enabled
  43581. */
  43582. isEnabled: boolean;
  43583. /**
  43584. * Disposes of the gizmo
  43585. */
  43586. dispose(): void;
  43587. }
  43588. }
  43589. declare module BABYLON {
  43590. /**
  43591. * Gizmo that enables rotating a mesh along 3 axis
  43592. */
  43593. export class RotationGizmo extends Gizmo {
  43594. /**
  43595. * Internal gizmo used for interactions on the x axis
  43596. */
  43597. xGizmo: PlaneRotationGizmo;
  43598. /**
  43599. * Internal gizmo used for interactions on the y axis
  43600. */
  43601. yGizmo: PlaneRotationGizmo;
  43602. /**
  43603. * Internal gizmo used for interactions on the z axis
  43604. */
  43605. zGizmo: PlaneRotationGizmo;
  43606. /** Fires an event when any of it's sub gizmos are dragged */
  43607. onDragStartObservable: Observable<unknown>;
  43608. /** Fires an event when any of it's sub gizmos are released from dragging */
  43609. onDragEndObservable: Observable<unknown>;
  43610. private _meshAttached;
  43611. attachedMesh: Nullable<AbstractMesh>;
  43612. /**
  43613. * Creates a RotationGizmo
  43614. * @param gizmoLayer The utility layer the gizmo will be added to
  43615. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43616. */
  43617. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43618. updateGizmoRotationToMatchAttachedMesh: boolean;
  43619. /**
  43620. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43621. */
  43622. snapDistance: number;
  43623. /**
  43624. * Ratio for the scale of the gizmo (Default: 1)
  43625. */
  43626. scaleRatio: number;
  43627. /**
  43628. * Disposes of the gizmo
  43629. */
  43630. dispose(): void;
  43631. /**
  43632. * CustomMeshes are not supported by this gizmo
  43633. * @param mesh The mesh to replace the default mesh of the gizmo
  43634. */
  43635. setCustomMesh(mesh: Mesh): void;
  43636. }
  43637. }
  43638. declare module BABYLON {
  43639. /**
  43640. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43641. */
  43642. export class GizmoManager implements IDisposable {
  43643. private scene;
  43644. /**
  43645. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43646. */
  43647. gizmos: {
  43648. positionGizmo: Nullable<PositionGizmo>;
  43649. rotationGizmo: Nullable<RotationGizmo>;
  43650. scaleGizmo: Nullable<ScaleGizmo>;
  43651. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43652. };
  43653. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43654. clearGizmoOnEmptyPointerEvent: boolean;
  43655. /** Fires an event when the manager is attached to a mesh */
  43656. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43657. private _gizmosEnabled;
  43658. private _pointerObserver;
  43659. private _attachedMesh;
  43660. private _boundingBoxColor;
  43661. private _defaultUtilityLayer;
  43662. private _defaultKeepDepthUtilityLayer;
  43663. /**
  43664. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43665. */
  43666. boundingBoxDragBehavior: SixDofDragBehavior;
  43667. /**
  43668. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43669. */
  43670. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43671. /**
  43672. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43673. */
  43674. usePointerToAttachGizmos: boolean;
  43675. /**
  43676. * Utility layer that the bounding box gizmo belongs to
  43677. */
  43678. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43679. /**
  43680. * Utility layer that all gizmos besides bounding box belong to
  43681. */
  43682. readonly utilityLayer: UtilityLayerRenderer;
  43683. /**
  43684. * Instatiates a gizmo manager
  43685. * @param scene the scene to overlay the gizmos on top of
  43686. */
  43687. constructor(scene: Scene);
  43688. /**
  43689. * Attaches a set of gizmos to the specified mesh
  43690. * @param mesh The mesh the gizmo's should be attached to
  43691. */
  43692. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43693. /**
  43694. * If the position gizmo is enabled
  43695. */
  43696. positionGizmoEnabled: boolean;
  43697. /**
  43698. * If the rotation gizmo is enabled
  43699. */
  43700. rotationGizmoEnabled: boolean;
  43701. /**
  43702. * If the scale gizmo is enabled
  43703. */
  43704. scaleGizmoEnabled: boolean;
  43705. /**
  43706. * If the boundingBox gizmo is enabled
  43707. */
  43708. boundingBoxGizmoEnabled: boolean;
  43709. /**
  43710. * Disposes of the gizmo manager
  43711. */
  43712. dispose(): void;
  43713. }
  43714. }
  43715. declare module BABYLON {
  43716. /**
  43717. * A directional light is defined by a direction (what a surprise!).
  43718. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43719. * 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.
  43720. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43721. */
  43722. export class DirectionalLight extends ShadowLight {
  43723. private _shadowFrustumSize;
  43724. /**
  43725. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43726. */
  43727. /**
  43728. * Specifies a fix frustum size for the shadow generation.
  43729. */
  43730. shadowFrustumSize: number;
  43731. private _shadowOrthoScale;
  43732. /**
  43733. * Gets the shadow projection scale against the optimal computed one.
  43734. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43735. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43736. */
  43737. /**
  43738. * Sets the shadow projection scale against the optimal computed one.
  43739. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43740. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43741. */
  43742. shadowOrthoScale: number;
  43743. /**
  43744. * Automatically compute the projection matrix to best fit (including all the casters)
  43745. * on each frame.
  43746. */
  43747. autoUpdateExtends: boolean;
  43748. private _orthoLeft;
  43749. private _orthoRight;
  43750. private _orthoTop;
  43751. private _orthoBottom;
  43752. /**
  43753. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43754. * The directional light is emitted from everywhere in the given direction.
  43755. * It can cast shadows.
  43756. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43757. * @param name The friendly name of the light
  43758. * @param direction The direction of the light
  43759. * @param scene The scene the light belongs to
  43760. */
  43761. constructor(name: string, direction: Vector3, scene: Scene);
  43762. /**
  43763. * Returns the string "DirectionalLight".
  43764. * @return The class name
  43765. */
  43766. getClassName(): string;
  43767. /**
  43768. * Returns the integer 1.
  43769. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43770. */
  43771. getTypeID(): number;
  43772. /**
  43773. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43774. * Returns the DirectionalLight Shadow projection matrix.
  43775. */
  43776. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43777. /**
  43778. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43779. * Returns the DirectionalLight Shadow projection matrix.
  43780. */
  43781. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43782. /**
  43783. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43784. * Returns the DirectionalLight Shadow projection matrix.
  43785. */
  43786. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43787. protected _buildUniformLayout(): void;
  43788. /**
  43789. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43790. * @param effect The effect to update
  43791. * @param lightIndex The index of the light in the effect to update
  43792. * @returns The directional light
  43793. */
  43794. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43795. /**
  43796. * Gets the minZ used for shadow according to both the scene and the light.
  43797. *
  43798. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43799. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43800. * @param activeCamera The camera we are returning the min for
  43801. * @returns the depth min z
  43802. */
  43803. getDepthMinZ(activeCamera: Camera): number;
  43804. /**
  43805. * Gets the maxZ used for shadow according to both the scene and the light.
  43806. *
  43807. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43808. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43809. * @param activeCamera The camera we are returning the max for
  43810. * @returns the depth max z
  43811. */
  43812. getDepthMaxZ(activeCamera: Camera): number;
  43813. /**
  43814. * Prepares the list of defines specific to the light type.
  43815. * @param defines the list of defines
  43816. * @param lightIndex defines the index of the light for the effect
  43817. */
  43818. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43819. }
  43820. }
  43821. declare module BABYLON {
  43822. /**
  43823. * Class containing static functions to help procedurally build meshes
  43824. */
  43825. export class HemisphereBuilder {
  43826. /**
  43827. * Creates a hemisphere mesh
  43828. * @param name defines the name of the mesh
  43829. * @param options defines the options used to create the mesh
  43830. * @param scene defines the hosting scene
  43831. * @returns the hemisphere mesh
  43832. */
  43833. static CreateHemisphere(name: string, options: {
  43834. segments?: number;
  43835. diameter?: number;
  43836. sideOrientation?: number;
  43837. }, scene: any): Mesh;
  43838. }
  43839. }
  43840. declare module BABYLON {
  43841. /**
  43842. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43843. * These values define a cone of light starting from the position, emitting toward the direction.
  43844. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43845. * and the exponent defines the speed of the decay of the light with distance (reach).
  43846. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43847. */
  43848. export class SpotLight extends ShadowLight {
  43849. private _angle;
  43850. private _innerAngle;
  43851. private _cosHalfAngle;
  43852. private _lightAngleScale;
  43853. private _lightAngleOffset;
  43854. /**
  43855. * Gets the cone angle of the spot light in Radians.
  43856. */
  43857. /**
  43858. * Sets the cone angle of the spot light in Radians.
  43859. */
  43860. angle: number;
  43861. /**
  43862. * Only used in gltf falloff mode, this defines the angle where
  43863. * the directional falloff will start before cutting at angle which could be seen
  43864. * as outer angle.
  43865. */
  43866. /**
  43867. * Only used in gltf falloff mode, this defines the angle where
  43868. * the directional falloff will start before cutting at angle which could be seen
  43869. * as outer angle.
  43870. */
  43871. innerAngle: number;
  43872. private _shadowAngleScale;
  43873. /**
  43874. * Allows scaling the angle of the light for shadow generation only.
  43875. */
  43876. /**
  43877. * Allows scaling the angle of the light for shadow generation only.
  43878. */
  43879. shadowAngleScale: number;
  43880. /**
  43881. * The light decay speed with the distance from the emission spot.
  43882. */
  43883. exponent: number;
  43884. private _projectionTextureMatrix;
  43885. /**
  43886. * Allows reading the projecton texture
  43887. */
  43888. readonly projectionTextureMatrix: Matrix;
  43889. protected _projectionTextureLightNear: number;
  43890. /**
  43891. * Gets the near clip of the Spotlight for texture projection.
  43892. */
  43893. /**
  43894. * Sets the near clip of the Spotlight for texture projection.
  43895. */
  43896. projectionTextureLightNear: number;
  43897. protected _projectionTextureLightFar: number;
  43898. /**
  43899. * Gets the far clip of the Spotlight for texture projection.
  43900. */
  43901. /**
  43902. * Sets the far clip of the Spotlight for texture projection.
  43903. */
  43904. projectionTextureLightFar: number;
  43905. protected _projectionTextureUpDirection: Vector3;
  43906. /**
  43907. * Gets the Up vector of the Spotlight for texture projection.
  43908. */
  43909. /**
  43910. * Sets the Up vector of the Spotlight for texture projection.
  43911. */
  43912. projectionTextureUpDirection: Vector3;
  43913. private _projectionTexture;
  43914. /**
  43915. * Gets the projection texture of the light.
  43916. */
  43917. /**
  43918. * Sets the projection texture of the light.
  43919. */
  43920. projectionTexture: Nullable<BaseTexture>;
  43921. private _projectionTextureViewLightDirty;
  43922. private _projectionTextureProjectionLightDirty;
  43923. private _projectionTextureDirty;
  43924. private _projectionTextureViewTargetVector;
  43925. private _projectionTextureViewLightMatrix;
  43926. private _projectionTextureProjectionLightMatrix;
  43927. private _projectionTextureScalingMatrix;
  43928. /**
  43929. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43930. * It can cast shadows.
  43931. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43932. * @param name The light friendly name
  43933. * @param position The position of the spot light in the scene
  43934. * @param direction The direction of the light in the scene
  43935. * @param angle The cone angle of the light in Radians
  43936. * @param exponent The light decay speed with the distance from the emission spot
  43937. * @param scene The scene the lights belongs to
  43938. */
  43939. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43940. /**
  43941. * Returns the string "SpotLight".
  43942. * @returns the class name
  43943. */
  43944. getClassName(): string;
  43945. /**
  43946. * Returns the integer 2.
  43947. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43948. */
  43949. getTypeID(): number;
  43950. /**
  43951. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43952. */
  43953. protected _setDirection(value: Vector3): void;
  43954. /**
  43955. * Overrides the position setter to recompute the projection texture view light Matrix.
  43956. */
  43957. protected _setPosition(value: Vector3): void;
  43958. /**
  43959. * 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.
  43960. * Returns the SpotLight.
  43961. */
  43962. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43963. protected _computeProjectionTextureViewLightMatrix(): void;
  43964. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43965. /**
  43966. * Main function for light texture projection matrix computing.
  43967. */
  43968. protected _computeProjectionTextureMatrix(): void;
  43969. protected _buildUniformLayout(): void;
  43970. private _computeAngleValues;
  43971. /**
  43972. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43973. * @param effect The effect to update
  43974. * @param lightIndex The index of the light in the effect to update
  43975. * @returns The spot light
  43976. */
  43977. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43978. /**
  43979. * Disposes the light and the associated resources.
  43980. */
  43981. dispose(): void;
  43982. /**
  43983. * Prepares the list of defines specific to the light type.
  43984. * @param defines the list of defines
  43985. * @param lightIndex defines the index of the light for the effect
  43986. */
  43987. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43988. }
  43989. }
  43990. declare module BABYLON {
  43991. /**
  43992. * Gizmo that enables viewing a light
  43993. */
  43994. export class LightGizmo extends Gizmo {
  43995. private _lightMesh;
  43996. private _material;
  43997. private cachedPosition;
  43998. private cachedForward;
  43999. /**
  44000. * Creates a LightGizmo
  44001. * @param gizmoLayer The utility layer the gizmo will be added to
  44002. */
  44003. constructor(gizmoLayer?: UtilityLayerRenderer);
  44004. private _light;
  44005. /**
  44006. * The light that the gizmo is attached to
  44007. */
  44008. light: Nullable<Light>;
  44009. /**
  44010. * @hidden
  44011. * Updates the gizmo to match the attached mesh's position/rotation
  44012. */
  44013. protected _update(): void;
  44014. private static _Scale;
  44015. /**
  44016. * Creates the lines for a light mesh
  44017. */
  44018. private static _createLightLines;
  44019. /**
  44020. * Disposes of the light gizmo
  44021. */
  44022. dispose(): void;
  44023. private static _CreateHemisphericLightMesh;
  44024. private static _CreatePointLightMesh;
  44025. private static _CreateSpotLightMesh;
  44026. private static _CreateDirectionalLightMesh;
  44027. }
  44028. }
  44029. declare module BABYLON {
  44030. /** @hidden */
  44031. export var backgroundFragmentDeclaration: {
  44032. name: string;
  44033. shader: string;
  44034. };
  44035. }
  44036. declare module BABYLON {
  44037. /** @hidden */
  44038. export var backgroundUboDeclaration: {
  44039. name: string;
  44040. shader: string;
  44041. };
  44042. }
  44043. declare module BABYLON {
  44044. /** @hidden */
  44045. export var backgroundPixelShader: {
  44046. name: string;
  44047. shader: string;
  44048. };
  44049. }
  44050. declare module BABYLON {
  44051. /** @hidden */
  44052. export var backgroundVertexDeclaration: {
  44053. name: string;
  44054. shader: string;
  44055. };
  44056. }
  44057. declare module BABYLON {
  44058. /** @hidden */
  44059. export var backgroundVertexShader: {
  44060. name: string;
  44061. shader: string;
  44062. };
  44063. }
  44064. declare module BABYLON {
  44065. /**
  44066. * Background material used to create an efficient environement around your scene.
  44067. */
  44068. export class BackgroundMaterial extends PushMaterial {
  44069. /**
  44070. * Standard reflectance value at parallel view angle.
  44071. */
  44072. static StandardReflectance0: number;
  44073. /**
  44074. * Standard reflectance value at grazing angle.
  44075. */
  44076. static StandardReflectance90: number;
  44077. protected _primaryColor: Color3;
  44078. /**
  44079. * Key light Color (multiply against the environement texture)
  44080. */
  44081. primaryColor: Color3;
  44082. protected __perceptualColor: Nullable<Color3>;
  44083. /**
  44084. * Experimental Internal Use Only.
  44085. *
  44086. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44087. * This acts as a helper to set the primary color to a more "human friendly" value.
  44088. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44089. * output color as close as possible from the chosen value.
  44090. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44091. * part of lighting setup.)
  44092. */
  44093. _perceptualColor: Nullable<Color3>;
  44094. protected _primaryColorShadowLevel: float;
  44095. /**
  44096. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44097. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44098. */
  44099. primaryColorShadowLevel: float;
  44100. protected _primaryColorHighlightLevel: float;
  44101. /**
  44102. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44103. * The primary color is used at the level chosen to define what the white area would look.
  44104. */
  44105. primaryColorHighlightLevel: float;
  44106. protected _reflectionTexture: Nullable<BaseTexture>;
  44107. /**
  44108. * Reflection Texture used in the material.
  44109. * Should be author in a specific way for the best result (refer to the documentation).
  44110. */
  44111. reflectionTexture: Nullable<BaseTexture>;
  44112. protected _reflectionBlur: float;
  44113. /**
  44114. * Reflection Texture level of blur.
  44115. *
  44116. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44117. * texture twice.
  44118. */
  44119. reflectionBlur: float;
  44120. protected _diffuseTexture: Nullable<BaseTexture>;
  44121. /**
  44122. * Diffuse Texture used in the material.
  44123. * Should be author in a specific way for the best result (refer to the documentation).
  44124. */
  44125. diffuseTexture: Nullable<BaseTexture>;
  44126. protected _shadowLights: Nullable<IShadowLight[]>;
  44127. /**
  44128. * Specify the list of lights casting shadow on the material.
  44129. * All scene shadow lights will be included if null.
  44130. */
  44131. shadowLights: Nullable<IShadowLight[]>;
  44132. protected _shadowLevel: float;
  44133. /**
  44134. * Helps adjusting the shadow to a softer level if required.
  44135. * 0 means black shadows and 1 means no shadows.
  44136. */
  44137. shadowLevel: float;
  44138. protected _sceneCenter: Vector3;
  44139. /**
  44140. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44141. * It is usually zero but might be interesting to modify according to your setup.
  44142. */
  44143. sceneCenter: Vector3;
  44144. protected _opacityFresnel: boolean;
  44145. /**
  44146. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44147. * This helps ensuring a nice transition when the camera goes under the ground.
  44148. */
  44149. opacityFresnel: boolean;
  44150. protected _reflectionFresnel: boolean;
  44151. /**
  44152. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44153. * This helps adding a mirror texture on the ground.
  44154. */
  44155. reflectionFresnel: boolean;
  44156. protected _reflectionFalloffDistance: number;
  44157. /**
  44158. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44159. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44160. */
  44161. reflectionFalloffDistance: number;
  44162. protected _reflectionAmount: number;
  44163. /**
  44164. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44165. */
  44166. reflectionAmount: number;
  44167. protected _reflectionReflectance0: number;
  44168. /**
  44169. * This specifies the weight of the reflection at grazing angle.
  44170. */
  44171. reflectionReflectance0: number;
  44172. protected _reflectionReflectance90: number;
  44173. /**
  44174. * This specifies the weight of the reflection at a perpendicular point of view.
  44175. */
  44176. reflectionReflectance90: number;
  44177. /**
  44178. * Sets the reflection reflectance fresnel values according to the default standard
  44179. * empirically know to work well :-)
  44180. */
  44181. reflectionStandardFresnelWeight: number;
  44182. protected _useRGBColor: boolean;
  44183. /**
  44184. * Helps to directly use the maps channels instead of their level.
  44185. */
  44186. useRGBColor: boolean;
  44187. protected _enableNoise: boolean;
  44188. /**
  44189. * This helps reducing the banding effect that could occur on the background.
  44190. */
  44191. enableNoise: boolean;
  44192. /**
  44193. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44194. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44195. * Recommended to be keep at 1.0 except for special cases.
  44196. */
  44197. fovMultiplier: number;
  44198. private _fovMultiplier;
  44199. /**
  44200. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44201. */
  44202. useEquirectangularFOV: boolean;
  44203. private _maxSimultaneousLights;
  44204. /**
  44205. * Number of Simultaneous lights allowed on the material.
  44206. */
  44207. maxSimultaneousLights: int;
  44208. /**
  44209. * Default configuration related to image processing available in the Background Material.
  44210. */
  44211. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44212. /**
  44213. * Keep track of the image processing observer to allow dispose and replace.
  44214. */
  44215. private _imageProcessingObserver;
  44216. /**
  44217. * Attaches a new image processing configuration to the PBR Material.
  44218. * @param configuration (if null the scene configuration will be use)
  44219. */
  44220. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44221. /**
  44222. * Gets the image processing configuration used either in this material.
  44223. */
  44224. /**
  44225. * Sets the Default image processing configuration used either in the this material.
  44226. *
  44227. * If sets to null, the scene one is in use.
  44228. */
  44229. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44230. /**
  44231. * Gets wether the color curves effect is enabled.
  44232. */
  44233. /**
  44234. * Sets wether the color curves effect is enabled.
  44235. */
  44236. cameraColorCurvesEnabled: boolean;
  44237. /**
  44238. * Gets wether the color grading effect is enabled.
  44239. */
  44240. /**
  44241. * Gets wether the color grading effect is enabled.
  44242. */
  44243. cameraColorGradingEnabled: boolean;
  44244. /**
  44245. * Gets wether tonemapping is enabled or not.
  44246. */
  44247. /**
  44248. * Sets wether tonemapping is enabled or not
  44249. */
  44250. cameraToneMappingEnabled: boolean;
  44251. /**
  44252. * The camera exposure used on this material.
  44253. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44254. * This corresponds to a photographic exposure.
  44255. */
  44256. /**
  44257. * The camera exposure used on this material.
  44258. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44259. * This corresponds to a photographic exposure.
  44260. */
  44261. cameraExposure: float;
  44262. /**
  44263. * Gets The camera contrast used on this material.
  44264. */
  44265. /**
  44266. * Sets The camera contrast used on this material.
  44267. */
  44268. cameraContrast: float;
  44269. /**
  44270. * Gets the Color Grading 2D Lookup Texture.
  44271. */
  44272. /**
  44273. * Sets the Color Grading 2D Lookup Texture.
  44274. */
  44275. cameraColorGradingTexture: Nullable<BaseTexture>;
  44276. /**
  44277. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44278. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44279. * 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;
  44280. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44281. */
  44282. /**
  44283. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44284. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44285. * 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;
  44286. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44287. */
  44288. cameraColorCurves: Nullable<ColorCurves>;
  44289. /**
  44290. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44291. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44292. */
  44293. switchToBGR: boolean;
  44294. private _renderTargets;
  44295. private _reflectionControls;
  44296. private _white;
  44297. private _primaryShadowColor;
  44298. private _primaryHighlightColor;
  44299. /**
  44300. * Instantiates a Background Material in the given scene
  44301. * @param name The friendly name of the material
  44302. * @param scene The scene to add the material to
  44303. */
  44304. constructor(name: string, scene: Scene);
  44305. /**
  44306. * Gets a boolean indicating that current material needs to register RTT
  44307. */
  44308. readonly hasRenderTargetTextures: boolean;
  44309. /**
  44310. * The entire material has been created in order to prevent overdraw.
  44311. * @returns false
  44312. */
  44313. needAlphaTesting(): boolean;
  44314. /**
  44315. * The entire material has been created in order to prevent overdraw.
  44316. * @returns true if blending is enable
  44317. */
  44318. needAlphaBlending(): boolean;
  44319. /**
  44320. * Checks wether the material is ready to be rendered for a given mesh.
  44321. * @param mesh The mesh to render
  44322. * @param subMesh The submesh to check against
  44323. * @param useInstances Specify wether or not the material is used with instances
  44324. * @returns true if all the dependencies are ready (Textures, Effects...)
  44325. */
  44326. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44327. /**
  44328. * Compute the primary color according to the chosen perceptual color.
  44329. */
  44330. private _computePrimaryColorFromPerceptualColor;
  44331. /**
  44332. * Compute the highlights and shadow colors according to their chosen levels.
  44333. */
  44334. private _computePrimaryColors;
  44335. /**
  44336. * Build the uniform buffer used in the material.
  44337. */
  44338. buildUniformLayout(): void;
  44339. /**
  44340. * Unbind the material.
  44341. */
  44342. unbind(): void;
  44343. /**
  44344. * Bind only the world matrix to the material.
  44345. * @param world The world matrix to bind.
  44346. */
  44347. bindOnlyWorldMatrix(world: Matrix): void;
  44348. /**
  44349. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44350. * @param world The world matrix to bind.
  44351. * @param subMesh The submesh to bind for.
  44352. */
  44353. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44354. /**
  44355. * Dispose the material.
  44356. * @param forceDisposeEffect Force disposal of the associated effect.
  44357. * @param forceDisposeTextures Force disposal of the associated textures.
  44358. */
  44359. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44360. /**
  44361. * Clones the material.
  44362. * @param name The cloned name.
  44363. * @returns The cloned material.
  44364. */
  44365. clone(name: string): BackgroundMaterial;
  44366. /**
  44367. * Serializes the current material to its JSON representation.
  44368. * @returns The JSON representation.
  44369. */
  44370. serialize(): any;
  44371. /**
  44372. * Gets the class name of the material
  44373. * @returns "BackgroundMaterial"
  44374. */
  44375. getClassName(): string;
  44376. /**
  44377. * Parse a JSON input to create back a background material.
  44378. * @param source The JSON data to parse
  44379. * @param scene The scene to create the parsed material in
  44380. * @param rootUrl The root url of the assets the material depends upon
  44381. * @returns the instantiated BackgroundMaterial.
  44382. */
  44383. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44384. }
  44385. }
  44386. declare module BABYLON {
  44387. /**
  44388. * Represents the different options available during the creation of
  44389. * a Environment helper.
  44390. *
  44391. * This can control the default ground, skybox and image processing setup of your scene.
  44392. */
  44393. export interface IEnvironmentHelperOptions {
  44394. /**
  44395. * Specifies wether or not to create a ground.
  44396. * True by default.
  44397. */
  44398. createGround: boolean;
  44399. /**
  44400. * Specifies the ground size.
  44401. * 15 by default.
  44402. */
  44403. groundSize: number;
  44404. /**
  44405. * The texture used on the ground for the main color.
  44406. * Comes from the BabylonJS CDN by default.
  44407. *
  44408. * Remarks: Can be either a texture or a url.
  44409. */
  44410. groundTexture: string | BaseTexture;
  44411. /**
  44412. * The color mixed in the ground texture by default.
  44413. * BabylonJS clearColor by default.
  44414. */
  44415. groundColor: Color3;
  44416. /**
  44417. * Specifies the ground opacity.
  44418. * 1 by default.
  44419. */
  44420. groundOpacity: number;
  44421. /**
  44422. * Enables the ground to receive shadows.
  44423. * True by default.
  44424. */
  44425. enableGroundShadow: boolean;
  44426. /**
  44427. * Helps preventing the shadow to be fully black on the ground.
  44428. * 0.5 by default.
  44429. */
  44430. groundShadowLevel: number;
  44431. /**
  44432. * Creates a mirror texture attach to the ground.
  44433. * false by default.
  44434. */
  44435. enableGroundMirror: boolean;
  44436. /**
  44437. * Specifies the ground mirror size ratio.
  44438. * 0.3 by default as the default kernel is 64.
  44439. */
  44440. groundMirrorSizeRatio: number;
  44441. /**
  44442. * Specifies the ground mirror blur kernel size.
  44443. * 64 by default.
  44444. */
  44445. groundMirrorBlurKernel: number;
  44446. /**
  44447. * Specifies the ground mirror visibility amount.
  44448. * 1 by default
  44449. */
  44450. groundMirrorAmount: number;
  44451. /**
  44452. * Specifies the ground mirror reflectance weight.
  44453. * This uses the standard weight of the background material to setup the fresnel effect
  44454. * of the mirror.
  44455. * 1 by default.
  44456. */
  44457. groundMirrorFresnelWeight: number;
  44458. /**
  44459. * Specifies the ground mirror Falloff distance.
  44460. * This can helps reducing the size of the reflection.
  44461. * 0 by Default.
  44462. */
  44463. groundMirrorFallOffDistance: number;
  44464. /**
  44465. * Specifies the ground mirror texture type.
  44466. * Unsigned Int by Default.
  44467. */
  44468. groundMirrorTextureType: number;
  44469. /**
  44470. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44471. * the shown objects.
  44472. */
  44473. groundYBias: number;
  44474. /**
  44475. * Specifies wether or not to create a skybox.
  44476. * True by default.
  44477. */
  44478. createSkybox: boolean;
  44479. /**
  44480. * Specifies the skybox size.
  44481. * 20 by default.
  44482. */
  44483. skyboxSize: number;
  44484. /**
  44485. * The texture used on the skybox for the main color.
  44486. * Comes from the BabylonJS CDN by default.
  44487. *
  44488. * Remarks: Can be either a texture or a url.
  44489. */
  44490. skyboxTexture: string | BaseTexture;
  44491. /**
  44492. * The color mixed in the skybox texture by default.
  44493. * BabylonJS clearColor by default.
  44494. */
  44495. skyboxColor: Color3;
  44496. /**
  44497. * The background rotation around the Y axis of the scene.
  44498. * This helps aligning the key lights of your scene with the background.
  44499. * 0 by default.
  44500. */
  44501. backgroundYRotation: number;
  44502. /**
  44503. * Compute automatically the size of the elements to best fit with the scene.
  44504. */
  44505. sizeAuto: boolean;
  44506. /**
  44507. * Default position of the rootMesh if autoSize is not true.
  44508. */
  44509. rootPosition: Vector3;
  44510. /**
  44511. * Sets up the image processing in the scene.
  44512. * true by default.
  44513. */
  44514. setupImageProcessing: boolean;
  44515. /**
  44516. * The texture used as your environment texture in the scene.
  44517. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44518. *
  44519. * Remarks: Can be either a texture or a url.
  44520. */
  44521. environmentTexture: string | BaseTexture;
  44522. /**
  44523. * The value of the exposure to apply to the scene.
  44524. * 0.6 by default if setupImageProcessing is true.
  44525. */
  44526. cameraExposure: number;
  44527. /**
  44528. * The value of the contrast to apply to the scene.
  44529. * 1.6 by default if setupImageProcessing is true.
  44530. */
  44531. cameraContrast: number;
  44532. /**
  44533. * Specifies wether or not tonemapping should be enabled in the scene.
  44534. * true by default if setupImageProcessing is true.
  44535. */
  44536. toneMappingEnabled: boolean;
  44537. }
  44538. /**
  44539. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44540. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44541. * It also helps with the default setup of your imageProcessing configuration.
  44542. */
  44543. export class EnvironmentHelper {
  44544. /**
  44545. * Default ground texture URL.
  44546. */
  44547. private static _groundTextureCDNUrl;
  44548. /**
  44549. * Default skybox texture URL.
  44550. */
  44551. private static _skyboxTextureCDNUrl;
  44552. /**
  44553. * Default environment texture URL.
  44554. */
  44555. private static _environmentTextureCDNUrl;
  44556. /**
  44557. * Creates the default options for the helper.
  44558. */
  44559. private static _getDefaultOptions;
  44560. private _rootMesh;
  44561. /**
  44562. * Gets the root mesh created by the helper.
  44563. */
  44564. readonly rootMesh: Mesh;
  44565. private _skybox;
  44566. /**
  44567. * Gets the skybox created by the helper.
  44568. */
  44569. readonly skybox: Nullable<Mesh>;
  44570. private _skyboxTexture;
  44571. /**
  44572. * Gets the skybox texture created by the helper.
  44573. */
  44574. readonly skyboxTexture: Nullable<BaseTexture>;
  44575. private _skyboxMaterial;
  44576. /**
  44577. * Gets the skybox material created by the helper.
  44578. */
  44579. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44580. private _ground;
  44581. /**
  44582. * Gets the ground mesh created by the helper.
  44583. */
  44584. readonly ground: Nullable<Mesh>;
  44585. private _groundTexture;
  44586. /**
  44587. * Gets the ground texture created by the helper.
  44588. */
  44589. readonly groundTexture: Nullable<BaseTexture>;
  44590. private _groundMirror;
  44591. /**
  44592. * Gets the ground mirror created by the helper.
  44593. */
  44594. readonly groundMirror: Nullable<MirrorTexture>;
  44595. /**
  44596. * Gets the ground mirror render list to helps pushing the meshes
  44597. * you wish in the ground reflection.
  44598. */
  44599. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44600. private _groundMaterial;
  44601. /**
  44602. * Gets the ground material created by the helper.
  44603. */
  44604. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44605. /**
  44606. * Stores the creation options.
  44607. */
  44608. private readonly _scene;
  44609. private _options;
  44610. /**
  44611. * This observable will be notified with any error during the creation of the environment,
  44612. * mainly texture creation errors.
  44613. */
  44614. onErrorObservable: Observable<{
  44615. message?: string;
  44616. exception?: any;
  44617. }>;
  44618. /**
  44619. * constructor
  44620. * @param options Defines the options we want to customize the helper
  44621. * @param scene The scene to add the material to
  44622. */
  44623. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44624. /**
  44625. * Updates the background according to the new options
  44626. * @param options
  44627. */
  44628. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44629. /**
  44630. * Sets the primary color of all the available elements.
  44631. * @param color the main color to affect to the ground and the background
  44632. */
  44633. setMainColor(color: Color3): void;
  44634. /**
  44635. * Setup the image processing according to the specified options.
  44636. */
  44637. private _setupImageProcessing;
  44638. /**
  44639. * Setup the environment texture according to the specified options.
  44640. */
  44641. private _setupEnvironmentTexture;
  44642. /**
  44643. * Setup the background according to the specified options.
  44644. */
  44645. private _setupBackground;
  44646. /**
  44647. * Get the scene sizes according to the setup.
  44648. */
  44649. private _getSceneSize;
  44650. /**
  44651. * Setup the ground according to the specified options.
  44652. */
  44653. private _setupGround;
  44654. /**
  44655. * Setup the ground material according to the specified options.
  44656. */
  44657. private _setupGroundMaterial;
  44658. /**
  44659. * Setup the ground diffuse texture according to the specified options.
  44660. */
  44661. private _setupGroundDiffuseTexture;
  44662. /**
  44663. * Setup the ground mirror texture according to the specified options.
  44664. */
  44665. private _setupGroundMirrorTexture;
  44666. /**
  44667. * Setup the ground to receive the mirror texture.
  44668. */
  44669. private _setupMirrorInGroundMaterial;
  44670. /**
  44671. * Setup the skybox according to the specified options.
  44672. */
  44673. private _setupSkybox;
  44674. /**
  44675. * Setup the skybox material according to the specified options.
  44676. */
  44677. private _setupSkyboxMaterial;
  44678. /**
  44679. * Setup the skybox reflection texture according to the specified options.
  44680. */
  44681. private _setupSkyboxReflectionTexture;
  44682. private _errorHandler;
  44683. /**
  44684. * Dispose all the elements created by the Helper.
  44685. */
  44686. dispose(): void;
  44687. }
  44688. }
  44689. declare module BABYLON {
  44690. /**
  44691. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44692. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44693. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44694. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44695. */
  44696. export class PhotoDome extends TransformNode {
  44697. /**
  44698. * Define the image as a Monoscopic panoramic 360 image.
  44699. */
  44700. static readonly MODE_MONOSCOPIC: number;
  44701. /**
  44702. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44703. */
  44704. static readonly MODE_TOPBOTTOM: number;
  44705. /**
  44706. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44707. */
  44708. static readonly MODE_SIDEBYSIDE: number;
  44709. private _useDirectMapping;
  44710. /**
  44711. * The texture being displayed on the sphere
  44712. */
  44713. protected _photoTexture: Texture;
  44714. /**
  44715. * Gets or sets the texture being displayed on the sphere
  44716. */
  44717. photoTexture: Texture;
  44718. /**
  44719. * Observable raised when an error occured while loading the 360 image
  44720. */
  44721. onLoadErrorObservable: Observable<string>;
  44722. /**
  44723. * The skybox material
  44724. */
  44725. protected _material: BackgroundMaterial;
  44726. /**
  44727. * The surface used for the skybox
  44728. */
  44729. protected _mesh: Mesh;
  44730. /**
  44731. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44732. * Also see the options.resolution property.
  44733. */
  44734. fovMultiplier: number;
  44735. private _imageMode;
  44736. /**
  44737. * Gets or set the current video mode for the video. It can be:
  44738. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44739. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44740. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44741. */
  44742. imageMode: number;
  44743. /**
  44744. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44745. * @param name Element's name, child elements will append suffixes for their own names.
  44746. * @param urlsOfPhoto defines the url of the photo to display
  44747. * @param options defines an object containing optional or exposed sub element properties
  44748. * @param onError defines a callback called when an error occured while loading the texture
  44749. */
  44750. constructor(name: string, urlOfPhoto: string, options: {
  44751. resolution?: number;
  44752. size?: number;
  44753. useDirectMapping?: boolean;
  44754. faceForward?: boolean;
  44755. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44756. private _onBeforeCameraRenderObserver;
  44757. private _changeImageMode;
  44758. /**
  44759. * Releases resources associated with this node.
  44760. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44761. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44762. */
  44763. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44764. }
  44765. }
  44766. declare module BABYLON {
  44767. /** @hidden */
  44768. export var rgbdDecodePixelShader: {
  44769. name: string;
  44770. shader: string;
  44771. };
  44772. }
  44773. declare module BABYLON {
  44774. /**
  44775. * Class used to host texture specific utilities
  44776. */
  44777. export class BRDFTextureTools {
  44778. /**
  44779. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44780. * @param texture the texture to expand.
  44781. */
  44782. private static _ExpandDefaultBRDFTexture;
  44783. /**
  44784. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44785. * @param scene defines the hosting scene
  44786. * @returns the environment BRDF texture
  44787. */
  44788. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44789. private static _environmentBRDFBase64Texture;
  44790. }
  44791. }
  44792. declare module BABYLON {
  44793. /**
  44794. * @hidden
  44795. */
  44796. export interface IMaterialClearCoatDefines {
  44797. CLEARCOAT: boolean;
  44798. CLEARCOAT_DEFAULTIOR: boolean;
  44799. CLEARCOAT_TEXTURE: boolean;
  44800. CLEARCOAT_TEXTUREDIRECTUV: number;
  44801. CLEARCOAT_BUMP: boolean;
  44802. CLEARCOAT_BUMPDIRECTUV: number;
  44803. CLEARCOAT_TINT: boolean;
  44804. CLEARCOAT_TINT_TEXTURE: boolean;
  44805. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44806. /** @hidden */
  44807. _areTexturesDirty: boolean;
  44808. }
  44809. /**
  44810. * Define the code related to the clear coat parameters of the pbr material.
  44811. */
  44812. export class PBRClearCoatConfiguration {
  44813. /**
  44814. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44815. * The default fits with a polyurethane material.
  44816. */
  44817. private static readonly _DefaultIndexOfRefraction;
  44818. private _isEnabled;
  44819. /**
  44820. * Defines if the clear coat is enabled in the material.
  44821. */
  44822. isEnabled: boolean;
  44823. /**
  44824. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44825. */
  44826. intensity: number;
  44827. /**
  44828. * Defines the clear coat layer roughness.
  44829. */
  44830. roughness: number;
  44831. private _indexOfRefraction;
  44832. /**
  44833. * Defines the index of refraction of the clear coat.
  44834. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44835. * The default fits with a polyurethane material.
  44836. * Changing the default value is more performance intensive.
  44837. */
  44838. indexOfRefraction: number;
  44839. private _texture;
  44840. /**
  44841. * Stores the clear coat values in a texture.
  44842. */
  44843. texture: Nullable<BaseTexture>;
  44844. private _bumpTexture;
  44845. /**
  44846. * Define the clear coat specific bump texture.
  44847. */
  44848. bumpTexture: Nullable<BaseTexture>;
  44849. private _isTintEnabled;
  44850. /**
  44851. * Defines if the clear coat tint is enabled in the material.
  44852. */
  44853. isTintEnabled: boolean;
  44854. /**
  44855. * Defines the clear coat tint of the material.
  44856. * This is only use if tint is enabled
  44857. */
  44858. tintColor: Color3;
  44859. /**
  44860. * Defines the distance at which the tint color should be found in the
  44861. * clear coat media.
  44862. * This is only use if tint is enabled
  44863. */
  44864. tintColorAtDistance: number;
  44865. /**
  44866. * Defines the clear coat layer thickness.
  44867. * This is only use if tint is enabled
  44868. */
  44869. tintThickness: number;
  44870. private _tintTexture;
  44871. /**
  44872. * Stores the clear tint values in a texture.
  44873. * rgb is tint
  44874. * a is a thickness factor
  44875. */
  44876. tintTexture: Nullable<BaseTexture>;
  44877. /** @hidden */
  44878. private _internalMarkAllSubMeshesAsTexturesDirty;
  44879. /** @hidden */
  44880. _markAllSubMeshesAsTexturesDirty(): void;
  44881. /**
  44882. * Instantiate a new istance of clear coat configuration.
  44883. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44884. */
  44885. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44886. /**
  44887. * Gets wehter the submesh is ready to be used or not.
  44888. * @param defines the list of "defines" to update.
  44889. * @param scene defines the scene the material belongs to.
  44890. * @param engine defines the engine the material belongs to.
  44891. * @param disableBumpMap defines wether the material disables bump or not.
  44892. * @returns - boolean indicating that the submesh is ready or not.
  44893. */
  44894. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44895. /**
  44896. * Checks to see if a texture is used in the material.
  44897. * @param defines the list of "defines" to update.
  44898. * @param scene defines the scene to the material belongs to.
  44899. */
  44900. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44901. /**
  44902. * Binds the material data.
  44903. * @param uniformBuffer defines the Uniform buffer to fill in.
  44904. * @param scene defines the scene the material belongs to.
  44905. * @param engine defines the engine the material belongs to.
  44906. * @param disableBumpMap defines wether the material disables bump or not.
  44907. * @param isFrozen defines wether the material is frozen or not.
  44908. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44909. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44910. */
  44911. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44912. /**
  44913. * Checks to see if a texture is used in the material.
  44914. * @param texture - Base texture to use.
  44915. * @returns - Boolean specifying if a texture is used in the material.
  44916. */
  44917. hasTexture(texture: BaseTexture): boolean;
  44918. /**
  44919. * Returns an array of the actively used textures.
  44920. * @param activeTextures Array of BaseTextures
  44921. */
  44922. getActiveTextures(activeTextures: BaseTexture[]): void;
  44923. /**
  44924. * Returns the animatable textures.
  44925. * @param animatables Array of animatable textures.
  44926. */
  44927. getAnimatables(animatables: IAnimatable[]): void;
  44928. /**
  44929. * Disposes the resources of the material.
  44930. * @param forceDisposeTextures - Forces the disposal of all textures.
  44931. */
  44932. dispose(forceDisposeTextures?: boolean): void;
  44933. /**
  44934. * Get the current class name of the texture useful for serialization or dynamic coding.
  44935. * @returns "PBRClearCoatConfiguration"
  44936. */
  44937. getClassName(): string;
  44938. /**
  44939. * Add fallbacks to the effect fallbacks list.
  44940. * @param defines defines the Base texture to use.
  44941. * @param fallbacks defines the current fallback list.
  44942. * @param currentRank defines the current fallback rank.
  44943. * @returns the new fallback rank.
  44944. */
  44945. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44946. /**
  44947. * Add the required uniforms to the current list.
  44948. * @param uniforms defines the current uniform list.
  44949. */
  44950. static AddUniforms(uniforms: string[]): void;
  44951. /**
  44952. * Add the required samplers to the current list.
  44953. * @param samplers defines the current sampler list.
  44954. */
  44955. static AddSamplers(samplers: string[]): void;
  44956. /**
  44957. * Add the required uniforms to the current buffer.
  44958. * @param uniformBuffer defines the current uniform buffer.
  44959. */
  44960. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44961. /**
  44962. * Makes a duplicate of the current configuration into another one.
  44963. * @param clearCoatConfiguration define the config where to copy the info
  44964. */
  44965. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44966. /**
  44967. * Serializes this clear coat configuration.
  44968. * @returns - An object with the serialized config.
  44969. */
  44970. serialize(): any;
  44971. /**
  44972. * Parses a anisotropy Configuration from a serialized object.
  44973. * @param source - Serialized object.
  44974. * @param scene Defines the scene we are parsing for
  44975. * @param rootUrl Defines the rootUrl to load from
  44976. */
  44977. parse(source: any, scene: Scene, rootUrl: string): void;
  44978. }
  44979. }
  44980. declare module BABYLON {
  44981. /**
  44982. * @hidden
  44983. */
  44984. export interface IMaterialAnisotropicDefines {
  44985. ANISOTROPIC: boolean;
  44986. ANISOTROPIC_TEXTURE: boolean;
  44987. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44988. MAINUV1: boolean;
  44989. _areTexturesDirty: boolean;
  44990. _needUVs: boolean;
  44991. }
  44992. /**
  44993. * Define the code related to the anisotropic parameters of the pbr material.
  44994. */
  44995. export class PBRAnisotropicConfiguration {
  44996. private _isEnabled;
  44997. /**
  44998. * Defines if the anisotropy is enabled in the material.
  44999. */
  45000. isEnabled: boolean;
  45001. /**
  45002. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45003. */
  45004. intensity: number;
  45005. /**
  45006. * Defines if the effect is along the tangents, bitangents or in between.
  45007. * By default, the effect is "strectching" the highlights along the tangents.
  45008. */
  45009. direction: Vector2;
  45010. private _texture;
  45011. /**
  45012. * Stores the anisotropy values in a texture.
  45013. * rg is direction (like normal from -1 to 1)
  45014. * b is a intensity
  45015. */
  45016. texture: Nullable<BaseTexture>;
  45017. /** @hidden */
  45018. private _internalMarkAllSubMeshesAsTexturesDirty;
  45019. /** @hidden */
  45020. _markAllSubMeshesAsTexturesDirty(): void;
  45021. /**
  45022. * Instantiate a new istance of anisotropy configuration.
  45023. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45024. */
  45025. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45026. /**
  45027. * Specifies that the submesh is ready to be used.
  45028. * @param defines the list of "defines" to update.
  45029. * @param scene defines the scene the material belongs to.
  45030. * @returns - boolean indicating that the submesh is ready or not.
  45031. */
  45032. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45033. /**
  45034. * Checks to see if a texture is used in the material.
  45035. * @param defines the list of "defines" to update.
  45036. * @param mesh the mesh we are preparing the defines for.
  45037. * @param scene defines the scene the material belongs to.
  45038. */
  45039. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45040. /**
  45041. * Binds the material data.
  45042. * @param uniformBuffer defines the Uniform buffer to fill in.
  45043. * @param scene defines the scene the material belongs to.
  45044. * @param isFrozen defines wether the material is frozen or not.
  45045. */
  45046. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45047. /**
  45048. * Checks to see if a texture is used in the material.
  45049. * @param texture - Base texture to use.
  45050. * @returns - Boolean specifying if a texture is used in the material.
  45051. */
  45052. hasTexture(texture: BaseTexture): boolean;
  45053. /**
  45054. * Returns an array of the actively used textures.
  45055. * @param activeTextures Array of BaseTextures
  45056. */
  45057. getActiveTextures(activeTextures: BaseTexture[]): void;
  45058. /**
  45059. * Returns the animatable textures.
  45060. * @param animatables Array of animatable textures.
  45061. */
  45062. getAnimatables(animatables: IAnimatable[]): void;
  45063. /**
  45064. * Disposes the resources of the material.
  45065. * @param forceDisposeTextures - Forces the disposal of all textures.
  45066. */
  45067. dispose(forceDisposeTextures?: boolean): void;
  45068. /**
  45069. * Get the current class name of the texture useful for serialization or dynamic coding.
  45070. * @returns "PBRAnisotropicConfiguration"
  45071. */
  45072. getClassName(): string;
  45073. /**
  45074. * Add fallbacks to the effect fallbacks list.
  45075. * @param defines defines the Base texture to use.
  45076. * @param fallbacks defines the current fallback list.
  45077. * @param currentRank defines the current fallback rank.
  45078. * @returns the new fallback rank.
  45079. */
  45080. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45081. /**
  45082. * Add the required uniforms to the current list.
  45083. * @param uniforms defines the current uniform list.
  45084. */
  45085. static AddUniforms(uniforms: string[]): void;
  45086. /**
  45087. * Add the required uniforms to the current buffer.
  45088. * @param uniformBuffer defines the current uniform buffer.
  45089. */
  45090. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45091. /**
  45092. * Add the required samplers to the current list.
  45093. * @param samplers defines the current sampler list.
  45094. */
  45095. static AddSamplers(samplers: string[]): void;
  45096. /**
  45097. * Makes a duplicate of the current configuration into another one.
  45098. * @param anisotropicConfiguration define the config where to copy the info
  45099. */
  45100. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45101. /**
  45102. * Serializes this anisotropy configuration.
  45103. * @returns - An object with the serialized config.
  45104. */
  45105. serialize(): any;
  45106. /**
  45107. * Parses a anisotropy Configuration from a serialized object.
  45108. * @param source - Serialized object.
  45109. * @param scene Defines the scene we are parsing for
  45110. * @param rootUrl Defines the rootUrl to load from
  45111. */
  45112. parse(source: any, scene: Scene, rootUrl: string): void;
  45113. }
  45114. }
  45115. declare module BABYLON {
  45116. /**
  45117. * @hidden
  45118. */
  45119. export interface IMaterialBRDFDefines {
  45120. BRDF_V_HEIGHT_CORRELATED: boolean;
  45121. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45122. SPHERICAL_HARMONICS: boolean;
  45123. /** @hidden */
  45124. _areMiscDirty: boolean;
  45125. }
  45126. /**
  45127. * Define the code related to the BRDF parameters of the pbr material.
  45128. */
  45129. export class PBRBRDFConfiguration {
  45130. /**
  45131. * Default value used for the energy conservation.
  45132. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45133. */
  45134. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45135. /**
  45136. * Default value used for the Smith Visibility Height Correlated mode.
  45137. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45138. */
  45139. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45140. /**
  45141. * Default value used for the IBL diffuse part.
  45142. * This can help switching back to the polynomials mode globally which is a tiny bit
  45143. * less GPU intensive at the drawback of a lower quality.
  45144. */
  45145. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45146. private _useEnergyConservation;
  45147. /**
  45148. * Defines if the material uses energy conservation.
  45149. */
  45150. useEnergyConservation: boolean;
  45151. private _useSmithVisibilityHeightCorrelated;
  45152. /**
  45153. * LEGACY Mode set to false
  45154. * Defines if the material uses height smith correlated visibility term.
  45155. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45156. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45157. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45158. * Not relying on height correlated will also disable energy conservation.
  45159. */
  45160. useSmithVisibilityHeightCorrelated: boolean;
  45161. private _useSphericalHarmonics;
  45162. /**
  45163. * LEGACY Mode set to false
  45164. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45165. * diffuse part of the IBL.
  45166. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45167. * to the ground truth.
  45168. */
  45169. useSphericalHarmonics: boolean;
  45170. /** @hidden */
  45171. private _internalMarkAllSubMeshesAsMiscDirty;
  45172. /** @hidden */
  45173. _markAllSubMeshesAsMiscDirty(): void;
  45174. /**
  45175. * Instantiate a new istance of clear coat configuration.
  45176. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45177. */
  45178. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45179. /**
  45180. * Checks to see if a texture is used in the material.
  45181. * @param defines the list of "defines" to update.
  45182. */
  45183. prepareDefines(defines: IMaterialBRDFDefines): void;
  45184. /**
  45185. * Get the current class name of the texture useful for serialization or dynamic coding.
  45186. * @returns "PBRClearCoatConfiguration"
  45187. */
  45188. getClassName(): string;
  45189. /**
  45190. * Makes a duplicate of the current configuration into another one.
  45191. * @param brdfConfiguration define the config where to copy the info
  45192. */
  45193. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45194. /**
  45195. * Serializes this BRDF configuration.
  45196. * @returns - An object with the serialized config.
  45197. */
  45198. serialize(): any;
  45199. /**
  45200. * Parses a anisotropy Configuration from a serialized object.
  45201. * @param source - Serialized object.
  45202. * @param scene Defines the scene we are parsing for
  45203. * @param rootUrl Defines the rootUrl to load from
  45204. */
  45205. parse(source: any, scene: Scene, rootUrl: string): void;
  45206. }
  45207. }
  45208. declare module BABYLON {
  45209. /**
  45210. * @hidden
  45211. */
  45212. export interface IMaterialSheenDefines {
  45213. SHEEN: boolean;
  45214. SHEEN_TEXTURE: boolean;
  45215. SHEEN_TEXTUREDIRECTUV: number;
  45216. SHEEN_LINKWITHALBEDO: boolean;
  45217. /** @hidden */
  45218. _areTexturesDirty: boolean;
  45219. }
  45220. /**
  45221. * Define the code related to the Sheen parameters of the pbr material.
  45222. */
  45223. export class PBRSheenConfiguration {
  45224. private _isEnabled;
  45225. /**
  45226. * Defines if the material uses sheen.
  45227. */
  45228. isEnabled: boolean;
  45229. private _linkSheenWithAlbedo;
  45230. /**
  45231. * Defines if the sheen is linked to the sheen color.
  45232. */
  45233. linkSheenWithAlbedo: boolean;
  45234. /**
  45235. * Defines the sheen intensity.
  45236. */
  45237. intensity: number;
  45238. /**
  45239. * Defines the sheen color.
  45240. */
  45241. color: Color3;
  45242. private _texture;
  45243. /**
  45244. * Stores the sheen tint values in a texture.
  45245. * rgb is tint
  45246. * a is a intensity
  45247. */
  45248. texture: Nullable<BaseTexture>;
  45249. /** @hidden */
  45250. private _internalMarkAllSubMeshesAsTexturesDirty;
  45251. /** @hidden */
  45252. _markAllSubMeshesAsTexturesDirty(): void;
  45253. /**
  45254. * Instantiate a new istance of clear coat configuration.
  45255. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45256. */
  45257. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45258. /**
  45259. * Specifies that the submesh is ready to be used.
  45260. * @param defines the list of "defines" to update.
  45261. * @param scene defines the scene the material belongs to.
  45262. * @returns - boolean indicating that the submesh is ready or not.
  45263. */
  45264. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45265. /**
  45266. * Checks to see if a texture is used in the material.
  45267. * @param defines the list of "defines" to update.
  45268. * @param scene defines the scene the material belongs to.
  45269. */
  45270. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45271. /**
  45272. * Binds the material data.
  45273. * @param uniformBuffer defines the Uniform buffer to fill in.
  45274. * @param scene defines the scene the material belongs to.
  45275. * @param isFrozen defines wether the material is frozen or not.
  45276. */
  45277. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45278. /**
  45279. * Checks to see if a texture is used in the material.
  45280. * @param texture - Base texture to use.
  45281. * @returns - Boolean specifying if a texture is used in the material.
  45282. */
  45283. hasTexture(texture: BaseTexture): boolean;
  45284. /**
  45285. * Returns an array of the actively used textures.
  45286. * @param activeTextures Array of BaseTextures
  45287. */
  45288. getActiveTextures(activeTextures: BaseTexture[]): void;
  45289. /**
  45290. * Returns the animatable textures.
  45291. * @param animatables Array of animatable textures.
  45292. */
  45293. getAnimatables(animatables: IAnimatable[]): void;
  45294. /**
  45295. * Disposes the resources of the material.
  45296. * @param forceDisposeTextures - Forces the disposal of all textures.
  45297. */
  45298. dispose(forceDisposeTextures?: boolean): void;
  45299. /**
  45300. * Get the current class name of the texture useful for serialization or dynamic coding.
  45301. * @returns "PBRSheenConfiguration"
  45302. */
  45303. getClassName(): string;
  45304. /**
  45305. * Add fallbacks to the effect fallbacks list.
  45306. * @param defines defines the Base texture to use.
  45307. * @param fallbacks defines the current fallback list.
  45308. * @param currentRank defines the current fallback rank.
  45309. * @returns the new fallback rank.
  45310. */
  45311. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45312. /**
  45313. * Add the required uniforms to the current list.
  45314. * @param uniforms defines the current uniform list.
  45315. */
  45316. static AddUniforms(uniforms: string[]): void;
  45317. /**
  45318. * Add the required uniforms to the current buffer.
  45319. * @param uniformBuffer defines the current uniform buffer.
  45320. */
  45321. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45322. /**
  45323. * Add the required samplers to the current list.
  45324. * @param samplers defines the current sampler list.
  45325. */
  45326. static AddSamplers(samplers: string[]): void;
  45327. /**
  45328. * Makes a duplicate of the current configuration into another one.
  45329. * @param sheenConfiguration define the config where to copy the info
  45330. */
  45331. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45332. /**
  45333. * Serializes this BRDF configuration.
  45334. * @returns - An object with the serialized config.
  45335. */
  45336. serialize(): any;
  45337. /**
  45338. * Parses a anisotropy Configuration from a serialized object.
  45339. * @param source - Serialized object.
  45340. * @param scene Defines the scene we are parsing for
  45341. * @param rootUrl Defines the rootUrl to load from
  45342. */
  45343. parse(source: any, scene: Scene, rootUrl: string): void;
  45344. }
  45345. }
  45346. declare module BABYLON {
  45347. /**
  45348. * @hidden
  45349. */
  45350. export interface IMaterialSubSurfaceDefines {
  45351. SUBSURFACE: boolean;
  45352. SS_REFRACTION: boolean;
  45353. SS_TRANSLUCENCY: boolean;
  45354. SS_SCATERRING: boolean;
  45355. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45356. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45357. SS_REFRACTIONMAP_3D: boolean;
  45358. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45359. SS_LODINREFRACTIONALPHA: boolean;
  45360. SS_GAMMAREFRACTION: boolean;
  45361. SS_RGBDREFRACTION: boolean;
  45362. SS_LINEARSPECULARREFRACTION: boolean;
  45363. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45364. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45365. /** @hidden */
  45366. _areTexturesDirty: boolean;
  45367. }
  45368. /**
  45369. * Define the code related to the sub surface parameters of the pbr material.
  45370. */
  45371. export class PBRSubSurfaceConfiguration {
  45372. private _isRefractionEnabled;
  45373. /**
  45374. * Defines if the refraction is enabled in the material.
  45375. */
  45376. isRefractionEnabled: boolean;
  45377. private _isTranslucencyEnabled;
  45378. /**
  45379. * Defines if the translucency is enabled in the material.
  45380. */
  45381. isTranslucencyEnabled: boolean;
  45382. private _isScatteringEnabled;
  45383. /**
  45384. * Defines the refraction intensity of the material.
  45385. * The refraction when enabled replaces the Diffuse part of the material.
  45386. * The intensity helps transitionning between diffuse and refraction.
  45387. */
  45388. refractionIntensity: number;
  45389. /**
  45390. * Defines the translucency intensity of the material.
  45391. * When translucency has been enabled, this defines how much of the "translucency"
  45392. * is addded to the diffuse part of the material.
  45393. */
  45394. translucencyIntensity: number;
  45395. /**
  45396. * Defines the scattering intensity of the material.
  45397. * When scattering has been enabled, this defines how much of the "scattered light"
  45398. * is addded to the diffuse part of the material.
  45399. */
  45400. scatteringIntensity: number;
  45401. private _thicknessTexture;
  45402. /**
  45403. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45404. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45405. * 0 would mean minimumThickness
  45406. * 1 would mean maximumThickness
  45407. * The other channels might be use as a mask to vary the different effects intensity.
  45408. */
  45409. thicknessTexture: Nullable<BaseTexture>;
  45410. private _refractionTexture;
  45411. /**
  45412. * Defines the texture to use for refraction.
  45413. */
  45414. refractionTexture: Nullable<BaseTexture>;
  45415. private _indexOfRefraction;
  45416. /**
  45417. * Defines the index of refraction used in the material.
  45418. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45419. */
  45420. indexOfRefraction: number;
  45421. private _invertRefractionY;
  45422. /**
  45423. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45424. */
  45425. invertRefractionY: boolean;
  45426. private _linkRefractionWithTransparency;
  45427. /**
  45428. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45429. * Materials half opaque for instance using refraction could benefit from this control.
  45430. */
  45431. linkRefractionWithTransparency: boolean;
  45432. /**
  45433. * Defines the minimum thickness stored in the thickness map.
  45434. * If no thickness map is defined, this value will be used to simulate thickness.
  45435. */
  45436. minimumThickness: number;
  45437. /**
  45438. * Defines the maximum thickness stored in the thickness map.
  45439. */
  45440. maximumThickness: number;
  45441. /**
  45442. * Defines the volume tint of the material.
  45443. * This is used for both translucency and scattering.
  45444. */
  45445. tintColor: Color3;
  45446. /**
  45447. * Defines the distance at which the tint color should be found in the media.
  45448. * This is used for refraction only.
  45449. */
  45450. tintColorAtDistance: number;
  45451. /**
  45452. * Defines how far each channel transmit through the media.
  45453. * It is defined as a color to simplify it selection.
  45454. */
  45455. diffusionDistance: Color3;
  45456. private _useMaskFromThicknessTexture;
  45457. /**
  45458. * Stores the intensity of the different subsurface effects in the thickness texture.
  45459. * * the green channel is the translucency intensity.
  45460. * * the blue channel is the scattering intensity.
  45461. * * the alpha channel is the refraction intensity.
  45462. */
  45463. useMaskFromThicknessTexture: boolean;
  45464. /** @hidden */
  45465. private _internalMarkAllSubMeshesAsTexturesDirty;
  45466. /** @hidden */
  45467. _markAllSubMeshesAsTexturesDirty(): void;
  45468. /**
  45469. * Instantiate a new istance of sub surface configuration.
  45470. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45471. */
  45472. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45473. /**
  45474. * Gets wehter the submesh is ready to be used or not.
  45475. * @param defines the list of "defines" to update.
  45476. * @param scene defines the scene the material belongs to.
  45477. * @returns - boolean indicating that the submesh is ready or not.
  45478. */
  45479. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45480. /**
  45481. * Checks to see if a texture is used in the material.
  45482. * @param defines the list of "defines" to update.
  45483. * @param scene defines the scene to the material belongs to.
  45484. */
  45485. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45486. /**
  45487. * Binds the material data.
  45488. * @param uniformBuffer defines the Uniform buffer to fill in.
  45489. * @param scene defines the scene the material belongs to.
  45490. * @param engine defines the engine the material belongs to.
  45491. * @param isFrozen defines wether the material is frozen or not.
  45492. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45493. */
  45494. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45495. /**
  45496. * Unbinds the material from the mesh.
  45497. * @param activeEffect defines the effect that should be unbound from.
  45498. * @returns true if unbound, otherwise false
  45499. */
  45500. unbind(activeEffect: Effect): boolean;
  45501. /**
  45502. * Returns the texture used for refraction or null if none is used.
  45503. * @param scene defines the scene the material belongs to.
  45504. * @returns - Refraction texture if present. If no refraction texture and refraction
  45505. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45506. */
  45507. private _getRefractionTexture;
  45508. /**
  45509. * Returns true if alpha blending should be disabled.
  45510. */
  45511. readonly disableAlphaBlending: boolean;
  45512. /**
  45513. * Fills the list of render target textures.
  45514. * @param renderTargets the list of render targets to update
  45515. */
  45516. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45517. /**
  45518. * Checks to see if a texture is used in the material.
  45519. * @param texture - Base texture to use.
  45520. * @returns - Boolean specifying if a texture is used in the material.
  45521. */
  45522. hasTexture(texture: BaseTexture): boolean;
  45523. /**
  45524. * Gets a boolean indicating that current material needs to register RTT
  45525. * @returns true if this uses a render target otherwise false.
  45526. */
  45527. hasRenderTargetTextures(): boolean;
  45528. /**
  45529. * Returns an array of the actively used textures.
  45530. * @param activeTextures Array of BaseTextures
  45531. */
  45532. getActiveTextures(activeTextures: BaseTexture[]): void;
  45533. /**
  45534. * Returns the animatable textures.
  45535. * @param animatables Array of animatable textures.
  45536. */
  45537. getAnimatables(animatables: IAnimatable[]): void;
  45538. /**
  45539. * Disposes the resources of the material.
  45540. * @param forceDisposeTextures - Forces the disposal of all textures.
  45541. */
  45542. dispose(forceDisposeTextures?: boolean): void;
  45543. /**
  45544. * Get the current class name of the texture useful for serialization or dynamic coding.
  45545. * @returns "PBRSubSurfaceConfiguration"
  45546. */
  45547. getClassName(): string;
  45548. /**
  45549. * Add fallbacks to the effect fallbacks list.
  45550. * @param defines defines the Base texture to use.
  45551. * @param fallbacks defines the current fallback list.
  45552. * @param currentRank defines the current fallback rank.
  45553. * @returns the new fallback rank.
  45554. */
  45555. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45556. /**
  45557. * Add the required uniforms to the current list.
  45558. * @param uniforms defines the current uniform list.
  45559. */
  45560. static AddUniforms(uniforms: string[]): void;
  45561. /**
  45562. * Add the required samplers to the current list.
  45563. * @param samplers defines the current sampler list.
  45564. */
  45565. static AddSamplers(samplers: string[]): void;
  45566. /**
  45567. * Add the required uniforms to the current buffer.
  45568. * @param uniformBuffer defines the current uniform buffer.
  45569. */
  45570. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45571. /**
  45572. * Makes a duplicate of the current configuration into another one.
  45573. * @param configuration define the config where to copy the info
  45574. */
  45575. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45576. /**
  45577. * Serializes this Sub Surface configuration.
  45578. * @returns - An object with the serialized config.
  45579. */
  45580. serialize(): any;
  45581. /**
  45582. * Parses a anisotropy Configuration from a serialized object.
  45583. * @param source - Serialized object.
  45584. * @param scene Defines the scene we are parsing for
  45585. * @param rootUrl Defines the rootUrl to load from
  45586. */
  45587. parse(source: any, scene: Scene, rootUrl: string): void;
  45588. }
  45589. }
  45590. declare module BABYLON {
  45591. /** @hidden */
  45592. export var pbrFragmentDeclaration: {
  45593. name: string;
  45594. shader: string;
  45595. };
  45596. }
  45597. declare module BABYLON {
  45598. /** @hidden */
  45599. export var pbrUboDeclaration: {
  45600. name: string;
  45601. shader: string;
  45602. };
  45603. }
  45604. declare module BABYLON {
  45605. /** @hidden */
  45606. export var pbrFragmentExtraDeclaration: {
  45607. name: string;
  45608. shader: string;
  45609. };
  45610. }
  45611. declare module BABYLON {
  45612. /** @hidden */
  45613. export var pbrFragmentSamplersDeclaration: {
  45614. name: string;
  45615. shader: string;
  45616. };
  45617. }
  45618. declare module BABYLON {
  45619. /** @hidden */
  45620. export var pbrHelperFunctions: {
  45621. name: string;
  45622. shader: string;
  45623. };
  45624. }
  45625. declare module BABYLON {
  45626. /** @hidden */
  45627. export var harmonicsFunctions: {
  45628. name: string;
  45629. shader: string;
  45630. };
  45631. }
  45632. declare module BABYLON {
  45633. /** @hidden */
  45634. export var pbrDirectLightingSetupFunctions: {
  45635. name: string;
  45636. shader: string;
  45637. };
  45638. }
  45639. declare module BABYLON {
  45640. /** @hidden */
  45641. export var pbrDirectLightingFalloffFunctions: {
  45642. name: string;
  45643. shader: string;
  45644. };
  45645. }
  45646. declare module BABYLON {
  45647. /** @hidden */
  45648. export var pbrBRDFFunctions: {
  45649. name: string;
  45650. shader: string;
  45651. };
  45652. }
  45653. declare module BABYLON {
  45654. /** @hidden */
  45655. export var pbrDirectLightingFunctions: {
  45656. name: string;
  45657. shader: string;
  45658. };
  45659. }
  45660. declare module BABYLON {
  45661. /** @hidden */
  45662. export var pbrIBLFunctions: {
  45663. name: string;
  45664. shader: string;
  45665. };
  45666. }
  45667. declare module BABYLON {
  45668. /** @hidden */
  45669. export var pbrDebug: {
  45670. name: string;
  45671. shader: string;
  45672. };
  45673. }
  45674. declare module BABYLON {
  45675. /** @hidden */
  45676. export var pbrPixelShader: {
  45677. name: string;
  45678. shader: string;
  45679. };
  45680. }
  45681. declare module BABYLON {
  45682. /** @hidden */
  45683. export var pbrVertexDeclaration: {
  45684. name: string;
  45685. shader: string;
  45686. };
  45687. }
  45688. declare module BABYLON {
  45689. /** @hidden */
  45690. export var pbrVertexShader: {
  45691. name: string;
  45692. shader: string;
  45693. };
  45694. }
  45695. declare module BABYLON {
  45696. /**
  45697. * Manages the defines for the PBR Material.
  45698. * @hidden
  45699. */
  45700. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45701. PBR: boolean;
  45702. MAINUV1: boolean;
  45703. MAINUV2: boolean;
  45704. UV1: boolean;
  45705. UV2: boolean;
  45706. ALBEDO: boolean;
  45707. ALBEDODIRECTUV: number;
  45708. VERTEXCOLOR: boolean;
  45709. AMBIENT: boolean;
  45710. AMBIENTDIRECTUV: number;
  45711. AMBIENTINGRAYSCALE: boolean;
  45712. OPACITY: boolean;
  45713. VERTEXALPHA: boolean;
  45714. OPACITYDIRECTUV: number;
  45715. OPACITYRGB: boolean;
  45716. ALPHATEST: boolean;
  45717. DEPTHPREPASS: boolean;
  45718. ALPHABLEND: boolean;
  45719. ALPHAFROMALBEDO: boolean;
  45720. ALPHATESTVALUE: string;
  45721. SPECULAROVERALPHA: boolean;
  45722. RADIANCEOVERALPHA: boolean;
  45723. ALPHAFRESNEL: boolean;
  45724. LINEARALPHAFRESNEL: boolean;
  45725. PREMULTIPLYALPHA: boolean;
  45726. EMISSIVE: boolean;
  45727. EMISSIVEDIRECTUV: number;
  45728. REFLECTIVITY: boolean;
  45729. REFLECTIVITYDIRECTUV: number;
  45730. SPECULARTERM: boolean;
  45731. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45732. MICROSURFACEAUTOMATIC: boolean;
  45733. LODBASEDMICROSFURACE: boolean;
  45734. MICROSURFACEMAP: boolean;
  45735. MICROSURFACEMAPDIRECTUV: number;
  45736. METALLICWORKFLOW: boolean;
  45737. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45738. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45739. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45740. AOSTOREINMETALMAPRED: boolean;
  45741. ENVIRONMENTBRDF: boolean;
  45742. ENVIRONMENTBRDF_RGBD: boolean;
  45743. NORMAL: boolean;
  45744. TANGENT: boolean;
  45745. BUMP: boolean;
  45746. BUMPDIRECTUV: number;
  45747. OBJECTSPACE_NORMALMAP: boolean;
  45748. PARALLAX: boolean;
  45749. PARALLAXOCCLUSION: boolean;
  45750. NORMALXYSCALE: boolean;
  45751. LIGHTMAP: boolean;
  45752. LIGHTMAPDIRECTUV: number;
  45753. USELIGHTMAPASSHADOWMAP: boolean;
  45754. GAMMALIGHTMAP: boolean;
  45755. REFLECTION: boolean;
  45756. REFLECTIONMAP_3D: boolean;
  45757. REFLECTIONMAP_SPHERICAL: boolean;
  45758. REFLECTIONMAP_PLANAR: boolean;
  45759. REFLECTIONMAP_CUBIC: boolean;
  45760. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45761. REFLECTIONMAP_PROJECTION: boolean;
  45762. REFLECTIONMAP_SKYBOX: boolean;
  45763. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45764. REFLECTIONMAP_EXPLICIT: boolean;
  45765. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45766. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45767. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45768. INVERTCUBICMAP: boolean;
  45769. USESPHERICALFROMREFLECTIONMAP: boolean;
  45770. USEIRRADIANCEMAP: boolean;
  45771. SPHERICAL_HARMONICS: boolean;
  45772. USESPHERICALINVERTEX: boolean;
  45773. REFLECTIONMAP_OPPOSITEZ: boolean;
  45774. LODINREFLECTIONALPHA: boolean;
  45775. GAMMAREFLECTION: boolean;
  45776. RGBDREFLECTION: boolean;
  45777. LINEARSPECULARREFLECTION: boolean;
  45778. RADIANCEOCCLUSION: boolean;
  45779. HORIZONOCCLUSION: boolean;
  45780. INSTANCES: boolean;
  45781. NUM_BONE_INFLUENCERS: number;
  45782. BonesPerMesh: number;
  45783. BONETEXTURE: boolean;
  45784. NONUNIFORMSCALING: boolean;
  45785. MORPHTARGETS: boolean;
  45786. MORPHTARGETS_NORMAL: boolean;
  45787. MORPHTARGETS_TANGENT: boolean;
  45788. MORPHTARGETS_UV: boolean;
  45789. NUM_MORPH_INFLUENCERS: number;
  45790. IMAGEPROCESSING: boolean;
  45791. VIGNETTE: boolean;
  45792. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45793. VIGNETTEBLENDMODEOPAQUE: boolean;
  45794. TONEMAPPING: boolean;
  45795. TONEMAPPING_ACES: boolean;
  45796. CONTRAST: boolean;
  45797. COLORCURVES: boolean;
  45798. COLORGRADING: boolean;
  45799. COLORGRADING3D: boolean;
  45800. SAMPLER3DGREENDEPTH: boolean;
  45801. SAMPLER3DBGRMAP: boolean;
  45802. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45803. EXPOSURE: boolean;
  45804. MULTIVIEW: boolean;
  45805. USEPHYSICALLIGHTFALLOFF: boolean;
  45806. USEGLTFLIGHTFALLOFF: boolean;
  45807. TWOSIDEDLIGHTING: boolean;
  45808. SHADOWFLOAT: boolean;
  45809. CLIPPLANE: boolean;
  45810. CLIPPLANE2: boolean;
  45811. CLIPPLANE3: boolean;
  45812. CLIPPLANE4: boolean;
  45813. POINTSIZE: boolean;
  45814. FOG: boolean;
  45815. LOGARITHMICDEPTH: boolean;
  45816. FORCENORMALFORWARD: boolean;
  45817. SPECULARAA: boolean;
  45818. CLEARCOAT: boolean;
  45819. CLEARCOAT_DEFAULTIOR: boolean;
  45820. CLEARCOAT_TEXTURE: boolean;
  45821. CLEARCOAT_TEXTUREDIRECTUV: number;
  45822. CLEARCOAT_BUMP: boolean;
  45823. CLEARCOAT_BUMPDIRECTUV: number;
  45824. CLEARCOAT_TINT: boolean;
  45825. CLEARCOAT_TINT_TEXTURE: boolean;
  45826. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45827. ANISOTROPIC: boolean;
  45828. ANISOTROPIC_TEXTURE: boolean;
  45829. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45830. BRDF_V_HEIGHT_CORRELATED: boolean;
  45831. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45832. SHEEN: boolean;
  45833. SHEEN_TEXTURE: boolean;
  45834. SHEEN_TEXTUREDIRECTUV: number;
  45835. SHEEN_LINKWITHALBEDO: boolean;
  45836. SUBSURFACE: boolean;
  45837. SS_REFRACTION: boolean;
  45838. SS_TRANSLUCENCY: boolean;
  45839. SS_SCATERRING: boolean;
  45840. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45841. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45842. SS_REFRACTIONMAP_3D: boolean;
  45843. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45844. SS_LODINREFRACTIONALPHA: boolean;
  45845. SS_GAMMAREFRACTION: boolean;
  45846. SS_RGBDREFRACTION: boolean;
  45847. SS_LINEARSPECULARREFRACTION: boolean;
  45848. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45849. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45850. UNLIT: boolean;
  45851. DEBUGMODE: number;
  45852. /**
  45853. * Initializes the PBR Material defines.
  45854. */
  45855. constructor();
  45856. /**
  45857. * Resets the PBR Material defines.
  45858. */
  45859. reset(): void;
  45860. }
  45861. /**
  45862. * The Physically based material base class of BJS.
  45863. *
  45864. * This offers the main features of a standard PBR material.
  45865. * For more information, please refer to the documentation :
  45866. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45867. */
  45868. export abstract class PBRBaseMaterial extends PushMaterial {
  45869. /**
  45870. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45871. */
  45872. static readonly PBRMATERIAL_OPAQUE: number;
  45873. /**
  45874. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45875. */
  45876. static readonly PBRMATERIAL_ALPHATEST: number;
  45877. /**
  45878. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45879. */
  45880. static readonly PBRMATERIAL_ALPHABLEND: number;
  45881. /**
  45882. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45883. * They are also discarded below the alpha cutoff threshold to improve performances.
  45884. */
  45885. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45886. /**
  45887. * Defines the default value of how much AO map is occluding the analytical lights
  45888. * (point spot...).
  45889. */
  45890. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45891. /**
  45892. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45893. */
  45894. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45895. /**
  45896. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45897. * to enhance interoperability with other engines.
  45898. */
  45899. static readonly LIGHTFALLOFF_GLTF: number;
  45900. /**
  45901. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45902. * to enhance interoperability with other materials.
  45903. */
  45904. static readonly LIGHTFALLOFF_STANDARD: number;
  45905. /**
  45906. * Intensity of the direct lights e.g. the four lights available in your scene.
  45907. * This impacts both the direct diffuse and specular highlights.
  45908. */
  45909. protected _directIntensity: number;
  45910. /**
  45911. * Intensity of the emissive part of the material.
  45912. * This helps controlling the emissive effect without modifying the emissive color.
  45913. */
  45914. protected _emissiveIntensity: number;
  45915. /**
  45916. * Intensity of the environment e.g. how much the environment will light the object
  45917. * either through harmonics for rough material or through the refelction for shiny ones.
  45918. */
  45919. protected _environmentIntensity: number;
  45920. /**
  45921. * This is a special control allowing the reduction of the specular highlights coming from the
  45922. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45923. */
  45924. protected _specularIntensity: number;
  45925. /**
  45926. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45927. */
  45928. private _lightingInfos;
  45929. /**
  45930. * Debug Control allowing disabling the bump map on this material.
  45931. */
  45932. protected _disableBumpMap: boolean;
  45933. /**
  45934. * AKA Diffuse Texture in standard nomenclature.
  45935. */
  45936. protected _albedoTexture: Nullable<BaseTexture>;
  45937. /**
  45938. * AKA Occlusion Texture in other nomenclature.
  45939. */
  45940. protected _ambientTexture: Nullable<BaseTexture>;
  45941. /**
  45942. * AKA Occlusion Texture Intensity in other nomenclature.
  45943. */
  45944. protected _ambientTextureStrength: number;
  45945. /**
  45946. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45947. * 1 means it completely occludes it
  45948. * 0 mean it has no impact
  45949. */
  45950. protected _ambientTextureImpactOnAnalyticalLights: number;
  45951. /**
  45952. * Stores the alpha values in a texture.
  45953. */
  45954. protected _opacityTexture: Nullable<BaseTexture>;
  45955. /**
  45956. * Stores the reflection values in a texture.
  45957. */
  45958. protected _reflectionTexture: Nullable<BaseTexture>;
  45959. /**
  45960. * Stores the emissive values in a texture.
  45961. */
  45962. protected _emissiveTexture: Nullable<BaseTexture>;
  45963. /**
  45964. * AKA Specular texture in other nomenclature.
  45965. */
  45966. protected _reflectivityTexture: Nullable<BaseTexture>;
  45967. /**
  45968. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45969. */
  45970. protected _metallicTexture: Nullable<BaseTexture>;
  45971. /**
  45972. * Specifies the metallic scalar of the metallic/roughness workflow.
  45973. * Can also be used to scale the metalness values of the metallic texture.
  45974. */
  45975. protected _metallic: Nullable<number>;
  45976. /**
  45977. * Specifies the roughness scalar of the metallic/roughness workflow.
  45978. * Can also be used to scale the roughness values of the metallic texture.
  45979. */
  45980. protected _roughness: Nullable<number>;
  45981. /**
  45982. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45983. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45984. */
  45985. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45986. /**
  45987. * Stores surface normal data used to displace a mesh in a texture.
  45988. */
  45989. protected _bumpTexture: Nullable<BaseTexture>;
  45990. /**
  45991. * Stores the pre-calculated light information of a mesh in a texture.
  45992. */
  45993. protected _lightmapTexture: Nullable<BaseTexture>;
  45994. /**
  45995. * The color of a material in ambient lighting.
  45996. */
  45997. protected _ambientColor: Color3;
  45998. /**
  45999. * AKA Diffuse Color in other nomenclature.
  46000. */
  46001. protected _albedoColor: Color3;
  46002. /**
  46003. * AKA Specular Color in other nomenclature.
  46004. */
  46005. protected _reflectivityColor: Color3;
  46006. /**
  46007. * The color applied when light is reflected from a material.
  46008. */
  46009. protected _reflectionColor: Color3;
  46010. /**
  46011. * The color applied when light is emitted from a material.
  46012. */
  46013. protected _emissiveColor: Color3;
  46014. /**
  46015. * AKA Glossiness in other nomenclature.
  46016. */
  46017. protected _microSurface: number;
  46018. /**
  46019. * Specifies that the material will use the light map as a show map.
  46020. */
  46021. protected _useLightmapAsShadowmap: boolean;
  46022. /**
  46023. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46024. * makes the reflect vector face the model (under horizon).
  46025. */
  46026. protected _useHorizonOcclusion: boolean;
  46027. /**
  46028. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46029. * too much the area relying on ambient texture to define their ambient occlusion.
  46030. */
  46031. protected _useRadianceOcclusion: boolean;
  46032. /**
  46033. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46034. */
  46035. protected _useAlphaFromAlbedoTexture: boolean;
  46036. /**
  46037. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46038. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46039. */
  46040. protected _useSpecularOverAlpha: boolean;
  46041. /**
  46042. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46043. */
  46044. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46045. /**
  46046. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46047. */
  46048. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46049. /**
  46050. * Specifies if the metallic texture contains the roughness information in its green channel.
  46051. */
  46052. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46053. /**
  46054. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46055. */
  46056. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46057. /**
  46058. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46059. */
  46060. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46061. /**
  46062. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46063. */
  46064. protected _useAmbientInGrayScale: boolean;
  46065. /**
  46066. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46067. * The material will try to infer what glossiness each pixel should be.
  46068. */
  46069. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46070. /**
  46071. * Defines the falloff type used in this material.
  46072. * It by default is Physical.
  46073. */
  46074. protected _lightFalloff: number;
  46075. /**
  46076. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46077. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46078. */
  46079. protected _useRadianceOverAlpha: boolean;
  46080. /**
  46081. * Allows using an object space normal map (instead of tangent space).
  46082. */
  46083. protected _useObjectSpaceNormalMap: boolean;
  46084. /**
  46085. * Allows using the bump map in parallax mode.
  46086. */
  46087. protected _useParallax: boolean;
  46088. /**
  46089. * Allows using the bump map in parallax occlusion mode.
  46090. */
  46091. protected _useParallaxOcclusion: boolean;
  46092. /**
  46093. * Controls the scale bias of the parallax mode.
  46094. */
  46095. protected _parallaxScaleBias: number;
  46096. /**
  46097. * If sets to true, disables all the lights affecting the material.
  46098. */
  46099. protected _disableLighting: boolean;
  46100. /**
  46101. * Number of Simultaneous lights allowed on the material.
  46102. */
  46103. protected _maxSimultaneousLights: number;
  46104. /**
  46105. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46106. */
  46107. protected _invertNormalMapX: boolean;
  46108. /**
  46109. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46110. */
  46111. protected _invertNormalMapY: boolean;
  46112. /**
  46113. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46114. */
  46115. protected _twoSidedLighting: boolean;
  46116. /**
  46117. * Defines the alpha limits in alpha test mode.
  46118. */
  46119. protected _alphaCutOff: number;
  46120. /**
  46121. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46122. */
  46123. protected _forceAlphaTest: boolean;
  46124. /**
  46125. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46126. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46127. */
  46128. protected _useAlphaFresnel: boolean;
  46129. /**
  46130. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46131. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46132. */
  46133. protected _useLinearAlphaFresnel: boolean;
  46134. /**
  46135. * The transparency mode of the material.
  46136. */
  46137. protected _transparencyMode: Nullable<number>;
  46138. /**
  46139. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46140. * from cos thetav and roughness:
  46141. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46142. */
  46143. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46144. /**
  46145. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46146. */
  46147. protected _forceIrradianceInFragment: boolean;
  46148. /**
  46149. * Force normal to face away from face.
  46150. */
  46151. protected _forceNormalForward: boolean;
  46152. /**
  46153. * Enables specular anti aliasing in the PBR shader.
  46154. * It will both interacts on the Geometry for analytical and IBL lighting.
  46155. * It also prefilter the roughness map based on the bump values.
  46156. */
  46157. protected _enableSpecularAntiAliasing: boolean;
  46158. /**
  46159. * Default configuration related to image processing available in the PBR Material.
  46160. */
  46161. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46162. /**
  46163. * Keep track of the image processing observer to allow dispose and replace.
  46164. */
  46165. private _imageProcessingObserver;
  46166. /**
  46167. * Attaches a new image processing configuration to the PBR Material.
  46168. * @param configuration
  46169. */
  46170. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46171. /**
  46172. * Stores the available render targets.
  46173. */
  46174. private _renderTargets;
  46175. /**
  46176. * Sets the global ambient color for the material used in lighting calculations.
  46177. */
  46178. private _globalAmbientColor;
  46179. /**
  46180. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46181. */
  46182. private _useLogarithmicDepth;
  46183. /**
  46184. * If set to true, no lighting calculations will be applied.
  46185. */
  46186. private _unlit;
  46187. private _debugMode;
  46188. /**
  46189. * @hidden
  46190. * This is reserved for the inspector.
  46191. * Defines the material debug mode.
  46192. * It helps seeing only some components of the material while troubleshooting.
  46193. */
  46194. debugMode: number;
  46195. /**
  46196. * @hidden
  46197. * This is reserved for the inspector.
  46198. * Specify from where on screen the debug mode should start.
  46199. * The value goes from -1 (full screen) to 1 (not visible)
  46200. * It helps with side by side comparison against the final render
  46201. * This defaults to -1
  46202. */
  46203. private debugLimit;
  46204. /**
  46205. * @hidden
  46206. * This is reserved for the inspector.
  46207. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46208. * You can use the factor to better multiply the final value.
  46209. */
  46210. private debugFactor;
  46211. /**
  46212. * Defines the clear coat layer parameters for the material.
  46213. */
  46214. readonly clearCoat: PBRClearCoatConfiguration;
  46215. /**
  46216. * Defines the anisotropic parameters for the material.
  46217. */
  46218. readonly anisotropy: PBRAnisotropicConfiguration;
  46219. /**
  46220. * Defines the BRDF parameters for the material.
  46221. */
  46222. readonly brdf: PBRBRDFConfiguration;
  46223. /**
  46224. * Defines the Sheen parameters for the material.
  46225. */
  46226. readonly sheen: PBRSheenConfiguration;
  46227. /**
  46228. * Defines the SubSurface parameters for the material.
  46229. */
  46230. readonly subSurface: PBRSubSurfaceConfiguration;
  46231. /**
  46232. * Custom callback helping to override the default shader used in the material.
  46233. */
  46234. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46235. /**
  46236. * Instantiates a new PBRMaterial instance.
  46237. *
  46238. * @param name The material name
  46239. * @param scene The scene the material will be use in.
  46240. */
  46241. constructor(name: string, scene: Scene);
  46242. /**
  46243. * Gets a boolean indicating that current material needs to register RTT
  46244. */
  46245. readonly hasRenderTargetTextures: boolean;
  46246. /**
  46247. * Gets the name of the material class.
  46248. */
  46249. getClassName(): string;
  46250. /**
  46251. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46252. */
  46253. /**
  46254. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46255. */
  46256. useLogarithmicDepth: boolean;
  46257. /**
  46258. * Gets the current transparency mode.
  46259. */
  46260. /**
  46261. * Sets the transparency mode of the material.
  46262. *
  46263. * | Value | Type | Description |
  46264. * | ----- | ----------------------------------- | ----------- |
  46265. * | 0 | OPAQUE | |
  46266. * | 1 | ALPHATEST | |
  46267. * | 2 | ALPHABLEND | |
  46268. * | 3 | ALPHATESTANDBLEND | |
  46269. *
  46270. */
  46271. transparencyMode: Nullable<number>;
  46272. /**
  46273. * Returns true if alpha blending should be disabled.
  46274. */
  46275. private readonly _disableAlphaBlending;
  46276. /**
  46277. * Specifies whether or not this material should be rendered in alpha blend mode.
  46278. */
  46279. needAlphaBlending(): boolean;
  46280. /**
  46281. * Specifies if the mesh will require alpha blending.
  46282. * @param mesh - BJS mesh.
  46283. */
  46284. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46285. /**
  46286. * Specifies whether or not this material should be rendered in alpha test mode.
  46287. */
  46288. needAlphaTesting(): boolean;
  46289. /**
  46290. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46291. */
  46292. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46293. /**
  46294. * Gets the texture used for the alpha test.
  46295. */
  46296. getAlphaTestTexture(): Nullable<BaseTexture>;
  46297. /**
  46298. * Specifies that the submesh is ready to be used.
  46299. * @param mesh - BJS mesh.
  46300. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46301. * @param useInstances - Specifies that instances should be used.
  46302. * @returns - boolean indicating that the submesh is ready or not.
  46303. */
  46304. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46305. /**
  46306. * Specifies if the material uses metallic roughness workflow.
  46307. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46308. */
  46309. isMetallicWorkflow(): boolean;
  46310. private _prepareEffect;
  46311. private _prepareDefines;
  46312. /**
  46313. * Force shader compilation
  46314. */
  46315. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46316. clipPlane: boolean;
  46317. }>): void;
  46318. /**
  46319. * Initializes the uniform buffer layout for the shader.
  46320. */
  46321. buildUniformLayout(): void;
  46322. /**
  46323. * Unbinds the material from the mesh
  46324. */
  46325. unbind(): void;
  46326. /**
  46327. * Binds the submesh data.
  46328. * @param world - The world matrix.
  46329. * @param mesh - The BJS mesh.
  46330. * @param subMesh - A submesh of the BJS mesh.
  46331. */
  46332. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46333. /**
  46334. * Returns the animatable textures.
  46335. * @returns - Array of animatable textures.
  46336. */
  46337. getAnimatables(): IAnimatable[];
  46338. /**
  46339. * Returns the texture used for reflections.
  46340. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46341. */
  46342. private _getReflectionTexture;
  46343. /**
  46344. * Returns an array of the actively used textures.
  46345. * @returns - Array of BaseTextures
  46346. */
  46347. getActiveTextures(): BaseTexture[];
  46348. /**
  46349. * Checks to see if a texture is used in the material.
  46350. * @param texture - Base texture to use.
  46351. * @returns - Boolean specifying if a texture is used in the material.
  46352. */
  46353. hasTexture(texture: BaseTexture): boolean;
  46354. /**
  46355. * Disposes the resources of the material.
  46356. * @param forceDisposeEffect - Forces the disposal of effects.
  46357. * @param forceDisposeTextures - Forces the disposal of all textures.
  46358. */
  46359. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46360. }
  46361. }
  46362. declare module BABYLON {
  46363. /**
  46364. * The Physically based material of BJS.
  46365. *
  46366. * This offers the main features of a standard PBR material.
  46367. * For more information, please refer to the documentation :
  46368. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46369. */
  46370. export class PBRMaterial extends PBRBaseMaterial {
  46371. /**
  46372. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46373. */
  46374. static readonly PBRMATERIAL_OPAQUE: number;
  46375. /**
  46376. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46377. */
  46378. static readonly PBRMATERIAL_ALPHATEST: number;
  46379. /**
  46380. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46381. */
  46382. static readonly PBRMATERIAL_ALPHABLEND: number;
  46383. /**
  46384. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46385. * They are also discarded below the alpha cutoff threshold to improve performances.
  46386. */
  46387. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46388. /**
  46389. * Defines the default value of how much AO map is occluding the analytical lights
  46390. * (point spot...).
  46391. */
  46392. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46393. /**
  46394. * Intensity of the direct lights e.g. the four lights available in your scene.
  46395. * This impacts both the direct diffuse and specular highlights.
  46396. */
  46397. directIntensity: number;
  46398. /**
  46399. * Intensity of the emissive part of the material.
  46400. * This helps controlling the emissive effect without modifying the emissive color.
  46401. */
  46402. emissiveIntensity: number;
  46403. /**
  46404. * Intensity of the environment e.g. how much the environment will light the object
  46405. * either through harmonics for rough material or through the refelction for shiny ones.
  46406. */
  46407. environmentIntensity: number;
  46408. /**
  46409. * This is a special control allowing the reduction of the specular highlights coming from the
  46410. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46411. */
  46412. specularIntensity: number;
  46413. /**
  46414. * Debug Control allowing disabling the bump map on this material.
  46415. */
  46416. disableBumpMap: boolean;
  46417. /**
  46418. * AKA Diffuse Texture in standard nomenclature.
  46419. */
  46420. albedoTexture: BaseTexture;
  46421. /**
  46422. * AKA Occlusion Texture in other nomenclature.
  46423. */
  46424. ambientTexture: BaseTexture;
  46425. /**
  46426. * AKA Occlusion Texture Intensity in other nomenclature.
  46427. */
  46428. ambientTextureStrength: number;
  46429. /**
  46430. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46431. * 1 means it completely occludes it
  46432. * 0 mean it has no impact
  46433. */
  46434. ambientTextureImpactOnAnalyticalLights: number;
  46435. /**
  46436. * Stores the alpha values in a texture.
  46437. */
  46438. opacityTexture: BaseTexture;
  46439. /**
  46440. * Stores the reflection values in a texture.
  46441. */
  46442. reflectionTexture: Nullable<BaseTexture>;
  46443. /**
  46444. * Stores the emissive values in a texture.
  46445. */
  46446. emissiveTexture: BaseTexture;
  46447. /**
  46448. * AKA Specular texture in other nomenclature.
  46449. */
  46450. reflectivityTexture: BaseTexture;
  46451. /**
  46452. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46453. */
  46454. metallicTexture: BaseTexture;
  46455. /**
  46456. * Specifies the metallic scalar of the metallic/roughness workflow.
  46457. * Can also be used to scale the metalness values of the metallic texture.
  46458. */
  46459. metallic: Nullable<number>;
  46460. /**
  46461. * Specifies the roughness scalar of the metallic/roughness workflow.
  46462. * Can also be used to scale the roughness values of the metallic texture.
  46463. */
  46464. roughness: Nullable<number>;
  46465. /**
  46466. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46467. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46468. */
  46469. microSurfaceTexture: BaseTexture;
  46470. /**
  46471. * Stores surface normal data used to displace a mesh in a texture.
  46472. */
  46473. bumpTexture: BaseTexture;
  46474. /**
  46475. * Stores the pre-calculated light information of a mesh in a texture.
  46476. */
  46477. lightmapTexture: BaseTexture;
  46478. /**
  46479. * Stores the refracted light information in a texture.
  46480. */
  46481. refractionTexture: Nullable<BaseTexture>;
  46482. /**
  46483. * The color of a material in ambient lighting.
  46484. */
  46485. ambientColor: Color3;
  46486. /**
  46487. * AKA Diffuse Color in other nomenclature.
  46488. */
  46489. albedoColor: Color3;
  46490. /**
  46491. * AKA Specular Color in other nomenclature.
  46492. */
  46493. reflectivityColor: Color3;
  46494. /**
  46495. * The color reflected from the material.
  46496. */
  46497. reflectionColor: Color3;
  46498. /**
  46499. * The color emitted from the material.
  46500. */
  46501. emissiveColor: Color3;
  46502. /**
  46503. * AKA Glossiness in other nomenclature.
  46504. */
  46505. microSurface: number;
  46506. /**
  46507. * source material index of refraction (IOR)' / 'destination material IOR.
  46508. */
  46509. indexOfRefraction: number;
  46510. /**
  46511. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46512. */
  46513. invertRefractionY: boolean;
  46514. /**
  46515. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46516. * Materials half opaque for instance using refraction could benefit from this control.
  46517. */
  46518. linkRefractionWithTransparency: boolean;
  46519. /**
  46520. * If true, the light map contains occlusion information instead of lighting info.
  46521. */
  46522. useLightmapAsShadowmap: boolean;
  46523. /**
  46524. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46525. */
  46526. useAlphaFromAlbedoTexture: boolean;
  46527. /**
  46528. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46529. */
  46530. forceAlphaTest: boolean;
  46531. /**
  46532. * Defines the alpha limits in alpha test mode.
  46533. */
  46534. alphaCutOff: number;
  46535. /**
  46536. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46537. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46538. */
  46539. useSpecularOverAlpha: boolean;
  46540. /**
  46541. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46542. */
  46543. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46544. /**
  46545. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46546. */
  46547. useRoughnessFromMetallicTextureAlpha: boolean;
  46548. /**
  46549. * Specifies if the metallic texture contains the roughness information in its green channel.
  46550. */
  46551. useRoughnessFromMetallicTextureGreen: boolean;
  46552. /**
  46553. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46554. */
  46555. useMetallnessFromMetallicTextureBlue: boolean;
  46556. /**
  46557. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46558. */
  46559. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46560. /**
  46561. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46562. */
  46563. useAmbientInGrayScale: boolean;
  46564. /**
  46565. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46566. * The material will try to infer what glossiness each pixel should be.
  46567. */
  46568. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46569. /**
  46570. * BJS is using an harcoded light falloff based on a manually sets up range.
  46571. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46572. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46573. */
  46574. /**
  46575. * BJS is using an harcoded light falloff based on a manually sets up range.
  46576. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46577. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46578. */
  46579. usePhysicalLightFalloff: boolean;
  46580. /**
  46581. * In order to support the falloff compatibility with gltf, a special mode has been added
  46582. * to reproduce the gltf light falloff.
  46583. */
  46584. /**
  46585. * In order to support the falloff compatibility with gltf, a special mode has been added
  46586. * to reproduce the gltf light falloff.
  46587. */
  46588. useGLTFLightFalloff: boolean;
  46589. /**
  46590. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46591. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46592. */
  46593. useRadianceOverAlpha: boolean;
  46594. /**
  46595. * Allows using an object space normal map (instead of tangent space).
  46596. */
  46597. useObjectSpaceNormalMap: boolean;
  46598. /**
  46599. * Allows using the bump map in parallax mode.
  46600. */
  46601. useParallax: boolean;
  46602. /**
  46603. * Allows using the bump map in parallax occlusion mode.
  46604. */
  46605. useParallaxOcclusion: boolean;
  46606. /**
  46607. * Controls the scale bias of the parallax mode.
  46608. */
  46609. parallaxScaleBias: number;
  46610. /**
  46611. * If sets to true, disables all the lights affecting the material.
  46612. */
  46613. disableLighting: boolean;
  46614. /**
  46615. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46616. */
  46617. forceIrradianceInFragment: boolean;
  46618. /**
  46619. * Number of Simultaneous lights allowed on the material.
  46620. */
  46621. maxSimultaneousLights: number;
  46622. /**
  46623. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46624. */
  46625. invertNormalMapX: boolean;
  46626. /**
  46627. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46628. */
  46629. invertNormalMapY: boolean;
  46630. /**
  46631. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46632. */
  46633. twoSidedLighting: boolean;
  46634. /**
  46635. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46636. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46637. */
  46638. useAlphaFresnel: boolean;
  46639. /**
  46640. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46641. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46642. */
  46643. useLinearAlphaFresnel: boolean;
  46644. /**
  46645. * Let user defines the brdf lookup texture used for IBL.
  46646. * A default 8bit version is embedded but you could point at :
  46647. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  46648. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46649. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  46650. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46651. */
  46652. environmentBRDFTexture: Nullable<BaseTexture>;
  46653. /**
  46654. * Force normal to face away from face.
  46655. */
  46656. forceNormalForward: boolean;
  46657. /**
  46658. * Enables specular anti aliasing in the PBR shader.
  46659. * It will both interacts on the Geometry for analytical and IBL lighting.
  46660. * It also prefilter the roughness map based on the bump values.
  46661. */
  46662. enableSpecularAntiAliasing: boolean;
  46663. /**
  46664. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46665. * makes the reflect vector face the model (under horizon).
  46666. */
  46667. useHorizonOcclusion: boolean;
  46668. /**
  46669. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46670. * too much the area relying on ambient texture to define their ambient occlusion.
  46671. */
  46672. useRadianceOcclusion: boolean;
  46673. /**
  46674. * If set to true, no lighting calculations will be applied.
  46675. */
  46676. unlit: boolean;
  46677. /**
  46678. * Gets the image processing configuration used either in this material.
  46679. */
  46680. /**
  46681. * Sets the Default image processing configuration used either in the this material.
  46682. *
  46683. * If sets to null, the scene one is in use.
  46684. */
  46685. imageProcessingConfiguration: ImageProcessingConfiguration;
  46686. /**
  46687. * Gets wether the color curves effect is enabled.
  46688. */
  46689. /**
  46690. * Sets wether the color curves effect is enabled.
  46691. */
  46692. cameraColorCurvesEnabled: boolean;
  46693. /**
  46694. * Gets wether the color grading effect is enabled.
  46695. */
  46696. /**
  46697. * Gets wether the color grading effect is enabled.
  46698. */
  46699. cameraColorGradingEnabled: boolean;
  46700. /**
  46701. * Gets wether tonemapping is enabled or not.
  46702. */
  46703. /**
  46704. * Sets wether tonemapping is enabled or not
  46705. */
  46706. cameraToneMappingEnabled: boolean;
  46707. /**
  46708. * The camera exposure used on this material.
  46709. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46710. * This corresponds to a photographic exposure.
  46711. */
  46712. /**
  46713. * The camera exposure used on this material.
  46714. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46715. * This corresponds to a photographic exposure.
  46716. */
  46717. cameraExposure: number;
  46718. /**
  46719. * Gets The camera contrast used on this material.
  46720. */
  46721. /**
  46722. * Sets The camera contrast used on this material.
  46723. */
  46724. cameraContrast: number;
  46725. /**
  46726. * Gets the Color Grading 2D Lookup Texture.
  46727. */
  46728. /**
  46729. * Sets the Color Grading 2D Lookup Texture.
  46730. */
  46731. cameraColorGradingTexture: Nullable<BaseTexture>;
  46732. /**
  46733. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46734. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46735. * 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;
  46736. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46737. */
  46738. /**
  46739. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46740. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46741. * 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;
  46742. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46743. */
  46744. cameraColorCurves: Nullable<ColorCurves>;
  46745. /**
  46746. * Instantiates a new PBRMaterial instance.
  46747. *
  46748. * @param name The material name
  46749. * @param scene The scene the material will be use in.
  46750. */
  46751. constructor(name: string, scene: Scene);
  46752. /**
  46753. * Returns the name of this material class.
  46754. */
  46755. getClassName(): string;
  46756. /**
  46757. * Makes a duplicate of the current material.
  46758. * @param name - name to use for the new material.
  46759. */
  46760. clone(name: string): PBRMaterial;
  46761. /**
  46762. * Serializes this PBR Material.
  46763. * @returns - An object with the serialized material.
  46764. */
  46765. serialize(): any;
  46766. /**
  46767. * Parses a PBR Material from a serialized object.
  46768. * @param source - Serialized object.
  46769. * @param scene - BJS scene instance.
  46770. * @param rootUrl - url for the scene object
  46771. * @returns - PBRMaterial
  46772. */
  46773. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46774. }
  46775. }
  46776. declare module BABYLON {
  46777. /**
  46778. * Direct draw surface info
  46779. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46780. */
  46781. export interface DDSInfo {
  46782. /**
  46783. * Width of the texture
  46784. */
  46785. width: number;
  46786. /**
  46787. * Width of the texture
  46788. */
  46789. height: number;
  46790. /**
  46791. * Number of Mipmaps for the texture
  46792. * @see https://en.wikipedia.org/wiki/Mipmap
  46793. */
  46794. mipmapCount: number;
  46795. /**
  46796. * If the textures format is a known fourCC format
  46797. * @see https://www.fourcc.org/
  46798. */
  46799. isFourCC: boolean;
  46800. /**
  46801. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46802. */
  46803. isRGB: boolean;
  46804. /**
  46805. * If the texture is a lumincance format
  46806. */
  46807. isLuminance: boolean;
  46808. /**
  46809. * If this is a cube texture
  46810. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46811. */
  46812. isCube: boolean;
  46813. /**
  46814. * If the texture is a compressed format eg. FOURCC_DXT1
  46815. */
  46816. isCompressed: boolean;
  46817. /**
  46818. * The dxgiFormat of the texture
  46819. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46820. */
  46821. dxgiFormat: number;
  46822. /**
  46823. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46824. */
  46825. textureType: number;
  46826. /**
  46827. * Sphericle polynomial created for the dds texture
  46828. */
  46829. sphericalPolynomial?: SphericalPolynomial;
  46830. }
  46831. /**
  46832. * Class used to provide DDS decompression tools
  46833. */
  46834. export class DDSTools {
  46835. /**
  46836. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46837. */
  46838. static StoreLODInAlphaChannel: boolean;
  46839. /**
  46840. * Gets DDS information from an array buffer
  46841. * @param arrayBuffer defines the array buffer to read data from
  46842. * @returns the DDS information
  46843. */
  46844. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46845. private static _FloatView;
  46846. private static _Int32View;
  46847. private static _ToHalfFloat;
  46848. private static _FromHalfFloat;
  46849. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46850. private static _GetHalfFloatRGBAArrayBuffer;
  46851. private static _GetFloatRGBAArrayBuffer;
  46852. private static _GetFloatAsUIntRGBAArrayBuffer;
  46853. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46854. private static _GetRGBAArrayBuffer;
  46855. private static _ExtractLongWordOrder;
  46856. private static _GetRGBArrayBuffer;
  46857. private static _GetLuminanceArrayBuffer;
  46858. /**
  46859. * Uploads DDS Levels to a Babylon Texture
  46860. * @hidden
  46861. */
  46862. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46863. }
  46864. interface Engine {
  46865. /**
  46866. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46867. * @param rootUrl defines the url where the file to load is located
  46868. * @param scene defines the current scene
  46869. * @param lodScale defines scale to apply to the mip map selection
  46870. * @param lodOffset defines offset to apply to the mip map selection
  46871. * @param onLoad defines an optional callback raised when the texture is loaded
  46872. * @param onError defines an optional callback raised if there is an issue to load the texture
  46873. * @param format defines the format of the data
  46874. * @param forcedExtension defines the extension to use to pick the right loader
  46875. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46876. * @returns the cube texture as an InternalTexture
  46877. */
  46878. 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;
  46879. }
  46880. }
  46881. declare module BABYLON {
  46882. /**
  46883. * Implementation of the DDS Texture Loader.
  46884. * @hidden
  46885. */
  46886. export class _DDSTextureLoader implements IInternalTextureLoader {
  46887. /**
  46888. * Defines wether the loader supports cascade loading the different faces.
  46889. */
  46890. readonly supportCascades: boolean;
  46891. /**
  46892. * This returns if the loader support the current file information.
  46893. * @param extension defines the file extension of the file being loaded
  46894. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46895. * @param fallback defines the fallback internal texture if any
  46896. * @param isBase64 defines whether the texture is encoded as a base64
  46897. * @param isBuffer defines whether the texture data are stored as a buffer
  46898. * @returns true if the loader can load the specified file
  46899. */
  46900. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46901. /**
  46902. * Transform the url before loading if required.
  46903. * @param rootUrl the url of the texture
  46904. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46905. * @returns the transformed texture
  46906. */
  46907. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46908. /**
  46909. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46910. * @param rootUrl the url of the texture
  46911. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46912. * @returns the fallback texture
  46913. */
  46914. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46915. /**
  46916. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46917. * @param data contains the texture data
  46918. * @param texture defines the BabylonJS internal texture
  46919. * @param createPolynomials will be true if polynomials have been requested
  46920. * @param onLoad defines the callback to trigger once the texture is ready
  46921. * @param onError defines the callback to trigger in case of error
  46922. */
  46923. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46924. /**
  46925. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46926. * @param data contains the texture data
  46927. * @param texture defines the BabylonJS internal texture
  46928. * @param callback defines the method to call once ready to upload
  46929. */
  46930. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46931. }
  46932. }
  46933. declare module BABYLON {
  46934. /** @hidden */
  46935. export var rgbdEncodePixelShader: {
  46936. name: string;
  46937. shader: string;
  46938. };
  46939. }
  46940. declare module BABYLON {
  46941. /**
  46942. * Raw texture data and descriptor sufficient for WebGL texture upload
  46943. */
  46944. export interface EnvironmentTextureInfo {
  46945. /**
  46946. * Version of the environment map
  46947. */
  46948. version: number;
  46949. /**
  46950. * Width of image
  46951. */
  46952. width: number;
  46953. /**
  46954. * Irradiance information stored in the file.
  46955. */
  46956. irradiance: any;
  46957. /**
  46958. * Specular information stored in the file.
  46959. */
  46960. specular: any;
  46961. }
  46962. /**
  46963. * Sets of helpers addressing the serialization and deserialization of environment texture
  46964. * stored in a BabylonJS env file.
  46965. * Those files are usually stored as .env files.
  46966. */
  46967. export class EnvironmentTextureTools {
  46968. /**
  46969. * Magic number identifying the env file.
  46970. */
  46971. private static _MagicBytes;
  46972. /**
  46973. * Gets the environment info from an env file.
  46974. * @param data The array buffer containing the .env bytes.
  46975. * @returns the environment file info (the json header) if successfully parsed.
  46976. */
  46977. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46978. /**
  46979. * Creates an environment texture from a loaded cube texture.
  46980. * @param texture defines the cube texture to convert in env file
  46981. * @return a promise containing the environment data if succesfull.
  46982. */
  46983. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46984. /**
  46985. * Creates a JSON representation of the spherical data.
  46986. * @param texture defines the texture containing the polynomials
  46987. * @return the JSON representation of the spherical info
  46988. */
  46989. private static _CreateEnvTextureIrradiance;
  46990. /**
  46991. * Uploads the texture info contained in the env file to the GPU.
  46992. * @param texture defines the internal texture to upload to
  46993. * @param arrayBuffer defines the buffer cotaining the data to load
  46994. * @param info defines the texture info retrieved through the GetEnvInfo method
  46995. * @returns a promise
  46996. */
  46997. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46998. /**
  46999. * Uploads the levels of image data to the GPU.
  47000. * @param texture defines the internal texture to upload to
  47001. * @param imageData defines the array buffer views of image data [mipmap][face]
  47002. * @returns a promise
  47003. */
  47004. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47005. /**
  47006. * Uploads spherical polynomials information to the texture.
  47007. * @param texture defines the texture we are trying to upload the information to
  47008. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47009. */
  47010. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47011. /** @hidden */
  47012. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47013. }
  47014. }
  47015. declare module BABYLON {
  47016. /**
  47017. * Implementation of the ENV Texture Loader.
  47018. * @hidden
  47019. */
  47020. export class _ENVTextureLoader implements IInternalTextureLoader {
  47021. /**
  47022. * Defines wether the loader supports cascade loading the different faces.
  47023. */
  47024. readonly supportCascades: boolean;
  47025. /**
  47026. * This returns if the loader support the current file information.
  47027. * @param extension defines the file extension of the file being loaded
  47028. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47029. * @param fallback defines the fallback internal texture if any
  47030. * @param isBase64 defines whether the texture is encoded as a base64
  47031. * @param isBuffer defines whether the texture data are stored as a buffer
  47032. * @returns true if the loader can load the specified file
  47033. */
  47034. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47035. /**
  47036. * Transform the url before loading if required.
  47037. * @param rootUrl the url of the texture
  47038. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47039. * @returns the transformed texture
  47040. */
  47041. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47042. /**
  47043. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47044. * @param rootUrl the url of the texture
  47045. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47046. * @returns the fallback texture
  47047. */
  47048. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47049. /**
  47050. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47051. * @param data contains the texture data
  47052. * @param texture defines the BabylonJS internal texture
  47053. * @param createPolynomials will be true if polynomials have been requested
  47054. * @param onLoad defines the callback to trigger once the texture is ready
  47055. * @param onError defines the callback to trigger in case of error
  47056. */
  47057. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47058. /**
  47059. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47060. * @param data contains the texture data
  47061. * @param texture defines the BabylonJS internal texture
  47062. * @param callback defines the method to call once ready to upload
  47063. */
  47064. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47065. }
  47066. }
  47067. declare module BABYLON {
  47068. /**
  47069. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47070. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47071. */
  47072. export class KhronosTextureContainer {
  47073. /** contents of the KTX container file */
  47074. arrayBuffer: any;
  47075. private static HEADER_LEN;
  47076. private static COMPRESSED_2D;
  47077. private static COMPRESSED_3D;
  47078. private static TEX_2D;
  47079. private static TEX_3D;
  47080. /**
  47081. * Gets the openGL type
  47082. */
  47083. glType: number;
  47084. /**
  47085. * Gets the openGL type size
  47086. */
  47087. glTypeSize: number;
  47088. /**
  47089. * Gets the openGL format
  47090. */
  47091. glFormat: number;
  47092. /**
  47093. * Gets the openGL internal format
  47094. */
  47095. glInternalFormat: number;
  47096. /**
  47097. * Gets the base internal format
  47098. */
  47099. glBaseInternalFormat: number;
  47100. /**
  47101. * Gets image width in pixel
  47102. */
  47103. pixelWidth: number;
  47104. /**
  47105. * Gets image height in pixel
  47106. */
  47107. pixelHeight: number;
  47108. /**
  47109. * Gets image depth in pixels
  47110. */
  47111. pixelDepth: number;
  47112. /**
  47113. * Gets the number of array elements
  47114. */
  47115. numberOfArrayElements: number;
  47116. /**
  47117. * Gets the number of faces
  47118. */
  47119. numberOfFaces: number;
  47120. /**
  47121. * Gets the number of mipmap levels
  47122. */
  47123. numberOfMipmapLevels: number;
  47124. /**
  47125. * Gets the bytes of key value data
  47126. */
  47127. bytesOfKeyValueData: number;
  47128. /**
  47129. * Gets the load type
  47130. */
  47131. loadType: number;
  47132. /**
  47133. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47134. */
  47135. isInvalid: boolean;
  47136. /**
  47137. * Creates a new KhronosTextureContainer
  47138. * @param arrayBuffer contents of the KTX container file
  47139. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47140. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47141. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47142. */
  47143. constructor(
  47144. /** contents of the KTX container file */
  47145. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47146. /**
  47147. * Uploads KTX content to a Babylon Texture.
  47148. * It is assumed that the texture has already been created & is currently bound
  47149. * @hidden
  47150. */
  47151. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47152. private _upload2DCompressedLevels;
  47153. }
  47154. }
  47155. declare module BABYLON {
  47156. /**
  47157. * Implementation of the KTX Texture Loader.
  47158. * @hidden
  47159. */
  47160. export class _KTXTextureLoader implements IInternalTextureLoader {
  47161. /**
  47162. * Defines wether the loader supports cascade loading the different faces.
  47163. */
  47164. readonly supportCascades: boolean;
  47165. /**
  47166. * This returns if the loader support the current file information.
  47167. * @param extension defines the file extension of the file being loaded
  47168. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47169. * @param fallback defines the fallback internal texture if any
  47170. * @param isBase64 defines whether the texture is encoded as a base64
  47171. * @param isBuffer defines whether the texture data are stored as a buffer
  47172. * @returns true if the loader can load the specified file
  47173. */
  47174. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47175. /**
  47176. * Transform the url before loading if required.
  47177. * @param rootUrl the url of the texture
  47178. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47179. * @returns the transformed texture
  47180. */
  47181. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47182. /**
  47183. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47184. * @param rootUrl the url of the texture
  47185. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47186. * @returns the fallback texture
  47187. */
  47188. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47189. /**
  47190. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47191. * @param data contains the texture data
  47192. * @param texture defines the BabylonJS internal texture
  47193. * @param createPolynomials will be true if polynomials have been requested
  47194. * @param onLoad defines the callback to trigger once the texture is ready
  47195. * @param onError defines the callback to trigger in case of error
  47196. */
  47197. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47198. /**
  47199. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47200. * @param data contains the texture data
  47201. * @param texture defines the BabylonJS internal texture
  47202. * @param callback defines the method to call once ready to upload
  47203. */
  47204. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47205. }
  47206. }
  47207. declare module BABYLON {
  47208. /**
  47209. * Options for the default xr helper
  47210. */
  47211. export class WebXRDefaultExperienceOptions {
  47212. /**
  47213. * Floor meshes that should be used for teleporting
  47214. */
  47215. floorMeshes: Array<AbstractMesh>;
  47216. }
  47217. /**
  47218. * Default experience which provides a similar setup to the previous webVRExperience
  47219. */
  47220. export class WebXRDefaultExperience {
  47221. /**
  47222. * Base experience
  47223. */
  47224. baseExperience: WebXRExperienceHelper;
  47225. /**
  47226. * Input experience extension
  47227. */
  47228. input: WebXRInput;
  47229. /**
  47230. * Loads the controller models
  47231. */
  47232. controllerModelLoader: WebXRControllerModelLoader;
  47233. /**
  47234. * Enables laser pointer and selection
  47235. */
  47236. pointerSelection: WebXRControllerPointerSelection;
  47237. /**
  47238. * Enables teleportation
  47239. */
  47240. teleportation: WebXRControllerTeleportation;
  47241. /**
  47242. * Enables ui for enetering/exiting xr
  47243. */
  47244. enterExitUI: WebXREnterExitUI;
  47245. /**
  47246. * Default output canvas xr should render to
  47247. */
  47248. outputCanvas: WebXRManagedOutputCanvas;
  47249. /**
  47250. * Creates the default xr experience
  47251. * @param scene scene
  47252. * @param options options for basic configuration
  47253. * @returns resulting WebXRDefaultExperience
  47254. */
  47255. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47256. private constructor();
  47257. /**
  47258. * DIsposes of the experience helper
  47259. */
  47260. dispose(): void;
  47261. }
  47262. }
  47263. declare module BABYLON {
  47264. /** @hidden */
  47265. export var _forceSceneHelpersToBundle: boolean;
  47266. interface Scene {
  47267. /**
  47268. * Creates a default light for the scene.
  47269. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47270. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47271. */
  47272. createDefaultLight(replace?: boolean): void;
  47273. /**
  47274. * Creates a default camera for the scene.
  47275. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47276. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47277. * @param replace has default false, when true replaces the active camera in the scene
  47278. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47279. */
  47280. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47281. /**
  47282. * Creates a default camera and a default light.
  47283. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47284. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47285. * @param replace has the default false, when true replaces the active camera/light in the scene
  47286. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47287. */
  47288. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47289. /**
  47290. * Creates a new sky box
  47291. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47292. * @param environmentTexture defines the texture to use as environment texture
  47293. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47294. * @param scale defines the overall scale of the skybox
  47295. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47296. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47297. * @returns a new mesh holding the sky box
  47298. */
  47299. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47300. /**
  47301. * Creates a new environment
  47302. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47303. * @param options defines the options you can use to configure the environment
  47304. * @returns the new EnvironmentHelper
  47305. */
  47306. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47307. /**
  47308. * Creates a new VREXperienceHelper
  47309. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47310. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47311. * @returns a new VREXperienceHelper
  47312. */
  47313. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47314. /**
  47315. * Creates a new WebXRDefaultExperience
  47316. * @see http://doc.babylonjs.com/how_to/webxr
  47317. * @param options experience options
  47318. * @returns a promise for a new WebXRDefaultExperience
  47319. */
  47320. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47321. }
  47322. }
  47323. declare module BABYLON {
  47324. /**
  47325. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47326. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47327. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47328. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47329. */
  47330. export class VideoDome extends TransformNode {
  47331. /**
  47332. * Define the video source as a Monoscopic panoramic 360 video.
  47333. */
  47334. static readonly MODE_MONOSCOPIC: number;
  47335. /**
  47336. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47337. */
  47338. static readonly MODE_TOPBOTTOM: number;
  47339. /**
  47340. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47341. */
  47342. static readonly MODE_SIDEBYSIDE: number;
  47343. private _useDirectMapping;
  47344. /**
  47345. * The video texture being displayed on the sphere
  47346. */
  47347. protected _videoTexture: VideoTexture;
  47348. /**
  47349. * Gets the video texture being displayed on the sphere
  47350. */
  47351. readonly videoTexture: VideoTexture;
  47352. /**
  47353. * The skybox material
  47354. */
  47355. protected _material: BackgroundMaterial;
  47356. /**
  47357. * The surface used for the skybox
  47358. */
  47359. protected _mesh: Mesh;
  47360. /**
  47361. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47362. * Also see the options.resolution property.
  47363. */
  47364. fovMultiplier: number;
  47365. private _videoMode;
  47366. /**
  47367. * Gets or set the current video mode for the video. It can be:
  47368. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47369. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47370. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47371. */
  47372. videoMode: number;
  47373. /**
  47374. * Oberserver used in Stereoscopic VR Mode.
  47375. */
  47376. private _onBeforeCameraRenderObserver;
  47377. /**
  47378. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47379. * @param name Element's name, child elements will append suffixes for their own names.
  47380. * @param urlsOrVideo defines the url(s) or the video element to use
  47381. * @param options An object containing optional or exposed sub element properties
  47382. */
  47383. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47384. resolution?: number;
  47385. clickToPlay?: boolean;
  47386. autoPlay?: boolean;
  47387. loop?: boolean;
  47388. size?: number;
  47389. poster?: string;
  47390. faceForward?: boolean;
  47391. useDirectMapping?: boolean;
  47392. }, scene: Scene);
  47393. private _changeVideoMode;
  47394. /**
  47395. * Releases resources associated with this node.
  47396. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47397. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47398. */
  47399. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47400. }
  47401. }
  47402. declare module BABYLON {
  47403. /**
  47404. * This class can be used to get instrumentation data from a Babylon engine
  47405. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47406. */
  47407. export class EngineInstrumentation implements IDisposable {
  47408. /**
  47409. * Define the instrumented engine.
  47410. */
  47411. engine: Engine;
  47412. private _captureGPUFrameTime;
  47413. private _gpuFrameTimeToken;
  47414. private _gpuFrameTime;
  47415. private _captureShaderCompilationTime;
  47416. private _shaderCompilationTime;
  47417. private _onBeginFrameObserver;
  47418. private _onEndFrameObserver;
  47419. private _onBeforeShaderCompilationObserver;
  47420. private _onAfterShaderCompilationObserver;
  47421. /**
  47422. * Gets the perf counter used for GPU frame time
  47423. */
  47424. readonly gpuFrameTimeCounter: PerfCounter;
  47425. /**
  47426. * Gets the GPU frame time capture status
  47427. */
  47428. /**
  47429. * Enable or disable the GPU frame time capture
  47430. */
  47431. captureGPUFrameTime: boolean;
  47432. /**
  47433. * Gets the perf counter used for shader compilation time
  47434. */
  47435. readonly shaderCompilationTimeCounter: PerfCounter;
  47436. /**
  47437. * Gets the shader compilation time capture status
  47438. */
  47439. /**
  47440. * Enable or disable the shader compilation time capture
  47441. */
  47442. captureShaderCompilationTime: boolean;
  47443. /**
  47444. * Instantiates a new engine instrumentation.
  47445. * This class can be used to get instrumentation data from a Babylon engine
  47446. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47447. * @param engine Defines the engine to instrument
  47448. */
  47449. constructor(
  47450. /**
  47451. * Define the instrumented engine.
  47452. */
  47453. engine: Engine);
  47454. /**
  47455. * Dispose and release associated resources.
  47456. */
  47457. dispose(): void;
  47458. }
  47459. }
  47460. declare module BABYLON {
  47461. /**
  47462. * This class can be used to get instrumentation data from a Babylon engine
  47463. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47464. */
  47465. export class SceneInstrumentation implements IDisposable {
  47466. /**
  47467. * Defines the scene to instrument
  47468. */
  47469. scene: Scene;
  47470. private _captureActiveMeshesEvaluationTime;
  47471. private _activeMeshesEvaluationTime;
  47472. private _captureRenderTargetsRenderTime;
  47473. private _renderTargetsRenderTime;
  47474. private _captureFrameTime;
  47475. private _frameTime;
  47476. private _captureRenderTime;
  47477. private _renderTime;
  47478. private _captureInterFrameTime;
  47479. private _interFrameTime;
  47480. private _captureParticlesRenderTime;
  47481. private _particlesRenderTime;
  47482. private _captureSpritesRenderTime;
  47483. private _spritesRenderTime;
  47484. private _capturePhysicsTime;
  47485. private _physicsTime;
  47486. private _captureAnimationsTime;
  47487. private _animationsTime;
  47488. private _captureCameraRenderTime;
  47489. private _cameraRenderTime;
  47490. private _onBeforeActiveMeshesEvaluationObserver;
  47491. private _onAfterActiveMeshesEvaluationObserver;
  47492. private _onBeforeRenderTargetsRenderObserver;
  47493. private _onAfterRenderTargetsRenderObserver;
  47494. private _onAfterRenderObserver;
  47495. private _onBeforeDrawPhaseObserver;
  47496. private _onAfterDrawPhaseObserver;
  47497. private _onBeforeAnimationsObserver;
  47498. private _onBeforeParticlesRenderingObserver;
  47499. private _onAfterParticlesRenderingObserver;
  47500. private _onBeforeSpritesRenderingObserver;
  47501. private _onAfterSpritesRenderingObserver;
  47502. private _onBeforePhysicsObserver;
  47503. private _onAfterPhysicsObserver;
  47504. private _onAfterAnimationsObserver;
  47505. private _onBeforeCameraRenderObserver;
  47506. private _onAfterCameraRenderObserver;
  47507. /**
  47508. * Gets the perf counter used for active meshes evaluation time
  47509. */
  47510. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47511. /**
  47512. * Gets the active meshes evaluation time capture status
  47513. */
  47514. /**
  47515. * Enable or disable the active meshes evaluation time capture
  47516. */
  47517. captureActiveMeshesEvaluationTime: boolean;
  47518. /**
  47519. * Gets the perf counter used for render targets render time
  47520. */
  47521. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47522. /**
  47523. * Gets the render targets render time capture status
  47524. */
  47525. /**
  47526. * Enable or disable the render targets render time capture
  47527. */
  47528. captureRenderTargetsRenderTime: boolean;
  47529. /**
  47530. * Gets the perf counter used for particles render time
  47531. */
  47532. readonly particlesRenderTimeCounter: PerfCounter;
  47533. /**
  47534. * Gets the particles render time capture status
  47535. */
  47536. /**
  47537. * Enable or disable the particles render time capture
  47538. */
  47539. captureParticlesRenderTime: boolean;
  47540. /**
  47541. * Gets the perf counter used for sprites render time
  47542. */
  47543. readonly spritesRenderTimeCounter: PerfCounter;
  47544. /**
  47545. * Gets the sprites render time capture status
  47546. */
  47547. /**
  47548. * Enable or disable the sprites render time capture
  47549. */
  47550. captureSpritesRenderTime: boolean;
  47551. /**
  47552. * Gets the perf counter used for physics time
  47553. */
  47554. readonly physicsTimeCounter: PerfCounter;
  47555. /**
  47556. * Gets the physics time capture status
  47557. */
  47558. /**
  47559. * Enable or disable the physics time capture
  47560. */
  47561. capturePhysicsTime: boolean;
  47562. /**
  47563. * Gets the perf counter used for animations time
  47564. */
  47565. readonly animationsTimeCounter: PerfCounter;
  47566. /**
  47567. * Gets the animations time capture status
  47568. */
  47569. /**
  47570. * Enable or disable the animations time capture
  47571. */
  47572. captureAnimationsTime: boolean;
  47573. /**
  47574. * Gets the perf counter used for frame time capture
  47575. */
  47576. readonly frameTimeCounter: PerfCounter;
  47577. /**
  47578. * Gets the frame time capture status
  47579. */
  47580. /**
  47581. * Enable or disable the frame time capture
  47582. */
  47583. captureFrameTime: boolean;
  47584. /**
  47585. * Gets the perf counter used for inter-frames time capture
  47586. */
  47587. readonly interFrameTimeCounter: PerfCounter;
  47588. /**
  47589. * Gets the inter-frames time capture status
  47590. */
  47591. /**
  47592. * Enable or disable the inter-frames time capture
  47593. */
  47594. captureInterFrameTime: boolean;
  47595. /**
  47596. * Gets the perf counter used for render time capture
  47597. */
  47598. readonly renderTimeCounter: PerfCounter;
  47599. /**
  47600. * Gets the render time capture status
  47601. */
  47602. /**
  47603. * Enable or disable the render time capture
  47604. */
  47605. captureRenderTime: boolean;
  47606. /**
  47607. * Gets the perf counter used for camera render time capture
  47608. */
  47609. readonly cameraRenderTimeCounter: PerfCounter;
  47610. /**
  47611. * Gets the camera render time capture status
  47612. */
  47613. /**
  47614. * Enable or disable the camera render time capture
  47615. */
  47616. captureCameraRenderTime: boolean;
  47617. /**
  47618. * Gets the perf counter used for draw calls
  47619. */
  47620. readonly drawCallsCounter: PerfCounter;
  47621. /**
  47622. * Instantiates a new scene instrumentation.
  47623. * This class can be used to get instrumentation data from a Babylon engine
  47624. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47625. * @param scene Defines the scene to instrument
  47626. */
  47627. constructor(
  47628. /**
  47629. * Defines the scene to instrument
  47630. */
  47631. scene: Scene);
  47632. /**
  47633. * Dispose and release associated resources.
  47634. */
  47635. dispose(): void;
  47636. }
  47637. }
  47638. declare module BABYLON {
  47639. /** @hidden */
  47640. export var glowMapGenerationPixelShader: {
  47641. name: string;
  47642. shader: string;
  47643. };
  47644. }
  47645. declare module BABYLON {
  47646. /** @hidden */
  47647. export var glowMapGenerationVertexShader: {
  47648. name: string;
  47649. shader: string;
  47650. };
  47651. }
  47652. declare module BABYLON {
  47653. /**
  47654. * Effect layer options. This helps customizing the behaviour
  47655. * of the effect layer.
  47656. */
  47657. export interface IEffectLayerOptions {
  47658. /**
  47659. * Multiplication factor apply to the canvas size to compute the render target size
  47660. * used to generated the objects (the smaller the faster).
  47661. */
  47662. mainTextureRatio: number;
  47663. /**
  47664. * Enforces a fixed size texture to ensure effect stability across devices.
  47665. */
  47666. mainTextureFixedSize?: number;
  47667. /**
  47668. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47669. */
  47670. alphaBlendingMode: number;
  47671. /**
  47672. * The camera attached to the layer.
  47673. */
  47674. camera: Nullable<Camera>;
  47675. /**
  47676. * The rendering group to draw the layer in.
  47677. */
  47678. renderingGroupId: number;
  47679. }
  47680. /**
  47681. * The effect layer Helps adding post process effect blended with the main pass.
  47682. *
  47683. * This can be for instance use to generate glow or higlight effects on the scene.
  47684. *
  47685. * The effect layer class can not be used directly and is intented to inherited from to be
  47686. * customized per effects.
  47687. */
  47688. export abstract class EffectLayer {
  47689. private _vertexBuffers;
  47690. private _indexBuffer;
  47691. private _cachedDefines;
  47692. private _effectLayerMapGenerationEffect;
  47693. private _effectLayerOptions;
  47694. private _mergeEffect;
  47695. protected _scene: Scene;
  47696. protected _engine: Engine;
  47697. protected _maxSize: number;
  47698. protected _mainTextureDesiredSize: ISize;
  47699. protected _mainTexture: RenderTargetTexture;
  47700. protected _shouldRender: boolean;
  47701. protected _postProcesses: PostProcess[];
  47702. protected _textures: BaseTexture[];
  47703. protected _emissiveTextureAndColor: {
  47704. texture: Nullable<BaseTexture>;
  47705. color: Color4;
  47706. };
  47707. /**
  47708. * The name of the layer
  47709. */
  47710. name: string;
  47711. /**
  47712. * The clear color of the texture used to generate the glow map.
  47713. */
  47714. neutralColor: Color4;
  47715. /**
  47716. * Specifies wether the highlight layer is enabled or not.
  47717. */
  47718. isEnabled: boolean;
  47719. /**
  47720. * Gets the camera attached to the layer.
  47721. */
  47722. readonly camera: Nullable<Camera>;
  47723. /**
  47724. * Gets the rendering group id the layer should render in.
  47725. */
  47726. renderingGroupId: number;
  47727. /**
  47728. * An event triggered when the effect layer has been disposed.
  47729. */
  47730. onDisposeObservable: Observable<EffectLayer>;
  47731. /**
  47732. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47733. */
  47734. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47735. /**
  47736. * An event triggered when the generated texture is being merged in the scene.
  47737. */
  47738. onBeforeComposeObservable: Observable<EffectLayer>;
  47739. /**
  47740. * An event triggered when the generated texture has been merged in the scene.
  47741. */
  47742. onAfterComposeObservable: Observable<EffectLayer>;
  47743. /**
  47744. * An event triggered when the efffect layer changes its size.
  47745. */
  47746. onSizeChangedObservable: Observable<EffectLayer>;
  47747. /** @hidden */
  47748. static _SceneComponentInitialization: (scene: Scene) => void;
  47749. /**
  47750. * Instantiates a new effect Layer and references it in the scene.
  47751. * @param name The name of the layer
  47752. * @param scene The scene to use the layer in
  47753. */
  47754. constructor(
  47755. /** The Friendly of the effect in the scene */
  47756. name: string, scene: Scene);
  47757. /**
  47758. * Get the effect name of the layer.
  47759. * @return The effect name
  47760. */
  47761. abstract getEffectName(): string;
  47762. /**
  47763. * Checks for the readiness of the element composing the layer.
  47764. * @param subMesh the mesh to check for
  47765. * @param useInstances specify wether or not to use instances to render the mesh
  47766. * @return true if ready otherwise, false
  47767. */
  47768. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47769. /**
  47770. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47771. * @returns true if the effect requires stencil during the main canvas render pass.
  47772. */
  47773. abstract needStencil(): boolean;
  47774. /**
  47775. * Create the merge effect. This is the shader use to blit the information back
  47776. * to the main canvas at the end of the scene rendering.
  47777. * @returns The effect containing the shader used to merge the effect on the main canvas
  47778. */
  47779. protected abstract _createMergeEffect(): Effect;
  47780. /**
  47781. * Creates the render target textures and post processes used in the effect layer.
  47782. */
  47783. protected abstract _createTextureAndPostProcesses(): void;
  47784. /**
  47785. * Implementation specific of rendering the generating effect on the main canvas.
  47786. * @param effect The effect used to render through
  47787. */
  47788. protected abstract _internalRender(effect: Effect): void;
  47789. /**
  47790. * Sets the required values for both the emissive texture and and the main color.
  47791. */
  47792. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47793. /**
  47794. * Free any resources and references associated to a mesh.
  47795. * Internal use
  47796. * @param mesh The mesh to free.
  47797. */
  47798. abstract _disposeMesh(mesh: Mesh): void;
  47799. /**
  47800. * Serializes this layer (Glow or Highlight for example)
  47801. * @returns a serialized layer object
  47802. */
  47803. abstract serialize?(): any;
  47804. /**
  47805. * Initializes the effect layer with the required options.
  47806. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47807. */
  47808. protected _init(options: Partial<IEffectLayerOptions>): void;
  47809. /**
  47810. * Generates the index buffer of the full screen quad blending to the main canvas.
  47811. */
  47812. private _generateIndexBuffer;
  47813. /**
  47814. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47815. */
  47816. private _generateVertexBuffer;
  47817. /**
  47818. * Sets the main texture desired size which is the closest power of two
  47819. * of the engine canvas size.
  47820. */
  47821. private _setMainTextureSize;
  47822. /**
  47823. * Creates the main texture for the effect layer.
  47824. */
  47825. protected _createMainTexture(): void;
  47826. /**
  47827. * Adds specific effects defines.
  47828. * @param defines The defines to add specifics to.
  47829. */
  47830. protected _addCustomEffectDefines(defines: string[]): void;
  47831. /**
  47832. * Checks for the readiness of the element composing the layer.
  47833. * @param subMesh the mesh to check for
  47834. * @param useInstances specify wether or not to use instances to render the mesh
  47835. * @param emissiveTexture the associated emissive texture used to generate the glow
  47836. * @return true if ready otherwise, false
  47837. */
  47838. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47839. /**
  47840. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47841. */
  47842. render(): void;
  47843. /**
  47844. * Determine if a given mesh will be used in the current effect.
  47845. * @param mesh mesh to test
  47846. * @returns true if the mesh will be used
  47847. */
  47848. hasMesh(mesh: AbstractMesh): boolean;
  47849. /**
  47850. * Returns true if the layer contains information to display, otherwise false.
  47851. * @returns true if the glow layer should be rendered
  47852. */
  47853. shouldRender(): boolean;
  47854. /**
  47855. * Returns true if the mesh should render, otherwise false.
  47856. * @param mesh The mesh to render
  47857. * @returns true if it should render otherwise false
  47858. */
  47859. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47860. /**
  47861. * Returns true if the mesh can be rendered, otherwise false.
  47862. * @param mesh The mesh to render
  47863. * @param material The material used on the mesh
  47864. * @returns true if it can be rendered otherwise false
  47865. */
  47866. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47867. /**
  47868. * Returns true if the mesh should render, otherwise false.
  47869. * @param mesh The mesh to render
  47870. * @returns true if it should render otherwise false
  47871. */
  47872. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47873. /**
  47874. * Renders the submesh passed in parameter to the generation map.
  47875. */
  47876. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47877. /**
  47878. * Rebuild the required buffers.
  47879. * @hidden Internal use only.
  47880. */
  47881. _rebuild(): void;
  47882. /**
  47883. * Dispose only the render target textures and post process.
  47884. */
  47885. private _disposeTextureAndPostProcesses;
  47886. /**
  47887. * Dispose the highlight layer and free resources.
  47888. */
  47889. dispose(): void;
  47890. /**
  47891. * Gets the class name of the effect layer
  47892. * @returns the string with the class name of the effect layer
  47893. */
  47894. getClassName(): string;
  47895. /**
  47896. * Creates an effect layer from parsed effect layer data
  47897. * @param parsedEffectLayer defines effect layer data
  47898. * @param scene defines the current scene
  47899. * @param rootUrl defines the root URL containing the effect layer information
  47900. * @returns a parsed effect Layer
  47901. */
  47902. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47903. }
  47904. }
  47905. declare module BABYLON {
  47906. interface AbstractScene {
  47907. /**
  47908. * The list of effect layers (highlights/glow) added to the scene
  47909. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47910. * @see http://doc.babylonjs.com/how_to/glow_layer
  47911. */
  47912. effectLayers: Array<EffectLayer>;
  47913. /**
  47914. * Removes the given effect layer from this scene.
  47915. * @param toRemove defines the effect layer to remove
  47916. * @returns the index of the removed effect layer
  47917. */
  47918. removeEffectLayer(toRemove: EffectLayer): number;
  47919. /**
  47920. * Adds the given effect layer to this scene
  47921. * @param newEffectLayer defines the effect layer to add
  47922. */
  47923. addEffectLayer(newEffectLayer: EffectLayer): void;
  47924. }
  47925. /**
  47926. * Defines the layer scene component responsible to manage any effect layers
  47927. * in a given scene.
  47928. */
  47929. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47930. /**
  47931. * The component name helpfull to identify the component in the list of scene components.
  47932. */
  47933. readonly name: string;
  47934. /**
  47935. * The scene the component belongs to.
  47936. */
  47937. scene: Scene;
  47938. private _engine;
  47939. private _renderEffects;
  47940. private _needStencil;
  47941. private _previousStencilState;
  47942. /**
  47943. * Creates a new instance of the component for the given scene
  47944. * @param scene Defines the scene to register the component in
  47945. */
  47946. constructor(scene: Scene);
  47947. /**
  47948. * Registers the component in a given scene
  47949. */
  47950. register(): void;
  47951. /**
  47952. * Rebuilds the elements related to this component in case of
  47953. * context lost for instance.
  47954. */
  47955. rebuild(): void;
  47956. /**
  47957. * Serializes the component data to the specified json object
  47958. * @param serializationObject The object to serialize to
  47959. */
  47960. serialize(serializationObject: any): void;
  47961. /**
  47962. * Adds all the elements from the container to the scene
  47963. * @param container the container holding the elements
  47964. */
  47965. addFromContainer(container: AbstractScene): void;
  47966. /**
  47967. * Removes all the elements in the container from the scene
  47968. * @param container contains the elements to remove
  47969. * @param dispose if the removed element should be disposed (default: false)
  47970. */
  47971. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47972. /**
  47973. * Disposes the component and the associated ressources.
  47974. */
  47975. dispose(): void;
  47976. private _isReadyForMesh;
  47977. private _renderMainTexture;
  47978. private _setStencil;
  47979. private _setStencilBack;
  47980. private _draw;
  47981. private _drawCamera;
  47982. private _drawRenderingGroup;
  47983. }
  47984. }
  47985. declare module BABYLON {
  47986. /** @hidden */
  47987. export var glowMapMergePixelShader: {
  47988. name: string;
  47989. shader: string;
  47990. };
  47991. }
  47992. declare module BABYLON {
  47993. /** @hidden */
  47994. export var glowMapMergeVertexShader: {
  47995. name: string;
  47996. shader: string;
  47997. };
  47998. }
  47999. declare module BABYLON {
  48000. interface AbstractScene {
  48001. /**
  48002. * Return a the first highlight layer of the scene with a given name.
  48003. * @param name The name of the highlight layer to look for.
  48004. * @return The highlight layer if found otherwise null.
  48005. */
  48006. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48007. }
  48008. /**
  48009. * Glow layer options. This helps customizing the behaviour
  48010. * of the glow layer.
  48011. */
  48012. export interface IGlowLayerOptions {
  48013. /**
  48014. * Multiplication factor apply to the canvas size to compute the render target size
  48015. * used to generated the glowing objects (the smaller the faster).
  48016. */
  48017. mainTextureRatio: number;
  48018. /**
  48019. * Enforces a fixed size texture to ensure resize independant blur.
  48020. */
  48021. mainTextureFixedSize?: number;
  48022. /**
  48023. * How big is the kernel of the blur texture.
  48024. */
  48025. blurKernelSize: number;
  48026. /**
  48027. * The camera attached to the layer.
  48028. */
  48029. camera: Nullable<Camera>;
  48030. /**
  48031. * Enable MSAA by chosing the number of samples.
  48032. */
  48033. mainTextureSamples?: number;
  48034. /**
  48035. * The rendering group to draw the layer in.
  48036. */
  48037. renderingGroupId: number;
  48038. }
  48039. /**
  48040. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48041. *
  48042. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48043. * glowy meshes to your scene.
  48044. *
  48045. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48046. */
  48047. export class GlowLayer extends EffectLayer {
  48048. /**
  48049. * Effect Name of the layer.
  48050. */
  48051. static readonly EffectName: string;
  48052. /**
  48053. * The default blur kernel size used for the glow.
  48054. */
  48055. static DefaultBlurKernelSize: number;
  48056. /**
  48057. * The default texture size ratio used for the glow.
  48058. */
  48059. static DefaultTextureRatio: number;
  48060. /**
  48061. * Sets the kernel size of the blur.
  48062. */
  48063. /**
  48064. * Gets the kernel size of the blur.
  48065. */
  48066. blurKernelSize: number;
  48067. /**
  48068. * Sets the glow intensity.
  48069. */
  48070. /**
  48071. * Gets the glow intensity.
  48072. */
  48073. intensity: number;
  48074. private _options;
  48075. private _intensity;
  48076. private _horizontalBlurPostprocess1;
  48077. private _verticalBlurPostprocess1;
  48078. private _horizontalBlurPostprocess2;
  48079. private _verticalBlurPostprocess2;
  48080. private _blurTexture1;
  48081. private _blurTexture2;
  48082. private _postProcesses1;
  48083. private _postProcesses2;
  48084. private _includedOnlyMeshes;
  48085. private _excludedMeshes;
  48086. /**
  48087. * Callback used to let the user override the color selection on a per mesh basis
  48088. */
  48089. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48090. /**
  48091. * Callback used to let the user override the texture selection on a per mesh basis
  48092. */
  48093. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48094. /**
  48095. * Instantiates a new glow Layer and references it to the scene.
  48096. * @param name The name of the layer
  48097. * @param scene The scene to use the layer in
  48098. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48099. */
  48100. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48101. /**
  48102. * Get the effect name of the layer.
  48103. * @return The effect name
  48104. */
  48105. getEffectName(): string;
  48106. /**
  48107. * Create the merge effect. This is the shader use to blit the information back
  48108. * to the main canvas at the end of the scene rendering.
  48109. */
  48110. protected _createMergeEffect(): Effect;
  48111. /**
  48112. * Creates the render target textures and post processes used in the glow layer.
  48113. */
  48114. protected _createTextureAndPostProcesses(): void;
  48115. /**
  48116. * Checks for the readiness of the element composing the layer.
  48117. * @param subMesh the mesh to check for
  48118. * @param useInstances specify wether or not to use instances to render the mesh
  48119. * @param emissiveTexture the associated emissive texture used to generate the glow
  48120. * @return true if ready otherwise, false
  48121. */
  48122. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48123. /**
  48124. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48125. */
  48126. needStencil(): boolean;
  48127. /**
  48128. * Returns true if the mesh can be rendered, otherwise false.
  48129. * @param mesh The mesh to render
  48130. * @param material The material used on the mesh
  48131. * @returns true if it can be rendered otherwise false
  48132. */
  48133. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48134. /**
  48135. * Implementation specific of rendering the generating effect on the main canvas.
  48136. * @param effect The effect used to render through
  48137. */
  48138. protected _internalRender(effect: Effect): void;
  48139. /**
  48140. * Sets the required values for both the emissive texture and and the main color.
  48141. */
  48142. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48143. /**
  48144. * Returns true if the mesh should render, otherwise false.
  48145. * @param mesh The mesh to render
  48146. * @returns true if it should render otherwise false
  48147. */
  48148. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48149. /**
  48150. * Adds specific effects defines.
  48151. * @param defines The defines to add specifics to.
  48152. */
  48153. protected _addCustomEffectDefines(defines: string[]): void;
  48154. /**
  48155. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48156. * @param mesh The mesh to exclude from the glow layer
  48157. */
  48158. addExcludedMesh(mesh: Mesh): void;
  48159. /**
  48160. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48161. * @param mesh The mesh to remove
  48162. */
  48163. removeExcludedMesh(mesh: Mesh): void;
  48164. /**
  48165. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48166. * @param mesh The mesh to include in the glow layer
  48167. */
  48168. addIncludedOnlyMesh(mesh: Mesh): void;
  48169. /**
  48170. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48171. * @param mesh The mesh to remove
  48172. */
  48173. removeIncludedOnlyMesh(mesh: Mesh): void;
  48174. /**
  48175. * Determine if a given mesh will be used in the glow layer
  48176. * @param mesh The mesh to test
  48177. * @returns true if the mesh will be highlighted by the current glow layer
  48178. */
  48179. hasMesh(mesh: AbstractMesh): boolean;
  48180. /**
  48181. * Free any resources and references associated to a mesh.
  48182. * Internal use
  48183. * @param mesh The mesh to free.
  48184. * @hidden
  48185. */
  48186. _disposeMesh(mesh: Mesh): void;
  48187. /**
  48188. * Gets the class name of the effect layer
  48189. * @returns the string with the class name of the effect layer
  48190. */
  48191. getClassName(): string;
  48192. /**
  48193. * Serializes this glow layer
  48194. * @returns a serialized glow layer object
  48195. */
  48196. serialize(): any;
  48197. /**
  48198. * Creates a Glow Layer from parsed glow layer data
  48199. * @param parsedGlowLayer defines glow layer data
  48200. * @param scene defines the current scene
  48201. * @param rootUrl defines the root URL containing the glow layer information
  48202. * @returns a parsed Glow Layer
  48203. */
  48204. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48205. }
  48206. }
  48207. declare module BABYLON {
  48208. /** @hidden */
  48209. export var glowBlurPostProcessPixelShader: {
  48210. name: string;
  48211. shader: string;
  48212. };
  48213. }
  48214. declare module BABYLON {
  48215. interface AbstractScene {
  48216. /**
  48217. * Return a the first highlight layer of the scene with a given name.
  48218. * @param name The name of the highlight layer to look for.
  48219. * @return The highlight layer if found otherwise null.
  48220. */
  48221. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48222. }
  48223. /**
  48224. * Highlight layer options. This helps customizing the behaviour
  48225. * of the highlight layer.
  48226. */
  48227. export interface IHighlightLayerOptions {
  48228. /**
  48229. * Multiplication factor apply to the canvas size to compute the render target size
  48230. * used to generated the glowing objects (the smaller the faster).
  48231. */
  48232. mainTextureRatio: number;
  48233. /**
  48234. * Enforces a fixed size texture to ensure resize independant blur.
  48235. */
  48236. mainTextureFixedSize?: number;
  48237. /**
  48238. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48239. * of the picture to blur (the smaller the faster).
  48240. */
  48241. blurTextureSizeRatio: number;
  48242. /**
  48243. * How big in texel of the blur texture is the vertical blur.
  48244. */
  48245. blurVerticalSize: number;
  48246. /**
  48247. * How big in texel of the blur texture is the horizontal blur.
  48248. */
  48249. blurHorizontalSize: number;
  48250. /**
  48251. * Alpha blending mode used to apply the blur. Default is combine.
  48252. */
  48253. alphaBlendingMode: number;
  48254. /**
  48255. * The camera attached to the layer.
  48256. */
  48257. camera: Nullable<Camera>;
  48258. /**
  48259. * Should we display highlight as a solid stroke?
  48260. */
  48261. isStroke?: boolean;
  48262. /**
  48263. * The rendering group to draw the layer in.
  48264. */
  48265. renderingGroupId: number;
  48266. }
  48267. /**
  48268. * The highlight layer Helps adding a glow effect around a mesh.
  48269. *
  48270. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48271. * glowy meshes to your scene.
  48272. *
  48273. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48274. */
  48275. export class HighlightLayer extends EffectLayer {
  48276. name: string;
  48277. /**
  48278. * Effect Name of the highlight layer.
  48279. */
  48280. static readonly EffectName: string;
  48281. /**
  48282. * The neutral color used during the preparation of the glow effect.
  48283. * This is black by default as the blend operation is a blend operation.
  48284. */
  48285. static NeutralColor: Color4;
  48286. /**
  48287. * Stencil value used for glowing meshes.
  48288. */
  48289. static GlowingMeshStencilReference: number;
  48290. /**
  48291. * Stencil value used for the other meshes in the scene.
  48292. */
  48293. static NormalMeshStencilReference: number;
  48294. /**
  48295. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48296. */
  48297. innerGlow: boolean;
  48298. /**
  48299. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48300. */
  48301. outerGlow: boolean;
  48302. /**
  48303. * Specifies the horizontal size of the blur.
  48304. */
  48305. /**
  48306. * Gets the horizontal size of the blur.
  48307. */
  48308. blurHorizontalSize: number;
  48309. /**
  48310. * Specifies the vertical size of the blur.
  48311. */
  48312. /**
  48313. * Gets the vertical size of the blur.
  48314. */
  48315. blurVerticalSize: number;
  48316. /**
  48317. * An event triggered when the highlight layer is being blurred.
  48318. */
  48319. onBeforeBlurObservable: Observable<HighlightLayer>;
  48320. /**
  48321. * An event triggered when the highlight layer has been blurred.
  48322. */
  48323. onAfterBlurObservable: Observable<HighlightLayer>;
  48324. private _instanceGlowingMeshStencilReference;
  48325. private _options;
  48326. private _downSamplePostprocess;
  48327. private _horizontalBlurPostprocess;
  48328. private _verticalBlurPostprocess;
  48329. private _blurTexture;
  48330. private _meshes;
  48331. private _excludedMeshes;
  48332. /**
  48333. * Instantiates a new highlight Layer and references it to the scene..
  48334. * @param name The name of the layer
  48335. * @param scene The scene to use the layer in
  48336. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48337. */
  48338. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48339. /**
  48340. * Get the effect name of the layer.
  48341. * @return The effect name
  48342. */
  48343. getEffectName(): string;
  48344. /**
  48345. * Create the merge effect. This is the shader use to blit the information back
  48346. * to the main canvas at the end of the scene rendering.
  48347. */
  48348. protected _createMergeEffect(): Effect;
  48349. /**
  48350. * Creates the render target textures and post processes used in the highlight layer.
  48351. */
  48352. protected _createTextureAndPostProcesses(): void;
  48353. /**
  48354. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48355. */
  48356. needStencil(): boolean;
  48357. /**
  48358. * Checks for the readiness of the element composing the layer.
  48359. * @param subMesh the mesh to check for
  48360. * @param useInstances specify wether or not to use instances to render the mesh
  48361. * @param emissiveTexture the associated emissive texture used to generate the glow
  48362. * @return true if ready otherwise, false
  48363. */
  48364. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48365. /**
  48366. * Implementation specific of rendering the generating effect on the main canvas.
  48367. * @param effect The effect used to render through
  48368. */
  48369. protected _internalRender(effect: Effect): void;
  48370. /**
  48371. * Returns true if the layer contains information to display, otherwise false.
  48372. */
  48373. shouldRender(): boolean;
  48374. /**
  48375. * Returns true if the mesh should render, otherwise false.
  48376. * @param mesh The mesh to render
  48377. * @returns true if it should render otherwise false
  48378. */
  48379. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48380. /**
  48381. * Sets the required values for both the emissive texture and and the main color.
  48382. */
  48383. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48384. /**
  48385. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48386. * @param mesh The mesh to exclude from the highlight layer
  48387. */
  48388. addExcludedMesh(mesh: Mesh): void;
  48389. /**
  48390. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48391. * @param mesh The mesh to highlight
  48392. */
  48393. removeExcludedMesh(mesh: Mesh): void;
  48394. /**
  48395. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48396. * @param mesh mesh to test
  48397. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48398. */
  48399. hasMesh(mesh: AbstractMesh): boolean;
  48400. /**
  48401. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48402. * @param mesh The mesh to highlight
  48403. * @param color The color of the highlight
  48404. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48405. */
  48406. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48407. /**
  48408. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48409. * @param mesh The mesh to highlight
  48410. */
  48411. removeMesh(mesh: Mesh): void;
  48412. /**
  48413. * Force the stencil to the normal expected value for none glowing parts
  48414. */
  48415. private _defaultStencilReference;
  48416. /**
  48417. * Free any resources and references associated to a mesh.
  48418. * Internal use
  48419. * @param mesh The mesh to free.
  48420. * @hidden
  48421. */
  48422. _disposeMesh(mesh: Mesh): void;
  48423. /**
  48424. * Dispose the highlight layer and free resources.
  48425. */
  48426. dispose(): void;
  48427. /**
  48428. * Gets the class name of the effect layer
  48429. * @returns the string with the class name of the effect layer
  48430. */
  48431. getClassName(): string;
  48432. /**
  48433. * Serializes this Highlight layer
  48434. * @returns a serialized Highlight layer object
  48435. */
  48436. serialize(): any;
  48437. /**
  48438. * Creates a Highlight layer from parsed Highlight layer data
  48439. * @param parsedHightlightLayer defines the Highlight layer data
  48440. * @param scene defines the current scene
  48441. * @param rootUrl defines the root URL containing the Highlight layer information
  48442. * @returns a parsed Highlight layer
  48443. */
  48444. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48445. }
  48446. }
  48447. declare module BABYLON {
  48448. interface AbstractScene {
  48449. /**
  48450. * The list of layers (background and foreground) of the scene
  48451. */
  48452. layers: Array<Layer>;
  48453. }
  48454. /**
  48455. * Defines the layer scene component responsible to manage any layers
  48456. * in a given scene.
  48457. */
  48458. export class LayerSceneComponent implements ISceneComponent {
  48459. /**
  48460. * The component name helpfull to identify the component in the list of scene components.
  48461. */
  48462. readonly name: string;
  48463. /**
  48464. * The scene the component belongs to.
  48465. */
  48466. scene: Scene;
  48467. private _engine;
  48468. /**
  48469. * Creates a new instance of the component for the given scene
  48470. * @param scene Defines the scene to register the component in
  48471. */
  48472. constructor(scene: Scene);
  48473. /**
  48474. * Registers the component in a given scene
  48475. */
  48476. register(): void;
  48477. /**
  48478. * Rebuilds the elements related to this component in case of
  48479. * context lost for instance.
  48480. */
  48481. rebuild(): void;
  48482. /**
  48483. * Disposes the component and the associated ressources.
  48484. */
  48485. dispose(): void;
  48486. private _draw;
  48487. private _drawCameraPredicate;
  48488. private _drawCameraBackground;
  48489. private _drawCameraForeground;
  48490. private _drawRenderTargetPredicate;
  48491. private _drawRenderTargetBackground;
  48492. private _drawRenderTargetForeground;
  48493. /**
  48494. * Adds all the elements from the container to the scene
  48495. * @param container the container holding the elements
  48496. */
  48497. addFromContainer(container: AbstractScene): void;
  48498. /**
  48499. * Removes all the elements in the container from the scene
  48500. * @param container contains the elements to remove
  48501. * @param dispose if the removed element should be disposed (default: false)
  48502. */
  48503. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48504. }
  48505. }
  48506. declare module BABYLON {
  48507. /** @hidden */
  48508. export var layerPixelShader: {
  48509. name: string;
  48510. shader: string;
  48511. };
  48512. }
  48513. declare module BABYLON {
  48514. /** @hidden */
  48515. export var layerVertexShader: {
  48516. name: string;
  48517. shader: string;
  48518. };
  48519. }
  48520. declare module BABYLON {
  48521. /**
  48522. * This represents a full screen 2d layer.
  48523. * This can be useful to display a picture in the background of your scene for instance.
  48524. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48525. */
  48526. export class Layer {
  48527. /**
  48528. * Define the name of the layer.
  48529. */
  48530. name: string;
  48531. /**
  48532. * Define the texture the layer should display.
  48533. */
  48534. texture: Nullable<Texture>;
  48535. /**
  48536. * Is the layer in background or foreground.
  48537. */
  48538. isBackground: boolean;
  48539. /**
  48540. * Define the color of the layer (instead of texture).
  48541. */
  48542. color: Color4;
  48543. /**
  48544. * Define the scale of the layer in order to zoom in out of the texture.
  48545. */
  48546. scale: Vector2;
  48547. /**
  48548. * Define an offset for the layer in order to shift the texture.
  48549. */
  48550. offset: Vector2;
  48551. /**
  48552. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48553. */
  48554. alphaBlendingMode: number;
  48555. /**
  48556. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48557. * Alpha test will not mix with the background color in case of transparency.
  48558. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48559. */
  48560. alphaTest: boolean;
  48561. /**
  48562. * Define a mask to restrict the layer to only some of the scene cameras.
  48563. */
  48564. layerMask: number;
  48565. /**
  48566. * Define the list of render target the layer is visible into.
  48567. */
  48568. renderTargetTextures: RenderTargetTexture[];
  48569. /**
  48570. * Define if the layer is only used in renderTarget or if it also
  48571. * renders in the main frame buffer of the canvas.
  48572. */
  48573. renderOnlyInRenderTargetTextures: boolean;
  48574. private _scene;
  48575. private _vertexBuffers;
  48576. private _indexBuffer;
  48577. private _effect;
  48578. private _alphaTestEffect;
  48579. /**
  48580. * An event triggered when the layer is disposed.
  48581. */
  48582. onDisposeObservable: Observable<Layer>;
  48583. private _onDisposeObserver;
  48584. /**
  48585. * Back compatibility with callback before the onDisposeObservable existed.
  48586. * The set callback will be triggered when the layer has been disposed.
  48587. */
  48588. onDispose: () => void;
  48589. /**
  48590. * An event triggered before rendering the scene
  48591. */
  48592. onBeforeRenderObservable: Observable<Layer>;
  48593. private _onBeforeRenderObserver;
  48594. /**
  48595. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48596. * The set callback will be triggered just before rendering the layer.
  48597. */
  48598. onBeforeRender: () => void;
  48599. /**
  48600. * An event triggered after rendering the scene
  48601. */
  48602. onAfterRenderObservable: Observable<Layer>;
  48603. private _onAfterRenderObserver;
  48604. /**
  48605. * Back compatibility with callback before the onAfterRenderObservable existed.
  48606. * The set callback will be triggered just after rendering the layer.
  48607. */
  48608. onAfterRender: () => void;
  48609. /**
  48610. * Instantiates a new layer.
  48611. * This represents a full screen 2d layer.
  48612. * This can be useful to display a picture in the background of your scene for instance.
  48613. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48614. * @param name Define the name of the layer in the scene
  48615. * @param imgUrl Define the url of the texture to display in the layer
  48616. * @param scene Define the scene the layer belongs to
  48617. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48618. * @param color Defines a color for the layer
  48619. */
  48620. constructor(
  48621. /**
  48622. * Define the name of the layer.
  48623. */
  48624. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48625. private _createIndexBuffer;
  48626. /** @hidden */
  48627. _rebuild(): void;
  48628. /**
  48629. * Renders the layer in the scene.
  48630. */
  48631. render(): void;
  48632. /**
  48633. * Disposes and releases the associated ressources.
  48634. */
  48635. dispose(): void;
  48636. }
  48637. }
  48638. declare module BABYLON {
  48639. /** @hidden */
  48640. export var lensFlarePixelShader: {
  48641. name: string;
  48642. shader: string;
  48643. };
  48644. }
  48645. declare module BABYLON {
  48646. /** @hidden */
  48647. export var lensFlareVertexShader: {
  48648. name: string;
  48649. shader: string;
  48650. };
  48651. }
  48652. declare module BABYLON {
  48653. /**
  48654. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48655. * It is usually composed of several `lensFlare`.
  48656. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48657. */
  48658. export class LensFlareSystem {
  48659. /**
  48660. * Define the name of the lens flare system
  48661. */
  48662. name: string;
  48663. /**
  48664. * List of lens flares used in this system.
  48665. */
  48666. lensFlares: LensFlare[];
  48667. /**
  48668. * Define a limit from the border the lens flare can be visible.
  48669. */
  48670. borderLimit: number;
  48671. /**
  48672. * Define a viewport border we do not want to see the lens flare in.
  48673. */
  48674. viewportBorder: number;
  48675. /**
  48676. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48677. */
  48678. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48679. /**
  48680. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48681. */
  48682. layerMask: number;
  48683. /**
  48684. * Define the id of the lens flare system in the scene.
  48685. * (equal to name by default)
  48686. */
  48687. id: string;
  48688. private _scene;
  48689. private _emitter;
  48690. private _vertexBuffers;
  48691. private _indexBuffer;
  48692. private _effect;
  48693. private _positionX;
  48694. private _positionY;
  48695. private _isEnabled;
  48696. /** @hidden */
  48697. static _SceneComponentInitialization: (scene: Scene) => void;
  48698. /**
  48699. * Instantiates a lens flare system.
  48700. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48701. * It is usually composed of several `lensFlare`.
  48702. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48703. * @param name Define the name of the lens flare system in the scene
  48704. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48705. * @param scene Define the scene the lens flare system belongs to
  48706. */
  48707. constructor(
  48708. /**
  48709. * Define the name of the lens flare system
  48710. */
  48711. name: string, emitter: any, scene: Scene);
  48712. /**
  48713. * Define if the lens flare system is enabled.
  48714. */
  48715. isEnabled: boolean;
  48716. /**
  48717. * Get the scene the effects belongs to.
  48718. * @returns the scene holding the lens flare system
  48719. */
  48720. getScene(): Scene;
  48721. /**
  48722. * Get the emitter of the lens flare system.
  48723. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48724. * @returns the emitter of the lens flare system
  48725. */
  48726. getEmitter(): any;
  48727. /**
  48728. * Set the emitter of the lens flare system.
  48729. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48730. * @param newEmitter Define the new emitter of the system
  48731. */
  48732. setEmitter(newEmitter: any): void;
  48733. /**
  48734. * Get the lens flare system emitter position.
  48735. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48736. * @returns the position
  48737. */
  48738. getEmitterPosition(): Vector3;
  48739. /**
  48740. * @hidden
  48741. */
  48742. computeEffectivePosition(globalViewport: Viewport): boolean;
  48743. /** @hidden */
  48744. _isVisible(): boolean;
  48745. /**
  48746. * @hidden
  48747. */
  48748. render(): boolean;
  48749. /**
  48750. * Dispose and release the lens flare with its associated resources.
  48751. */
  48752. dispose(): void;
  48753. /**
  48754. * Parse a lens flare system from a JSON repressentation
  48755. * @param parsedLensFlareSystem Define the JSON to parse
  48756. * @param scene Define the scene the parsed system should be instantiated in
  48757. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48758. * @returns the parsed system
  48759. */
  48760. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48761. /**
  48762. * Serialize the current Lens Flare System into a JSON representation.
  48763. * @returns the serialized JSON
  48764. */
  48765. serialize(): any;
  48766. }
  48767. }
  48768. declare module BABYLON {
  48769. /**
  48770. * This represents one of the lens effect in a `lensFlareSystem`.
  48771. * It controls one of the indiviual texture used in the effect.
  48772. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48773. */
  48774. export class LensFlare {
  48775. /**
  48776. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48777. */
  48778. size: number;
  48779. /**
  48780. * 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.
  48781. */
  48782. position: number;
  48783. /**
  48784. * Define the lens color.
  48785. */
  48786. color: Color3;
  48787. /**
  48788. * Define the lens texture.
  48789. */
  48790. texture: Nullable<Texture>;
  48791. /**
  48792. * Define the alpha mode to render this particular lens.
  48793. */
  48794. alphaMode: number;
  48795. private _system;
  48796. /**
  48797. * Creates a new Lens Flare.
  48798. * This represents one of the lens effect in a `lensFlareSystem`.
  48799. * It controls one of the indiviual texture used in the effect.
  48800. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48801. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48802. * @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.
  48803. * @param color Define the lens color
  48804. * @param imgUrl Define the lens texture url
  48805. * @param system Define the `lensFlareSystem` this flare is part of
  48806. * @returns The newly created Lens Flare
  48807. */
  48808. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48809. /**
  48810. * Instantiates a new Lens Flare.
  48811. * This represents one of the lens effect in a `lensFlareSystem`.
  48812. * It controls one of the indiviual texture used in the effect.
  48813. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48814. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48815. * @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.
  48816. * @param color Define the lens color
  48817. * @param imgUrl Define the lens texture url
  48818. * @param system Define the `lensFlareSystem` this flare is part of
  48819. */
  48820. constructor(
  48821. /**
  48822. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48823. */
  48824. size: number,
  48825. /**
  48826. * 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.
  48827. */
  48828. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48829. /**
  48830. * Dispose and release the lens flare with its associated resources.
  48831. */
  48832. dispose(): void;
  48833. }
  48834. }
  48835. declare module BABYLON {
  48836. interface AbstractScene {
  48837. /**
  48838. * The list of lens flare system added to the scene
  48839. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48840. */
  48841. lensFlareSystems: Array<LensFlareSystem>;
  48842. /**
  48843. * Removes the given lens flare system from this scene.
  48844. * @param toRemove The lens flare system to remove
  48845. * @returns The index of the removed lens flare system
  48846. */
  48847. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48848. /**
  48849. * Adds the given lens flare system to this scene
  48850. * @param newLensFlareSystem The lens flare system to add
  48851. */
  48852. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48853. /**
  48854. * Gets a lens flare system using its name
  48855. * @param name defines the name to look for
  48856. * @returns the lens flare system or null if not found
  48857. */
  48858. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48859. /**
  48860. * Gets a lens flare system using its id
  48861. * @param id defines the id to look for
  48862. * @returns the lens flare system or null if not found
  48863. */
  48864. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48865. }
  48866. /**
  48867. * Defines the lens flare scene component responsible to manage any lens flares
  48868. * in a given scene.
  48869. */
  48870. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48871. /**
  48872. * The component name helpfull to identify the component in the list of scene components.
  48873. */
  48874. readonly name: string;
  48875. /**
  48876. * The scene the component belongs to.
  48877. */
  48878. scene: Scene;
  48879. /**
  48880. * Creates a new instance of the component for the given scene
  48881. * @param scene Defines the scene to register the component in
  48882. */
  48883. constructor(scene: Scene);
  48884. /**
  48885. * Registers the component in a given scene
  48886. */
  48887. register(): void;
  48888. /**
  48889. * Rebuilds the elements related to this component in case of
  48890. * context lost for instance.
  48891. */
  48892. rebuild(): void;
  48893. /**
  48894. * Adds all the elements from the container to the scene
  48895. * @param container the container holding the elements
  48896. */
  48897. addFromContainer(container: AbstractScene): void;
  48898. /**
  48899. * Removes all the elements in the container from the scene
  48900. * @param container contains the elements to remove
  48901. * @param dispose if the removed element should be disposed (default: false)
  48902. */
  48903. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48904. /**
  48905. * Serializes the component data to the specified json object
  48906. * @param serializationObject The object to serialize to
  48907. */
  48908. serialize(serializationObject: any): void;
  48909. /**
  48910. * Disposes the component and the associated ressources.
  48911. */
  48912. dispose(): void;
  48913. private _draw;
  48914. }
  48915. }
  48916. declare module BABYLON {
  48917. /**
  48918. * Defines the shadow generator component responsible to manage any shadow generators
  48919. * in a given scene.
  48920. */
  48921. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48922. /**
  48923. * The component name helpfull to identify the component in the list of scene components.
  48924. */
  48925. readonly name: string;
  48926. /**
  48927. * The scene the component belongs to.
  48928. */
  48929. scene: Scene;
  48930. /**
  48931. * Creates a new instance of the component for the given scene
  48932. * @param scene Defines the scene to register the component in
  48933. */
  48934. constructor(scene: Scene);
  48935. /**
  48936. * Registers the component in a given scene
  48937. */
  48938. register(): void;
  48939. /**
  48940. * Rebuilds the elements related to this component in case of
  48941. * context lost for instance.
  48942. */
  48943. rebuild(): void;
  48944. /**
  48945. * Serializes the component data to the specified json object
  48946. * @param serializationObject The object to serialize to
  48947. */
  48948. serialize(serializationObject: any): void;
  48949. /**
  48950. * Adds all the elements from the container to the scene
  48951. * @param container the container holding the elements
  48952. */
  48953. addFromContainer(container: AbstractScene): void;
  48954. /**
  48955. * Removes all the elements in the container from the scene
  48956. * @param container contains the elements to remove
  48957. * @param dispose if the removed element should be disposed (default: false)
  48958. */
  48959. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48960. /**
  48961. * Rebuilds the elements related to this component in case of
  48962. * context lost for instance.
  48963. */
  48964. dispose(): void;
  48965. private _gatherRenderTargets;
  48966. }
  48967. }
  48968. declare module BABYLON {
  48969. /**
  48970. * A point light is a light defined by an unique point in world space.
  48971. * The light is emitted in every direction from this point.
  48972. * A good example of a point light is a standard light bulb.
  48973. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48974. */
  48975. export class PointLight extends ShadowLight {
  48976. private _shadowAngle;
  48977. /**
  48978. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48979. * This specifies what angle the shadow will use to be created.
  48980. *
  48981. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48982. */
  48983. /**
  48984. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48985. * This specifies what angle the shadow will use to be created.
  48986. *
  48987. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48988. */
  48989. shadowAngle: number;
  48990. /**
  48991. * Gets the direction if it has been set.
  48992. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48993. */
  48994. /**
  48995. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48996. */
  48997. direction: Vector3;
  48998. /**
  48999. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49000. * A PointLight emits the light in every direction.
  49001. * It can cast shadows.
  49002. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49003. * ```javascript
  49004. * var pointLight = new PointLight("pl", camera.position, scene);
  49005. * ```
  49006. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49007. * @param name The light friendly name
  49008. * @param position The position of the point light in the scene
  49009. * @param scene The scene the lights belongs to
  49010. */
  49011. constructor(name: string, position: Vector3, scene: Scene);
  49012. /**
  49013. * Returns the string "PointLight"
  49014. * @returns the class name
  49015. */
  49016. getClassName(): string;
  49017. /**
  49018. * Returns the integer 0.
  49019. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49020. */
  49021. getTypeID(): number;
  49022. /**
  49023. * Specifies wether or not the shadowmap should be a cube texture.
  49024. * @returns true if the shadowmap needs to be a cube texture.
  49025. */
  49026. needCube(): boolean;
  49027. /**
  49028. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49029. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49030. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49031. */
  49032. getShadowDirection(faceIndex?: number): Vector3;
  49033. /**
  49034. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49035. * - fov = PI / 2
  49036. * - aspect ratio : 1.0
  49037. * - z-near and far equal to the active camera minZ and maxZ.
  49038. * Returns the PointLight.
  49039. */
  49040. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49041. protected _buildUniformLayout(): void;
  49042. /**
  49043. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49044. * @param effect The effect to update
  49045. * @param lightIndex The index of the light in the effect to update
  49046. * @returns The point light
  49047. */
  49048. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49049. /**
  49050. * Prepares the list of defines specific to the light type.
  49051. * @param defines the list of defines
  49052. * @param lightIndex defines the index of the light for the effect
  49053. */
  49054. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49055. }
  49056. }
  49057. declare module BABYLON {
  49058. /**
  49059. * Header information of HDR texture files.
  49060. */
  49061. export interface HDRInfo {
  49062. /**
  49063. * The height of the texture in pixels.
  49064. */
  49065. height: number;
  49066. /**
  49067. * The width of the texture in pixels.
  49068. */
  49069. width: number;
  49070. /**
  49071. * The index of the beginning of the data in the binary file.
  49072. */
  49073. dataPosition: number;
  49074. }
  49075. /**
  49076. * This groups tools to convert HDR texture to native colors array.
  49077. */
  49078. export class HDRTools {
  49079. private static Ldexp;
  49080. private static Rgbe2float;
  49081. private static readStringLine;
  49082. /**
  49083. * Reads header information from an RGBE texture stored in a native array.
  49084. * More information on this format are available here:
  49085. * https://en.wikipedia.org/wiki/RGBE_image_format
  49086. *
  49087. * @param uint8array The binary file stored in native array.
  49088. * @return The header information.
  49089. */
  49090. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49091. /**
  49092. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49093. * This RGBE texture needs to store the information as a panorama.
  49094. *
  49095. * More information on this format are available here:
  49096. * https://en.wikipedia.org/wiki/RGBE_image_format
  49097. *
  49098. * @param buffer The binary file stored in an array buffer.
  49099. * @param size The expected size of the extracted cubemap.
  49100. * @return The Cube Map information.
  49101. */
  49102. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49103. /**
  49104. * Returns the pixels data extracted from an RGBE texture.
  49105. * This pixels will be stored left to right up to down in the R G B order in one array.
  49106. *
  49107. * More information on this format are available here:
  49108. * https://en.wikipedia.org/wiki/RGBE_image_format
  49109. *
  49110. * @param uint8array The binary file stored in an array buffer.
  49111. * @param hdrInfo The header information of the file.
  49112. * @return The pixels data in RGB right to left up to down order.
  49113. */
  49114. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49115. private static RGBE_ReadPixels_RLE;
  49116. }
  49117. }
  49118. declare module BABYLON {
  49119. /**
  49120. * This represents a texture coming from an HDR input.
  49121. *
  49122. * The only supported format is currently panorama picture stored in RGBE format.
  49123. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49124. */
  49125. export class HDRCubeTexture extends BaseTexture {
  49126. private static _facesMapping;
  49127. private _generateHarmonics;
  49128. private _noMipmap;
  49129. private _textureMatrix;
  49130. private _size;
  49131. private _onLoad;
  49132. private _onError;
  49133. /**
  49134. * The texture URL.
  49135. */
  49136. url: string;
  49137. /**
  49138. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49139. */
  49140. coordinatesMode: number;
  49141. protected _isBlocking: boolean;
  49142. /**
  49143. * Sets wether or not the texture is blocking during loading.
  49144. */
  49145. /**
  49146. * Gets wether or not the texture is blocking during loading.
  49147. */
  49148. isBlocking: boolean;
  49149. protected _rotationY: number;
  49150. /**
  49151. * Sets texture matrix rotation angle around Y axis in radians.
  49152. */
  49153. /**
  49154. * Gets texture matrix rotation angle around Y axis radians.
  49155. */
  49156. rotationY: number;
  49157. /**
  49158. * Gets or sets the center of the bounding box associated with the cube texture
  49159. * It must define where the camera used to render the texture was set
  49160. */
  49161. boundingBoxPosition: Vector3;
  49162. private _boundingBoxSize;
  49163. /**
  49164. * Gets or sets the size of the bounding box associated with the cube texture
  49165. * When defined, the cubemap will switch to local mode
  49166. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49167. * @example https://www.babylonjs-playground.com/#RNASML
  49168. */
  49169. boundingBoxSize: Vector3;
  49170. /**
  49171. * Instantiates an HDRTexture from the following parameters.
  49172. *
  49173. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49174. * @param scene The scene the texture will be used in
  49175. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49176. * @param noMipmap Forces to not generate the mipmap if true
  49177. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49178. * @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)
  49179. * @param reserved Reserved flag for internal use.
  49180. */
  49181. 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>);
  49182. /**
  49183. * Get the current class name of the texture useful for serialization or dynamic coding.
  49184. * @returns "HDRCubeTexture"
  49185. */
  49186. getClassName(): string;
  49187. /**
  49188. * Occurs when the file is raw .hdr file.
  49189. */
  49190. private loadTexture;
  49191. clone(): HDRCubeTexture;
  49192. delayLoad(): void;
  49193. /**
  49194. * Get the texture reflection matrix used to rotate/transform the reflection.
  49195. * @returns the reflection matrix
  49196. */
  49197. getReflectionTextureMatrix(): Matrix;
  49198. /**
  49199. * Set the texture reflection matrix used to rotate/transform the reflection.
  49200. * @param value Define the reflection matrix to set
  49201. */
  49202. setReflectionTextureMatrix(value: Matrix): void;
  49203. /**
  49204. * Parses a JSON representation of an HDR Texture in order to create the texture
  49205. * @param parsedTexture Define the JSON representation
  49206. * @param scene Define the scene the texture should be created in
  49207. * @param rootUrl Define the root url in case we need to load relative dependencies
  49208. * @returns the newly created texture after parsing
  49209. */
  49210. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49211. serialize(): any;
  49212. }
  49213. }
  49214. declare module BABYLON {
  49215. /**
  49216. * Class used to control physics engine
  49217. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49218. */
  49219. export class PhysicsEngine implements IPhysicsEngine {
  49220. private _physicsPlugin;
  49221. /**
  49222. * Global value used to control the smallest number supported by the simulation
  49223. */
  49224. static Epsilon: number;
  49225. private _impostors;
  49226. private _joints;
  49227. /**
  49228. * Gets the gravity vector used by the simulation
  49229. */
  49230. gravity: Vector3;
  49231. /**
  49232. * Factory used to create the default physics plugin.
  49233. * @returns The default physics plugin
  49234. */
  49235. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49236. /**
  49237. * Creates a new Physics Engine
  49238. * @param gravity defines the gravity vector used by the simulation
  49239. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49240. */
  49241. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49242. /**
  49243. * Sets the gravity vector used by the simulation
  49244. * @param gravity defines the gravity vector to use
  49245. */
  49246. setGravity(gravity: Vector3): void;
  49247. /**
  49248. * Set the time step of the physics engine.
  49249. * Default is 1/60.
  49250. * To slow it down, enter 1/600 for example.
  49251. * To speed it up, 1/30
  49252. * @param newTimeStep defines the new timestep to apply to this world.
  49253. */
  49254. setTimeStep(newTimeStep?: number): void;
  49255. /**
  49256. * Get the time step of the physics engine.
  49257. * @returns the current time step
  49258. */
  49259. getTimeStep(): number;
  49260. /**
  49261. * Release all resources
  49262. */
  49263. dispose(): void;
  49264. /**
  49265. * Gets the name of the current physics plugin
  49266. * @returns the name of the plugin
  49267. */
  49268. getPhysicsPluginName(): string;
  49269. /**
  49270. * Adding a new impostor for the impostor tracking.
  49271. * This will be done by the impostor itself.
  49272. * @param impostor the impostor to add
  49273. */
  49274. addImpostor(impostor: PhysicsImpostor): void;
  49275. /**
  49276. * Remove an impostor from the engine.
  49277. * This impostor and its mesh will not longer be updated by the physics engine.
  49278. * @param impostor the impostor to remove
  49279. */
  49280. removeImpostor(impostor: PhysicsImpostor): void;
  49281. /**
  49282. * Add a joint to the physics engine
  49283. * @param mainImpostor defines the main impostor to which the joint is added.
  49284. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49285. * @param joint defines the joint that will connect both impostors.
  49286. */
  49287. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49288. /**
  49289. * Removes a joint from the simulation
  49290. * @param mainImpostor defines the impostor used with the joint
  49291. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49292. * @param joint defines the joint to remove
  49293. */
  49294. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49295. /**
  49296. * Called by the scene. No need to call it.
  49297. * @param delta defines the timespam between frames
  49298. */
  49299. _step(delta: number): void;
  49300. /**
  49301. * Gets the current plugin used to run the simulation
  49302. * @returns current plugin
  49303. */
  49304. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49305. /**
  49306. * Gets the list of physic impostors
  49307. * @returns an array of PhysicsImpostor
  49308. */
  49309. getImpostors(): Array<PhysicsImpostor>;
  49310. /**
  49311. * Gets the impostor for a physics enabled object
  49312. * @param object defines the object impersonated by the impostor
  49313. * @returns the PhysicsImpostor or null if not found
  49314. */
  49315. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49316. /**
  49317. * Gets the impostor for a physics body object
  49318. * @param body defines physics body used by the impostor
  49319. * @returns the PhysicsImpostor or null if not found
  49320. */
  49321. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49322. /**
  49323. * Does a raycast in the physics world
  49324. * @param from when should the ray start?
  49325. * @param to when should the ray end?
  49326. * @returns PhysicsRaycastResult
  49327. */
  49328. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49329. }
  49330. }
  49331. declare module BABYLON {
  49332. /** @hidden */
  49333. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49334. private _useDeltaForWorldStep;
  49335. world: any;
  49336. name: string;
  49337. private _physicsMaterials;
  49338. private _fixedTimeStep;
  49339. private _cannonRaycastResult;
  49340. private _raycastResult;
  49341. private _physicsBodysToRemoveAfterStep;
  49342. BJSCANNON: any;
  49343. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49344. setGravity(gravity: Vector3): void;
  49345. setTimeStep(timeStep: number): void;
  49346. getTimeStep(): number;
  49347. executeStep(delta: number): void;
  49348. private _removeMarkedPhysicsBodiesFromWorld;
  49349. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49350. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49351. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49352. private _processChildMeshes;
  49353. removePhysicsBody(impostor: PhysicsImpostor): void;
  49354. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49355. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49356. private _addMaterial;
  49357. private _checkWithEpsilon;
  49358. private _createShape;
  49359. private _createHeightmap;
  49360. private _minus90X;
  49361. private _plus90X;
  49362. private _tmpPosition;
  49363. private _tmpDeltaPosition;
  49364. private _tmpUnityRotation;
  49365. private _updatePhysicsBodyTransformation;
  49366. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49367. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49368. isSupported(): boolean;
  49369. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49370. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49371. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49372. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49373. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49374. getBodyMass(impostor: PhysicsImpostor): number;
  49375. getBodyFriction(impostor: PhysicsImpostor): number;
  49376. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49377. getBodyRestitution(impostor: PhysicsImpostor): number;
  49378. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49379. sleepBody(impostor: PhysicsImpostor): void;
  49380. wakeUpBody(impostor: PhysicsImpostor): void;
  49381. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49382. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49383. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49384. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49385. getRadius(impostor: PhysicsImpostor): number;
  49386. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49387. dispose(): void;
  49388. private _extendNamespace;
  49389. /**
  49390. * Does a raycast in the physics world
  49391. * @param from when should the ray start?
  49392. * @param to when should the ray end?
  49393. * @returns PhysicsRaycastResult
  49394. */
  49395. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49396. }
  49397. }
  49398. declare module BABYLON {
  49399. /** @hidden */
  49400. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49401. world: any;
  49402. name: string;
  49403. BJSOIMO: any;
  49404. private _raycastResult;
  49405. constructor(iterations?: number, oimoInjection?: any);
  49406. setGravity(gravity: Vector3): void;
  49407. setTimeStep(timeStep: number): void;
  49408. getTimeStep(): number;
  49409. private _tmpImpostorsArray;
  49410. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49411. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49412. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49413. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49414. private _tmpPositionVector;
  49415. removePhysicsBody(impostor: PhysicsImpostor): void;
  49416. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49417. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49418. isSupported(): boolean;
  49419. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49420. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49421. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49422. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49423. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49424. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49425. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49426. getBodyMass(impostor: PhysicsImpostor): number;
  49427. getBodyFriction(impostor: PhysicsImpostor): number;
  49428. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49429. getBodyRestitution(impostor: PhysicsImpostor): number;
  49430. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49431. sleepBody(impostor: PhysicsImpostor): void;
  49432. wakeUpBody(impostor: PhysicsImpostor): void;
  49433. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49434. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49435. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49436. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49437. getRadius(impostor: PhysicsImpostor): number;
  49438. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49439. dispose(): void;
  49440. /**
  49441. * Does a raycast in the physics world
  49442. * @param from when should the ray start?
  49443. * @param to when should the ray end?
  49444. * @returns PhysicsRaycastResult
  49445. */
  49446. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49447. }
  49448. }
  49449. declare module BABYLON {
  49450. /**
  49451. * Class containing static functions to help procedurally build meshes
  49452. */
  49453. export class RibbonBuilder {
  49454. /**
  49455. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49456. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49457. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49458. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49459. * * 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
  49460. * * 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
  49461. * * 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
  49462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49463. * * 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
  49464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49465. * * 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
  49466. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49467. * * 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
  49468. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49470. * @param name defines the name of the mesh
  49471. * @param options defines the options used to create the mesh
  49472. * @param scene defines the hosting scene
  49473. * @returns the ribbon mesh
  49474. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49475. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49476. */
  49477. static CreateRibbon(name: string, options: {
  49478. pathArray: Vector3[][];
  49479. closeArray?: boolean;
  49480. closePath?: boolean;
  49481. offset?: number;
  49482. updatable?: boolean;
  49483. sideOrientation?: number;
  49484. frontUVs?: Vector4;
  49485. backUVs?: Vector4;
  49486. instance?: Mesh;
  49487. invertUV?: boolean;
  49488. uvs?: Vector2[];
  49489. colors?: Color4[];
  49490. }, scene?: Nullable<Scene>): Mesh;
  49491. }
  49492. }
  49493. declare module BABYLON {
  49494. /**
  49495. * Class containing static functions to help procedurally build meshes
  49496. */
  49497. export class ShapeBuilder {
  49498. /**
  49499. * 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.
  49500. * * 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.
  49501. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49502. * * 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.
  49503. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49504. * * 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
  49505. * * 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
  49506. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49508. * * 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
  49509. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49511. * @param name defines the name of the mesh
  49512. * @param options defines the options used to create the mesh
  49513. * @param scene defines the hosting scene
  49514. * @returns the extruded shape mesh
  49515. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49516. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49517. */
  49518. static ExtrudeShape(name: string, options: {
  49519. shape: Vector3[];
  49520. path: Vector3[];
  49521. scale?: number;
  49522. rotation?: number;
  49523. cap?: number;
  49524. updatable?: boolean;
  49525. sideOrientation?: number;
  49526. frontUVs?: Vector4;
  49527. backUVs?: Vector4;
  49528. instance?: Mesh;
  49529. invertUV?: boolean;
  49530. }, scene?: Nullable<Scene>): Mesh;
  49531. /**
  49532. * Creates an custom extruded shape mesh.
  49533. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49534. * * 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.
  49535. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49536. * * 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
  49537. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49538. * * 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
  49539. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49540. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49541. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49542. * * 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
  49543. * * 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
  49544. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49546. * * 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
  49547. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49549. * @param name defines the name of the mesh
  49550. * @param options defines the options used to create the mesh
  49551. * @param scene defines the hosting scene
  49552. * @returns the custom extruded shape mesh
  49553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49554. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49556. */
  49557. static ExtrudeShapeCustom(name: string, options: {
  49558. shape: Vector3[];
  49559. path: Vector3[];
  49560. scaleFunction?: any;
  49561. rotationFunction?: any;
  49562. ribbonCloseArray?: boolean;
  49563. ribbonClosePath?: boolean;
  49564. cap?: number;
  49565. updatable?: boolean;
  49566. sideOrientation?: number;
  49567. frontUVs?: Vector4;
  49568. backUVs?: Vector4;
  49569. instance?: Mesh;
  49570. invertUV?: boolean;
  49571. }, scene?: Nullable<Scene>): Mesh;
  49572. private static _ExtrudeShapeGeneric;
  49573. }
  49574. }
  49575. declare module BABYLON {
  49576. /**
  49577. * AmmoJS Physics plugin
  49578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49579. * @see https://github.com/kripken/ammo.js/
  49580. */
  49581. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49582. private _useDeltaForWorldStep;
  49583. /**
  49584. * Reference to the Ammo library
  49585. */
  49586. bjsAMMO: any;
  49587. /**
  49588. * Created ammoJS world which physics bodies are added to
  49589. */
  49590. world: any;
  49591. /**
  49592. * Name of the plugin
  49593. */
  49594. name: string;
  49595. private _timeStep;
  49596. private _fixedTimeStep;
  49597. private _maxSteps;
  49598. private _tmpQuaternion;
  49599. private _tmpAmmoTransform;
  49600. private _tmpAmmoQuaternion;
  49601. private _tmpAmmoConcreteContactResultCallback;
  49602. private _collisionConfiguration;
  49603. private _dispatcher;
  49604. private _overlappingPairCache;
  49605. private _solver;
  49606. private _softBodySolver;
  49607. private _tmpAmmoVectorA;
  49608. private _tmpAmmoVectorB;
  49609. private _tmpAmmoVectorC;
  49610. private _tmpAmmoVectorD;
  49611. private _tmpContactCallbackResult;
  49612. private _tmpAmmoVectorRCA;
  49613. private _tmpAmmoVectorRCB;
  49614. private _raycastResult;
  49615. private static readonly DISABLE_COLLISION_FLAG;
  49616. private static readonly KINEMATIC_FLAG;
  49617. private static readonly DISABLE_DEACTIVATION_FLAG;
  49618. /**
  49619. * Initializes the ammoJS plugin
  49620. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49621. * @param ammoInjection can be used to inject your own ammo reference
  49622. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49623. */
  49624. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49625. /**
  49626. * Sets the gravity of the physics world (m/(s^2))
  49627. * @param gravity Gravity to set
  49628. */
  49629. setGravity(gravity: Vector3): void;
  49630. /**
  49631. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49632. * @param timeStep timestep to use in seconds
  49633. */
  49634. setTimeStep(timeStep: number): void;
  49635. /**
  49636. * 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)
  49637. * @param fixedTimeStep fixedTimeStep to use in seconds
  49638. */
  49639. setFixedTimeStep(fixedTimeStep: number): void;
  49640. /**
  49641. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49642. * @param maxSteps the maximum number of steps by the physics engine per frame
  49643. */
  49644. setMaxSteps(maxSteps: number): void;
  49645. /**
  49646. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49647. * @returns the current timestep in seconds
  49648. */
  49649. getTimeStep(): number;
  49650. private _isImpostorInContact;
  49651. private _isImpostorPairInContact;
  49652. private _stepSimulation;
  49653. /**
  49654. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49655. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49656. * After the step the babylon meshes are set to the position of the physics imposters
  49657. * @param delta amount of time to step forward
  49658. * @param impostors array of imposters to update before/after the step
  49659. */
  49660. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49661. /**
  49662. * Update babylon mesh to match physics world object
  49663. * @param impostor imposter to match
  49664. */
  49665. private _afterSoftStep;
  49666. /**
  49667. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49668. * @param impostor imposter to match
  49669. */
  49670. private _ropeStep;
  49671. /**
  49672. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49673. * @param impostor imposter to match
  49674. */
  49675. private _softbodyOrClothStep;
  49676. private _tmpVector;
  49677. private _tmpMatrix;
  49678. /**
  49679. * Applies an impulse on the imposter
  49680. * @param impostor imposter to apply impulse to
  49681. * @param force amount of force to be applied to the imposter
  49682. * @param contactPoint the location to apply the impulse on the imposter
  49683. */
  49684. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49685. /**
  49686. * Applies a force on the imposter
  49687. * @param impostor imposter to apply force
  49688. * @param force amount of force to be applied to the imposter
  49689. * @param contactPoint the location to apply the force on the imposter
  49690. */
  49691. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49692. /**
  49693. * Creates a physics body using the plugin
  49694. * @param impostor the imposter to create the physics body on
  49695. */
  49696. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49697. /**
  49698. * Removes the physics body from the imposter and disposes of the body's memory
  49699. * @param impostor imposter to remove the physics body from
  49700. */
  49701. removePhysicsBody(impostor: PhysicsImpostor): void;
  49702. /**
  49703. * Generates a joint
  49704. * @param impostorJoint the imposter joint to create the joint with
  49705. */
  49706. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49707. /**
  49708. * Removes a joint
  49709. * @param impostorJoint the imposter joint to remove the joint from
  49710. */
  49711. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49712. private _addMeshVerts;
  49713. /**
  49714. * Initialise the soft body vertices to match its object's (mesh) vertices
  49715. * Softbody vertices (nodes) are in world space and to match this
  49716. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49717. * @param impostor to create the softbody for
  49718. */
  49719. private _softVertexData;
  49720. /**
  49721. * Create an impostor's soft body
  49722. * @param impostor to create the softbody for
  49723. */
  49724. private _createSoftbody;
  49725. /**
  49726. * Create cloth for an impostor
  49727. * @param impostor to create the softbody for
  49728. */
  49729. private _createCloth;
  49730. /**
  49731. * Create rope for an impostor
  49732. * @param impostor to create the softbody for
  49733. */
  49734. private _createRope;
  49735. private _addHullVerts;
  49736. private _createShape;
  49737. /**
  49738. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49739. * @param impostor imposter containing the physics body and babylon object
  49740. */
  49741. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49742. /**
  49743. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49744. * @param impostor imposter containing the physics body and babylon object
  49745. * @param newPosition new position
  49746. * @param newRotation new rotation
  49747. */
  49748. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49749. /**
  49750. * If this plugin is supported
  49751. * @returns true if its supported
  49752. */
  49753. isSupported(): boolean;
  49754. /**
  49755. * Sets the linear velocity of the physics body
  49756. * @param impostor imposter to set the velocity on
  49757. * @param velocity velocity to set
  49758. */
  49759. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49760. /**
  49761. * Sets the angular velocity of the physics body
  49762. * @param impostor imposter to set the velocity on
  49763. * @param velocity velocity to set
  49764. */
  49765. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49766. /**
  49767. * gets the linear velocity
  49768. * @param impostor imposter to get linear velocity from
  49769. * @returns linear velocity
  49770. */
  49771. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49772. /**
  49773. * gets the angular velocity
  49774. * @param impostor imposter to get angular velocity from
  49775. * @returns angular velocity
  49776. */
  49777. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49778. /**
  49779. * Sets the mass of physics body
  49780. * @param impostor imposter to set the mass on
  49781. * @param mass mass to set
  49782. */
  49783. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49784. /**
  49785. * Gets the mass of the physics body
  49786. * @param impostor imposter to get the mass from
  49787. * @returns mass
  49788. */
  49789. getBodyMass(impostor: PhysicsImpostor): number;
  49790. /**
  49791. * Gets friction of the impostor
  49792. * @param impostor impostor to get friction from
  49793. * @returns friction value
  49794. */
  49795. getBodyFriction(impostor: PhysicsImpostor): number;
  49796. /**
  49797. * Sets friction of the impostor
  49798. * @param impostor impostor to set friction on
  49799. * @param friction friction value
  49800. */
  49801. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49802. /**
  49803. * Gets restitution of the impostor
  49804. * @param impostor impostor to get restitution from
  49805. * @returns restitution value
  49806. */
  49807. getBodyRestitution(impostor: PhysicsImpostor): number;
  49808. /**
  49809. * Sets resitution of the impostor
  49810. * @param impostor impostor to set resitution on
  49811. * @param restitution resitution value
  49812. */
  49813. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49814. /**
  49815. * Gets pressure inside the impostor
  49816. * @param impostor impostor to get pressure from
  49817. * @returns pressure value
  49818. */
  49819. getBodyPressure(impostor: PhysicsImpostor): number;
  49820. /**
  49821. * Sets pressure inside a soft body impostor
  49822. * Cloth and rope must remain 0 pressure
  49823. * @param impostor impostor to set pressure on
  49824. * @param pressure pressure value
  49825. */
  49826. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49827. /**
  49828. * Gets stiffness of the impostor
  49829. * @param impostor impostor to get stiffness from
  49830. * @returns pressure value
  49831. */
  49832. getBodyStiffness(impostor: PhysicsImpostor): number;
  49833. /**
  49834. * Sets stiffness of the impostor
  49835. * @param impostor impostor to set stiffness on
  49836. * @param stiffness stiffness value from 0 to 1
  49837. */
  49838. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49839. /**
  49840. * Gets velocityIterations of the impostor
  49841. * @param impostor impostor to get velocity iterations from
  49842. * @returns velocityIterations value
  49843. */
  49844. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49845. /**
  49846. * Sets velocityIterations of the impostor
  49847. * @param impostor impostor to set velocity iterations on
  49848. * @param velocityIterations velocityIterations value
  49849. */
  49850. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49851. /**
  49852. * Gets positionIterations of the impostor
  49853. * @param impostor impostor to get position iterations from
  49854. * @returns positionIterations value
  49855. */
  49856. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49857. /**
  49858. * Sets positionIterations of the impostor
  49859. * @param impostor impostor to set position on
  49860. * @param positionIterations positionIterations value
  49861. */
  49862. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49863. /**
  49864. * Append an anchor to a cloth object
  49865. * @param impostor is the cloth impostor to add anchor to
  49866. * @param otherImpostor is the rigid impostor to anchor to
  49867. * @param width ratio across width from 0 to 1
  49868. * @param height ratio up height from 0 to 1
  49869. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49870. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49871. */
  49872. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49873. /**
  49874. * Append an hook to a rope object
  49875. * @param impostor is the rope impostor to add hook to
  49876. * @param otherImpostor is the rigid impostor to hook to
  49877. * @param length ratio along the rope from 0 to 1
  49878. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49879. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49880. */
  49881. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49882. /**
  49883. * Sleeps the physics body and stops it from being active
  49884. * @param impostor impostor to sleep
  49885. */
  49886. sleepBody(impostor: PhysicsImpostor): void;
  49887. /**
  49888. * Activates the physics body
  49889. * @param impostor impostor to activate
  49890. */
  49891. wakeUpBody(impostor: PhysicsImpostor): void;
  49892. /**
  49893. * Updates the distance parameters of the joint
  49894. * @param joint joint to update
  49895. * @param maxDistance maximum distance of the joint
  49896. * @param minDistance minimum distance of the joint
  49897. */
  49898. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49899. /**
  49900. * Sets a motor on the joint
  49901. * @param joint joint to set motor on
  49902. * @param speed speed of the motor
  49903. * @param maxForce maximum force of the motor
  49904. * @param motorIndex index of the motor
  49905. */
  49906. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49907. /**
  49908. * Sets the motors limit
  49909. * @param joint joint to set limit on
  49910. * @param upperLimit upper limit
  49911. * @param lowerLimit lower limit
  49912. */
  49913. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49914. /**
  49915. * Syncs the position and rotation of a mesh with the impostor
  49916. * @param mesh mesh to sync
  49917. * @param impostor impostor to update the mesh with
  49918. */
  49919. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49920. /**
  49921. * Gets the radius of the impostor
  49922. * @param impostor impostor to get radius from
  49923. * @returns the radius
  49924. */
  49925. getRadius(impostor: PhysicsImpostor): number;
  49926. /**
  49927. * Gets the box size of the impostor
  49928. * @param impostor impostor to get box size from
  49929. * @param result the resulting box size
  49930. */
  49931. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49932. /**
  49933. * Disposes of the impostor
  49934. */
  49935. dispose(): void;
  49936. /**
  49937. * Does a raycast in the physics world
  49938. * @param from when should the ray start?
  49939. * @param to when should the ray end?
  49940. * @returns PhysicsRaycastResult
  49941. */
  49942. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49943. }
  49944. }
  49945. declare module BABYLON {
  49946. interface AbstractScene {
  49947. /**
  49948. * The list of reflection probes added to the scene
  49949. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49950. */
  49951. reflectionProbes: Array<ReflectionProbe>;
  49952. /**
  49953. * Removes the given reflection probe from this scene.
  49954. * @param toRemove The reflection probe to remove
  49955. * @returns The index of the removed reflection probe
  49956. */
  49957. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49958. /**
  49959. * Adds the given reflection probe to this scene.
  49960. * @param newReflectionProbe The reflection probe to add
  49961. */
  49962. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49963. }
  49964. /**
  49965. * Class used to generate realtime reflection / refraction cube textures
  49966. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49967. */
  49968. export class ReflectionProbe {
  49969. /** defines the name of the probe */
  49970. name: string;
  49971. private _scene;
  49972. private _renderTargetTexture;
  49973. private _projectionMatrix;
  49974. private _viewMatrix;
  49975. private _target;
  49976. private _add;
  49977. private _attachedMesh;
  49978. private _invertYAxis;
  49979. /** Gets or sets probe position (center of the cube map) */
  49980. position: Vector3;
  49981. /**
  49982. * Creates a new reflection probe
  49983. * @param name defines the name of the probe
  49984. * @param size defines the texture resolution (for each face)
  49985. * @param scene defines the hosting scene
  49986. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49987. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49988. */
  49989. constructor(
  49990. /** defines the name of the probe */
  49991. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49992. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49993. samples: number;
  49994. /** Gets or sets the refresh rate to use (on every frame by default) */
  49995. refreshRate: number;
  49996. /**
  49997. * Gets the hosting scene
  49998. * @returns a Scene
  49999. */
  50000. getScene(): Scene;
  50001. /** Gets the internal CubeTexture used to render to */
  50002. readonly cubeTexture: RenderTargetTexture;
  50003. /** Gets the list of meshes to render */
  50004. readonly renderList: Nullable<AbstractMesh[]>;
  50005. /**
  50006. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50007. * @param mesh defines the mesh to attach to
  50008. */
  50009. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50010. /**
  50011. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50012. * @param renderingGroupId The rendering group id corresponding to its index
  50013. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50014. */
  50015. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50016. /**
  50017. * Clean all associated resources
  50018. */
  50019. dispose(): void;
  50020. /**
  50021. * Converts the reflection probe information to a readable string for debug purpose.
  50022. * @param fullDetails Supports for multiple levels of logging within scene loading
  50023. * @returns the human readable reflection probe info
  50024. */
  50025. toString(fullDetails?: boolean): string;
  50026. /**
  50027. * Get the class name of the relfection probe.
  50028. * @returns "ReflectionProbe"
  50029. */
  50030. getClassName(): string;
  50031. /**
  50032. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50033. * @returns The JSON representation of the texture
  50034. */
  50035. serialize(): any;
  50036. /**
  50037. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50038. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50039. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50040. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50041. * @returns The parsed reflection probe if successful
  50042. */
  50043. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50044. }
  50045. }
  50046. declare module BABYLON {
  50047. /** @hidden */
  50048. export var _BabylonLoaderRegistered: boolean;
  50049. }
  50050. declare module BABYLON {
  50051. /**
  50052. * The Physically based simple base material of BJS.
  50053. *
  50054. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50055. * It is used as the base class for both the specGloss and metalRough conventions.
  50056. */
  50057. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50058. /**
  50059. * Number of Simultaneous lights allowed on the material.
  50060. */
  50061. maxSimultaneousLights: number;
  50062. /**
  50063. * If sets to true, disables all the lights affecting the material.
  50064. */
  50065. disableLighting: boolean;
  50066. /**
  50067. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50068. */
  50069. environmentTexture: BaseTexture;
  50070. /**
  50071. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50072. */
  50073. invertNormalMapX: boolean;
  50074. /**
  50075. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50076. */
  50077. invertNormalMapY: boolean;
  50078. /**
  50079. * Normal map used in the model.
  50080. */
  50081. normalTexture: BaseTexture;
  50082. /**
  50083. * Emissivie color used to self-illuminate the model.
  50084. */
  50085. emissiveColor: Color3;
  50086. /**
  50087. * Emissivie texture used to self-illuminate the model.
  50088. */
  50089. emissiveTexture: BaseTexture;
  50090. /**
  50091. * Occlusion Channel Strenght.
  50092. */
  50093. occlusionStrength: number;
  50094. /**
  50095. * Occlusion Texture of the material (adding extra occlusion effects).
  50096. */
  50097. occlusionTexture: BaseTexture;
  50098. /**
  50099. * Defines the alpha limits in alpha test mode.
  50100. */
  50101. alphaCutOff: number;
  50102. /**
  50103. * Gets the current double sided mode.
  50104. */
  50105. /**
  50106. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50107. */
  50108. doubleSided: boolean;
  50109. /**
  50110. * Stores the pre-calculated light information of a mesh in a texture.
  50111. */
  50112. lightmapTexture: BaseTexture;
  50113. /**
  50114. * If true, the light map contains occlusion information instead of lighting info.
  50115. */
  50116. useLightmapAsShadowmap: boolean;
  50117. /**
  50118. * Instantiates a new PBRMaterial instance.
  50119. *
  50120. * @param name The material name
  50121. * @param scene The scene the material will be use in.
  50122. */
  50123. constructor(name: string, scene: Scene);
  50124. getClassName(): string;
  50125. }
  50126. }
  50127. declare module BABYLON {
  50128. /**
  50129. * The PBR material of BJS following the metal roughness convention.
  50130. *
  50131. * This fits to the PBR convention in the GLTF definition:
  50132. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50133. */
  50134. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50135. /**
  50136. * The base color has two different interpretations depending on the value of metalness.
  50137. * When the material is a metal, the base color is the specific measured reflectance value
  50138. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50139. * of the material.
  50140. */
  50141. baseColor: Color3;
  50142. /**
  50143. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50144. * well as opacity information in the alpha channel.
  50145. */
  50146. baseTexture: BaseTexture;
  50147. /**
  50148. * Specifies the metallic scalar value of the material.
  50149. * Can also be used to scale the metalness values of the metallic texture.
  50150. */
  50151. metallic: number;
  50152. /**
  50153. * Specifies the roughness scalar value of the material.
  50154. * Can also be used to scale the roughness values of the metallic texture.
  50155. */
  50156. roughness: number;
  50157. /**
  50158. * Texture containing both the metallic value in the B channel and the
  50159. * roughness value in the G channel to keep better precision.
  50160. */
  50161. metallicRoughnessTexture: BaseTexture;
  50162. /**
  50163. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50164. *
  50165. * @param name The material name
  50166. * @param scene The scene the material will be use in.
  50167. */
  50168. constructor(name: string, scene: Scene);
  50169. /**
  50170. * Return the currrent class name of the material.
  50171. */
  50172. getClassName(): string;
  50173. /**
  50174. * Makes a duplicate of the current material.
  50175. * @param name - name to use for the new material.
  50176. */
  50177. clone(name: string): PBRMetallicRoughnessMaterial;
  50178. /**
  50179. * Serialize the material to a parsable JSON object.
  50180. */
  50181. serialize(): any;
  50182. /**
  50183. * Parses a JSON object correponding to the serialize function.
  50184. */
  50185. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50186. }
  50187. }
  50188. declare module BABYLON {
  50189. /**
  50190. * The PBR material of BJS following the specular glossiness convention.
  50191. *
  50192. * This fits to the PBR convention in the GLTF definition:
  50193. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50194. */
  50195. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50196. /**
  50197. * Specifies the diffuse color of the material.
  50198. */
  50199. diffuseColor: Color3;
  50200. /**
  50201. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50202. * channel.
  50203. */
  50204. diffuseTexture: BaseTexture;
  50205. /**
  50206. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50207. */
  50208. specularColor: Color3;
  50209. /**
  50210. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50211. */
  50212. glossiness: number;
  50213. /**
  50214. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50215. */
  50216. specularGlossinessTexture: BaseTexture;
  50217. /**
  50218. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50219. *
  50220. * @param name The material name
  50221. * @param scene The scene the material will be use in.
  50222. */
  50223. constructor(name: string, scene: Scene);
  50224. /**
  50225. * Return the currrent class name of the material.
  50226. */
  50227. getClassName(): string;
  50228. /**
  50229. * Makes a duplicate of the current material.
  50230. * @param name - name to use for the new material.
  50231. */
  50232. clone(name: string): PBRSpecularGlossinessMaterial;
  50233. /**
  50234. * Serialize the material to a parsable JSON object.
  50235. */
  50236. serialize(): any;
  50237. /**
  50238. * Parses a JSON object correponding to the serialize function.
  50239. */
  50240. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50241. }
  50242. }
  50243. declare module BABYLON {
  50244. /**
  50245. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50246. * It can help converting any input color in a desired output one. This can then be used to create effects
  50247. * from sepia, black and white to sixties or futuristic rendering...
  50248. *
  50249. * The only supported format is currently 3dl.
  50250. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50251. */
  50252. export class ColorGradingTexture extends BaseTexture {
  50253. /**
  50254. * The current texture matrix. (will always be identity in color grading texture)
  50255. */
  50256. private _textureMatrix;
  50257. /**
  50258. * The texture URL.
  50259. */
  50260. url: string;
  50261. /**
  50262. * Empty line regex stored for GC.
  50263. */
  50264. private static _noneEmptyLineRegex;
  50265. private _engine;
  50266. /**
  50267. * Instantiates a ColorGradingTexture from the following parameters.
  50268. *
  50269. * @param url The location of the color gradind data (currently only supporting 3dl)
  50270. * @param scene The scene the texture will be used in
  50271. */
  50272. constructor(url: string, scene: Scene);
  50273. /**
  50274. * Returns the texture matrix used in most of the material.
  50275. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50276. */
  50277. getTextureMatrix(): Matrix;
  50278. /**
  50279. * Occurs when the file being loaded is a .3dl LUT file.
  50280. */
  50281. private load3dlTexture;
  50282. /**
  50283. * Starts the loading process of the texture.
  50284. */
  50285. private loadTexture;
  50286. /**
  50287. * Clones the color gradind texture.
  50288. */
  50289. clone(): ColorGradingTexture;
  50290. /**
  50291. * Called during delayed load for textures.
  50292. */
  50293. delayLoad(): void;
  50294. /**
  50295. * Parses a color grading texture serialized by Babylon.
  50296. * @param parsedTexture The texture information being parsedTexture
  50297. * @param scene The scene to load the texture in
  50298. * @param rootUrl The root url of the data assets to load
  50299. * @return A color gradind texture
  50300. */
  50301. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50302. /**
  50303. * Serializes the LUT texture to json format.
  50304. */
  50305. serialize(): any;
  50306. }
  50307. }
  50308. declare module BABYLON {
  50309. /**
  50310. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50311. */
  50312. export class EquiRectangularCubeTexture extends BaseTexture {
  50313. /** The six faces of the cube. */
  50314. private static _FacesMapping;
  50315. private _noMipmap;
  50316. private _onLoad;
  50317. private _onError;
  50318. /** The size of the cubemap. */
  50319. private _size;
  50320. /** The buffer of the image. */
  50321. private _buffer;
  50322. /** The width of the input image. */
  50323. private _width;
  50324. /** The height of the input image. */
  50325. private _height;
  50326. /** The URL to the image. */
  50327. url: string;
  50328. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50329. coordinatesMode: number;
  50330. /**
  50331. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50332. * @param url The location of the image
  50333. * @param scene The scene the texture will be used in
  50334. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50335. * @param noMipmap Forces to not generate the mipmap if true
  50336. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50337. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50338. * @param onLoad — defines a callback called when texture is loaded
  50339. * @param onError — defines a callback called if there is an error
  50340. */
  50341. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50342. /**
  50343. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50344. */
  50345. private loadImage;
  50346. /**
  50347. * Convert the image buffer into a cubemap and create a CubeTexture.
  50348. */
  50349. private loadTexture;
  50350. /**
  50351. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50352. * @param buffer The ArrayBuffer that should be converted.
  50353. * @returns The buffer as Float32Array.
  50354. */
  50355. private getFloat32ArrayFromArrayBuffer;
  50356. /**
  50357. * Get the current class name of the texture useful for serialization or dynamic coding.
  50358. * @returns "EquiRectangularCubeTexture"
  50359. */
  50360. getClassName(): string;
  50361. /**
  50362. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50363. * @returns A clone of the current EquiRectangularCubeTexture.
  50364. */
  50365. clone(): EquiRectangularCubeTexture;
  50366. }
  50367. }
  50368. declare module BABYLON {
  50369. /**
  50370. * Based on jsTGALoader - Javascript loader for TGA file
  50371. * By Vincent Thibault
  50372. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50373. */
  50374. export class TGATools {
  50375. private static _TYPE_INDEXED;
  50376. private static _TYPE_RGB;
  50377. private static _TYPE_GREY;
  50378. private static _TYPE_RLE_INDEXED;
  50379. private static _TYPE_RLE_RGB;
  50380. private static _TYPE_RLE_GREY;
  50381. private static _ORIGIN_MASK;
  50382. private static _ORIGIN_SHIFT;
  50383. private static _ORIGIN_BL;
  50384. private static _ORIGIN_BR;
  50385. private static _ORIGIN_UL;
  50386. private static _ORIGIN_UR;
  50387. /**
  50388. * Gets the header of a TGA file
  50389. * @param data defines the TGA data
  50390. * @returns the header
  50391. */
  50392. static GetTGAHeader(data: Uint8Array): any;
  50393. /**
  50394. * Uploads TGA content to a Babylon Texture
  50395. * @hidden
  50396. */
  50397. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50398. /** @hidden */
  50399. 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;
  50400. /** @hidden */
  50401. 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;
  50402. /** @hidden */
  50403. 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;
  50404. /** @hidden */
  50405. 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;
  50406. /** @hidden */
  50407. 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;
  50408. /** @hidden */
  50409. 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;
  50410. }
  50411. }
  50412. declare module BABYLON {
  50413. /**
  50414. * Implementation of the TGA Texture Loader.
  50415. * @hidden
  50416. */
  50417. export class _TGATextureLoader implements IInternalTextureLoader {
  50418. /**
  50419. * Defines wether the loader supports cascade loading the different faces.
  50420. */
  50421. readonly supportCascades: boolean;
  50422. /**
  50423. * This returns if the loader support the current file information.
  50424. * @param extension defines the file extension of the file being loaded
  50425. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50426. * @param fallback defines the fallback internal texture if any
  50427. * @param isBase64 defines whether the texture is encoded as a base64
  50428. * @param isBuffer defines whether the texture data are stored as a buffer
  50429. * @returns true if the loader can load the specified file
  50430. */
  50431. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50432. /**
  50433. * Transform the url before loading if required.
  50434. * @param rootUrl the url of the texture
  50435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50436. * @returns the transformed texture
  50437. */
  50438. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50439. /**
  50440. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50441. * @param rootUrl the url of the texture
  50442. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50443. * @returns the fallback texture
  50444. */
  50445. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50446. /**
  50447. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50448. * @param data contains the texture data
  50449. * @param texture defines the BabylonJS internal texture
  50450. * @param createPolynomials will be true if polynomials have been requested
  50451. * @param onLoad defines the callback to trigger once the texture is ready
  50452. * @param onError defines the callback to trigger in case of error
  50453. */
  50454. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50455. /**
  50456. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50457. * @param data contains the texture data
  50458. * @param texture defines the BabylonJS internal texture
  50459. * @param callback defines the method to call once ready to upload
  50460. */
  50461. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50462. }
  50463. }
  50464. declare module BABYLON {
  50465. /**
  50466. * Info about the .basis files
  50467. */
  50468. class BasisFileInfo {
  50469. /**
  50470. * If the file has alpha
  50471. */
  50472. hasAlpha: boolean;
  50473. /**
  50474. * Info about each image of the basis file
  50475. */
  50476. images: Array<{
  50477. levels: Array<{
  50478. width: number;
  50479. height: number;
  50480. transcodedPixels: ArrayBufferView;
  50481. }>;
  50482. }>;
  50483. }
  50484. /**
  50485. * Result of transcoding a basis file
  50486. */
  50487. class TranscodeResult {
  50488. /**
  50489. * Info about the .basis file
  50490. */
  50491. fileInfo: BasisFileInfo;
  50492. /**
  50493. * Format to use when loading the file
  50494. */
  50495. format: number;
  50496. }
  50497. /**
  50498. * Configuration options for the Basis transcoder
  50499. */
  50500. export class BasisTranscodeConfiguration {
  50501. /**
  50502. * Supported compression formats used to determine the supported output format of the transcoder
  50503. */
  50504. supportedCompressionFormats?: {
  50505. /**
  50506. * etc1 compression format
  50507. */
  50508. etc1?: boolean;
  50509. /**
  50510. * s3tc compression format
  50511. */
  50512. s3tc?: boolean;
  50513. /**
  50514. * pvrtc compression format
  50515. */
  50516. pvrtc?: boolean;
  50517. /**
  50518. * etc2 compression format
  50519. */
  50520. etc2?: boolean;
  50521. };
  50522. /**
  50523. * If mipmap levels should be loaded for transcoded images (Default: true)
  50524. */
  50525. loadMipmapLevels?: boolean;
  50526. /**
  50527. * Index of a single image to load (Default: all images)
  50528. */
  50529. loadSingleImage?: number;
  50530. }
  50531. /**
  50532. * Used to load .Basis files
  50533. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50534. */
  50535. export class BasisTools {
  50536. private static _IgnoreSupportedFormats;
  50537. /**
  50538. * URL to use when loading the basis transcoder
  50539. */
  50540. static JSModuleURL: string;
  50541. /**
  50542. * URL to use when loading the wasm module for the transcoder
  50543. */
  50544. static WasmModuleURL: string;
  50545. /**
  50546. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50547. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50548. * @returns internal format corresponding to the Basis format
  50549. */
  50550. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50551. private static _WorkerPromise;
  50552. private static _Worker;
  50553. private static _actionId;
  50554. private static _CreateWorkerAsync;
  50555. /**
  50556. * Transcodes a loaded image file to compressed pixel data
  50557. * @param imageData image data to transcode
  50558. * @param config configuration options for the transcoding
  50559. * @returns a promise resulting in the transcoded image
  50560. */
  50561. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50562. /**
  50563. * Loads a texture from the transcode result
  50564. * @param texture texture load to
  50565. * @param transcodeResult the result of transcoding the basis file to load from
  50566. */
  50567. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50568. }
  50569. }
  50570. declare module BABYLON {
  50571. /**
  50572. * Loader for .basis file format
  50573. */
  50574. export class _BasisTextureLoader implements IInternalTextureLoader {
  50575. /**
  50576. * Defines whether the loader supports cascade loading the different faces.
  50577. */
  50578. readonly supportCascades: boolean;
  50579. /**
  50580. * This returns if the loader support the current file information.
  50581. * @param extension defines the file extension of the file being loaded
  50582. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50583. * @param fallback defines the fallback internal texture if any
  50584. * @param isBase64 defines whether the texture is encoded as a base64
  50585. * @param isBuffer defines whether the texture data are stored as a buffer
  50586. * @returns true if the loader can load the specified file
  50587. */
  50588. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50589. /**
  50590. * Transform the url before loading if required.
  50591. * @param rootUrl the url of the texture
  50592. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50593. * @returns the transformed texture
  50594. */
  50595. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50596. /**
  50597. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50598. * @param rootUrl the url of the texture
  50599. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50600. * @returns the fallback texture
  50601. */
  50602. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50603. /**
  50604. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50605. * @param data contains the texture data
  50606. * @param texture defines the BabylonJS internal texture
  50607. * @param createPolynomials will be true if polynomials have been requested
  50608. * @param onLoad defines the callback to trigger once the texture is ready
  50609. * @param onError defines the callback to trigger in case of error
  50610. */
  50611. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50612. /**
  50613. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50614. * @param data contains the texture data
  50615. * @param texture defines the BabylonJS internal texture
  50616. * @param callback defines the method to call once ready to upload
  50617. */
  50618. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50619. }
  50620. }
  50621. declare module BABYLON {
  50622. /**
  50623. * 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.
  50624. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50625. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50626. */
  50627. export class CustomProceduralTexture extends ProceduralTexture {
  50628. private _animate;
  50629. private _time;
  50630. private _config;
  50631. private _texturePath;
  50632. /**
  50633. * Instantiates a new Custom Procedural Texture.
  50634. * 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.
  50635. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50636. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50637. * @param name Define the name of the texture
  50638. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50639. * @param size Define the size of the texture to create
  50640. * @param scene Define the scene the texture belongs to
  50641. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50642. * @param generateMipMaps Define if the texture should creates mip maps or not
  50643. */
  50644. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50645. private _loadJson;
  50646. /**
  50647. * Is the texture ready to be used ? (rendered at least once)
  50648. * @returns true if ready, otherwise, false.
  50649. */
  50650. isReady(): boolean;
  50651. /**
  50652. * Render the texture to its associated render target.
  50653. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50654. */
  50655. render(useCameraPostProcess?: boolean): void;
  50656. /**
  50657. * Update the list of dependant textures samplers in the shader.
  50658. */
  50659. updateTextures(): void;
  50660. /**
  50661. * Update the uniform values of the procedural texture in the shader.
  50662. */
  50663. updateShaderUniforms(): void;
  50664. /**
  50665. * Define if the texture animates or not.
  50666. */
  50667. animate: boolean;
  50668. }
  50669. }
  50670. declare module BABYLON {
  50671. /** @hidden */
  50672. export var noisePixelShader: {
  50673. name: string;
  50674. shader: string;
  50675. };
  50676. }
  50677. declare module BABYLON {
  50678. /**
  50679. * Class used to generate noise procedural textures
  50680. */
  50681. export class NoiseProceduralTexture extends ProceduralTexture {
  50682. private _time;
  50683. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50684. brightness: number;
  50685. /** Defines the number of octaves to process */
  50686. octaves: number;
  50687. /** Defines the level of persistence (0.8 by default) */
  50688. persistence: number;
  50689. /** Gets or sets animation speed factor (default is 1) */
  50690. animationSpeedFactor: number;
  50691. /**
  50692. * Creates a new NoiseProceduralTexture
  50693. * @param name defines the name fo the texture
  50694. * @param size defines the size of the texture (default is 256)
  50695. * @param scene defines the hosting scene
  50696. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50697. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50698. */
  50699. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50700. private _updateShaderUniforms;
  50701. protected _getDefines(): string;
  50702. /** Generate the current state of the procedural texture */
  50703. render(useCameraPostProcess?: boolean): void;
  50704. /**
  50705. * Serializes this noise procedural texture
  50706. * @returns a serialized noise procedural texture object
  50707. */
  50708. serialize(): any;
  50709. /**
  50710. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50711. * @param parsedTexture defines parsed texture data
  50712. * @param scene defines the current scene
  50713. * @param rootUrl defines the root URL containing noise procedural texture information
  50714. * @returns a parsed NoiseProceduralTexture
  50715. */
  50716. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50717. }
  50718. }
  50719. declare module BABYLON {
  50720. /**
  50721. * Raw cube texture where the raw buffers are passed in
  50722. */
  50723. export class RawCubeTexture extends CubeTexture {
  50724. /**
  50725. * Creates a cube texture where the raw buffers are passed in.
  50726. * @param scene defines the scene the texture is attached to
  50727. * @param data defines the array of data to use to create each face
  50728. * @param size defines the size of the textures
  50729. * @param format defines the format of the data
  50730. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50731. * @param generateMipMaps defines if the engine should generate the mip levels
  50732. * @param invertY defines if data must be stored with Y axis inverted
  50733. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50734. * @param compression defines the compression used (null by default)
  50735. */
  50736. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50737. /**
  50738. * Updates the raw cube texture.
  50739. * @param data defines the data to store
  50740. * @param format defines the data format
  50741. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50742. * @param invertY defines if data must be stored with Y axis inverted
  50743. * @param compression defines the compression used (null by default)
  50744. * @param level defines which level of the texture to update
  50745. */
  50746. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50747. /**
  50748. * Updates a raw cube texture with RGBD encoded data.
  50749. * @param data defines the array of data [mipmap][face] to use to create each face
  50750. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50751. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50752. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50753. * @returns a promsie that resolves when the operation is complete
  50754. */
  50755. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50756. /**
  50757. * Clones the raw cube texture.
  50758. * @return a new cube texture
  50759. */
  50760. clone(): CubeTexture;
  50761. /** @hidden */
  50762. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50763. }
  50764. }
  50765. declare module BABYLON {
  50766. /**
  50767. * Class used to store 3D textures containing user data
  50768. */
  50769. export class RawTexture3D extends Texture {
  50770. /** Gets or sets the texture format to use */
  50771. format: number;
  50772. private _engine;
  50773. /**
  50774. * Create a new RawTexture3D
  50775. * @param data defines the data of the texture
  50776. * @param width defines the width of the texture
  50777. * @param height defines the height of the texture
  50778. * @param depth defines the depth of the texture
  50779. * @param format defines the texture format to use
  50780. * @param scene defines the hosting scene
  50781. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50782. * @param invertY defines if texture must be stored with Y axis inverted
  50783. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50784. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50785. */
  50786. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50787. /** Gets or sets the texture format to use */
  50788. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50789. /**
  50790. * Update the texture with new data
  50791. * @param data defines the data to store in the texture
  50792. */
  50793. update(data: ArrayBufferView): void;
  50794. }
  50795. }
  50796. declare module BABYLON {
  50797. /**
  50798. * Creates a refraction texture used by refraction channel of the standard material.
  50799. * It is like a mirror but to see through a material.
  50800. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50801. */
  50802. export class RefractionTexture extends RenderTargetTexture {
  50803. /**
  50804. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50805. * 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.
  50806. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50807. */
  50808. refractionPlane: Plane;
  50809. /**
  50810. * Define how deep under the surface we should see.
  50811. */
  50812. depth: number;
  50813. /**
  50814. * Creates a refraction texture used by refraction channel of the standard material.
  50815. * It is like a mirror but to see through a material.
  50816. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50817. * @param name Define the texture name
  50818. * @param size Define the size of the underlying texture
  50819. * @param scene Define the scene the refraction belongs to
  50820. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50821. */
  50822. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50823. /**
  50824. * Clone the refraction texture.
  50825. * @returns the cloned texture
  50826. */
  50827. clone(): RefractionTexture;
  50828. /**
  50829. * Serialize the texture to a JSON representation you could use in Parse later on
  50830. * @returns the serialized JSON representation
  50831. */
  50832. serialize(): any;
  50833. }
  50834. }
  50835. declare module BABYLON {
  50836. /**
  50837. * Defines the options related to the creation of an HtmlElementTexture
  50838. */
  50839. export interface IHtmlElementTextureOptions {
  50840. /**
  50841. * Defines wether mip maps should be created or not.
  50842. */
  50843. generateMipMaps?: boolean;
  50844. /**
  50845. * Defines the sampling mode of the texture.
  50846. */
  50847. samplingMode?: number;
  50848. /**
  50849. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  50850. */
  50851. engine: Nullable<Engine>;
  50852. /**
  50853. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  50854. */
  50855. scene: Nullable<Scene>;
  50856. }
  50857. /**
  50858. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  50859. * To be as efficient as possible depending on your constraints nothing aside the first upload
  50860. * is automatically managed.
  50861. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  50862. * in your application.
  50863. *
  50864. * As the update is not automatic, you need to call them manually.
  50865. */
  50866. export class HtmlElementTexture extends BaseTexture {
  50867. /**
  50868. * The texture URL.
  50869. */
  50870. element: HTMLVideoElement | HTMLCanvasElement;
  50871. private static readonly DefaultOptions;
  50872. private _textureMatrix;
  50873. private _engine;
  50874. private _isVideo;
  50875. private _generateMipMaps;
  50876. private _samplingMode;
  50877. /**
  50878. * Instantiates a HtmlElementTexture from the following parameters.
  50879. *
  50880. * @param name Defines the name of the texture
  50881. * @param element Defines the video or canvas the texture is filled with
  50882. * @param options Defines the other none mandatory texture creation options
  50883. */
  50884. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  50885. private _createInternalTexture;
  50886. /**
  50887. * Returns the texture matrix used in most of the material.
  50888. */
  50889. getTextureMatrix(): Matrix;
  50890. /**
  50891. * Updates the content of the texture.
  50892. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  50893. */
  50894. update(invertY?: Nullable<boolean>): void;
  50895. }
  50896. }
  50897. declare module BABYLON {
  50898. /**
  50899. * Enum used to define the target of a block
  50900. */
  50901. export enum NodeMaterialBlockTargets {
  50902. /** Vertex shader */
  50903. Vertex = 1,
  50904. /** Fragment shader */
  50905. Fragment = 2,
  50906. /** Neutral */
  50907. Neutral = 4,
  50908. /** Vertex and Fragment */
  50909. VertexAndFragment = 3
  50910. }
  50911. }
  50912. declare module BABYLON {
  50913. /**
  50914. * Defines the kind of connection point for node based material
  50915. */
  50916. export enum NodeMaterialBlockConnectionPointTypes {
  50917. /** Float */
  50918. Float = 1,
  50919. /** Int */
  50920. Int = 2,
  50921. /** Vector2 */
  50922. Vector2 = 4,
  50923. /** Vector3 */
  50924. Vector3 = 8,
  50925. /** Vector4 */
  50926. Vector4 = 16,
  50927. /** Color3 */
  50928. Color3 = 32,
  50929. /** Color4 */
  50930. Color4 = 64,
  50931. /** Matrix */
  50932. Matrix = 128,
  50933. /** Vector3 or Color3 */
  50934. Vector3OrColor3 = 40,
  50935. /** Vector3 or Vector4 */
  50936. Vector3OrVector4 = 24,
  50937. /** Vector4 or Color4 */
  50938. Vector4OrColor4 = 80,
  50939. /** Color3 or Color4 */
  50940. Color3OrColor4 = 96,
  50941. /** Vector2 or Color3 or Color4 */
  50942. Vector2OrColor3OrColor4 = 100,
  50943. /** Vector3 or Color3 or Color4 or Vector4 */
  50944. Vector3OrColor3OrVector4OrColor4 = 120,
  50945. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  50946. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  50947. /** Detect type based on connection */
  50948. AutoDetect = 1024,
  50949. /** Output type that will be defined by input type */
  50950. BasedOnInput = 2048
  50951. }
  50952. }
  50953. declare module BABYLON {
  50954. /**
  50955. * Root class for all node material optimizers
  50956. */
  50957. export class NodeMaterialOptimizer {
  50958. /**
  50959. * Function used to optimize a NodeMaterial graph
  50960. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50961. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50962. */
  50963. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50964. }
  50965. }
  50966. declare module BABYLON {
  50967. /**
  50968. * Block used to transform a vector4 with a matrix
  50969. */
  50970. export class Vector4TransformBlock extends NodeMaterialBlock {
  50971. /**
  50972. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50973. */
  50974. complementW: number;
  50975. /**
  50976. * Creates a new Vector4TransformBlock
  50977. * @param name defines the block name
  50978. */
  50979. constructor(name: string);
  50980. /**
  50981. * Gets the current class name
  50982. * @returns the class name
  50983. */
  50984. getClassName(): string;
  50985. /**
  50986. * Gets the vector input
  50987. */
  50988. readonly vector: NodeMaterialConnectionPoint;
  50989. /**
  50990. * Gets the output component
  50991. */
  50992. readonly output: NodeMaterialConnectionPoint;
  50993. /**
  50994. * Gets the matrix transform input
  50995. */
  50996. readonly transform: NodeMaterialConnectionPoint;
  50997. protected _buildBlock(state: NodeMaterialBuildState): this;
  50998. }
  50999. }
  51000. declare module BABYLON {
  51001. /**
  51002. * Block used to output the vertex position
  51003. */
  51004. export class VertexOutputBlock extends NodeMaterialBlock {
  51005. /**
  51006. * Creates a new VertexOutputBlock
  51007. * @param name defines the block name
  51008. */
  51009. constructor(name: string);
  51010. /**
  51011. * Gets the current class name
  51012. * @returns the class name
  51013. */
  51014. getClassName(): string;
  51015. /**
  51016. * Gets the vector input component
  51017. */
  51018. readonly vector: NodeMaterialConnectionPoint;
  51019. protected _buildBlock(state: NodeMaterialBuildState): this;
  51020. }
  51021. }
  51022. declare module BABYLON {
  51023. /**
  51024. * Block used to output the final color
  51025. */
  51026. export class FragmentOutputBlock extends NodeMaterialBlock {
  51027. /**
  51028. * Gets or sets a boolean indicating if this block will output an alpha value
  51029. */
  51030. alphaBlendingEnabled: boolean;
  51031. /**
  51032. * Create a new FragmentOutputBlock
  51033. * @param name defines the block name
  51034. */
  51035. constructor(name: string);
  51036. /**
  51037. * Gets the current class name
  51038. * @returns the class name
  51039. */
  51040. getClassName(): string;
  51041. /**
  51042. * Gets the color input component
  51043. */
  51044. readonly color: NodeMaterialConnectionPoint;
  51045. protected _buildBlock(state: NodeMaterialBuildState): this;
  51046. }
  51047. }
  51048. declare module BABYLON {
  51049. /**
  51050. * Interface used to configure the node material editor
  51051. */
  51052. export interface INodeMaterialEditorOptions {
  51053. /** Define the URl to load node editor script */
  51054. editorURL?: string;
  51055. }
  51056. /** @hidden */
  51057. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51058. /** BONES */
  51059. NUM_BONE_INFLUENCERS: number;
  51060. BonesPerMesh: number;
  51061. BONETEXTURE: boolean;
  51062. /** MORPH TARGETS */
  51063. MORPHTARGETS: boolean;
  51064. MORPHTARGETS_NORMAL: boolean;
  51065. MORPHTARGETS_TANGENT: boolean;
  51066. MORPHTARGETS_UV: boolean;
  51067. NUM_MORPH_INFLUENCERS: number;
  51068. /** IMAGE PROCESSING */
  51069. IMAGEPROCESSING: boolean;
  51070. VIGNETTE: boolean;
  51071. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51072. VIGNETTEBLENDMODEOPAQUE: boolean;
  51073. TONEMAPPING: boolean;
  51074. TONEMAPPING_ACES: boolean;
  51075. CONTRAST: boolean;
  51076. EXPOSURE: boolean;
  51077. COLORCURVES: boolean;
  51078. COLORGRADING: boolean;
  51079. COLORGRADING3D: boolean;
  51080. SAMPLER3DGREENDEPTH: boolean;
  51081. SAMPLER3DBGRMAP: boolean;
  51082. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51083. constructor();
  51084. setValue(name: string, value: boolean): void;
  51085. }
  51086. /**
  51087. * Class used to configure NodeMaterial
  51088. */
  51089. export interface INodeMaterialOptions {
  51090. /**
  51091. * Defines if blocks should emit comments
  51092. */
  51093. emitComments: boolean;
  51094. }
  51095. /**
  51096. * Class used to create a node based material built by assembling shader blocks
  51097. */
  51098. export class NodeMaterial extends PushMaterial {
  51099. private _options;
  51100. private _vertexCompilationState;
  51101. private _fragmentCompilationState;
  51102. private _sharedData;
  51103. private _buildId;
  51104. private _buildWasSuccessful;
  51105. private _cachedWorldViewMatrix;
  51106. private _cachedWorldViewProjectionMatrix;
  51107. private _optimizers;
  51108. /** Define the URl to load node editor script */
  51109. static EditorURL: string;
  51110. private BJSNODEMATERIALEDITOR;
  51111. /** Get the inspector from bundle or global */
  51112. private _getGlobalNodeMaterialEditor;
  51113. /**
  51114. * Defines the maximum number of lights that can be used in the material
  51115. */
  51116. maxSimultaneousLights: number;
  51117. /**
  51118. * Observable raised when the material is built
  51119. */
  51120. onBuildObservable: Observable<NodeMaterial>;
  51121. /**
  51122. * Gets or sets the root nodes of the material vertex shader
  51123. */
  51124. _vertexOutputNodes: NodeMaterialBlock[];
  51125. /**
  51126. * Gets or sets the root nodes of the material fragment (pixel) shader
  51127. */
  51128. _fragmentOutputNodes: NodeMaterialBlock[];
  51129. /** Gets or sets options to control the node material overall behavior */
  51130. options: INodeMaterialOptions;
  51131. /**
  51132. * Default configuration related to image processing available in the standard Material.
  51133. */
  51134. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51135. /**
  51136. * Gets the image processing configuration used either in this material.
  51137. */
  51138. /**
  51139. * Sets the Default image processing configuration used either in the this material.
  51140. *
  51141. * If sets to null, the scene one is in use.
  51142. */
  51143. imageProcessingConfiguration: ImageProcessingConfiguration;
  51144. /**
  51145. * Create a new node based material
  51146. * @param name defines the material name
  51147. * @param scene defines the hosting scene
  51148. * @param options defines creation option
  51149. */
  51150. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51151. /**
  51152. * Gets the current class name of the material e.g. "NodeMaterial"
  51153. * @returns the class name
  51154. */
  51155. getClassName(): string;
  51156. /**
  51157. * Keep track of the image processing observer to allow dispose and replace.
  51158. */
  51159. private _imageProcessingObserver;
  51160. /**
  51161. * Attaches a new image processing configuration to the Standard Material.
  51162. * @param configuration
  51163. */
  51164. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51165. /**
  51166. * Adds a new optimizer to the list of optimizers
  51167. * @param optimizer defines the optimizers to add
  51168. * @returns the current material
  51169. */
  51170. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51171. /**
  51172. * Remove an optimizer from the list of optimizers
  51173. * @param optimizer defines the optimizers to remove
  51174. * @returns the current material
  51175. */
  51176. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51177. /**
  51178. * Add a new block to the list of output nodes
  51179. * @param node defines the node to add
  51180. * @returns the current material
  51181. */
  51182. addOutputNode(node: NodeMaterialBlock): this;
  51183. /**
  51184. * Remove a block from the list of root nodes
  51185. * @param node defines the node to remove
  51186. * @returns the current material
  51187. */
  51188. removeOutputNode(node: NodeMaterialBlock): this;
  51189. private _addVertexOutputNode;
  51190. private _removeVertexOutputNode;
  51191. private _addFragmentOutputNode;
  51192. private _removeFragmentOutputNode;
  51193. /**
  51194. * Specifies if the material will require alpha blending
  51195. * @returns a boolean specifying if alpha blending is needed
  51196. */
  51197. needAlphaBlending(): boolean;
  51198. /**
  51199. * Specifies if this material should be rendered in alpha test mode
  51200. * @returns a boolean specifying if an alpha test is needed.
  51201. */
  51202. needAlphaTesting(): boolean;
  51203. private _initializeBlock;
  51204. private _resetDualBlocks;
  51205. /**
  51206. * Build the material and generates the inner effect
  51207. * @param verbose defines if the build should log activity
  51208. */
  51209. build(verbose?: boolean): void;
  51210. /**
  51211. * Runs an otpimization phase to try to improve the shader code
  51212. */
  51213. optimize(): void;
  51214. private _prepareDefinesForAttributes;
  51215. /**
  51216. * Get if the submesh is ready to be used and all its information available.
  51217. * Child classes can use it to update shaders
  51218. * @param mesh defines the mesh to check
  51219. * @param subMesh defines which submesh to check
  51220. * @param useInstances specifies that instances should be used
  51221. * @returns a boolean indicating that the submesh is ready or not
  51222. */
  51223. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51224. /**
  51225. * Binds the world matrix to the material
  51226. * @param world defines the world transformation matrix
  51227. */
  51228. bindOnlyWorldMatrix(world: Matrix): void;
  51229. /**
  51230. * Binds the submesh to this material by preparing the effect and shader to draw
  51231. * @param world defines the world transformation matrix
  51232. * @param mesh defines the mesh containing the submesh
  51233. * @param subMesh defines the submesh to bind the material to
  51234. */
  51235. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51236. /**
  51237. * Gets the active textures from the material
  51238. * @returns an array of textures
  51239. */
  51240. getActiveTextures(): BaseTexture[];
  51241. /**
  51242. * Specifies if the material uses a texture
  51243. * @param texture defines the texture to check against the material
  51244. * @returns a boolean specifying if the material uses the texture
  51245. */
  51246. hasTexture(texture: BaseTexture): boolean;
  51247. /**
  51248. * Disposes the material
  51249. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51250. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51251. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51252. */
  51253. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51254. /** Creates the node editor window. */
  51255. private _createNodeEditor;
  51256. /**
  51257. * Launch the node material editor
  51258. * @param config Define the configuration of the editor
  51259. * @return a promise fulfilled when the node editor is visible
  51260. */
  51261. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51262. /**
  51263. * Clear the current material
  51264. */
  51265. clear(): void;
  51266. /**
  51267. * Clear the current material and set it to a default state
  51268. */
  51269. setToDefault(): void;
  51270. }
  51271. }
  51272. declare module BABYLON {
  51273. /**
  51274. * Block used to read a texture from a sampler
  51275. */
  51276. export class TextureBlock extends NodeMaterialBlock {
  51277. private _defineName;
  51278. private _samplerName;
  51279. private _transformedUVName;
  51280. private _textureTransformName;
  51281. private _textureInfoName;
  51282. private _mainUVName;
  51283. private _mainUVDefineName;
  51284. /**
  51285. * Gets or sets the texture associated with the node
  51286. */
  51287. texture: Nullable<BaseTexture>;
  51288. /**
  51289. * Create a new TextureBlock
  51290. * @param name defines the block name
  51291. */
  51292. constructor(name: string);
  51293. /**
  51294. * Gets the current class name
  51295. * @returns the class name
  51296. */
  51297. getClassName(): string;
  51298. /**
  51299. * Gets the uv input component
  51300. */
  51301. readonly uv: NodeMaterialConnectionPoint;
  51302. /**
  51303. * Gets the output component
  51304. */
  51305. readonly output: NodeMaterialConnectionPoint;
  51306. autoConfigure(): void;
  51307. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51308. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51309. isReady(): boolean;
  51310. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51311. private _injectVertexCode;
  51312. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51313. }
  51314. }
  51315. declare module BABYLON {
  51316. /**
  51317. * Class used to store shared data between 2 NodeMaterialBuildState
  51318. */
  51319. export class NodeMaterialBuildStateSharedData {
  51320. /**
  51321. * Gets the list of emitted varyings
  51322. */
  51323. varyings: string[];
  51324. /**
  51325. * Gets the varying declaration string
  51326. */
  51327. varyingDeclaration: string;
  51328. /**
  51329. * Input blocks
  51330. */
  51331. inputBlocks: InputBlock[];
  51332. /**
  51333. * Input blocks
  51334. */
  51335. textureBlocks: TextureBlock[];
  51336. /**
  51337. * Bindable blocks (Blocks that need to set data to the effect)
  51338. */
  51339. bindableBlocks: NodeMaterialBlock[];
  51340. /**
  51341. * List of blocks that can provide a compilation fallback
  51342. */
  51343. blocksWithFallbacks: NodeMaterialBlock[];
  51344. /**
  51345. * List of blocks that can provide a define update
  51346. */
  51347. blocksWithDefines: NodeMaterialBlock[];
  51348. /**
  51349. * List of blocks that can provide a repeatable content
  51350. */
  51351. repeatableContentBlocks: NodeMaterialBlock[];
  51352. /**
  51353. * List of blocks that can provide a dynamic list of uniforms
  51354. */
  51355. dynamicUniformBlocks: NodeMaterialBlock[];
  51356. /**
  51357. * List of blocks that can block the isReady function for the material
  51358. */
  51359. blockingBlocks: NodeMaterialBlock[];
  51360. /**
  51361. * Build Id used to avoid multiple recompilations
  51362. */
  51363. buildId: number;
  51364. /** List of emitted variables */
  51365. variableNames: {
  51366. [key: string]: number;
  51367. };
  51368. /** List of emitted defines */
  51369. defineNames: {
  51370. [key: string]: number;
  51371. };
  51372. /** Should emit comments? */
  51373. emitComments: boolean;
  51374. /** Emit build activity */
  51375. verbose: boolean;
  51376. /**
  51377. * Gets the compilation hints emitted at compilation time
  51378. */
  51379. hints: {
  51380. needWorldViewMatrix: boolean;
  51381. needWorldViewProjectionMatrix: boolean;
  51382. needAlphaBlending: boolean;
  51383. needAlphaTesting: boolean;
  51384. };
  51385. /**
  51386. * List of compilation checks
  51387. */
  51388. checks: {
  51389. emitVertex: boolean;
  51390. emitFragment: boolean;
  51391. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  51392. };
  51393. /** Creates a new shared data */
  51394. constructor();
  51395. /**
  51396. * Emits console errors and exceptions if there is a failing check
  51397. */
  51398. emitErrors(): void;
  51399. }
  51400. }
  51401. declare module BABYLON {
  51402. /**
  51403. * Class used to store node based material build state
  51404. */
  51405. export class NodeMaterialBuildState {
  51406. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  51407. supportUniformBuffers: boolean;
  51408. /**
  51409. * Gets the list of emitted attributes
  51410. */
  51411. attributes: string[];
  51412. /**
  51413. * Gets the list of emitted uniforms
  51414. */
  51415. uniforms: string[];
  51416. /**
  51417. * Gets the list of emitted uniform buffers
  51418. */
  51419. uniformBuffers: string[];
  51420. /**
  51421. * Gets the list of emitted samplers
  51422. */
  51423. samplers: string[];
  51424. /**
  51425. * Gets the list of emitted functions
  51426. */
  51427. functions: {
  51428. [key: string]: string;
  51429. };
  51430. /**
  51431. * Gets the target of the compilation state
  51432. */
  51433. target: NodeMaterialBlockTargets;
  51434. /**
  51435. * Gets the list of emitted counters
  51436. */
  51437. counters: {
  51438. [key: string]: number;
  51439. };
  51440. /**
  51441. * Shared data between multiple NodeMaterialBuildState instances
  51442. */
  51443. sharedData: NodeMaterialBuildStateSharedData;
  51444. /** @hidden */
  51445. _vertexState: NodeMaterialBuildState;
  51446. /** @hidden */
  51447. _attributeDeclaration: string;
  51448. /** @hidden */
  51449. _uniformDeclaration: string;
  51450. /** @hidden */
  51451. _samplerDeclaration: string;
  51452. /** @hidden */
  51453. _varyingTransfer: string;
  51454. private _repeatableContentAnchorIndex;
  51455. /** @hidden */
  51456. _builtCompilationString: string;
  51457. /**
  51458. * Gets the emitted compilation strings
  51459. */
  51460. compilationString: string;
  51461. /**
  51462. * Finalize the compilation strings
  51463. * @param state defines the current compilation state
  51464. */
  51465. finalize(state: NodeMaterialBuildState): void;
  51466. /** @hidden */
  51467. readonly _repeatableContentAnchor: string;
  51468. /** @hidden */
  51469. _getFreeVariableName(prefix: string): string;
  51470. /** @hidden */
  51471. _getFreeDefineName(prefix: string): string;
  51472. /** @hidden */
  51473. _excludeVariableName(name: string): void;
  51474. /** @hidden */
  51475. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  51476. /** @hidden */
  51477. _emitFunction(name: string, code: string, comments: string): void;
  51478. /** @hidden */
  51479. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  51480. replaceStrings?: {
  51481. search: RegExp;
  51482. replace: string;
  51483. }[];
  51484. repeatKey?: string;
  51485. }): string;
  51486. /** @hidden */
  51487. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  51488. repeatKey?: string;
  51489. removeAttributes?: boolean;
  51490. removeUniforms?: boolean;
  51491. removeVaryings?: boolean;
  51492. removeIfDef?: boolean;
  51493. replaceStrings?: {
  51494. search: RegExp;
  51495. replace: string;
  51496. }[];
  51497. }, storeKey?: string): void;
  51498. /** @hidden */
  51499. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51500. /** @hidden */
  51501. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51502. }
  51503. }
  51504. declare module BABYLON {
  51505. /**
  51506. * Defines a block that can be used inside a node based material
  51507. */
  51508. export class NodeMaterialBlock {
  51509. private _buildId;
  51510. private _buildTarget;
  51511. private _target;
  51512. private _isFinalMerger;
  51513. private _isInput;
  51514. /** @hidden */
  51515. _inputs: NodeMaterialConnectionPoint[];
  51516. /** @hidden */
  51517. _outputs: NodeMaterialConnectionPoint[];
  51518. /**
  51519. * Gets or sets the name of the block
  51520. */
  51521. name: string;
  51522. /**
  51523. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51524. */
  51525. readonly isFinalMerger: boolean;
  51526. /**
  51527. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  51528. */
  51529. readonly isInput: boolean;
  51530. /**
  51531. * Gets or sets the build Id
  51532. */
  51533. buildId: number;
  51534. /**
  51535. * Gets or sets the target of the block
  51536. */
  51537. target: NodeMaterialBlockTargets;
  51538. /**
  51539. * Gets the list of input points
  51540. */
  51541. readonly inputs: NodeMaterialConnectionPoint[];
  51542. /** Gets the list of output points */
  51543. readonly outputs: NodeMaterialConnectionPoint[];
  51544. /**
  51545. * Find an input by its name
  51546. * @param name defines the name of the input to look for
  51547. * @returns the input or null if not found
  51548. */
  51549. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51550. /**
  51551. * Find an output by its name
  51552. * @param name defines the name of the outputto look for
  51553. * @returns the output or null if not found
  51554. */
  51555. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51556. /**
  51557. * Creates a new NodeMaterialBlock
  51558. * @param name defines the block name
  51559. * @param target defines the target of that block (Vertex by default)
  51560. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51561. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  51562. */
  51563. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  51564. /**
  51565. * Initialize the block and prepare the context for build
  51566. * @param state defines the state that will be used for the build
  51567. */
  51568. initialize(state: NodeMaterialBuildState): void;
  51569. /**
  51570. * Bind data to effect. Will only be called for blocks with isBindable === true
  51571. * @param effect defines the effect to bind data to
  51572. * @param nodeMaterial defines the hosting NodeMaterial
  51573. * @param mesh defines the mesh that will be rendered
  51574. */
  51575. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51576. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51577. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51578. protected _writeFloat(value: number): string;
  51579. /**
  51580. * Gets the current class name e.g. "NodeMaterialBlock"
  51581. * @returns the class name
  51582. */
  51583. getClassName(): string;
  51584. /**
  51585. * Register a new input. Must be called inside a block constructor
  51586. * @param name defines the connection point name
  51587. * @param type defines the connection point type
  51588. * @param isOptional defines a boolean indicating that this input can be omitted
  51589. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51590. * @returns the current block
  51591. */
  51592. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51593. /**
  51594. * Register a new output. Must be called inside a block constructor
  51595. * @param name defines the connection point name
  51596. * @param type defines the connection point type
  51597. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51598. * @returns the current block
  51599. */
  51600. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51601. /**
  51602. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51603. * @param forOutput defines an optional connection point to check compatibility with
  51604. * @returns the first available input or null
  51605. */
  51606. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51607. /**
  51608. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51609. * @param forBlock defines an optional block to check compatibility with
  51610. * @returns the first available input or null
  51611. */
  51612. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51613. /**
  51614. * Connect current block with another block
  51615. * @param other defines the block to connect with
  51616. * @param options define the various options to help pick the right connections
  51617. * @returns the current block
  51618. */
  51619. connectTo(other: NodeMaterialBlock, options?: {
  51620. input?: string;
  51621. output?: string;
  51622. outputSwizzle?: string;
  51623. }): this | undefined;
  51624. protected _buildBlock(state: NodeMaterialBuildState): void;
  51625. /**
  51626. * Add uniforms, samplers and uniform buffers at compilation time
  51627. * @param state defines the state to update
  51628. * @param nodeMaterial defines the node material requesting the update
  51629. * @param defines defines the material defines to update
  51630. */
  51631. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51632. /**
  51633. * Add potential fallbacks if shader compilation fails
  51634. * @param mesh defines the mesh to be rendered
  51635. * @param fallbacks defines the current prioritized list of fallbacks
  51636. */
  51637. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51638. /**
  51639. * Update defines for shader compilation
  51640. * @param mesh defines the mesh to be rendered
  51641. * @param nodeMaterial defines the node material requesting the update
  51642. * @param defines defines the material defines to update
  51643. * @param useInstances specifies that instances should be used
  51644. */
  51645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51646. /**
  51647. * Initialize defines for shader compilation
  51648. * @param mesh defines the mesh to be rendered
  51649. * @param nodeMaterial defines the node material requesting the update
  51650. * @param defines defines the material defines to be prepared
  51651. * @param useInstances specifies that instances should be used
  51652. */
  51653. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51654. /**
  51655. * Lets the block try to connect some inputs automatically
  51656. */
  51657. autoConfigure(): void;
  51658. /**
  51659. * Function called when a block is declared as repeatable content generator
  51660. * @param vertexShaderState defines the current compilation state for the vertex shader
  51661. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51662. * @param mesh defines the mesh to be rendered
  51663. * @param defines defines the material defines to update
  51664. */
  51665. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51666. /**
  51667. * Checks if the block is ready
  51668. * @param mesh defines the mesh to be rendered
  51669. * @param nodeMaterial defines the node material requesting the update
  51670. * @param defines defines the material defines to update
  51671. * @param useInstances specifies that instances should be used
  51672. * @returns true if the block is ready
  51673. */
  51674. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51675. private _processBuild;
  51676. /**
  51677. * Compile the current node and generate the shader code
  51678. * @param state defines the current compilation state (uniforms, samplers, current string)
  51679. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  51680. * @returns true if already built
  51681. */
  51682. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  51683. }
  51684. }
  51685. declare module BABYLON {
  51686. /**
  51687. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  51688. */
  51689. export enum NodeMaterialBlockConnectionPointMode {
  51690. /** Value is an uniform */
  51691. Uniform = 0,
  51692. /** Value is a mesh attribute */
  51693. Attribute = 1,
  51694. /** Value is a varying between vertex and fragment shaders */
  51695. Varying = 2,
  51696. /** Mode is undefined */
  51697. Undefined = 3
  51698. }
  51699. }
  51700. declare module BABYLON {
  51701. /**
  51702. * Enum used to define well known values e.g. values automatically provided by the system
  51703. */
  51704. export enum NodeMaterialWellKnownValues {
  51705. /** World */
  51706. World = 1,
  51707. /** View */
  51708. View = 2,
  51709. /** Projection */
  51710. Projection = 3,
  51711. /** ViewProjection */
  51712. ViewProjection = 4,
  51713. /** WorldView */
  51714. WorldView = 5,
  51715. /** WorldViewProjection */
  51716. WorldViewProjection = 6,
  51717. /** CameraPosition */
  51718. CameraPosition = 7,
  51719. /** Fog Color */
  51720. FogColor = 8
  51721. }
  51722. }
  51723. declare module BABYLON {
  51724. /**
  51725. * Block used to expose an input value
  51726. */
  51727. export class InputBlock extends NodeMaterialBlock {
  51728. private _mode;
  51729. private _associatedVariableName;
  51730. private _storedValue;
  51731. private _valueCallback;
  51732. private _type;
  51733. /** @hidden */
  51734. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51735. /**
  51736. * Gets or sets the connection point type (default is float)
  51737. */
  51738. readonly type: NodeMaterialBlockConnectionPointTypes;
  51739. /**
  51740. * Creates a new InputBlock
  51741. * @param name defines the block name
  51742. * @param target defines the target of that block (Vertex by default)
  51743. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  51744. */
  51745. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  51746. /**
  51747. * Gets the output component
  51748. */
  51749. readonly output: NodeMaterialConnectionPoint;
  51750. /**
  51751. * Set the source of this connection point to a vertex attribute
  51752. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  51753. * @returns the current connection point
  51754. */
  51755. setAsAttribute(attributeName?: string): InputBlock;
  51756. /**
  51757. * Set the source of this connection point to a well known value
  51758. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  51759. * @returns the current connection point
  51760. */
  51761. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  51762. /**
  51763. * Gets or sets the value of that point.
  51764. * Please note that this value will be ignored if valueCallback is defined
  51765. */
  51766. value: any;
  51767. /**
  51768. * Gets or sets a callback used to get the value of that point.
  51769. * Please note that setting this value will force the connection point to ignore the value property
  51770. */
  51771. valueCallback: () => any;
  51772. /**
  51773. * Gets or sets the associated variable name in the shader
  51774. */
  51775. associatedVariableName: string;
  51776. /**
  51777. * Gets a boolean indicating that this connection point not defined yet
  51778. */
  51779. readonly isUndefined: boolean;
  51780. /**
  51781. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  51782. * In this case the connection point name must be the name of the uniform to use.
  51783. * Can only be set on inputs
  51784. */
  51785. isUniform: boolean;
  51786. /**
  51787. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  51788. * In this case the connection point name must be the name of the attribute to use
  51789. * Can only be set on inputs
  51790. */
  51791. isAttribute: boolean;
  51792. /**
  51793. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  51794. * Can only be set on exit points
  51795. */
  51796. isVarying: boolean;
  51797. /**
  51798. * Gets a boolean indicating that the current connection point is a well known value
  51799. */
  51800. readonly isWellKnownValue: boolean;
  51801. /**
  51802. * Gets or sets the current well known value or null if not defined as well know value
  51803. */
  51804. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51805. /**
  51806. * Gets the current class name
  51807. * @returns the class name
  51808. */
  51809. getClassName(): string;
  51810. private _emitDefine;
  51811. /**
  51812. * Set the input block to its default value (based on its type)
  51813. */
  51814. setDefaultValue(): void;
  51815. private _emit;
  51816. /** @hidden */
  51817. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  51818. /** @hidden */
  51819. _transmit(effect: Effect, scene: Scene): void;
  51820. protected _buildBlock(state: NodeMaterialBuildState): void;
  51821. }
  51822. }
  51823. declare module BABYLON {
  51824. /**
  51825. * Defines a connection point for a block
  51826. */
  51827. export class NodeMaterialConnectionPoint {
  51828. /** @hidden */
  51829. _ownerBlock: NodeMaterialBlock;
  51830. /** @hidden */
  51831. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51832. private _endpoints;
  51833. private _associatedVariableName;
  51834. /** @hidden */
  51835. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  51836. private _type;
  51837. /** @hidden */
  51838. _enforceAssociatedVariableName: boolean;
  51839. /**
  51840. * Gets or sets the associated variable name in the shader
  51841. */
  51842. associatedVariableName: string;
  51843. /**
  51844. * Gets or sets the connection point type (default is float)
  51845. */
  51846. type: NodeMaterialBlockConnectionPointTypes;
  51847. /**
  51848. * Gets or sets the connection point name
  51849. */
  51850. name: string;
  51851. /**
  51852. * Gets or sets the swizzle to apply to this connection point when reading or writing
  51853. */
  51854. swizzle: string;
  51855. /**
  51856. * Gets or sets a boolean indicating that this connection point can be omitted
  51857. */
  51858. isOptional: boolean;
  51859. /**
  51860. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  51861. */
  51862. define: string;
  51863. /** Gets or sets the target of that connection point */
  51864. target: NodeMaterialBlockTargets;
  51865. /**
  51866. * Gets a boolean indicating that the current point is connected
  51867. */
  51868. readonly isConnected: boolean;
  51869. /**
  51870. * Gets a boolean indicating that the current point is connected to an input block
  51871. */
  51872. readonly isConnectedToInput: boolean;
  51873. /**
  51874. * Gets a the connected input block (if any)
  51875. */
  51876. readonly connectInputBlock: Nullable<InputBlock>;
  51877. /** Get the other side of the connection (if any) */
  51878. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51879. /** Get the block that owns this connection point */
  51880. readonly ownerBlock: NodeMaterialBlock;
  51881. /** Get the block connected on the other side of this connection (if any) */
  51882. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  51883. /** Get the block connected on the endpoints of this connection (if any) */
  51884. readonly connectedBlocks: Array<NodeMaterialBlock>;
  51885. /** Gets the list of connected endpoints */
  51886. readonly endpoints: NodeMaterialConnectionPoint[];
  51887. /**
  51888. * Creates a new connection point
  51889. * @param name defines the connection point name
  51890. * @param ownerBlock defines the block hosting this connection point
  51891. */
  51892. constructor(name: string, ownerBlock: NodeMaterialBlock);
  51893. /**
  51894. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  51895. * @returns the class name
  51896. */
  51897. getClassName(): string;
  51898. private _getTypeLength;
  51899. /**
  51900. * Gets an boolean indicating if the current point can be connected to another point
  51901. * @param connectionPoint defines the other connection point
  51902. * @returns true if the connection is possible
  51903. */
  51904. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  51905. /**
  51906. * Connect this point to another connection point
  51907. * @param connectionPoint defines the other connection point
  51908. * @returns the current connection point
  51909. */
  51910. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51911. /**
  51912. * Disconnect this point from one of his endpoint
  51913. * @param endpoint defines the other connection point
  51914. * @returns the current connection point
  51915. */
  51916. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51917. }
  51918. }
  51919. declare module BABYLON {
  51920. /**
  51921. * Block used to add support for vertex skinning (bones)
  51922. */
  51923. export class BonesBlock extends NodeMaterialBlock {
  51924. /**
  51925. * Creates a new BonesBlock
  51926. * @param name defines the block name
  51927. */
  51928. constructor(name: string);
  51929. /**
  51930. * Initialize the block and prepare the context for build
  51931. * @param state defines the state that will be used for the build
  51932. */
  51933. initialize(state: NodeMaterialBuildState): void;
  51934. /**
  51935. * Gets the current class name
  51936. * @returns the class name
  51937. */
  51938. getClassName(): string;
  51939. /**
  51940. * Gets the matrix indices input component
  51941. */
  51942. readonly matricesIndices: NodeMaterialConnectionPoint;
  51943. /**
  51944. * Gets the matrix weights input component
  51945. */
  51946. readonly matricesWeights: NodeMaterialConnectionPoint;
  51947. /**
  51948. * Gets the extra matrix indices input component
  51949. */
  51950. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  51951. /**
  51952. * Gets the extra matrix weights input component
  51953. */
  51954. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  51955. /**
  51956. * Gets the world input component
  51957. */
  51958. readonly world: NodeMaterialConnectionPoint;
  51959. /**
  51960. * Gets the output component
  51961. */
  51962. readonly output: NodeMaterialConnectionPoint;
  51963. autoConfigure(): void;
  51964. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51965. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51967. protected _buildBlock(state: NodeMaterialBuildState): this;
  51968. }
  51969. }
  51970. declare module BABYLON {
  51971. /**
  51972. * Block used to add support for instances
  51973. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  51974. */
  51975. export class InstancesBlock extends NodeMaterialBlock {
  51976. /**
  51977. * Creates a new InstancesBlock
  51978. * @param name defines the block name
  51979. */
  51980. constructor(name: string);
  51981. /**
  51982. * Gets the current class name
  51983. * @returns the class name
  51984. */
  51985. getClassName(): string;
  51986. /**
  51987. * Gets the first world row input component
  51988. */
  51989. readonly world0: NodeMaterialConnectionPoint;
  51990. /**
  51991. * Gets the second world row input component
  51992. */
  51993. readonly world1: NodeMaterialConnectionPoint;
  51994. /**
  51995. * Gets the third world row input component
  51996. */
  51997. readonly world2: NodeMaterialConnectionPoint;
  51998. /**
  51999. * Gets the forth world row input component
  52000. */
  52001. readonly world3: NodeMaterialConnectionPoint;
  52002. /**
  52003. * Gets the world input component
  52004. */
  52005. readonly world: NodeMaterialConnectionPoint;
  52006. /**
  52007. * Gets the output component
  52008. */
  52009. readonly output: NodeMaterialConnectionPoint;
  52010. autoConfigure(): void;
  52011. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52012. protected _buildBlock(state: NodeMaterialBuildState): this;
  52013. }
  52014. }
  52015. declare module BABYLON {
  52016. /**
  52017. * Block used to add morph targets support to vertex shader
  52018. */
  52019. export class MorphTargetsBlock extends NodeMaterialBlock {
  52020. private _repeatableContentAnchor;
  52021. private _repeatebleContentGenerated;
  52022. /**
  52023. * Create a new MorphTargetsBlock
  52024. * @param name defines the block name
  52025. */
  52026. constructor(name: string);
  52027. /**
  52028. * Gets the current class name
  52029. * @returns the class name
  52030. */
  52031. getClassName(): string;
  52032. /**
  52033. * Gets the position input component
  52034. */
  52035. readonly position: NodeMaterialConnectionPoint;
  52036. /**
  52037. * Gets the normal input component
  52038. */
  52039. readonly normal: NodeMaterialConnectionPoint;
  52040. /**
  52041. * Gets the tangent input component
  52042. */
  52043. readonly tangent: NodeMaterialConnectionPoint;
  52044. /**
  52045. * Gets the tangent input component
  52046. */
  52047. readonly uv: NodeMaterialConnectionPoint;
  52048. /**
  52049. * Gets the position output component
  52050. */
  52051. readonly positionOutput: NodeMaterialConnectionPoint;
  52052. /**
  52053. * Gets the normal output component
  52054. */
  52055. readonly normalOutput: NodeMaterialConnectionPoint;
  52056. /**
  52057. * Gets the tangent output component
  52058. */
  52059. readonly tangentOutput: NodeMaterialConnectionPoint;
  52060. /**
  52061. * Gets the tangent output component
  52062. */
  52063. readonly uvOutput: NodeMaterialConnectionPoint;
  52064. initialize(state: NodeMaterialBuildState): void;
  52065. autoConfigure(): void;
  52066. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52068. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52069. protected _buildBlock(state: NodeMaterialBuildState): this;
  52070. }
  52071. }
  52072. declare module BABYLON {
  52073. /**
  52074. * Block used to add an alpha test in the fragment shader
  52075. */
  52076. export class AlphaTestBlock extends NodeMaterialBlock {
  52077. /**
  52078. * Gets or sets the alpha value where alpha testing happens
  52079. */
  52080. alphaCutOff: number;
  52081. /**
  52082. * Create a new AlphaTestBlock
  52083. * @param name defines the block name
  52084. */
  52085. constructor(name: string);
  52086. /**
  52087. * Gets the current class name
  52088. * @returns the class name
  52089. */
  52090. getClassName(): string;
  52091. /**
  52092. * Gets the color input component
  52093. */
  52094. readonly color: NodeMaterialConnectionPoint;
  52095. protected _buildBlock(state: NodeMaterialBuildState): this;
  52096. }
  52097. }
  52098. declare module BABYLON {
  52099. /**
  52100. * Block used to create a Color4 out of 4 inputs (one for each component)
  52101. */
  52102. export class RGBAMergerBlock extends NodeMaterialBlock {
  52103. /**
  52104. * Create a new RGBAMergerBlock
  52105. * @param name defines the block name
  52106. */
  52107. constructor(name: string);
  52108. /**
  52109. * Gets the current class name
  52110. * @returns the class name
  52111. */
  52112. getClassName(): string;
  52113. /**
  52114. * Gets the R input component
  52115. */
  52116. readonly r: NodeMaterialConnectionPoint;
  52117. /**
  52118. * Gets the G input component
  52119. */
  52120. readonly g: NodeMaterialConnectionPoint;
  52121. /**
  52122. * Gets the B input component
  52123. */
  52124. readonly b: NodeMaterialConnectionPoint;
  52125. /**
  52126. * Gets the RGB input component
  52127. */
  52128. readonly rgb: NodeMaterialConnectionPoint;
  52129. /**
  52130. * Gets the R input component
  52131. */
  52132. readonly a: NodeMaterialConnectionPoint;
  52133. /**
  52134. * Gets the output component
  52135. */
  52136. readonly output: NodeMaterialConnectionPoint;
  52137. protected _buildBlock(state: NodeMaterialBuildState): this;
  52138. }
  52139. }
  52140. declare module BABYLON {
  52141. /**
  52142. * Block used to create a Color3 out of 3 inputs (one for each component)
  52143. */
  52144. export class RGBMergerBlock extends NodeMaterialBlock {
  52145. /**
  52146. * Create a new RGBMergerBlock
  52147. * @param name defines the block name
  52148. */
  52149. constructor(name: string);
  52150. /**
  52151. * Gets the current class name
  52152. * @returns the class name
  52153. */
  52154. getClassName(): string;
  52155. /**
  52156. * Gets the R component input
  52157. */
  52158. readonly r: NodeMaterialConnectionPoint;
  52159. /**
  52160. * Gets the G component input
  52161. */
  52162. readonly g: NodeMaterialConnectionPoint;
  52163. /**
  52164. * Gets the B component input
  52165. */
  52166. readonly b: NodeMaterialConnectionPoint;
  52167. /**
  52168. * Gets the output component
  52169. */
  52170. readonly output: NodeMaterialConnectionPoint;
  52171. protected _buildBlock(state: NodeMaterialBuildState): this;
  52172. }
  52173. }
  52174. declare module BABYLON {
  52175. /**
  52176. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  52177. */
  52178. export class RGBASplitterBlock extends NodeMaterialBlock {
  52179. /**
  52180. * Create a new RGBASplitterBlock
  52181. * @param name defines the block name
  52182. */
  52183. constructor(name: string);
  52184. /**
  52185. * Gets the current class name
  52186. * @returns the class name
  52187. */
  52188. getClassName(): string;
  52189. /**
  52190. * Gets the input component
  52191. */
  52192. readonly input: NodeMaterialConnectionPoint;
  52193. protected _buildBlock(state: NodeMaterialBuildState): this;
  52194. }
  52195. }
  52196. declare module BABYLON {
  52197. /**
  52198. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  52199. */
  52200. export class RGBSplitterBlock extends NodeMaterialBlock {
  52201. /**
  52202. * Create a new RGBSplitterBlock
  52203. * @param name defines the block name
  52204. */
  52205. constructor(name: string);
  52206. /**
  52207. * Gets the current class name
  52208. * @returns the class name
  52209. */
  52210. getClassName(): string;
  52211. /**
  52212. * Gets the input component
  52213. */
  52214. readonly input: NodeMaterialConnectionPoint;
  52215. protected _buildBlock(state: NodeMaterialBuildState): this;
  52216. }
  52217. }
  52218. declare module BABYLON {
  52219. /**
  52220. * Block used to add image processing support to fragment shader
  52221. */
  52222. export class ImageProcessingBlock extends NodeMaterialBlock {
  52223. /**
  52224. * Create a new ImageProcessingBlock
  52225. * @param name defines the block name
  52226. */
  52227. constructor(name: string);
  52228. /**
  52229. * Gets the current class name
  52230. * @returns the class name
  52231. */
  52232. getClassName(): string;
  52233. /**
  52234. * Gets the color input component
  52235. */
  52236. readonly color: NodeMaterialConnectionPoint;
  52237. /**
  52238. * Gets the output component
  52239. */
  52240. readonly output: NodeMaterialConnectionPoint;
  52241. /**
  52242. * Initialize the block and prepare the context for build
  52243. * @param state defines the state that will be used for the build
  52244. */
  52245. initialize(state: NodeMaterialBuildState): void;
  52246. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52247. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52248. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52249. protected _buildBlock(state: NodeMaterialBuildState): this;
  52250. }
  52251. }
  52252. declare module BABYLON {
  52253. /**
  52254. * Block used to add support for scene fog
  52255. */
  52256. export class FogBlock extends NodeMaterialBlock {
  52257. private _fogDistanceName;
  52258. private _fogParameters;
  52259. /**
  52260. * Create a new FogBlock
  52261. * @param name defines the block name
  52262. */
  52263. constructor(name: string);
  52264. /**
  52265. * Gets the current class name
  52266. * @returns the class name
  52267. */
  52268. getClassName(): string;
  52269. /**
  52270. * Gets the world position input component
  52271. */
  52272. readonly worldPosition: NodeMaterialConnectionPoint;
  52273. /**
  52274. * Gets the view input component
  52275. */
  52276. readonly view: NodeMaterialConnectionPoint;
  52277. /**
  52278. * Gets the color input component
  52279. */
  52280. readonly color: NodeMaterialConnectionPoint;
  52281. /**
  52282. * Gets the fog color input component
  52283. */
  52284. readonly fogColor: NodeMaterialConnectionPoint;
  52285. /**
  52286. * Gets the output component
  52287. */
  52288. readonly output: NodeMaterialConnectionPoint;
  52289. autoConfigure(): void;
  52290. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52291. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52292. protected _buildBlock(state: NodeMaterialBuildState): this;
  52293. }
  52294. }
  52295. declare module BABYLON {
  52296. /**
  52297. * Block used to add light in the fragment shader
  52298. */
  52299. export class LightBlock extends NodeMaterialBlock {
  52300. private _lightId;
  52301. /**
  52302. * Gets or sets the light associated with this block
  52303. */
  52304. light: Nullable<Light>;
  52305. /**
  52306. * Create a new LightBlock
  52307. * @param name defines the block name
  52308. */
  52309. constructor(name: string);
  52310. /**
  52311. * Gets the current class name
  52312. * @returns the class name
  52313. */
  52314. getClassName(): string;
  52315. /**
  52316. * Gets the world position input component
  52317. */
  52318. readonly worldPosition: NodeMaterialConnectionPoint;
  52319. /**
  52320. * Gets the world normal input component
  52321. */
  52322. readonly worldNormal: NodeMaterialConnectionPoint;
  52323. /**
  52324. * Gets the camera (or eye) position component
  52325. */
  52326. readonly cameraPosition: NodeMaterialConnectionPoint;
  52327. /**
  52328. * Gets the diffuse output component
  52329. */
  52330. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52331. /**
  52332. * Gets the specular output component
  52333. */
  52334. readonly specularOutput: NodeMaterialConnectionPoint;
  52335. autoConfigure(): void;
  52336. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52337. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52338. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52339. private _injectVertexCode;
  52340. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52341. }
  52342. }
  52343. declare module BABYLON {
  52344. /**
  52345. * Block used to multiply 2 values
  52346. */
  52347. export class MultiplyBlock extends NodeMaterialBlock {
  52348. /**
  52349. * Creates a new MultiplyBlock
  52350. * @param name defines the block name
  52351. */
  52352. constructor(name: string);
  52353. /**
  52354. * Gets the current class name
  52355. * @returns the class name
  52356. */
  52357. getClassName(): string;
  52358. /**
  52359. * Gets the left operand input component
  52360. */
  52361. readonly left: NodeMaterialConnectionPoint;
  52362. /**
  52363. * Gets the right operand input component
  52364. */
  52365. readonly right: NodeMaterialConnectionPoint;
  52366. /**
  52367. * Gets the output component
  52368. */
  52369. readonly output: NodeMaterialConnectionPoint;
  52370. protected _buildBlock(state: NodeMaterialBuildState): this;
  52371. }
  52372. }
  52373. declare module BABYLON {
  52374. /**
  52375. * Block used to add 2 vector4
  52376. */
  52377. export class AddBlock extends NodeMaterialBlock {
  52378. /**
  52379. * Creates a new AddBlock
  52380. * @param name defines the block name
  52381. */
  52382. constructor(name: string);
  52383. /**
  52384. * Gets the current class name
  52385. * @returns the class name
  52386. */
  52387. getClassName(): string;
  52388. /**
  52389. * Gets the left operand input component
  52390. */
  52391. readonly left: NodeMaterialConnectionPoint;
  52392. /**
  52393. * Gets the right operand input component
  52394. */
  52395. readonly right: NodeMaterialConnectionPoint;
  52396. /**
  52397. * Gets the output component
  52398. */
  52399. readonly output: NodeMaterialConnectionPoint;
  52400. protected _buildBlock(state: NodeMaterialBuildState): this;
  52401. }
  52402. }
  52403. declare module BABYLON {
  52404. /**
  52405. * Block used to clamp a float
  52406. */
  52407. export class ClampBlock extends NodeMaterialBlock {
  52408. /** Gets or sets the minimum range */
  52409. minimum: number;
  52410. /** Gets or sets the maximum range */
  52411. maximum: number;
  52412. /**
  52413. * Creates a new ClampBlock
  52414. * @param name defines the block name
  52415. */
  52416. constructor(name: string);
  52417. /**
  52418. * Gets the current class name
  52419. * @returns the class name
  52420. */
  52421. getClassName(): string;
  52422. /**
  52423. * Gets the value input component
  52424. */
  52425. readonly value: NodeMaterialConnectionPoint;
  52426. /**
  52427. * Gets the output component
  52428. */
  52429. readonly output: NodeMaterialConnectionPoint;
  52430. protected _buildBlock(state: NodeMaterialBuildState): this;
  52431. }
  52432. }
  52433. declare module BABYLON {
  52434. /**
  52435. * Block used to transform a vector2 with a matrix
  52436. */
  52437. export class Vector2TransformBlock extends NodeMaterialBlock {
  52438. /**
  52439. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52440. */
  52441. complementZ: number;
  52442. /**
  52443. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52444. */
  52445. complementW: number;
  52446. /**
  52447. * Creates a new Vector2TransformBlock
  52448. * @param name defines the block name
  52449. */
  52450. constructor(name: string);
  52451. /**
  52452. * Gets the vector input
  52453. */
  52454. readonly vector: NodeMaterialConnectionPoint;
  52455. /**
  52456. * Gets the matrix transform input
  52457. */
  52458. readonly transform: NodeMaterialConnectionPoint;
  52459. /**
  52460. * Gets the output component
  52461. */
  52462. readonly output: NodeMaterialConnectionPoint;
  52463. /**
  52464. * Gets the current class name
  52465. * @returns the class name
  52466. */
  52467. getClassName(): string;
  52468. protected _buildBlock(state: NodeMaterialBuildState): this;
  52469. }
  52470. }
  52471. declare module BABYLON {
  52472. /**
  52473. * Block used to transform a vector3 with a matrix
  52474. */
  52475. export class Vector3TransformBlock extends NodeMaterialBlock {
  52476. /**
  52477. * Defines the value to use to complement Vector3 to transform it to a Vector4
  52478. */
  52479. complement: number;
  52480. /**
  52481. * Creates a new Vector3TransformBlock
  52482. * @param name defines the block name
  52483. */
  52484. constructor(name: string);
  52485. /**
  52486. * Gets the vector input
  52487. */
  52488. readonly vector: NodeMaterialConnectionPoint;
  52489. /**
  52490. * Gets the matrix transform input
  52491. */
  52492. readonly transform: NodeMaterialConnectionPoint;
  52493. /**
  52494. * Gets the output component
  52495. */
  52496. readonly output: NodeMaterialConnectionPoint;
  52497. /**
  52498. * Gets the current class name
  52499. * @returns the class name
  52500. */
  52501. getClassName(): string;
  52502. protected _buildBlock(state: NodeMaterialBuildState): this;
  52503. }
  52504. }
  52505. declare module BABYLON {
  52506. /**
  52507. * Helper class to render one or more effects
  52508. */
  52509. export class EffectRenderer {
  52510. private engine;
  52511. private static _Vertices;
  52512. private static _Indices;
  52513. private _vertexBuffers;
  52514. private _indexBuffer;
  52515. private _ringBufferIndex;
  52516. private _ringScreenBuffer;
  52517. private _getNextFrameBuffer;
  52518. /**
  52519. * Creates an effect renderer
  52520. * @param engine the engine to use for rendering
  52521. */
  52522. constructor(engine: Engine);
  52523. /**
  52524. * renders one or more effects to a specified texture
  52525. * @param effectWrappers list of effects to renderer
  52526. * @param outputTexture texture to draw to, if null it will render to the screen
  52527. */
  52528. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  52529. /**
  52530. * Disposes of the effect renderer
  52531. */
  52532. dispose(): void;
  52533. }
  52534. /**
  52535. * Options to create an EffectWrapper
  52536. */
  52537. interface EffectWrapperCreationOptions {
  52538. /**
  52539. * Engine to use to create the effect
  52540. */
  52541. engine: Engine;
  52542. /**
  52543. * Fragment shader for the effect
  52544. */
  52545. fragmentShader: string;
  52546. /**
  52547. * Attributes to use in the shader
  52548. */
  52549. attributeNames: Array<string>;
  52550. /**
  52551. * Uniforms to use in the shader
  52552. */
  52553. uniformNames: Array<string>;
  52554. /**
  52555. * Texture sampler names to use in the shader
  52556. */
  52557. samplerNames: Array<string>;
  52558. }
  52559. /**
  52560. * Wraps an effect to be used for rendering
  52561. */
  52562. export class EffectWrapper {
  52563. /**
  52564. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  52565. */
  52566. onApplyObservable: Observable<{}>;
  52567. /**
  52568. * The underlying effect
  52569. */
  52570. effect: Effect;
  52571. /**
  52572. * Creates an effect to be renderer
  52573. * @param creationOptions options to create the effect
  52574. */
  52575. constructor(creationOptions: EffectWrapperCreationOptions);
  52576. /**
  52577. * Disposes of the effect wrapper
  52578. */
  52579. dispose(): void;
  52580. }
  52581. }
  52582. declare module BABYLON {
  52583. /**
  52584. * Helper class to push actions to a pool of workers.
  52585. */
  52586. export class WorkerPool implements IDisposable {
  52587. private _workerInfos;
  52588. private _pendingActions;
  52589. /**
  52590. * Constructor
  52591. * @param workers Array of workers to use for actions
  52592. */
  52593. constructor(workers: Array<Worker>);
  52594. /**
  52595. * Terminates all workers and clears any pending actions.
  52596. */
  52597. dispose(): void;
  52598. /**
  52599. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52600. * pended until a worker has completed its action.
  52601. * @param action The action to perform. Call onComplete when the action is complete.
  52602. */
  52603. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52604. private _execute;
  52605. }
  52606. }
  52607. declare module BABYLON {
  52608. /**
  52609. * Configuration for Draco compression
  52610. */
  52611. export interface IDracoCompressionConfiguration {
  52612. /**
  52613. * Configuration for the decoder.
  52614. */
  52615. decoder: {
  52616. /**
  52617. * The url to the WebAssembly module.
  52618. */
  52619. wasmUrl?: string;
  52620. /**
  52621. * The url to the WebAssembly binary.
  52622. */
  52623. wasmBinaryUrl?: string;
  52624. /**
  52625. * The url to the fallback JavaScript module.
  52626. */
  52627. fallbackUrl?: string;
  52628. };
  52629. }
  52630. /**
  52631. * Draco compression (https://google.github.io/draco/)
  52632. *
  52633. * This class wraps the Draco module.
  52634. *
  52635. * **Encoder**
  52636. *
  52637. * The encoder is not currently implemented.
  52638. *
  52639. * **Decoder**
  52640. *
  52641. * 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.
  52642. *
  52643. * To update the configuration, use the following code:
  52644. * ```javascript
  52645. * DracoCompression.Configuration = {
  52646. * decoder: {
  52647. * wasmUrl: "<url to the WebAssembly library>",
  52648. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52649. * fallbackUrl: "<url to the fallback JavaScript library>",
  52650. * }
  52651. * };
  52652. * ```
  52653. *
  52654. * 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.
  52655. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52656. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52657. *
  52658. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52659. * ```javascript
  52660. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52661. * ```
  52662. *
  52663. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52664. */
  52665. export class DracoCompression implements IDisposable {
  52666. private _workerPoolPromise?;
  52667. private _decoderModulePromise?;
  52668. /**
  52669. * The configuration. Defaults to the following urls:
  52670. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52671. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52672. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52673. */
  52674. static Configuration: IDracoCompressionConfiguration;
  52675. /**
  52676. * Returns true if the decoder configuration is available.
  52677. */
  52678. static readonly DecoderAvailable: boolean;
  52679. /**
  52680. * Default number of workers to create when creating the draco compression object.
  52681. */
  52682. static DefaultNumWorkers: number;
  52683. private static GetDefaultNumWorkers;
  52684. private static _Default;
  52685. /**
  52686. * Default instance for the draco compression object.
  52687. */
  52688. static readonly Default: DracoCompression;
  52689. /**
  52690. * Constructor
  52691. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52692. */
  52693. constructor(numWorkers?: number);
  52694. /**
  52695. * Stop all async operations and release resources.
  52696. */
  52697. dispose(): void;
  52698. /**
  52699. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52700. * @returns a promise that resolves when ready
  52701. */
  52702. whenReadyAsync(): Promise<void>;
  52703. /**
  52704. * Decode Draco compressed mesh data to vertex data.
  52705. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52706. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52707. * @returns A promise that resolves with the decoded vertex data
  52708. */
  52709. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52710. [kind: string]: number;
  52711. }): Promise<VertexData>;
  52712. }
  52713. }
  52714. declare module BABYLON {
  52715. /**
  52716. * Class for building Constructive Solid Geometry
  52717. */
  52718. export class CSG {
  52719. private polygons;
  52720. /**
  52721. * The world matrix
  52722. */
  52723. matrix: Matrix;
  52724. /**
  52725. * Stores the position
  52726. */
  52727. position: Vector3;
  52728. /**
  52729. * Stores the rotation
  52730. */
  52731. rotation: Vector3;
  52732. /**
  52733. * Stores the rotation quaternion
  52734. */
  52735. rotationQuaternion: Nullable<Quaternion>;
  52736. /**
  52737. * Stores the scaling vector
  52738. */
  52739. scaling: Vector3;
  52740. /**
  52741. * Convert the Mesh to CSG
  52742. * @param mesh The Mesh to convert to CSG
  52743. * @returns A new CSG from the Mesh
  52744. */
  52745. static FromMesh(mesh: Mesh): CSG;
  52746. /**
  52747. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52748. * @param polygons Polygons used to construct a CSG solid
  52749. */
  52750. private static FromPolygons;
  52751. /**
  52752. * Clones, or makes a deep copy, of the CSG
  52753. * @returns A new CSG
  52754. */
  52755. clone(): CSG;
  52756. /**
  52757. * Unions this CSG with another CSG
  52758. * @param csg The CSG to union against this CSG
  52759. * @returns The unioned CSG
  52760. */
  52761. union(csg: CSG): CSG;
  52762. /**
  52763. * Unions this CSG with another CSG in place
  52764. * @param csg The CSG to union against this CSG
  52765. */
  52766. unionInPlace(csg: CSG): void;
  52767. /**
  52768. * Subtracts this CSG with another CSG
  52769. * @param csg The CSG to subtract against this CSG
  52770. * @returns A new CSG
  52771. */
  52772. subtract(csg: CSG): CSG;
  52773. /**
  52774. * Subtracts this CSG with another CSG in place
  52775. * @param csg The CSG to subtact against this CSG
  52776. */
  52777. subtractInPlace(csg: CSG): void;
  52778. /**
  52779. * Intersect this CSG with another CSG
  52780. * @param csg The CSG to intersect against this CSG
  52781. * @returns A new CSG
  52782. */
  52783. intersect(csg: CSG): CSG;
  52784. /**
  52785. * Intersects this CSG with another CSG in place
  52786. * @param csg The CSG to intersect against this CSG
  52787. */
  52788. intersectInPlace(csg: CSG): void;
  52789. /**
  52790. * Return a new CSG solid with solid and empty space switched. This solid is
  52791. * not modified.
  52792. * @returns A new CSG solid with solid and empty space switched
  52793. */
  52794. inverse(): CSG;
  52795. /**
  52796. * Inverses the CSG in place
  52797. */
  52798. inverseInPlace(): void;
  52799. /**
  52800. * This is used to keep meshes transformations so they can be restored
  52801. * when we build back a Babylon Mesh
  52802. * NB : All CSG operations are performed in world coordinates
  52803. * @param csg The CSG to copy the transform attributes from
  52804. * @returns This CSG
  52805. */
  52806. copyTransformAttributes(csg: CSG): CSG;
  52807. /**
  52808. * Build Raw mesh from CSG
  52809. * Coordinates here are in world space
  52810. * @param name The name of the mesh geometry
  52811. * @param scene The Scene
  52812. * @param keepSubMeshes Specifies if the submeshes should be kept
  52813. * @returns A new Mesh
  52814. */
  52815. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52816. /**
  52817. * Build Mesh from CSG taking material and transforms into account
  52818. * @param name The name of the Mesh
  52819. * @param material The material of the Mesh
  52820. * @param scene The Scene
  52821. * @param keepSubMeshes Specifies if submeshes should be kept
  52822. * @returns The new Mesh
  52823. */
  52824. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52825. }
  52826. }
  52827. declare module BABYLON {
  52828. /**
  52829. * Class used to create a trail following a mesh
  52830. */
  52831. export class TrailMesh extends Mesh {
  52832. private _generator;
  52833. private _autoStart;
  52834. private _running;
  52835. private _diameter;
  52836. private _length;
  52837. private _sectionPolygonPointsCount;
  52838. private _sectionVectors;
  52839. private _sectionNormalVectors;
  52840. private _beforeRenderObserver;
  52841. /**
  52842. * @constructor
  52843. * @param name The value used by scene.getMeshByName() to do a lookup.
  52844. * @param generator The mesh to generate a trail.
  52845. * @param scene The scene to add this mesh to.
  52846. * @param diameter Diameter of trailing mesh. Default is 1.
  52847. * @param length Length of trailing mesh. Default is 60.
  52848. * @param autoStart Automatically start trailing mesh. Default true.
  52849. */
  52850. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52851. /**
  52852. * "TrailMesh"
  52853. * @returns "TrailMesh"
  52854. */
  52855. getClassName(): string;
  52856. private _createMesh;
  52857. /**
  52858. * Start trailing mesh.
  52859. */
  52860. start(): void;
  52861. /**
  52862. * Stop trailing mesh.
  52863. */
  52864. stop(): void;
  52865. /**
  52866. * Update trailing mesh geometry.
  52867. */
  52868. update(): void;
  52869. /**
  52870. * Returns a new TrailMesh object.
  52871. * @param name is a string, the name given to the new mesh
  52872. * @param newGenerator use new generator object for cloned trail mesh
  52873. * @returns a new mesh
  52874. */
  52875. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52876. /**
  52877. * Serializes this trail mesh
  52878. * @param serializationObject object to write serialization to
  52879. */
  52880. serialize(serializationObject: any): void;
  52881. /**
  52882. * Parses a serialized trail mesh
  52883. * @param parsedMesh the serialized mesh
  52884. * @param scene the scene to create the trail mesh in
  52885. * @returns the created trail mesh
  52886. */
  52887. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52888. }
  52889. }
  52890. declare module BABYLON {
  52891. /**
  52892. * Class containing static functions to help procedurally build meshes
  52893. */
  52894. export class TiledBoxBuilder {
  52895. /**
  52896. * Creates a box mesh
  52897. * 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)
  52898. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52900. * * 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
  52901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52902. * @param name defines the name of the mesh
  52903. * @param options defines the options used to create the mesh
  52904. * @param scene defines the hosting scene
  52905. * @returns the box mesh
  52906. */
  52907. static CreateTiledBox(name: string, options: {
  52908. pattern?: number;
  52909. width?: number;
  52910. height?: number;
  52911. depth?: number;
  52912. tileSize?: number;
  52913. tileWidth?: number;
  52914. tileHeight?: number;
  52915. alignHorizontal?: number;
  52916. alignVertical?: number;
  52917. faceUV?: Vector4[];
  52918. faceColors?: Color4[];
  52919. sideOrientation?: number;
  52920. updatable?: boolean;
  52921. }, scene?: Nullable<Scene>): Mesh;
  52922. }
  52923. }
  52924. declare module BABYLON {
  52925. /**
  52926. * Class containing static functions to help procedurally build meshes
  52927. */
  52928. export class TorusKnotBuilder {
  52929. /**
  52930. * Creates a torus knot mesh
  52931. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52932. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52933. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52934. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52936. * * 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
  52937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52938. * @param name defines the name of the mesh
  52939. * @param options defines the options used to create the mesh
  52940. * @param scene defines the hosting scene
  52941. * @returns the torus knot mesh
  52942. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52943. */
  52944. static CreateTorusKnot(name: string, options: {
  52945. radius?: number;
  52946. tube?: number;
  52947. radialSegments?: number;
  52948. tubularSegments?: number;
  52949. p?: number;
  52950. q?: number;
  52951. updatable?: boolean;
  52952. sideOrientation?: number;
  52953. frontUVs?: Vector4;
  52954. backUVs?: Vector4;
  52955. }, scene: any): Mesh;
  52956. }
  52957. }
  52958. declare module BABYLON {
  52959. /**
  52960. * Polygon
  52961. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52962. */
  52963. export class Polygon {
  52964. /**
  52965. * Creates a rectangle
  52966. * @param xmin bottom X coord
  52967. * @param ymin bottom Y coord
  52968. * @param xmax top X coord
  52969. * @param ymax top Y coord
  52970. * @returns points that make the resulting rectation
  52971. */
  52972. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52973. /**
  52974. * Creates a circle
  52975. * @param radius radius of circle
  52976. * @param cx scale in x
  52977. * @param cy scale in y
  52978. * @param numberOfSides number of sides that make up the circle
  52979. * @returns points that make the resulting circle
  52980. */
  52981. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52982. /**
  52983. * Creates a polygon from input string
  52984. * @param input Input polygon data
  52985. * @returns the parsed points
  52986. */
  52987. static Parse(input: string): Vector2[];
  52988. /**
  52989. * Starts building a polygon from x and y coordinates
  52990. * @param x x coordinate
  52991. * @param y y coordinate
  52992. * @returns the started path2
  52993. */
  52994. static StartingAt(x: number, y: number): Path2;
  52995. }
  52996. /**
  52997. * Builds a polygon
  52998. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52999. */
  53000. export class PolygonMeshBuilder {
  53001. private _points;
  53002. private _outlinepoints;
  53003. private _holes;
  53004. private _name;
  53005. private _scene;
  53006. private _epoints;
  53007. private _eholes;
  53008. private _addToepoint;
  53009. /**
  53010. * Babylon reference to the earcut plugin.
  53011. */
  53012. bjsEarcut: any;
  53013. /**
  53014. * Creates a PolygonMeshBuilder
  53015. * @param name name of the builder
  53016. * @param contours Path of the polygon
  53017. * @param scene scene to add to when creating the mesh
  53018. * @param earcutInjection can be used to inject your own earcut reference
  53019. */
  53020. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  53021. /**
  53022. * Adds a whole within the polygon
  53023. * @param hole Array of points defining the hole
  53024. * @returns this
  53025. */
  53026. addHole(hole: Vector2[]): PolygonMeshBuilder;
  53027. /**
  53028. * Creates the polygon
  53029. * @param updatable If the mesh should be updatable
  53030. * @param depth The depth of the mesh created
  53031. * @returns the created mesh
  53032. */
  53033. build(updatable?: boolean, depth?: number): Mesh;
  53034. /**
  53035. * Creates the polygon
  53036. * @param depth The depth of the mesh created
  53037. * @returns the created VertexData
  53038. */
  53039. buildVertexData(depth?: number): VertexData;
  53040. /**
  53041. * Adds a side to the polygon
  53042. * @param positions points that make the polygon
  53043. * @param normals normals of the polygon
  53044. * @param uvs uvs of the polygon
  53045. * @param indices indices of the polygon
  53046. * @param bounds bounds of the polygon
  53047. * @param points points of the polygon
  53048. * @param depth depth of the polygon
  53049. * @param flip flip of the polygon
  53050. */
  53051. private addSide;
  53052. }
  53053. }
  53054. declare module BABYLON {
  53055. /**
  53056. * Class containing static functions to help procedurally build meshes
  53057. */
  53058. export class PolygonBuilder {
  53059. /**
  53060. * Creates a polygon mesh
  53061. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53062. * * 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
  53063. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53065. * * 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)
  53066. * * Remember you can only change the shape positions, not their number when updating a polygon
  53067. * @param name defines the name of the mesh
  53068. * @param options defines the options used to create the mesh
  53069. * @param scene defines the hosting scene
  53070. * @param earcutInjection can be used to inject your own earcut reference
  53071. * @returns the polygon mesh
  53072. */
  53073. static CreatePolygon(name: string, options: {
  53074. shape: Vector3[];
  53075. holes?: Vector3[][];
  53076. depth?: number;
  53077. faceUV?: Vector4[];
  53078. faceColors?: Color4[];
  53079. updatable?: boolean;
  53080. sideOrientation?: number;
  53081. frontUVs?: Vector4;
  53082. backUVs?: Vector4;
  53083. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53084. /**
  53085. * Creates an extruded polygon mesh, with depth in the Y direction.
  53086. * * 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)
  53087. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53088. * @param name defines the name of the mesh
  53089. * @param options defines the options used to create the mesh
  53090. * @param scene defines the hosting scene
  53091. * @param earcutInjection can be used to inject your own earcut reference
  53092. * @returns the polygon mesh
  53093. */
  53094. static ExtrudePolygon(name: string, options: {
  53095. shape: Vector3[];
  53096. holes?: Vector3[][];
  53097. depth?: number;
  53098. faceUV?: Vector4[];
  53099. faceColors?: Color4[];
  53100. updatable?: boolean;
  53101. sideOrientation?: number;
  53102. frontUVs?: Vector4;
  53103. backUVs?: Vector4;
  53104. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53105. }
  53106. }
  53107. declare module BABYLON {
  53108. /**
  53109. * Class containing static functions to help procedurally build meshes
  53110. */
  53111. export class LatheBuilder {
  53112. /**
  53113. * Creates lathe mesh.
  53114. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53115. * * 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
  53116. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53117. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53118. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53119. * * 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
  53120. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53121. * * 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
  53122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53123. * * 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
  53124. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53126. * @param name defines the name of the mesh
  53127. * @param options defines the options used to create the mesh
  53128. * @param scene defines the hosting scene
  53129. * @returns the lathe mesh
  53130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53131. */
  53132. static CreateLathe(name: string, options: {
  53133. shape: Vector3[];
  53134. radius?: number;
  53135. tessellation?: number;
  53136. clip?: number;
  53137. arc?: number;
  53138. closed?: boolean;
  53139. updatable?: boolean;
  53140. sideOrientation?: number;
  53141. frontUVs?: Vector4;
  53142. backUVs?: Vector4;
  53143. cap?: number;
  53144. invertUV?: boolean;
  53145. }, scene?: Nullable<Scene>): Mesh;
  53146. }
  53147. }
  53148. declare module BABYLON {
  53149. /**
  53150. * Class containing static functions to help procedurally build meshes
  53151. */
  53152. export class TiledPlaneBuilder {
  53153. /**
  53154. * Creates a tiled plane mesh
  53155. * * The parameter `pattern` will, depending on value, do nothing or
  53156. * * * flip (reflect about central vertical) alternate tiles across and up
  53157. * * * flip every tile on alternate rows
  53158. * * * rotate (180 degs) alternate tiles across and up
  53159. * * * rotate every tile on alternate rows
  53160. * * * flip and rotate alternate tiles across and up
  53161. * * * flip and rotate every tile on alternate rows
  53162. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  53163. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  53164. * * 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
  53165. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53166. * * 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)
  53167. * * 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)
  53168. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53169. * @param name defines the name of the mesh
  53170. * @param options defines the options used to create the mesh
  53171. * @param scene defines the hosting scene
  53172. * @returns the box mesh
  53173. */
  53174. static CreateTiledPlane(name: string, options: {
  53175. pattern?: number;
  53176. tileSize?: number;
  53177. tileWidth?: number;
  53178. tileHeight?: number;
  53179. size?: number;
  53180. width?: number;
  53181. height?: number;
  53182. alignHorizontal?: number;
  53183. alignVertical?: number;
  53184. sideOrientation?: number;
  53185. frontUVs?: Vector4;
  53186. backUVs?: Vector4;
  53187. updatable?: boolean;
  53188. }, scene?: Nullable<Scene>): Mesh;
  53189. }
  53190. }
  53191. declare module BABYLON {
  53192. /**
  53193. * Class containing static functions to help procedurally build meshes
  53194. */
  53195. export class TubeBuilder {
  53196. /**
  53197. * Creates a tube mesh.
  53198. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53199. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53200. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53201. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53202. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53203. * * 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)
  53204. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53205. * * 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
  53206. * * 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
  53207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53208. * * 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
  53209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53211. * @param name defines the name of the mesh
  53212. * @param options defines the options used to create the mesh
  53213. * @param scene defines the hosting scene
  53214. * @returns the tube mesh
  53215. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53216. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53217. */
  53218. static CreateTube(name: string, options: {
  53219. path: Vector3[];
  53220. radius?: number;
  53221. tessellation?: number;
  53222. radiusFunction?: {
  53223. (i: number, distance: number): number;
  53224. };
  53225. cap?: number;
  53226. arc?: number;
  53227. updatable?: boolean;
  53228. sideOrientation?: number;
  53229. frontUVs?: Vector4;
  53230. backUVs?: Vector4;
  53231. instance?: Mesh;
  53232. invertUV?: boolean;
  53233. }, scene?: Nullable<Scene>): Mesh;
  53234. }
  53235. }
  53236. declare module BABYLON {
  53237. /**
  53238. * Class containing static functions to help procedurally build meshes
  53239. */
  53240. export class IcoSphereBuilder {
  53241. /**
  53242. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53243. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53244. * * 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`)
  53245. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53246. * * 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
  53247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53248. * * 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
  53249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53250. * @param name defines the name of the mesh
  53251. * @param options defines the options used to create the mesh
  53252. * @param scene defines the hosting scene
  53253. * @returns the icosahedron mesh
  53254. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53255. */
  53256. static CreateIcoSphere(name: string, options: {
  53257. radius?: number;
  53258. radiusX?: number;
  53259. radiusY?: number;
  53260. radiusZ?: number;
  53261. flat?: boolean;
  53262. subdivisions?: number;
  53263. sideOrientation?: number;
  53264. frontUVs?: Vector4;
  53265. backUVs?: Vector4;
  53266. updatable?: boolean;
  53267. }, scene?: Nullable<Scene>): Mesh;
  53268. }
  53269. }
  53270. declare module BABYLON {
  53271. /**
  53272. * Class containing static functions to help procedurally build meshes
  53273. */
  53274. export class DecalBuilder {
  53275. /**
  53276. * Creates a decal mesh.
  53277. * 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
  53278. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53279. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53280. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53281. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53282. * @param name defines the name of the mesh
  53283. * @param sourceMesh defines the mesh where the decal must be applied
  53284. * @param options defines the options used to create the mesh
  53285. * @param scene defines the hosting scene
  53286. * @returns the decal mesh
  53287. * @see https://doc.babylonjs.com/how_to/decals
  53288. */
  53289. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53290. position?: Vector3;
  53291. normal?: Vector3;
  53292. size?: Vector3;
  53293. angle?: number;
  53294. }): Mesh;
  53295. }
  53296. }
  53297. declare module BABYLON {
  53298. /**
  53299. * Class containing static functions to help procedurally build meshes
  53300. */
  53301. export class MeshBuilder {
  53302. /**
  53303. * Creates a box mesh
  53304. * * The parameter `size` sets the size (float) of each box side (default 1)
  53305. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53306. * * 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)
  53307. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53311. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53312. * @param name defines the name of the mesh
  53313. * @param options defines the options used to create the mesh
  53314. * @param scene defines the hosting scene
  53315. * @returns the box mesh
  53316. */
  53317. static CreateBox(name: string, options: {
  53318. size?: number;
  53319. width?: number;
  53320. height?: number;
  53321. depth?: number;
  53322. faceUV?: Vector4[];
  53323. faceColors?: Color4[];
  53324. sideOrientation?: number;
  53325. frontUVs?: Vector4;
  53326. backUVs?: Vector4;
  53327. updatable?: boolean;
  53328. }, scene?: Nullable<Scene>): Mesh;
  53329. /**
  53330. * Creates a tiled box mesh
  53331. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53333. * @param name defines the name of the mesh
  53334. * @param options defines the options used to create the mesh
  53335. * @param scene defines the hosting scene
  53336. * @returns the tiled box mesh
  53337. */
  53338. static CreateTiledBox(name: string, options: {
  53339. pattern?: number;
  53340. size?: number;
  53341. width?: number;
  53342. height?: number;
  53343. depth: number;
  53344. tileSize?: number;
  53345. tileWidth?: number;
  53346. tileHeight?: number;
  53347. faceUV?: Vector4[];
  53348. faceColors?: Color4[];
  53349. alignHorizontal?: number;
  53350. alignVertical?: number;
  53351. sideOrientation?: number;
  53352. updatable?: boolean;
  53353. }, scene?: Nullable<Scene>): Mesh;
  53354. /**
  53355. * Creates a sphere mesh
  53356. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53357. * * 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`)
  53358. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53359. * * 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
  53360. * * 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)
  53361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53362. * * 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
  53363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53364. * @param name defines the name of the mesh
  53365. * @param options defines the options used to create the mesh
  53366. * @param scene defines the hosting scene
  53367. * @returns the sphere mesh
  53368. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53369. */
  53370. static CreateSphere(name: string, options: {
  53371. segments?: number;
  53372. diameter?: number;
  53373. diameterX?: number;
  53374. diameterY?: number;
  53375. diameterZ?: number;
  53376. arc?: number;
  53377. slice?: number;
  53378. sideOrientation?: number;
  53379. frontUVs?: Vector4;
  53380. backUVs?: Vector4;
  53381. updatable?: boolean;
  53382. }, scene?: Nullable<Scene>): Mesh;
  53383. /**
  53384. * Creates a plane polygonal mesh. By default, this is a disc
  53385. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53386. * * 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
  53387. * * 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
  53388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53391. * @param name defines the name of the mesh
  53392. * @param options defines the options used to create the mesh
  53393. * @param scene defines the hosting scene
  53394. * @returns the plane polygonal mesh
  53395. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53396. */
  53397. static CreateDisc(name: string, options: {
  53398. radius?: number;
  53399. tessellation?: number;
  53400. arc?: number;
  53401. updatable?: boolean;
  53402. sideOrientation?: number;
  53403. frontUVs?: Vector4;
  53404. backUVs?: Vector4;
  53405. }, scene?: Nullable<Scene>): Mesh;
  53406. /**
  53407. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53408. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53409. * * 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`)
  53410. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53411. * * 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
  53412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53415. * @param name defines the name of the mesh
  53416. * @param options defines the options used to create the mesh
  53417. * @param scene defines the hosting scene
  53418. * @returns the icosahedron mesh
  53419. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53420. */
  53421. static CreateIcoSphere(name: string, options: {
  53422. radius?: number;
  53423. radiusX?: number;
  53424. radiusY?: number;
  53425. radiusZ?: number;
  53426. flat?: boolean;
  53427. subdivisions?: number;
  53428. sideOrientation?: number;
  53429. frontUVs?: Vector4;
  53430. backUVs?: Vector4;
  53431. updatable?: boolean;
  53432. }, scene?: Nullable<Scene>): Mesh;
  53433. /**
  53434. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53435. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53436. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53437. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53438. * * 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
  53439. * * 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
  53440. * * 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
  53441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53442. * * 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
  53443. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53444. * * 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
  53445. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53446. * * 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
  53447. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53449. * @param name defines the name of the mesh
  53450. * @param options defines the options used to create the mesh
  53451. * @param scene defines the hosting scene
  53452. * @returns the ribbon mesh
  53453. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53454. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53455. */
  53456. static CreateRibbon(name: string, options: {
  53457. pathArray: Vector3[][];
  53458. closeArray?: boolean;
  53459. closePath?: boolean;
  53460. offset?: number;
  53461. updatable?: boolean;
  53462. sideOrientation?: number;
  53463. frontUVs?: Vector4;
  53464. backUVs?: Vector4;
  53465. instance?: Mesh;
  53466. invertUV?: boolean;
  53467. uvs?: Vector2[];
  53468. colors?: Color4[];
  53469. }, scene?: Nullable<Scene>): Mesh;
  53470. /**
  53471. * Creates a cylinder or a cone mesh
  53472. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53473. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53474. * * 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.
  53475. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53476. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53477. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53478. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53479. * * 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).
  53480. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53481. * * 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).
  53482. * * 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
  53483. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53484. * * 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
  53485. * * 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.
  53486. * * If `enclose` is false, a ring surface is one element.
  53487. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53488. * * 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
  53489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53490. * * 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
  53491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53492. * @param name defines the name of the mesh
  53493. * @param options defines the options used to create the mesh
  53494. * @param scene defines the hosting scene
  53495. * @returns the cylinder mesh
  53496. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53497. */
  53498. static CreateCylinder(name: string, options: {
  53499. height?: number;
  53500. diameterTop?: number;
  53501. diameterBottom?: number;
  53502. diameter?: number;
  53503. tessellation?: number;
  53504. subdivisions?: number;
  53505. arc?: number;
  53506. faceColors?: Color4[];
  53507. faceUV?: Vector4[];
  53508. updatable?: boolean;
  53509. hasRings?: boolean;
  53510. enclose?: boolean;
  53511. cap?: number;
  53512. sideOrientation?: number;
  53513. frontUVs?: Vector4;
  53514. backUVs?: Vector4;
  53515. }, scene?: Nullable<Scene>): Mesh;
  53516. /**
  53517. * Creates a torus mesh
  53518. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53519. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53520. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53522. * * 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
  53523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53524. * @param name defines the name of the mesh
  53525. * @param options defines the options used to create the mesh
  53526. * @param scene defines the hosting scene
  53527. * @returns the torus mesh
  53528. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53529. */
  53530. static CreateTorus(name: string, options: {
  53531. diameter?: number;
  53532. thickness?: number;
  53533. tessellation?: number;
  53534. updatable?: boolean;
  53535. sideOrientation?: number;
  53536. frontUVs?: Vector4;
  53537. backUVs?: Vector4;
  53538. }, scene?: Nullable<Scene>): Mesh;
  53539. /**
  53540. * Creates a torus knot mesh
  53541. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53542. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53543. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53544. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53546. * * 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
  53547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53548. * @param name defines the name of the mesh
  53549. * @param options defines the options used to create the mesh
  53550. * @param scene defines the hosting scene
  53551. * @returns the torus knot mesh
  53552. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53553. */
  53554. static CreateTorusKnot(name: string, options: {
  53555. radius?: number;
  53556. tube?: number;
  53557. radialSegments?: number;
  53558. tubularSegments?: number;
  53559. p?: number;
  53560. q?: number;
  53561. updatable?: boolean;
  53562. sideOrientation?: number;
  53563. frontUVs?: Vector4;
  53564. backUVs?: Vector4;
  53565. }, scene?: Nullable<Scene>): Mesh;
  53566. /**
  53567. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  53568. * * 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
  53569. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  53570. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  53571. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  53572. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  53573. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  53574. * * 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
  53575. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  53576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53577. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  53578. * @param name defines the name of the new line system
  53579. * @param options defines the options used to create the line system
  53580. * @param scene defines the hosting scene
  53581. * @returns a new line system mesh
  53582. */
  53583. static CreateLineSystem(name: string, options: {
  53584. lines: Vector3[][];
  53585. updatable?: boolean;
  53586. instance?: Nullable<LinesMesh>;
  53587. colors?: Nullable<Color4[][]>;
  53588. useVertexAlpha?: boolean;
  53589. }, scene: Nullable<Scene>): LinesMesh;
  53590. /**
  53591. * Creates a line mesh
  53592. * 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
  53593. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53594. * * The parameter `points` is an array successive Vector3
  53595. * * 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
  53596. * * The optional parameter `colors` is an array of successive Color4, one per line point
  53597. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  53598. * * When updating an instance, remember that only point positions can change, not the number of points
  53599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  53601. * @param name defines the name of the new line system
  53602. * @param options defines the options used to create the line system
  53603. * @param scene defines the hosting scene
  53604. * @returns a new line mesh
  53605. */
  53606. static CreateLines(name: string, options: {
  53607. points: Vector3[];
  53608. updatable?: boolean;
  53609. instance?: Nullable<LinesMesh>;
  53610. colors?: Color4[];
  53611. useVertexAlpha?: boolean;
  53612. }, scene?: Nullable<Scene>): LinesMesh;
  53613. /**
  53614. * Creates a dashed line mesh
  53615. * * 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
  53616. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53617. * * The parameter `points` is an array successive Vector3
  53618. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  53619. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  53620. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  53621. * * 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
  53622. * * When updating an instance, remember that only point positions can change, not the number of points
  53623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53624. * @param name defines the name of the mesh
  53625. * @param options defines the options used to create the mesh
  53626. * @param scene defines the hosting scene
  53627. * @returns the dashed line mesh
  53628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  53629. */
  53630. static CreateDashedLines(name: string, options: {
  53631. points: Vector3[];
  53632. dashSize?: number;
  53633. gapSize?: number;
  53634. dashNb?: number;
  53635. updatable?: boolean;
  53636. instance?: LinesMesh;
  53637. }, scene?: Nullable<Scene>): LinesMesh;
  53638. /**
  53639. * 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.
  53640. * * 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.
  53641. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53642. * * 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.
  53643. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53644. * * 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
  53645. * * 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
  53646. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53648. * * 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
  53649. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53651. * @param name defines the name of the mesh
  53652. * @param options defines the options used to create the mesh
  53653. * @param scene defines the hosting scene
  53654. * @returns the extruded shape mesh
  53655. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53657. */
  53658. static ExtrudeShape(name: string, options: {
  53659. shape: Vector3[];
  53660. path: Vector3[];
  53661. scale?: number;
  53662. rotation?: number;
  53663. cap?: number;
  53664. updatable?: boolean;
  53665. sideOrientation?: number;
  53666. frontUVs?: Vector4;
  53667. backUVs?: Vector4;
  53668. instance?: Mesh;
  53669. invertUV?: boolean;
  53670. }, scene?: Nullable<Scene>): Mesh;
  53671. /**
  53672. * Creates an custom extruded shape mesh.
  53673. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53674. * * 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.
  53675. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53676. * * 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
  53677. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53678. * * 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
  53679. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53680. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53681. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53682. * * 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
  53683. * * 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
  53684. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53686. * * 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
  53687. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53689. * @param name defines the name of the mesh
  53690. * @param options defines the options used to create the mesh
  53691. * @param scene defines the hosting scene
  53692. * @returns the custom extruded shape mesh
  53693. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53694. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53695. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53696. */
  53697. static ExtrudeShapeCustom(name: string, options: {
  53698. shape: Vector3[];
  53699. path: Vector3[];
  53700. scaleFunction?: any;
  53701. rotationFunction?: any;
  53702. ribbonCloseArray?: boolean;
  53703. ribbonClosePath?: boolean;
  53704. cap?: number;
  53705. updatable?: boolean;
  53706. sideOrientation?: number;
  53707. frontUVs?: Vector4;
  53708. backUVs?: Vector4;
  53709. instance?: Mesh;
  53710. invertUV?: boolean;
  53711. }, scene?: Nullable<Scene>): Mesh;
  53712. /**
  53713. * Creates lathe mesh.
  53714. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53715. * * 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
  53716. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53717. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53718. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53719. * * 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
  53720. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53721. * * 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
  53722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53723. * * 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
  53724. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53726. * @param name defines the name of the mesh
  53727. * @param options defines the options used to create the mesh
  53728. * @param scene defines the hosting scene
  53729. * @returns the lathe mesh
  53730. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53731. */
  53732. static CreateLathe(name: string, options: {
  53733. shape: Vector3[];
  53734. radius?: number;
  53735. tessellation?: number;
  53736. clip?: number;
  53737. arc?: number;
  53738. closed?: boolean;
  53739. updatable?: boolean;
  53740. sideOrientation?: number;
  53741. frontUVs?: Vector4;
  53742. backUVs?: Vector4;
  53743. cap?: number;
  53744. invertUV?: boolean;
  53745. }, scene?: Nullable<Scene>): Mesh;
  53746. /**
  53747. * Creates a tiled plane mesh
  53748. * * You can set a limited pattern arrangement with the tiles
  53749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53750. * * 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
  53751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53752. * @param name defines the name of the mesh
  53753. * @param options defines the options used to create the mesh
  53754. * @param scene defines the hosting scene
  53755. * @returns the plane mesh
  53756. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53757. */
  53758. static CreateTiledPlane(name: string, options: {
  53759. pattern?: number;
  53760. tileSize?: number;
  53761. tileWidth?: number;
  53762. tileHeight?: number;
  53763. size?: number;
  53764. width?: number;
  53765. height?: number;
  53766. alignHorizontal?: number;
  53767. alignVertical?: number;
  53768. sideOrientation?: number;
  53769. frontUVs?: Vector4;
  53770. backUVs?: Vector4;
  53771. updatable?: boolean;
  53772. }, scene?: Nullable<Scene>): Mesh;
  53773. /**
  53774. * Creates a plane mesh
  53775. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53776. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53777. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53779. * * 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
  53780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53781. * @param name defines the name of the mesh
  53782. * @param options defines the options used to create the mesh
  53783. * @param scene defines the hosting scene
  53784. * @returns the plane mesh
  53785. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53786. */
  53787. static CreatePlane(name: string, options: {
  53788. size?: number;
  53789. width?: number;
  53790. height?: number;
  53791. sideOrientation?: number;
  53792. frontUVs?: Vector4;
  53793. backUVs?: Vector4;
  53794. updatable?: boolean;
  53795. sourcePlane?: Plane;
  53796. }, scene?: Nullable<Scene>): Mesh;
  53797. /**
  53798. * Creates a ground mesh
  53799. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53800. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53802. * @param name defines the name of the mesh
  53803. * @param options defines the options used to create the mesh
  53804. * @param scene defines the hosting scene
  53805. * @returns the ground mesh
  53806. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53807. */
  53808. static CreateGround(name: string, options: {
  53809. width?: number;
  53810. height?: number;
  53811. subdivisions?: number;
  53812. subdivisionsX?: number;
  53813. subdivisionsY?: number;
  53814. updatable?: boolean;
  53815. }, scene?: Nullable<Scene>): Mesh;
  53816. /**
  53817. * Creates a tiled ground mesh
  53818. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53819. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53820. * * 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
  53821. * * 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
  53822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53823. * @param name defines the name of the mesh
  53824. * @param options defines the options used to create the mesh
  53825. * @param scene defines the hosting scene
  53826. * @returns the tiled ground mesh
  53827. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53828. */
  53829. static CreateTiledGround(name: string, options: {
  53830. xmin: number;
  53831. zmin: number;
  53832. xmax: number;
  53833. zmax: number;
  53834. subdivisions?: {
  53835. w: number;
  53836. h: number;
  53837. };
  53838. precision?: {
  53839. w: number;
  53840. h: number;
  53841. };
  53842. updatable?: boolean;
  53843. }, scene?: Nullable<Scene>): Mesh;
  53844. /**
  53845. * Creates a ground mesh from a height map
  53846. * * The parameter `url` sets the URL of the height map image resource.
  53847. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53848. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53849. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53850. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53851. * * 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.
  53852. * * 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).
  53853. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53855. * @param name defines the name of the mesh
  53856. * @param url defines the url to the height map
  53857. * @param options defines the options used to create the mesh
  53858. * @param scene defines the hosting scene
  53859. * @returns the ground mesh
  53860. * @see https://doc.babylonjs.com/babylon101/height_map
  53861. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53862. */
  53863. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53864. width?: number;
  53865. height?: number;
  53866. subdivisions?: number;
  53867. minHeight?: number;
  53868. maxHeight?: number;
  53869. colorFilter?: Color3;
  53870. alphaFilter?: number;
  53871. updatable?: boolean;
  53872. onReady?: (mesh: GroundMesh) => void;
  53873. }, scene?: Nullable<Scene>): GroundMesh;
  53874. /**
  53875. * Creates a polygon mesh
  53876. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53877. * * 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
  53878. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53880. * * 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)
  53881. * * Remember you can only change the shape positions, not their number when updating a polygon
  53882. * @param name defines the name of the mesh
  53883. * @param options defines the options used to create the mesh
  53884. * @param scene defines the hosting scene
  53885. * @param earcutInjection can be used to inject your own earcut reference
  53886. * @returns the polygon mesh
  53887. */
  53888. static CreatePolygon(name: string, options: {
  53889. shape: Vector3[];
  53890. holes?: Vector3[][];
  53891. depth?: number;
  53892. faceUV?: Vector4[];
  53893. faceColors?: Color4[];
  53894. updatable?: boolean;
  53895. sideOrientation?: number;
  53896. frontUVs?: Vector4;
  53897. backUVs?: Vector4;
  53898. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53899. /**
  53900. * Creates an extruded polygon mesh, with depth in the Y direction.
  53901. * * 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)
  53902. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53903. * @param name defines the name of the mesh
  53904. * @param options defines the options used to create the mesh
  53905. * @param scene defines the hosting scene
  53906. * @param earcutInjection can be used to inject your own earcut reference
  53907. * @returns the polygon mesh
  53908. */
  53909. static ExtrudePolygon(name: string, options: {
  53910. shape: Vector3[];
  53911. holes?: Vector3[][];
  53912. depth?: number;
  53913. faceUV?: Vector4[];
  53914. faceColors?: Color4[];
  53915. updatable?: boolean;
  53916. sideOrientation?: number;
  53917. frontUVs?: Vector4;
  53918. backUVs?: Vector4;
  53919. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53920. /**
  53921. * Creates a tube mesh.
  53922. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53923. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53924. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53925. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53926. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53927. * * 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)
  53928. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53929. * * 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
  53930. * * 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
  53931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53932. * * 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
  53933. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53935. * @param name defines the name of the mesh
  53936. * @param options defines the options used to create the mesh
  53937. * @param scene defines the hosting scene
  53938. * @returns the tube mesh
  53939. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53940. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53941. */
  53942. static CreateTube(name: string, options: {
  53943. path: Vector3[];
  53944. radius?: number;
  53945. tessellation?: number;
  53946. radiusFunction?: {
  53947. (i: number, distance: number): number;
  53948. };
  53949. cap?: number;
  53950. arc?: number;
  53951. updatable?: boolean;
  53952. sideOrientation?: number;
  53953. frontUVs?: Vector4;
  53954. backUVs?: Vector4;
  53955. instance?: Mesh;
  53956. invertUV?: boolean;
  53957. }, scene?: Nullable<Scene>): Mesh;
  53958. /**
  53959. * Creates a polyhedron mesh
  53960. * * 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
  53961. * * The parameter `size` (positive float, default 1) sets the polygon size
  53962. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53963. * * 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`
  53964. * * 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
  53965. * * 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)`)
  53966. * * 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
  53967. * * 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
  53968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53969. * * 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
  53970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53971. * @param name defines the name of the mesh
  53972. * @param options defines the options used to create the mesh
  53973. * @param scene defines the hosting scene
  53974. * @returns the polyhedron mesh
  53975. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53976. */
  53977. static CreatePolyhedron(name: string, options: {
  53978. type?: number;
  53979. size?: number;
  53980. sizeX?: number;
  53981. sizeY?: number;
  53982. sizeZ?: number;
  53983. custom?: any;
  53984. faceUV?: Vector4[];
  53985. faceColors?: Color4[];
  53986. flat?: boolean;
  53987. updatable?: boolean;
  53988. sideOrientation?: number;
  53989. frontUVs?: Vector4;
  53990. backUVs?: Vector4;
  53991. }, scene?: Nullable<Scene>): Mesh;
  53992. /**
  53993. * Creates a decal mesh.
  53994. * 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
  53995. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53996. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53997. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53998. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53999. * @param name defines the name of the mesh
  54000. * @param sourceMesh defines the mesh where the decal must be applied
  54001. * @param options defines the options used to create the mesh
  54002. * @param scene defines the hosting scene
  54003. * @returns the decal mesh
  54004. * @see https://doc.babylonjs.com/how_to/decals
  54005. */
  54006. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54007. position?: Vector3;
  54008. normal?: Vector3;
  54009. size?: Vector3;
  54010. angle?: number;
  54011. }): Mesh;
  54012. }
  54013. }
  54014. declare module BABYLON {
  54015. /**
  54016. * A simplifier interface for future simplification implementations
  54017. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54018. */
  54019. export interface ISimplifier {
  54020. /**
  54021. * Simplification of a given mesh according to the given settings.
  54022. * Since this requires computation, it is assumed that the function runs async.
  54023. * @param settings The settings of the simplification, including quality and distance
  54024. * @param successCallback A callback that will be called after the mesh was simplified.
  54025. * @param errorCallback in case of an error, this callback will be called. optional.
  54026. */
  54027. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  54028. }
  54029. /**
  54030. * Expected simplification settings.
  54031. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  54032. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54033. */
  54034. export interface ISimplificationSettings {
  54035. /**
  54036. * Gets or sets the expected quality
  54037. */
  54038. quality: number;
  54039. /**
  54040. * Gets or sets the distance when this optimized version should be used
  54041. */
  54042. distance: number;
  54043. /**
  54044. * Gets an already optimized mesh
  54045. */
  54046. optimizeMesh?: boolean;
  54047. }
  54048. /**
  54049. * Class used to specify simplification options
  54050. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54051. */
  54052. export class SimplificationSettings implements ISimplificationSettings {
  54053. /** expected quality */
  54054. quality: number;
  54055. /** distance when this optimized version should be used */
  54056. distance: number;
  54057. /** already optimized mesh */
  54058. optimizeMesh?: boolean | undefined;
  54059. /**
  54060. * Creates a SimplificationSettings
  54061. * @param quality expected quality
  54062. * @param distance distance when this optimized version should be used
  54063. * @param optimizeMesh already optimized mesh
  54064. */
  54065. constructor(
  54066. /** expected quality */
  54067. quality: number,
  54068. /** distance when this optimized version should be used */
  54069. distance: number,
  54070. /** already optimized mesh */
  54071. optimizeMesh?: boolean | undefined);
  54072. }
  54073. /**
  54074. * Interface used to define a simplification task
  54075. */
  54076. export interface ISimplificationTask {
  54077. /**
  54078. * Array of settings
  54079. */
  54080. settings: Array<ISimplificationSettings>;
  54081. /**
  54082. * Simplification type
  54083. */
  54084. simplificationType: SimplificationType;
  54085. /**
  54086. * Mesh to simplify
  54087. */
  54088. mesh: Mesh;
  54089. /**
  54090. * Callback called on success
  54091. */
  54092. successCallback?: () => void;
  54093. /**
  54094. * Defines if parallel processing can be used
  54095. */
  54096. parallelProcessing: boolean;
  54097. }
  54098. /**
  54099. * Queue used to order the simplification tasks
  54100. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54101. */
  54102. export class SimplificationQueue {
  54103. private _simplificationArray;
  54104. /**
  54105. * Gets a boolean indicating that the process is still running
  54106. */
  54107. running: boolean;
  54108. /**
  54109. * Creates a new queue
  54110. */
  54111. constructor();
  54112. /**
  54113. * Adds a new simplification task
  54114. * @param task defines a task to add
  54115. */
  54116. addTask(task: ISimplificationTask): void;
  54117. /**
  54118. * Execute next task
  54119. */
  54120. executeNext(): void;
  54121. /**
  54122. * Execute a simplification task
  54123. * @param task defines the task to run
  54124. */
  54125. runSimplification(task: ISimplificationTask): void;
  54126. private getSimplifier;
  54127. }
  54128. /**
  54129. * The implemented types of simplification
  54130. * At the moment only Quadratic Error Decimation is implemented
  54131. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54132. */
  54133. export enum SimplificationType {
  54134. /** Quadratic error decimation */
  54135. QUADRATIC = 0
  54136. }
  54137. }
  54138. declare module BABYLON {
  54139. interface Scene {
  54140. /** @hidden (Backing field) */
  54141. _simplificationQueue: SimplificationQueue;
  54142. /**
  54143. * Gets or sets the simplification queue attached to the scene
  54144. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54145. */
  54146. simplificationQueue: SimplificationQueue;
  54147. }
  54148. interface Mesh {
  54149. /**
  54150. * Simplify the mesh according to the given array of settings.
  54151. * Function will return immediately and will simplify async
  54152. * @param settings a collection of simplification settings
  54153. * @param parallelProcessing should all levels calculate parallel or one after the other
  54154. * @param simplificationType the type of simplification to run
  54155. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  54156. * @returns the current mesh
  54157. */
  54158. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  54159. }
  54160. /**
  54161. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  54162. * created in a scene
  54163. */
  54164. export class SimplicationQueueSceneComponent implements ISceneComponent {
  54165. /**
  54166. * The component name helpfull to identify the component in the list of scene components.
  54167. */
  54168. readonly name: string;
  54169. /**
  54170. * The scene the component belongs to.
  54171. */
  54172. scene: Scene;
  54173. /**
  54174. * Creates a new instance of the component for the given scene
  54175. * @param scene Defines the scene to register the component in
  54176. */
  54177. constructor(scene: Scene);
  54178. /**
  54179. * Registers the component in a given scene
  54180. */
  54181. register(): void;
  54182. /**
  54183. * Rebuilds the elements related to this component in case of
  54184. * context lost for instance.
  54185. */
  54186. rebuild(): void;
  54187. /**
  54188. * Disposes the component and the associated ressources
  54189. */
  54190. dispose(): void;
  54191. private _beforeCameraUpdate;
  54192. }
  54193. }
  54194. declare module BABYLON {
  54195. /**
  54196. * Class used to enable access to IndexedDB
  54197. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  54198. */
  54199. export class Database implements IOfflineProvider {
  54200. private _callbackManifestChecked;
  54201. private _currentSceneUrl;
  54202. private _db;
  54203. private _enableSceneOffline;
  54204. private _enableTexturesOffline;
  54205. private _manifestVersionFound;
  54206. private _mustUpdateRessources;
  54207. private _hasReachedQuota;
  54208. private _isSupported;
  54209. private _idbFactory;
  54210. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  54211. private static IsUASupportingBlobStorage;
  54212. /**
  54213. * Gets a boolean indicating if Database storate is enabled (off by default)
  54214. */
  54215. static IDBStorageEnabled: boolean;
  54216. /**
  54217. * Gets a boolean indicating if scene must be saved in the database
  54218. */
  54219. readonly enableSceneOffline: boolean;
  54220. /**
  54221. * Gets a boolean indicating if textures must be saved in the database
  54222. */
  54223. readonly enableTexturesOffline: boolean;
  54224. /**
  54225. * Creates a new Database
  54226. * @param urlToScene defines the url to load the scene
  54227. * @param callbackManifestChecked defines the callback to use when manifest is checked
  54228. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  54229. */
  54230. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  54231. private static _ParseURL;
  54232. private static _ReturnFullUrlLocation;
  54233. private _checkManifestFile;
  54234. /**
  54235. * Open the database and make it available
  54236. * @param successCallback defines the callback to call on success
  54237. * @param errorCallback defines the callback to call on error
  54238. */
  54239. open(successCallback: () => void, errorCallback: () => void): void;
  54240. /**
  54241. * Loads an image from the database
  54242. * @param url defines the url to load from
  54243. * @param image defines the target DOM image
  54244. */
  54245. loadImage(url: string, image: HTMLImageElement): void;
  54246. private _loadImageFromDBAsync;
  54247. private _saveImageIntoDBAsync;
  54248. private _checkVersionFromDB;
  54249. private _loadVersionFromDBAsync;
  54250. private _saveVersionIntoDBAsync;
  54251. /**
  54252. * Loads a file from database
  54253. * @param url defines the URL to load from
  54254. * @param sceneLoaded defines a callback to call on success
  54255. * @param progressCallBack defines a callback to call when progress changed
  54256. * @param errorCallback defines a callback to call on error
  54257. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  54258. */
  54259. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  54260. private _loadFileAsync;
  54261. private _saveFileAsync;
  54262. /**
  54263. * Validates if xhr data is correct
  54264. * @param xhr defines the request to validate
  54265. * @param dataType defines the expected data type
  54266. * @returns true if data is correct
  54267. */
  54268. private static _ValidateXHRData;
  54269. }
  54270. }
  54271. declare module BABYLON {
  54272. /** @hidden */
  54273. export var gpuUpdateParticlesPixelShader: {
  54274. name: string;
  54275. shader: string;
  54276. };
  54277. }
  54278. declare module BABYLON {
  54279. /** @hidden */
  54280. export var gpuUpdateParticlesVertexShader: {
  54281. name: string;
  54282. shader: string;
  54283. };
  54284. }
  54285. declare module BABYLON {
  54286. /** @hidden */
  54287. export var clipPlaneFragmentDeclaration2: {
  54288. name: string;
  54289. shader: string;
  54290. };
  54291. }
  54292. declare module BABYLON {
  54293. /** @hidden */
  54294. export var gpuRenderParticlesPixelShader: {
  54295. name: string;
  54296. shader: string;
  54297. };
  54298. }
  54299. declare module BABYLON {
  54300. /** @hidden */
  54301. export var clipPlaneVertexDeclaration2: {
  54302. name: string;
  54303. shader: string;
  54304. };
  54305. }
  54306. declare module BABYLON {
  54307. /** @hidden */
  54308. export var gpuRenderParticlesVertexShader: {
  54309. name: string;
  54310. shader: string;
  54311. };
  54312. }
  54313. declare module BABYLON {
  54314. /**
  54315. * This represents a GPU particle system in Babylon
  54316. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  54317. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  54318. */
  54319. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  54320. /**
  54321. * The layer mask we are rendering the particles through.
  54322. */
  54323. layerMask: number;
  54324. private _capacity;
  54325. private _activeCount;
  54326. private _currentActiveCount;
  54327. private _accumulatedCount;
  54328. private _renderEffect;
  54329. private _updateEffect;
  54330. private _buffer0;
  54331. private _buffer1;
  54332. private _spriteBuffer;
  54333. private _updateVAO;
  54334. private _renderVAO;
  54335. private _targetIndex;
  54336. private _sourceBuffer;
  54337. private _targetBuffer;
  54338. private _engine;
  54339. private _currentRenderId;
  54340. private _started;
  54341. private _stopped;
  54342. private _timeDelta;
  54343. private _randomTexture;
  54344. private _randomTexture2;
  54345. private _attributesStrideSize;
  54346. private _updateEffectOptions;
  54347. private _randomTextureSize;
  54348. private _actualFrame;
  54349. private readonly _rawTextureWidth;
  54350. /**
  54351. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  54352. */
  54353. static readonly IsSupported: boolean;
  54354. /**
  54355. * An event triggered when the system is disposed.
  54356. */
  54357. onDisposeObservable: Observable<GPUParticleSystem>;
  54358. /**
  54359. * Gets the maximum number of particles active at the same time.
  54360. * @returns The max number of active particles.
  54361. */
  54362. getCapacity(): number;
  54363. /**
  54364. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  54365. * to override the particles.
  54366. */
  54367. forceDepthWrite: boolean;
  54368. /**
  54369. * Gets or set the number of active particles
  54370. */
  54371. activeParticleCount: number;
  54372. private _preWarmDone;
  54373. /**
  54374. * Is this system ready to be used/rendered
  54375. * @return true if the system is ready
  54376. */
  54377. isReady(): boolean;
  54378. /**
  54379. * Gets if the system has been started. (Note: this will still be true after stop is called)
  54380. * @returns True if it has been started, otherwise false.
  54381. */
  54382. isStarted(): boolean;
  54383. /**
  54384. * Starts the particle system and begins to emit
  54385. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  54386. */
  54387. start(delay?: number): void;
  54388. /**
  54389. * Stops the particle system.
  54390. */
  54391. stop(): void;
  54392. /**
  54393. * Remove all active particles
  54394. */
  54395. reset(): void;
  54396. /**
  54397. * Returns the string "GPUParticleSystem"
  54398. * @returns a string containing the class name
  54399. */
  54400. getClassName(): string;
  54401. private _colorGradientsTexture;
  54402. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  54403. /**
  54404. * Adds a new color gradient
  54405. * @param gradient defines the gradient to use (between 0 and 1)
  54406. * @param color1 defines the color to affect to the specified gradient
  54407. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  54408. * @returns the current particle system
  54409. */
  54410. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  54411. /**
  54412. * Remove a specific color gradient
  54413. * @param gradient defines the gradient to remove
  54414. * @returns the current particle system
  54415. */
  54416. removeColorGradient(gradient: number): GPUParticleSystem;
  54417. private _angularSpeedGradientsTexture;
  54418. private _sizeGradientsTexture;
  54419. private _velocityGradientsTexture;
  54420. private _limitVelocityGradientsTexture;
  54421. private _dragGradientsTexture;
  54422. private _addFactorGradient;
  54423. /**
  54424. * Adds a new size gradient
  54425. * @param gradient defines the gradient to use (between 0 and 1)
  54426. * @param factor defines the size factor to affect to the specified gradient
  54427. * @returns the current particle system
  54428. */
  54429. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  54430. /**
  54431. * Remove a specific size gradient
  54432. * @param gradient defines the gradient to remove
  54433. * @returns the current particle system
  54434. */
  54435. removeSizeGradient(gradient: number): GPUParticleSystem;
  54436. /**
  54437. * Adds a new angular speed gradient
  54438. * @param gradient defines the gradient to use (between 0 and 1)
  54439. * @param factor defines the angular speed to affect to the specified gradient
  54440. * @returns the current particle system
  54441. */
  54442. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  54443. /**
  54444. * Remove a specific angular speed gradient
  54445. * @param gradient defines the gradient to remove
  54446. * @returns the current particle system
  54447. */
  54448. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  54449. /**
  54450. * Adds a new velocity gradient
  54451. * @param gradient defines the gradient to use (between 0 and 1)
  54452. * @param factor defines the velocity to affect to the specified gradient
  54453. * @returns the current particle system
  54454. */
  54455. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54456. /**
  54457. * Remove a specific velocity gradient
  54458. * @param gradient defines the gradient to remove
  54459. * @returns the current particle system
  54460. */
  54461. removeVelocityGradient(gradient: number): GPUParticleSystem;
  54462. /**
  54463. * Adds a new limit velocity gradient
  54464. * @param gradient defines the gradient to use (between 0 and 1)
  54465. * @param factor defines the limit velocity value to affect to the specified gradient
  54466. * @returns the current particle system
  54467. */
  54468. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54469. /**
  54470. * Remove a specific limit velocity gradient
  54471. * @param gradient defines the gradient to remove
  54472. * @returns the current particle system
  54473. */
  54474. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  54475. /**
  54476. * Adds a new drag gradient
  54477. * @param gradient defines the gradient to use (between 0 and 1)
  54478. * @param factor defines the drag value to affect to the specified gradient
  54479. * @returns the current particle system
  54480. */
  54481. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  54482. /**
  54483. * Remove a specific drag gradient
  54484. * @param gradient defines the gradient to remove
  54485. * @returns the current particle system
  54486. */
  54487. removeDragGradient(gradient: number): GPUParticleSystem;
  54488. /**
  54489. * Not supported by GPUParticleSystem
  54490. * @param gradient defines the gradient to use (between 0 and 1)
  54491. * @param factor defines the emit rate value to affect to the specified gradient
  54492. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54493. * @returns the current particle system
  54494. */
  54495. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54496. /**
  54497. * Not supported by GPUParticleSystem
  54498. * @param gradient defines the gradient to remove
  54499. * @returns the current particle system
  54500. */
  54501. removeEmitRateGradient(gradient: number): IParticleSystem;
  54502. /**
  54503. * Not supported by GPUParticleSystem
  54504. * @param gradient defines the gradient to use (between 0 and 1)
  54505. * @param factor defines the start size value to affect to the specified gradient
  54506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54507. * @returns the current particle system
  54508. */
  54509. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54510. /**
  54511. * Not supported by GPUParticleSystem
  54512. * @param gradient defines the gradient to remove
  54513. * @returns the current particle system
  54514. */
  54515. removeStartSizeGradient(gradient: number): IParticleSystem;
  54516. /**
  54517. * Not supported by GPUParticleSystem
  54518. * @param gradient defines the gradient to use (between 0 and 1)
  54519. * @param min defines the color remap minimal range
  54520. * @param max defines the color remap maximal range
  54521. * @returns the current particle system
  54522. */
  54523. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54524. /**
  54525. * Not supported by GPUParticleSystem
  54526. * @param gradient defines the gradient to remove
  54527. * @returns the current particle system
  54528. */
  54529. removeColorRemapGradient(): IParticleSystem;
  54530. /**
  54531. * Not supported by GPUParticleSystem
  54532. * @param gradient defines the gradient to use (between 0 and 1)
  54533. * @param min defines the alpha remap minimal range
  54534. * @param max defines the alpha remap maximal range
  54535. * @returns the current particle system
  54536. */
  54537. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54538. /**
  54539. * Not supported by GPUParticleSystem
  54540. * @param gradient defines the gradient to remove
  54541. * @returns the current particle system
  54542. */
  54543. removeAlphaRemapGradient(): IParticleSystem;
  54544. /**
  54545. * Not supported by GPUParticleSystem
  54546. * @param gradient defines the gradient to use (between 0 and 1)
  54547. * @param color defines the color to affect to the specified gradient
  54548. * @returns the current particle system
  54549. */
  54550. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  54551. /**
  54552. * Not supported by GPUParticleSystem
  54553. * @param gradient defines the gradient to remove
  54554. * @returns the current particle system
  54555. */
  54556. removeRampGradient(): IParticleSystem;
  54557. /**
  54558. * Not supported by GPUParticleSystem
  54559. * @returns the list of ramp gradients
  54560. */
  54561. getRampGradients(): Nullable<Array<Color3Gradient>>;
  54562. /**
  54563. * Not supported by GPUParticleSystem
  54564. * Gets or sets a boolean indicating that ramp gradients must be used
  54565. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  54566. */
  54567. useRampGradients: boolean;
  54568. /**
  54569. * Not supported by GPUParticleSystem
  54570. * @param gradient defines the gradient to use (between 0 and 1)
  54571. * @param factor defines the life time factor to affect to the specified gradient
  54572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54573. * @returns the current particle system
  54574. */
  54575. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54576. /**
  54577. * Not supported by GPUParticleSystem
  54578. * @param gradient defines the gradient to remove
  54579. * @returns the current particle system
  54580. */
  54581. removeLifeTimeGradient(gradient: number): IParticleSystem;
  54582. /**
  54583. * Instantiates a GPU particle system.
  54584. * 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.
  54585. * @param name The name of the particle system
  54586. * @param options The options used to create the system
  54587. * @param scene The scene the particle system belongs to
  54588. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  54589. */
  54590. constructor(name: string, options: Partial<{
  54591. capacity: number;
  54592. randomTextureSize: number;
  54593. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  54594. protected _reset(): void;
  54595. private _createUpdateVAO;
  54596. private _createRenderVAO;
  54597. private _initialize;
  54598. /** @hidden */
  54599. _recreateUpdateEffect(): void;
  54600. /** @hidden */
  54601. _recreateRenderEffect(): void;
  54602. /**
  54603. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  54604. * @param preWarm defines if we are in the pre-warmimg phase
  54605. */
  54606. animate(preWarm?: boolean): void;
  54607. private _createFactorGradientTexture;
  54608. private _createSizeGradientTexture;
  54609. private _createAngularSpeedGradientTexture;
  54610. private _createVelocityGradientTexture;
  54611. private _createLimitVelocityGradientTexture;
  54612. private _createDragGradientTexture;
  54613. private _createColorGradientTexture;
  54614. /**
  54615. * Renders the particle system in its current state
  54616. * @param preWarm defines if the system should only update the particles but not render them
  54617. * @returns the current number of particles
  54618. */
  54619. render(preWarm?: boolean): number;
  54620. /**
  54621. * Rebuilds the particle system
  54622. */
  54623. rebuild(): void;
  54624. private _releaseBuffers;
  54625. private _releaseVAOs;
  54626. /**
  54627. * Disposes the particle system and free the associated resources
  54628. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  54629. */
  54630. dispose(disposeTexture?: boolean): void;
  54631. /**
  54632. * Clones the particle system.
  54633. * @param name The name of the cloned object
  54634. * @param newEmitter The new emitter to use
  54635. * @returns the cloned particle system
  54636. */
  54637. clone(name: string, newEmitter: any): GPUParticleSystem;
  54638. /**
  54639. * Serializes the particle system to a JSON object.
  54640. * @returns the JSON object
  54641. */
  54642. serialize(): any;
  54643. /**
  54644. * Parses a JSON object to create a GPU particle system.
  54645. * @param parsedParticleSystem The JSON object to parse
  54646. * @param scene The scene to create the particle system in
  54647. * @param rootUrl The root url to use to load external dependencies like texture
  54648. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  54649. * @returns the parsed GPU particle system
  54650. */
  54651. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  54652. }
  54653. }
  54654. declare module BABYLON {
  54655. /**
  54656. * Represents a set of particle systems working together to create a specific effect
  54657. */
  54658. export class ParticleSystemSet implements IDisposable {
  54659. private _emitterCreationOptions;
  54660. private _emitterNode;
  54661. /**
  54662. * Gets the particle system list
  54663. */
  54664. systems: IParticleSystem[];
  54665. /**
  54666. * Gets the emitter node used with this set
  54667. */
  54668. readonly emitterNode: Nullable<TransformNode>;
  54669. /**
  54670. * Creates a new emitter mesh as a sphere
  54671. * @param options defines the options used to create the sphere
  54672. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54673. * @param scene defines the hosting scene
  54674. */
  54675. setEmitterAsSphere(options: {
  54676. diameter: number;
  54677. segments: number;
  54678. color: Color3;
  54679. }, renderingGroupId: number, scene: Scene): void;
  54680. /**
  54681. * Starts all particle systems of the set
  54682. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54683. */
  54684. start(emitter?: AbstractMesh): void;
  54685. /**
  54686. * Release all associated resources
  54687. */
  54688. dispose(): void;
  54689. /**
  54690. * Serialize the set into a JSON compatible object
  54691. * @returns a JSON compatible representation of the set
  54692. */
  54693. serialize(): any;
  54694. /**
  54695. * Parse a new ParticleSystemSet from a serialized source
  54696. * @param data defines a JSON compatible representation of the set
  54697. * @param scene defines the hosting scene
  54698. * @param gpu defines if we want GPU particles or CPU particles
  54699. * @returns a new ParticleSystemSet
  54700. */
  54701. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54702. }
  54703. }
  54704. declare module BABYLON {
  54705. /**
  54706. * This class is made for on one-liner static method to help creating particle system set.
  54707. */
  54708. export class ParticleHelper {
  54709. /**
  54710. * Gets or sets base Assets URL
  54711. */
  54712. static BaseAssetsUrl: string;
  54713. /**
  54714. * Create a default particle system that you can tweak
  54715. * @param emitter defines the emitter to use
  54716. * @param capacity defines the system capacity (default is 500 particles)
  54717. * @param scene defines the hosting scene
  54718. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54719. * @returns the new Particle system
  54720. */
  54721. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54722. /**
  54723. * This is the main static method (one-liner) of this helper to create different particle systems
  54724. * @param type This string represents the type to the particle system to create
  54725. * @param scene The scene where the particle system should live
  54726. * @param gpu If the system will use gpu
  54727. * @returns the ParticleSystemSet created
  54728. */
  54729. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54730. /**
  54731. * Static function used to export a particle system to a ParticleSystemSet variable.
  54732. * Please note that the emitter shape is not exported
  54733. * @param systems defines the particle systems to export
  54734. * @returns the created particle system set
  54735. */
  54736. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54737. }
  54738. }
  54739. declare module BABYLON {
  54740. interface Engine {
  54741. /**
  54742. * Create an effect to use with particle systems.
  54743. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54744. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54745. * @param uniformsNames defines a list of attribute names
  54746. * @param samplers defines an array of string used to represent textures
  54747. * @param defines defines the string containing the defines to use to compile the shaders
  54748. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54749. * @param onCompiled defines a function to call when the effect creation is successful
  54750. * @param onError defines a function to call when the effect creation has failed
  54751. * @returns the new Effect
  54752. */
  54753. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54754. }
  54755. interface Mesh {
  54756. /**
  54757. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54758. * @returns an array of IParticleSystem
  54759. */
  54760. getEmittedParticleSystems(): IParticleSystem[];
  54761. /**
  54762. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54763. * @returns an array of IParticleSystem
  54764. */
  54765. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54766. }
  54767. /**
  54768. * @hidden
  54769. */
  54770. export var _IDoNeedToBeInTheBuild: number;
  54771. }
  54772. declare module BABYLON {
  54773. interface Scene {
  54774. /** @hidden (Backing field) */
  54775. _physicsEngine: Nullable<IPhysicsEngine>;
  54776. /**
  54777. * Gets the current physics engine
  54778. * @returns a IPhysicsEngine or null if none attached
  54779. */
  54780. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54781. /**
  54782. * Enables physics to the current scene
  54783. * @param gravity defines the scene's gravity for the physics engine
  54784. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54785. * @return a boolean indicating if the physics engine was initialized
  54786. */
  54787. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54788. /**
  54789. * Disables and disposes the physics engine associated with the scene
  54790. */
  54791. disablePhysicsEngine(): void;
  54792. /**
  54793. * Gets a boolean indicating if there is an active physics engine
  54794. * @returns a boolean indicating if there is an active physics engine
  54795. */
  54796. isPhysicsEnabled(): boolean;
  54797. /**
  54798. * Deletes a physics compound impostor
  54799. * @param compound defines the compound to delete
  54800. */
  54801. deleteCompoundImpostor(compound: any): void;
  54802. /**
  54803. * An event triggered when physic simulation is about to be run
  54804. */
  54805. onBeforePhysicsObservable: Observable<Scene>;
  54806. /**
  54807. * An event triggered when physic simulation has been done
  54808. */
  54809. onAfterPhysicsObservable: Observable<Scene>;
  54810. }
  54811. interface AbstractMesh {
  54812. /** @hidden */
  54813. _physicsImpostor: Nullable<PhysicsImpostor>;
  54814. /**
  54815. * Gets or sets impostor used for physic simulation
  54816. * @see http://doc.babylonjs.com/features/physics_engine
  54817. */
  54818. physicsImpostor: Nullable<PhysicsImpostor>;
  54819. /**
  54820. * Gets the current physics impostor
  54821. * @see http://doc.babylonjs.com/features/physics_engine
  54822. * @returns a physics impostor or null
  54823. */
  54824. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54825. /** Apply a physic impulse to the mesh
  54826. * @param force defines the force to apply
  54827. * @param contactPoint defines where to apply the force
  54828. * @returns the current mesh
  54829. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54830. */
  54831. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54832. /**
  54833. * Creates a physic joint between two meshes
  54834. * @param otherMesh defines the other mesh to use
  54835. * @param pivot1 defines the pivot to use on this mesh
  54836. * @param pivot2 defines the pivot to use on the other mesh
  54837. * @param options defines additional options (can be plugin dependent)
  54838. * @returns the current mesh
  54839. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54840. */
  54841. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54842. /** @hidden */
  54843. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54844. }
  54845. /**
  54846. * Defines the physics engine scene component responsible to manage a physics engine
  54847. */
  54848. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54849. /**
  54850. * The component name helpful to identify the component in the list of scene components.
  54851. */
  54852. readonly name: string;
  54853. /**
  54854. * The scene the component belongs to.
  54855. */
  54856. scene: Scene;
  54857. /**
  54858. * Creates a new instance of the component for the given scene
  54859. * @param scene Defines the scene to register the component in
  54860. */
  54861. constructor(scene: Scene);
  54862. /**
  54863. * Registers the component in a given scene
  54864. */
  54865. register(): void;
  54866. /**
  54867. * Rebuilds the elements related to this component in case of
  54868. * context lost for instance.
  54869. */
  54870. rebuild(): void;
  54871. /**
  54872. * Disposes the component and the associated ressources
  54873. */
  54874. dispose(): void;
  54875. }
  54876. }
  54877. declare module BABYLON {
  54878. /**
  54879. * A helper for physics simulations
  54880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54881. */
  54882. export class PhysicsHelper {
  54883. private _scene;
  54884. private _physicsEngine;
  54885. /**
  54886. * Initializes the Physics helper
  54887. * @param scene Babylon.js scene
  54888. */
  54889. constructor(scene: Scene);
  54890. /**
  54891. * Applies a radial explosion impulse
  54892. * @param origin the origin of the explosion
  54893. * @param radiusOrEventOptions the radius or the options of radial explosion
  54894. * @param strength the explosion strength
  54895. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54896. * @returns A physics radial explosion event, or null
  54897. */
  54898. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54899. /**
  54900. * Applies a radial explosion force
  54901. * @param origin the origin of the explosion
  54902. * @param radiusOrEventOptions the radius or the options of radial explosion
  54903. * @param strength the explosion strength
  54904. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54905. * @returns A physics radial explosion event, or null
  54906. */
  54907. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54908. /**
  54909. * Creates a gravitational field
  54910. * @param origin the origin of the explosion
  54911. * @param radiusOrEventOptions the radius or the options of radial explosion
  54912. * @param strength the explosion strength
  54913. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54914. * @returns A physics gravitational field event, or null
  54915. */
  54916. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54917. /**
  54918. * Creates a physics updraft event
  54919. * @param origin the origin of the updraft
  54920. * @param radiusOrEventOptions the radius or the options of the updraft
  54921. * @param strength the strength of the updraft
  54922. * @param height the height of the updraft
  54923. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54924. * @returns A physics updraft event, or null
  54925. */
  54926. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54927. /**
  54928. * Creates a physics vortex event
  54929. * @param origin the of the vortex
  54930. * @param radiusOrEventOptions the radius or the options of the vortex
  54931. * @param strength the strength of the vortex
  54932. * @param height the height of the vortex
  54933. * @returns a Physics vortex event, or null
  54934. * A physics vortex event or null
  54935. */
  54936. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54937. }
  54938. /**
  54939. * Represents a physics radial explosion event
  54940. */
  54941. class PhysicsRadialExplosionEvent {
  54942. private _scene;
  54943. private _options;
  54944. private _sphere;
  54945. private _dataFetched;
  54946. /**
  54947. * Initializes a radial explosioin event
  54948. * @param _scene BabylonJS scene
  54949. * @param _options The options for the vortex event
  54950. */
  54951. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54952. /**
  54953. * Returns the data related to the radial explosion event (sphere).
  54954. * @returns The radial explosion event data
  54955. */
  54956. getData(): PhysicsRadialExplosionEventData;
  54957. /**
  54958. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54959. * @param impostor A physics imposter
  54960. * @param origin the origin of the explosion
  54961. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54962. */
  54963. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54964. /**
  54965. * Triggers affecterd impostors callbacks
  54966. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54967. */
  54968. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54969. /**
  54970. * Disposes the sphere.
  54971. * @param force Specifies if the sphere should be disposed by force
  54972. */
  54973. dispose(force?: boolean): void;
  54974. /*** Helpers ***/
  54975. private _prepareSphere;
  54976. private _intersectsWithSphere;
  54977. }
  54978. /**
  54979. * Represents a gravitational field event
  54980. */
  54981. class PhysicsGravitationalFieldEvent {
  54982. private _physicsHelper;
  54983. private _scene;
  54984. private _origin;
  54985. private _options;
  54986. private _tickCallback;
  54987. private _sphere;
  54988. private _dataFetched;
  54989. /**
  54990. * Initializes the physics gravitational field event
  54991. * @param _physicsHelper A physics helper
  54992. * @param _scene BabylonJS scene
  54993. * @param _origin The origin position of the gravitational field event
  54994. * @param _options The options for the vortex event
  54995. */
  54996. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54997. /**
  54998. * Returns the data related to the gravitational field event (sphere).
  54999. * @returns A gravitational field event
  55000. */
  55001. getData(): PhysicsGravitationalFieldEventData;
  55002. /**
  55003. * Enables the gravitational field.
  55004. */
  55005. enable(): void;
  55006. /**
  55007. * Disables the gravitational field.
  55008. */
  55009. disable(): void;
  55010. /**
  55011. * Disposes the sphere.
  55012. * @param force The force to dispose from the gravitational field event
  55013. */
  55014. dispose(force?: boolean): void;
  55015. private _tick;
  55016. }
  55017. /**
  55018. * Represents a physics updraft event
  55019. */
  55020. class PhysicsUpdraftEvent {
  55021. private _scene;
  55022. private _origin;
  55023. private _options;
  55024. private _physicsEngine;
  55025. private _originTop;
  55026. private _originDirection;
  55027. private _tickCallback;
  55028. private _cylinder;
  55029. private _cylinderPosition;
  55030. private _dataFetched;
  55031. /**
  55032. * Initializes the physics updraft event
  55033. * @param _scene BabylonJS scene
  55034. * @param _origin The origin position of the updraft
  55035. * @param _options The options for the updraft event
  55036. */
  55037. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  55038. /**
  55039. * Returns the data related to the updraft event (cylinder).
  55040. * @returns A physics updraft event
  55041. */
  55042. getData(): PhysicsUpdraftEventData;
  55043. /**
  55044. * Enables the updraft.
  55045. */
  55046. enable(): void;
  55047. /**
  55048. * Disables the updraft.
  55049. */
  55050. disable(): void;
  55051. /**
  55052. * Disposes the cylinder.
  55053. * @param force Specifies if the updraft should be disposed by force
  55054. */
  55055. dispose(force?: boolean): void;
  55056. private getImpostorHitData;
  55057. private _tick;
  55058. /*** Helpers ***/
  55059. private _prepareCylinder;
  55060. private _intersectsWithCylinder;
  55061. }
  55062. /**
  55063. * Represents a physics vortex event
  55064. */
  55065. class PhysicsVortexEvent {
  55066. private _scene;
  55067. private _origin;
  55068. private _options;
  55069. private _physicsEngine;
  55070. private _originTop;
  55071. private _tickCallback;
  55072. private _cylinder;
  55073. private _cylinderPosition;
  55074. private _dataFetched;
  55075. /**
  55076. * Initializes the physics vortex event
  55077. * @param _scene The BabylonJS scene
  55078. * @param _origin The origin position of the vortex
  55079. * @param _options The options for the vortex event
  55080. */
  55081. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  55082. /**
  55083. * Returns the data related to the vortex event (cylinder).
  55084. * @returns The physics vortex event data
  55085. */
  55086. getData(): PhysicsVortexEventData;
  55087. /**
  55088. * Enables the vortex.
  55089. */
  55090. enable(): void;
  55091. /**
  55092. * Disables the cortex.
  55093. */
  55094. disable(): void;
  55095. /**
  55096. * Disposes the sphere.
  55097. * @param force
  55098. */
  55099. dispose(force?: boolean): void;
  55100. private getImpostorHitData;
  55101. private _tick;
  55102. /*** Helpers ***/
  55103. private _prepareCylinder;
  55104. private _intersectsWithCylinder;
  55105. }
  55106. /**
  55107. * Options fot the radial explosion event
  55108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55109. */
  55110. export class PhysicsRadialExplosionEventOptions {
  55111. /**
  55112. * The radius of the sphere for the radial explosion.
  55113. */
  55114. radius: number;
  55115. /**
  55116. * The strenth of the explosion.
  55117. */
  55118. strength: number;
  55119. /**
  55120. * The strenght of the force in correspondence to the distance of the affected object
  55121. */
  55122. falloff: PhysicsRadialImpulseFalloff;
  55123. /**
  55124. * Sphere options for the radial explosion.
  55125. */
  55126. sphere: {
  55127. segments: number;
  55128. diameter: number;
  55129. };
  55130. /**
  55131. * Sphere options for the radial explosion.
  55132. */
  55133. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  55134. }
  55135. /**
  55136. * Options fot the updraft event
  55137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55138. */
  55139. export class PhysicsUpdraftEventOptions {
  55140. /**
  55141. * The radius of the cylinder for the vortex
  55142. */
  55143. radius: number;
  55144. /**
  55145. * The strenth of the updraft.
  55146. */
  55147. strength: number;
  55148. /**
  55149. * The height of the cylinder for the updraft.
  55150. */
  55151. height: number;
  55152. /**
  55153. * The mode for the the updraft.
  55154. */
  55155. updraftMode: PhysicsUpdraftMode;
  55156. }
  55157. /**
  55158. * Options fot the vortex event
  55159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55160. */
  55161. export class PhysicsVortexEventOptions {
  55162. /**
  55163. * The radius of the cylinder for the vortex
  55164. */
  55165. radius: number;
  55166. /**
  55167. * The strenth of the vortex.
  55168. */
  55169. strength: number;
  55170. /**
  55171. * The height of the cylinder for the vortex.
  55172. */
  55173. height: number;
  55174. /**
  55175. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  55176. */
  55177. centripetalForceThreshold: number;
  55178. /**
  55179. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  55180. */
  55181. centripetalForceMultiplier: number;
  55182. /**
  55183. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  55184. */
  55185. centrifugalForceMultiplier: number;
  55186. /**
  55187. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  55188. */
  55189. updraftForceMultiplier: number;
  55190. }
  55191. /**
  55192. * The strenght of the force in correspondence to the distance of the affected object
  55193. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55194. */
  55195. export enum PhysicsRadialImpulseFalloff {
  55196. /** Defines that impulse is constant in strength across it's whole radius */
  55197. Constant = 0,
  55198. /** Defines that impulse gets weaker if it's further from the origin */
  55199. Linear = 1
  55200. }
  55201. /**
  55202. * The strength of the force in correspondence to the distance of the affected object
  55203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55204. */
  55205. export enum PhysicsUpdraftMode {
  55206. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  55207. Center = 0,
  55208. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  55209. Perpendicular = 1
  55210. }
  55211. /**
  55212. * Interface for a physics hit data
  55213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55214. */
  55215. export interface PhysicsHitData {
  55216. /**
  55217. * The force applied at the contact point
  55218. */
  55219. force: Vector3;
  55220. /**
  55221. * The contact point
  55222. */
  55223. contactPoint: Vector3;
  55224. /**
  55225. * The distance from the origin to the contact point
  55226. */
  55227. distanceFromOrigin: number;
  55228. }
  55229. /**
  55230. * Interface for radial explosion event data
  55231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55232. */
  55233. export interface PhysicsRadialExplosionEventData {
  55234. /**
  55235. * A sphere used for the radial explosion event
  55236. */
  55237. sphere: Mesh;
  55238. }
  55239. /**
  55240. * Interface for gravitational field event data
  55241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55242. */
  55243. export interface PhysicsGravitationalFieldEventData {
  55244. /**
  55245. * A sphere mesh used for the gravitational field event
  55246. */
  55247. sphere: Mesh;
  55248. }
  55249. /**
  55250. * Interface for updraft event data
  55251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55252. */
  55253. export interface PhysicsUpdraftEventData {
  55254. /**
  55255. * A cylinder used for the updraft event
  55256. */
  55257. cylinder: Mesh;
  55258. }
  55259. /**
  55260. * Interface for vortex event data
  55261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55262. */
  55263. export interface PhysicsVortexEventData {
  55264. /**
  55265. * A cylinder used for the vortex event
  55266. */
  55267. cylinder: Mesh;
  55268. }
  55269. /**
  55270. * Interface for an affected physics impostor
  55271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55272. */
  55273. export interface PhysicsAffectedImpostorWithData {
  55274. /**
  55275. * The impostor affected by the effect
  55276. */
  55277. impostor: PhysicsImpostor;
  55278. /**
  55279. * The data about the hit/horce from the explosion
  55280. */
  55281. hitData: PhysicsHitData;
  55282. }
  55283. }
  55284. declare module BABYLON {
  55285. /** @hidden */
  55286. export var blackAndWhitePixelShader: {
  55287. name: string;
  55288. shader: string;
  55289. };
  55290. }
  55291. declare module BABYLON {
  55292. /**
  55293. * Post process used to render in black and white
  55294. */
  55295. export class BlackAndWhitePostProcess extends PostProcess {
  55296. /**
  55297. * Linear about to convert he result to black and white (default: 1)
  55298. */
  55299. degree: number;
  55300. /**
  55301. * Creates a black and white post process
  55302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  55303. * @param name The name of the effect.
  55304. * @param options The required width/height ratio to downsize to before computing the render pass.
  55305. * @param camera The camera to apply the render pass to.
  55306. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55307. * @param engine The engine which the post process will be applied. (default: current engine)
  55308. * @param reusable If the post process can be reused on the same frame. (default: false)
  55309. */
  55310. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55311. }
  55312. }
  55313. declare module BABYLON {
  55314. /**
  55315. * This represents a set of one or more post processes in Babylon.
  55316. * A post process can be used to apply a shader to a texture after it is rendered.
  55317. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55318. */
  55319. export class PostProcessRenderEffect {
  55320. private _postProcesses;
  55321. private _getPostProcesses;
  55322. private _singleInstance;
  55323. private _cameras;
  55324. private _indicesForCamera;
  55325. /**
  55326. * Name of the effect
  55327. * @hidden
  55328. */
  55329. _name: string;
  55330. /**
  55331. * Instantiates a post process render effect.
  55332. * A post process can be used to apply a shader to a texture after it is rendered.
  55333. * @param engine The engine the effect is tied to
  55334. * @param name The name of the effect
  55335. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  55336. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  55337. */
  55338. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  55339. /**
  55340. * Checks if all the post processes in the effect are supported.
  55341. */
  55342. readonly isSupported: boolean;
  55343. /**
  55344. * Updates the current state of the effect
  55345. * @hidden
  55346. */
  55347. _update(): void;
  55348. /**
  55349. * Attaches the effect on cameras
  55350. * @param cameras The camera to attach to.
  55351. * @hidden
  55352. */
  55353. _attachCameras(cameras: Camera): void;
  55354. /**
  55355. * Attaches the effect on cameras
  55356. * @param cameras The camera to attach to.
  55357. * @hidden
  55358. */
  55359. _attachCameras(cameras: Camera[]): void;
  55360. /**
  55361. * Detaches the effect on cameras
  55362. * @param cameras The camera to detatch from.
  55363. * @hidden
  55364. */
  55365. _detachCameras(cameras: Camera): void;
  55366. /**
  55367. * Detatches the effect on cameras
  55368. * @param cameras The camera to detatch from.
  55369. * @hidden
  55370. */
  55371. _detachCameras(cameras: Camera[]): void;
  55372. /**
  55373. * Enables the effect on given cameras
  55374. * @param cameras The camera to enable.
  55375. * @hidden
  55376. */
  55377. _enable(cameras: Camera): void;
  55378. /**
  55379. * Enables the effect on given cameras
  55380. * @param cameras The camera to enable.
  55381. * @hidden
  55382. */
  55383. _enable(cameras: Nullable<Camera[]>): void;
  55384. /**
  55385. * Disables the effect on the given cameras
  55386. * @param cameras The camera to disable.
  55387. * @hidden
  55388. */
  55389. _disable(cameras: Camera): void;
  55390. /**
  55391. * Disables the effect on the given cameras
  55392. * @param cameras The camera to disable.
  55393. * @hidden
  55394. */
  55395. _disable(cameras: Nullable<Camera[]>): void;
  55396. /**
  55397. * Gets a list of the post processes contained in the effect.
  55398. * @param camera The camera to get the post processes on.
  55399. * @returns The list of the post processes in the effect.
  55400. */
  55401. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  55402. }
  55403. }
  55404. declare module BABYLON {
  55405. /** @hidden */
  55406. export var extractHighlightsPixelShader: {
  55407. name: string;
  55408. shader: string;
  55409. };
  55410. }
  55411. declare module BABYLON {
  55412. /**
  55413. * 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.
  55414. */
  55415. export class ExtractHighlightsPostProcess extends PostProcess {
  55416. /**
  55417. * The luminance threshold, pixels below this value will be set to black.
  55418. */
  55419. threshold: number;
  55420. /** @hidden */
  55421. _exposure: number;
  55422. /**
  55423. * Post process which has the input texture to be used when performing highlight extraction
  55424. * @hidden
  55425. */
  55426. _inputPostProcess: Nullable<PostProcess>;
  55427. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55428. }
  55429. }
  55430. declare module BABYLON {
  55431. /** @hidden */
  55432. export var bloomMergePixelShader: {
  55433. name: string;
  55434. shader: string;
  55435. };
  55436. }
  55437. declare module BABYLON {
  55438. /**
  55439. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55440. */
  55441. export class BloomMergePostProcess extends PostProcess {
  55442. /** Weight of the bloom to be added to the original input. */
  55443. weight: number;
  55444. /**
  55445. * Creates a new instance of @see BloomMergePostProcess
  55446. * @param name The name of the effect.
  55447. * @param originalFromInput Post process which's input will be used for the merge.
  55448. * @param blurred Blurred highlights post process which's output will be used.
  55449. * @param weight Weight of the bloom to be added to the original input.
  55450. * @param options The required width/height ratio to downsize to before computing the render pass.
  55451. * @param camera The camera to apply the render pass to.
  55452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55453. * @param engine The engine which the post process will be applied. (default: current engine)
  55454. * @param reusable If the post process can be reused on the same frame. (default: false)
  55455. * @param textureType Type of textures used when performing the post process. (default: 0)
  55456. * @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)
  55457. */
  55458. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  55459. /** Weight of the bloom to be added to the original input. */
  55460. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55461. }
  55462. }
  55463. declare module BABYLON {
  55464. /**
  55465. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  55466. */
  55467. export class BloomEffect extends PostProcessRenderEffect {
  55468. private bloomScale;
  55469. /**
  55470. * @hidden Internal
  55471. */
  55472. _effects: Array<PostProcess>;
  55473. /**
  55474. * @hidden Internal
  55475. */
  55476. _downscale: ExtractHighlightsPostProcess;
  55477. private _blurX;
  55478. private _blurY;
  55479. private _merge;
  55480. /**
  55481. * The luminance threshold to find bright areas of the image to bloom.
  55482. */
  55483. threshold: number;
  55484. /**
  55485. * The strength of the bloom.
  55486. */
  55487. weight: number;
  55488. /**
  55489. * Specifies the size of the bloom blur kernel, relative to the final output size
  55490. */
  55491. kernel: number;
  55492. /**
  55493. * Creates a new instance of @see BloomEffect
  55494. * @param scene The scene the effect belongs to.
  55495. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  55496. * @param bloomKernel The size of the kernel to be used when applying the blur.
  55497. * @param bloomWeight The the strength of bloom.
  55498. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55499. * @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)
  55500. */
  55501. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  55502. /**
  55503. * Disposes each of the internal effects for a given camera.
  55504. * @param camera The camera to dispose the effect on.
  55505. */
  55506. disposeEffects(camera: Camera): void;
  55507. /**
  55508. * @hidden Internal
  55509. */
  55510. _updateEffects(): void;
  55511. /**
  55512. * Internal
  55513. * @returns if all the contained post processes are ready.
  55514. * @hidden
  55515. */
  55516. _isReady(): boolean;
  55517. }
  55518. }
  55519. declare module BABYLON {
  55520. /** @hidden */
  55521. export var chromaticAberrationPixelShader: {
  55522. name: string;
  55523. shader: string;
  55524. };
  55525. }
  55526. declare module BABYLON {
  55527. /**
  55528. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  55529. */
  55530. export class ChromaticAberrationPostProcess extends PostProcess {
  55531. /**
  55532. * The amount of seperation of rgb channels (default: 30)
  55533. */
  55534. aberrationAmount: number;
  55535. /**
  55536. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  55537. */
  55538. radialIntensity: number;
  55539. /**
  55540. * 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))
  55541. */
  55542. direction: Vector2;
  55543. /**
  55544. * 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))
  55545. */
  55546. centerPosition: Vector2;
  55547. /**
  55548. * Creates a new instance ChromaticAberrationPostProcess
  55549. * @param name The name of the effect.
  55550. * @param screenWidth The width of the screen to apply the effect on.
  55551. * @param screenHeight The height of the screen to apply the effect on.
  55552. * @param options The required width/height ratio to downsize to before computing the render pass.
  55553. * @param camera The camera to apply the render pass to.
  55554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55555. * @param engine The engine which the post process will be applied. (default: current engine)
  55556. * @param reusable If the post process can be reused on the same frame. (default: false)
  55557. * @param textureType Type of textures used when performing the post process. (default: 0)
  55558. * @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)
  55559. */
  55560. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55561. }
  55562. }
  55563. declare module BABYLON {
  55564. /** @hidden */
  55565. export var circleOfConfusionPixelShader: {
  55566. name: string;
  55567. shader: string;
  55568. };
  55569. }
  55570. declare module BABYLON {
  55571. /**
  55572. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55573. */
  55574. export class CircleOfConfusionPostProcess extends PostProcess {
  55575. /**
  55576. * 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.
  55577. */
  55578. lensSize: number;
  55579. /**
  55580. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55581. */
  55582. fStop: number;
  55583. /**
  55584. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55585. */
  55586. focusDistance: number;
  55587. /**
  55588. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55589. */
  55590. focalLength: number;
  55591. private _depthTexture;
  55592. /**
  55593. * Creates a new instance CircleOfConfusionPostProcess
  55594. * @param name The name of the effect.
  55595. * @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.
  55596. * @param options The required width/height ratio to downsize to before computing the render pass.
  55597. * @param camera The camera to apply the render pass to.
  55598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55599. * @param engine The engine which the post process will be applied. (default: current engine)
  55600. * @param reusable If the post process can be reused on the same frame. (default: false)
  55601. * @param textureType Type of textures used when performing the post process. (default: 0)
  55602. * @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)
  55603. */
  55604. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55605. /**
  55606. * 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.
  55607. */
  55608. depthTexture: RenderTargetTexture;
  55609. }
  55610. }
  55611. declare module BABYLON {
  55612. /** @hidden */
  55613. export var colorCorrectionPixelShader: {
  55614. name: string;
  55615. shader: string;
  55616. };
  55617. }
  55618. declare module BABYLON {
  55619. /**
  55620. *
  55621. * This post-process allows the modification of rendered colors by using
  55622. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55623. *
  55624. * The object needs to be provided an url to a texture containing the color
  55625. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55626. * Use an image editing software to tweak the LUT to match your needs.
  55627. *
  55628. * For an example of a color LUT, see here:
  55629. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55630. * For explanations on color grading, see here:
  55631. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55632. *
  55633. */
  55634. export class ColorCorrectionPostProcess extends PostProcess {
  55635. private _colorTableTexture;
  55636. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55637. }
  55638. }
  55639. declare module BABYLON {
  55640. /** @hidden */
  55641. export var convolutionPixelShader: {
  55642. name: string;
  55643. shader: string;
  55644. };
  55645. }
  55646. declare module BABYLON {
  55647. /**
  55648. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55649. * input texture to perform effects such as edge detection or sharpening
  55650. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55651. */
  55652. export class ConvolutionPostProcess extends PostProcess {
  55653. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55654. kernel: number[];
  55655. /**
  55656. * Creates a new instance ConvolutionPostProcess
  55657. * @param name The name of the effect.
  55658. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  55659. * @param options The required width/height ratio to downsize to before computing the render pass.
  55660. * @param camera The camera to apply the render pass to.
  55661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55662. * @param engine The engine which the post process will be applied. (default: current engine)
  55663. * @param reusable If the post process can be reused on the same frame. (default: false)
  55664. * @param textureType Type of textures used when performing the post process. (default: 0)
  55665. */
  55666. constructor(name: string,
  55667. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55668. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55669. /**
  55670. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55671. */
  55672. static EdgeDetect0Kernel: number[];
  55673. /**
  55674. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55675. */
  55676. static EdgeDetect1Kernel: number[];
  55677. /**
  55678. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55679. */
  55680. static EdgeDetect2Kernel: number[];
  55681. /**
  55682. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55683. */
  55684. static SharpenKernel: number[];
  55685. /**
  55686. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55687. */
  55688. static EmbossKernel: number[];
  55689. /**
  55690. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55691. */
  55692. static GaussianKernel: number[];
  55693. }
  55694. }
  55695. declare module BABYLON {
  55696. /**
  55697. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55698. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55699. * based on samples that have a large difference in distance than the center pixel.
  55700. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55701. */
  55702. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55703. direction: Vector2;
  55704. /**
  55705. * Creates a new instance CircleOfConfusionPostProcess
  55706. * @param name The name of the effect.
  55707. * @param scene The scene the effect belongs to.
  55708. * @param direction The direction the blur should be applied.
  55709. * @param kernel The size of the kernel used to blur.
  55710. * @param options The required width/height ratio to downsize to before computing the render pass.
  55711. * @param camera The camera to apply the render pass to.
  55712. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55713. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55715. * @param engine The engine which the post process will be applied. (default: current engine)
  55716. * @param reusable If the post process can be reused on the same frame. (default: false)
  55717. * @param textureType Type of textures used when performing the post process. (default: 0)
  55718. * @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)
  55719. */
  55720. 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);
  55721. }
  55722. }
  55723. declare module BABYLON {
  55724. /** @hidden */
  55725. export var depthOfFieldMergePixelShader: {
  55726. name: string;
  55727. shader: string;
  55728. };
  55729. }
  55730. declare module BABYLON {
  55731. /**
  55732. * Options to be set when merging outputs from the default pipeline.
  55733. */
  55734. export class DepthOfFieldMergePostProcessOptions {
  55735. /**
  55736. * The original image to merge on top of
  55737. */
  55738. originalFromInput: PostProcess;
  55739. /**
  55740. * Parameters to perform the merge of the depth of field effect
  55741. */
  55742. depthOfField?: {
  55743. circleOfConfusion: PostProcess;
  55744. blurSteps: Array<PostProcess>;
  55745. };
  55746. /**
  55747. * Parameters to perform the merge of bloom effect
  55748. */
  55749. bloom?: {
  55750. blurred: PostProcess;
  55751. weight: number;
  55752. };
  55753. }
  55754. /**
  55755. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55756. */
  55757. export class DepthOfFieldMergePostProcess extends PostProcess {
  55758. private blurSteps;
  55759. /**
  55760. * Creates a new instance of DepthOfFieldMergePostProcess
  55761. * @param name The name of the effect.
  55762. * @param originalFromInput Post process which's input will be used for the merge.
  55763. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55764. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55765. * @param options The required width/height ratio to downsize to before computing the render pass.
  55766. * @param camera The camera to apply the render pass to.
  55767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55768. * @param engine The engine which the post process will be applied. (default: current engine)
  55769. * @param reusable If the post process can be reused on the same frame. (default: false)
  55770. * @param textureType Type of textures used when performing the post process. (default: 0)
  55771. * @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)
  55772. */
  55773. 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);
  55774. /**
  55775. * Updates the effect with the current post process compile time values and recompiles the shader.
  55776. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55777. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55778. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55779. * @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
  55780. * @param onCompiled Called when the shader has been compiled.
  55781. * @param onError Called if there is an error when compiling a shader.
  55782. */
  55783. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55784. }
  55785. }
  55786. declare module BABYLON {
  55787. /**
  55788. * Specifies the level of max blur that should be applied when using the depth of field effect
  55789. */
  55790. export enum DepthOfFieldEffectBlurLevel {
  55791. /**
  55792. * Subtle blur
  55793. */
  55794. Low = 0,
  55795. /**
  55796. * Medium blur
  55797. */
  55798. Medium = 1,
  55799. /**
  55800. * Large blur
  55801. */
  55802. High = 2
  55803. }
  55804. /**
  55805. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55806. */
  55807. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55808. private _circleOfConfusion;
  55809. /**
  55810. * @hidden Internal, blurs from high to low
  55811. */
  55812. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55813. private _depthOfFieldBlurY;
  55814. private _dofMerge;
  55815. /**
  55816. * @hidden Internal post processes in depth of field effect
  55817. */
  55818. _effects: Array<PostProcess>;
  55819. /**
  55820. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55821. */
  55822. focalLength: number;
  55823. /**
  55824. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55825. */
  55826. fStop: number;
  55827. /**
  55828. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55829. */
  55830. focusDistance: number;
  55831. /**
  55832. * 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.
  55833. */
  55834. lensSize: number;
  55835. /**
  55836. * Creates a new instance DepthOfFieldEffect
  55837. * @param scene The scene the effect belongs to.
  55838. * @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.
  55839. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55840. * @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)
  55841. */
  55842. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55843. /**
  55844. * Get the current class name of the current effet
  55845. * @returns "DepthOfFieldEffect"
  55846. */
  55847. getClassName(): string;
  55848. /**
  55849. * 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.
  55850. */
  55851. depthTexture: RenderTargetTexture;
  55852. /**
  55853. * Disposes each of the internal effects for a given camera.
  55854. * @param camera The camera to dispose the effect on.
  55855. */
  55856. disposeEffects(camera: Camera): void;
  55857. /**
  55858. * @hidden Internal
  55859. */
  55860. _updateEffects(): void;
  55861. /**
  55862. * Internal
  55863. * @returns if all the contained post processes are ready.
  55864. * @hidden
  55865. */
  55866. _isReady(): boolean;
  55867. }
  55868. }
  55869. declare module BABYLON {
  55870. /** @hidden */
  55871. export var displayPassPixelShader: {
  55872. name: string;
  55873. shader: string;
  55874. };
  55875. }
  55876. declare module BABYLON {
  55877. /**
  55878. * DisplayPassPostProcess which produces an output the same as it's input
  55879. */
  55880. export class DisplayPassPostProcess extends PostProcess {
  55881. /**
  55882. * Creates the DisplayPassPostProcess
  55883. * @param name The name of the effect.
  55884. * @param options The required width/height ratio to downsize to before computing the render pass.
  55885. * @param camera The camera to apply the render pass to.
  55886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55887. * @param engine The engine which the post process will be applied. (default: current engine)
  55888. * @param reusable If the post process can be reused on the same frame. (default: false)
  55889. */
  55890. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55891. }
  55892. }
  55893. declare module BABYLON {
  55894. /** @hidden */
  55895. export var filterPixelShader: {
  55896. name: string;
  55897. shader: string;
  55898. };
  55899. }
  55900. declare module BABYLON {
  55901. /**
  55902. * Applies a kernel filter to the image
  55903. */
  55904. export class FilterPostProcess extends PostProcess {
  55905. /** The matrix to be applied to the image */
  55906. kernelMatrix: Matrix;
  55907. /**
  55908. *
  55909. * @param name The name of the effect.
  55910. * @param kernelMatrix The matrix to be applied to the image
  55911. * @param options The required width/height ratio to downsize to before computing the render pass.
  55912. * @param camera The camera to apply the render pass to.
  55913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55914. * @param engine The engine which the post process will be applied. (default: current engine)
  55915. * @param reusable If the post process can be reused on the same frame. (default: false)
  55916. */
  55917. constructor(name: string,
  55918. /** The matrix to be applied to the image */
  55919. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55920. }
  55921. }
  55922. declare module BABYLON {
  55923. /** @hidden */
  55924. export var fxaaPixelShader: {
  55925. name: string;
  55926. shader: string;
  55927. };
  55928. }
  55929. declare module BABYLON {
  55930. /** @hidden */
  55931. export var fxaaVertexShader: {
  55932. name: string;
  55933. shader: string;
  55934. };
  55935. }
  55936. declare module BABYLON {
  55937. /**
  55938. * Fxaa post process
  55939. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55940. */
  55941. export class FxaaPostProcess extends PostProcess {
  55942. /** @hidden */
  55943. texelWidth: number;
  55944. /** @hidden */
  55945. texelHeight: number;
  55946. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55947. private _getDefines;
  55948. }
  55949. }
  55950. declare module BABYLON {
  55951. /** @hidden */
  55952. export var grainPixelShader: {
  55953. name: string;
  55954. shader: string;
  55955. };
  55956. }
  55957. declare module BABYLON {
  55958. /**
  55959. * The GrainPostProcess adds noise to the image at mid luminance levels
  55960. */
  55961. export class GrainPostProcess extends PostProcess {
  55962. /**
  55963. * The intensity of the grain added (default: 30)
  55964. */
  55965. intensity: number;
  55966. /**
  55967. * If the grain should be randomized on every frame
  55968. */
  55969. animated: boolean;
  55970. /**
  55971. * Creates a new instance of @see GrainPostProcess
  55972. * @param name The name of the effect.
  55973. * @param options The required width/height ratio to downsize to before computing the render pass.
  55974. * @param camera The camera to apply the render pass to.
  55975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55976. * @param engine The engine which the post process will be applied. (default: current engine)
  55977. * @param reusable If the post process can be reused on the same frame. (default: false)
  55978. * @param textureType Type of textures used when performing the post process. (default: 0)
  55979. * @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)
  55980. */
  55981. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55982. }
  55983. }
  55984. declare module BABYLON {
  55985. /** @hidden */
  55986. export var highlightsPixelShader: {
  55987. name: string;
  55988. shader: string;
  55989. };
  55990. }
  55991. declare module BABYLON {
  55992. /**
  55993. * Extracts highlights from the image
  55994. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55995. */
  55996. export class HighlightsPostProcess extends PostProcess {
  55997. /**
  55998. * Extracts highlights from the image
  55999. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56000. * @param name The name of the effect.
  56001. * @param options The required width/height ratio to downsize to before computing the render pass.
  56002. * @param camera The camera to apply the render pass to.
  56003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56004. * @param engine The engine which the post process will be applied. (default: current engine)
  56005. * @param reusable If the post process can be reused on the same frame. (default: false)
  56006. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  56007. */
  56008. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56009. }
  56010. }
  56011. declare module BABYLON {
  56012. /** @hidden */
  56013. export var mrtFragmentDeclaration: {
  56014. name: string;
  56015. shader: string;
  56016. };
  56017. }
  56018. declare module BABYLON {
  56019. /** @hidden */
  56020. export var geometryPixelShader: {
  56021. name: string;
  56022. shader: string;
  56023. };
  56024. }
  56025. declare module BABYLON {
  56026. /** @hidden */
  56027. export var geometryVertexShader: {
  56028. name: string;
  56029. shader: string;
  56030. };
  56031. }
  56032. declare module BABYLON {
  56033. /** @hidden */
  56034. interface ISavedTransformationMatrix {
  56035. world: Matrix;
  56036. viewProjection: Matrix;
  56037. }
  56038. /**
  56039. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  56040. */
  56041. export class GeometryBufferRenderer {
  56042. /**
  56043. * Constant used to retrieve the position texture index in the G-Buffer textures array
  56044. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  56045. */
  56046. static readonly POSITION_TEXTURE_TYPE: number;
  56047. /**
  56048. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  56049. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  56050. */
  56051. static readonly VELOCITY_TEXTURE_TYPE: number;
  56052. /**
  56053. * Dictionary used to store the previous transformation matrices of each rendered mesh
  56054. * in order to compute objects velocities when enableVelocity is set to "true"
  56055. * @hidden
  56056. */
  56057. _previousTransformationMatrices: {
  56058. [index: number]: ISavedTransformationMatrix;
  56059. };
  56060. /**
  56061. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  56062. * in order to compute objects velocities when enableVelocity is set to "true"
  56063. * @hidden
  56064. */
  56065. _previousBonesTransformationMatrices: {
  56066. [index: number]: Float32Array;
  56067. };
  56068. /**
  56069. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  56070. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  56071. */
  56072. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  56073. private _scene;
  56074. private _multiRenderTarget;
  56075. private _ratio;
  56076. private _enablePosition;
  56077. private _enableVelocity;
  56078. private _positionIndex;
  56079. private _velocityIndex;
  56080. protected _effect: Effect;
  56081. protected _cachedDefines: string;
  56082. /**
  56083. * Set the render list (meshes to be rendered) used in the G buffer.
  56084. */
  56085. renderList: Mesh[];
  56086. /**
  56087. * Gets wether or not G buffer are supported by the running hardware.
  56088. * This requires draw buffer supports
  56089. */
  56090. readonly isSupported: boolean;
  56091. /**
  56092. * Returns the index of the given texture type in the G-Buffer textures array
  56093. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  56094. * @returns the index of the given texture type in the G-Buffer textures array
  56095. */
  56096. getTextureIndex(textureType: number): number;
  56097. /**
  56098. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  56099. */
  56100. /**
  56101. * Sets whether or not objects positions are enabled for the G buffer.
  56102. */
  56103. enablePosition: boolean;
  56104. /**
  56105. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  56106. */
  56107. /**
  56108. * Sets wether or not objects velocities are enabled for the G buffer.
  56109. */
  56110. enableVelocity: boolean;
  56111. /**
  56112. * Gets the scene associated with the buffer.
  56113. */
  56114. readonly scene: Scene;
  56115. /**
  56116. * Gets the ratio used by the buffer during its creation.
  56117. * How big is the buffer related to the main canvas.
  56118. */
  56119. readonly ratio: number;
  56120. /** @hidden */
  56121. static _SceneComponentInitialization: (scene: Scene) => void;
  56122. /**
  56123. * Creates a new G Buffer for the scene
  56124. * @param scene The scene the buffer belongs to
  56125. * @param ratio How big is the buffer related to the main canvas.
  56126. */
  56127. constructor(scene: Scene, ratio?: number);
  56128. /**
  56129. * Checks wether everything is ready to render a submesh to the G buffer.
  56130. * @param subMesh the submesh to check readiness for
  56131. * @param useInstances is the mesh drawn using instance or not
  56132. * @returns true if ready otherwise false
  56133. */
  56134. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56135. /**
  56136. * Gets the current underlying G Buffer.
  56137. * @returns the buffer
  56138. */
  56139. getGBuffer(): MultiRenderTarget;
  56140. /**
  56141. * Gets the number of samples used to render the buffer (anti aliasing).
  56142. */
  56143. /**
  56144. * Sets the number of samples used to render the buffer (anti aliasing).
  56145. */
  56146. samples: number;
  56147. /**
  56148. * Disposes the renderer and frees up associated resources.
  56149. */
  56150. dispose(): void;
  56151. protected _createRenderTargets(): void;
  56152. private _copyBonesTransformationMatrices;
  56153. }
  56154. }
  56155. declare module BABYLON {
  56156. interface Scene {
  56157. /** @hidden (Backing field) */
  56158. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56159. /**
  56160. * Gets or Sets the current geometry buffer associated to the scene.
  56161. */
  56162. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56163. /**
  56164. * Enables a GeometryBufferRender and associates it with the scene
  56165. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  56166. * @returns the GeometryBufferRenderer
  56167. */
  56168. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  56169. /**
  56170. * Disables the GeometryBufferRender associated with the scene
  56171. */
  56172. disableGeometryBufferRenderer(): void;
  56173. }
  56174. /**
  56175. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  56176. * in several rendering techniques.
  56177. */
  56178. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  56179. /**
  56180. * The component name helpful to identify the component in the list of scene components.
  56181. */
  56182. readonly name: string;
  56183. /**
  56184. * The scene the component belongs to.
  56185. */
  56186. scene: Scene;
  56187. /**
  56188. * Creates a new instance of the component for the given scene
  56189. * @param scene Defines the scene to register the component in
  56190. */
  56191. constructor(scene: Scene);
  56192. /**
  56193. * Registers the component in a given scene
  56194. */
  56195. register(): void;
  56196. /**
  56197. * Rebuilds the elements related to this component in case of
  56198. * context lost for instance.
  56199. */
  56200. rebuild(): void;
  56201. /**
  56202. * Disposes the component and the associated ressources
  56203. */
  56204. dispose(): void;
  56205. private _gatherRenderTargets;
  56206. }
  56207. }
  56208. declare module BABYLON {
  56209. /** @hidden */
  56210. export var motionBlurPixelShader: {
  56211. name: string;
  56212. shader: string;
  56213. };
  56214. }
  56215. declare module BABYLON {
  56216. /**
  56217. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  56218. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  56219. * As an example, all you have to do is to create the post-process:
  56220. * var mb = new BABYLON.MotionBlurPostProcess(
  56221. * 'mb', // The name of the effect.
  56222. * scene, // The scene containing the objects to blur according to their velocity.
  56223. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  56224. * camera // The camera to apply the render pass to.
  56225. * );
  56226. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  56227. */
  56228. export class MotionBlurPostProcess extends PostProcess {
  56229. /**
  56230. * Defines how much the image is blurred by the movement. Default value is equal to 1
  56231. */
  56232. motionStrength: number;
  56233. /**
  56234. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  56235. */
  56236. /**
  56237. * Sets the number of iterations to be used for motion blur quality
  56238. */
  56239. motionBlurSamples: number;
  56240. private _motionBlurSamples;
  56241. private _geometryBufferRenderer;
  56242. /**
  56243. * Creates a new instance MotionBlurPostProcess
  56244. * @param name The name of the effect.
  56245. * @param scene The scene containing the objects to blur according to their velocity.
  56246. * @param options The required width/height ratio to downsize to before computing the render pass.
  56247. * @param camera The camera to apply the render pass to.
  56248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56249. * @param engine The engine which the post process will be applied. (default: current engine)
  56250. * @param reusable If the post process can be reused on the same frame. (default: false)
  56251. * @param textureType Type of textures used when performing the post process. (default: 0)
  56252. * @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)
  56253. */
  56254. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56255. /**
  56256. * Excludes the given skinned mesh from computing bones velocities.
  56257. * 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.
  56258. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  56259. */
  56260. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56261. /**
  56262. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  56263. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  56264. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  56265. */
  56266. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56267. /**
  56268. * Disposes the post process.
  56269. * @param camera The camera to dispose the post process on.
  56270. */
  56271. dispose(camera?: Camera): void;
  56272. }
  56273. }
  56274. declare module BABYLON {
  56275. /** @hidden */
  56276. export var refractionPixelShader: {
  56277. name: string;
  56278. shader: string;
  56279. };
  56280. }
  56281. declare module BABYLON {
  56282. /**
  56283. * Post process which applies a refractin texture
  56284. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56285. */
  56286. export class RefractionPostProcess extends PostProcess {
  56287. /** the base color of the refraction (used to taint the rendering) */
  56288. color: Color3;
  56289. /** simulated refraction depth */
  56290. depth: number;
  56291. /** the coefficient of the base color (0 to remove base color tainting) */
  56292. colorLevel: number;
  56293. private _refTexture;
  56294. private _ownRefractionTexture;
  56295. /**
  56296. * Gets or sets the refraction texture
  56297. * Please note that you are responsible for disposing the texture if you set it manually
  56298. */
  56299. refractionTexture: Texture;
  56300. /**
  56301. * Initializes the RefractionPostProcess
  56302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56303. * @param name The name of the effect.
  56304. * @param refractionTextureUrl Url of the refraction texture to use
  56305. * @param color the base color of the refraction (used to taint the rendering)
  56306. * @param depth simulated refraction depth
  56307. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  56308. * @param camera The camera to apply the render pass to.
  56309. * @param options The required width/height ratio to downsize to before computing the render pass.
  56310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56311. * @param engine The engine which the post process will be applied. (default: current engine)
  56312. * @param reusable If the post process can be reused on the same frame. (default: false)
  56313. */
  56314. constructor(name: string, refractionTextureUrl: string,
  56315. /** the base color of the refraction (used to taint the rendering) */
  56316. color: Color3,
  56317. /** simulated refraction depth */
  56318. depth: number,
  56319. /** the coefficient of the base color (0 to remove base color tainting) */
  56320. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56321. /**
  56322. * Disposes of the post process
  56323. * @param camera Camera to dispose post process on
  56324. */
  56325. dispose(camera: Camera): void;
  56326. }
  56327. }
  56328. declare module BABYLON {
  56329. /** @hidden */
  56330. export var sharpenPixelShader: {
  56331. name: string;
  56332. shader: string;
  56333. };
  56334. }
  56335. declare module BABYLON {
  56336. /**
  56337. * The SharpenPostProcess applies a sharpen kernel to every pixel
  56338. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56339. */
  56340. export class SharpenPostProcess extends PostProcess {
  56341. /**
  56342. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  56343. */
  56344. colorAmount: number;
  56345. /**
  56346. * How much sharpness should be applied (default: 0.3)
  56347. */
  56348. edgeAmount: number;
  56349. /**
  56350. * Creates a new instance ConvolutionPostProcess
  56351. * @param name The name of the effect.
  56352. * @param options The required width/height ratio to downsize to before computing the render pass.
  56353. * @param camera The camera to apply the render pass to.
  56354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56355. * @param engine The engine which the post process will be applied. (default: current engine)
  56356. * @param reusable If the post process can be reused on the same frame. (default: false)
  56357. * @param textureType Type of textures used when performing the post process. (default: 0)
  56358. * @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)
  56359. */
  56360. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56361. }
  56362. }
  56363. declare module BABYLON {
  56364. /**
  56365. * PostProcessRenderPipeline
  56366. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56367. */
  56368. export class PostProcessRenderPipeline {
  56369. private engine;
  56370. private _renderEffects;
  56371. private _renderEffectsForIsolatedPass;
  56372. /**
  56373. * List of inspectable custom properties (used by the Inspector)
  56374. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  56375. */
  56376. inspectableCustomProperties: IInspectable[];
  56377. /**
  56378. * @hidden
  56379. */
  56380. protected _cameras: Camera[];
  56381. /** @hidden */
  56382. _name: string;
  56383. /**
  56384. * Gets pipeline name
  56385. */
  56386. readonly name: string;
  56387. /**
  56388. * Initializes a PostProcessRenderPipeline
  56389. * @param engine engine to add the pipeline to
  56390. * @param name name of the pipeline
  56391. */
  56392. constructor(engine: Engine, name: string);
  56393. /**
  56394. * Gets the class name
  56395. * @returns "PostProcessRenderPipeline"
  56396. */
  56397. getClassName(): string;
  56398. /**
  56399. * If all the render effects in the pipeline are supported
  56400. */
  56401. readonly isSupported: boolean;
  56402. /**
  56403. * Adds an effect to the pipeline
  56404. * @param renderEffect the effect to add
  56405. */
  56406. addEffect(renderEffect: PostProcessRenderEffect): void;
  56407. /** @hidden */
  56408. _rebuild(): void;
  56409. /** @hidden */
  56410. _enableEffect(renderEffectName: string, cameras: Camera): void;
  56411. /** @hidden */
  56412. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  56413. /** @hidden */
  56414. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56415. /** @hidden */
  56416. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56417. /** @hidden */
  56418. _attachCameras(cameras: Camera, unique: boolean): void;
  56419. /** @hidden */
  56420. _attachCameras(cameras: Camera[], unique: boolean): void;
  56421. /** @hidden */
  56422. _detachCameras(cameras: Camera): void;
  56423. /** @hidden */
  56424. _detachCameras(cameras: Nullable<Camera[]>): void;
  56425. /** @hidden */
  56426. _update(): void;
  56427. /** @hidden */
  56428. _reset(): void;
  56429. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  56430. /**
  56431. * Disposes of the pipeline
  56432. */
  56433. dispose(): void;
  56434. }
  56435. }
  56436. declare module BABYLON {
  56437. /**
  56438. * PostProcessRenderPipelineManager class
  56439. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56440. */
  56441. export class PostProcessRenderPipelineManager {
  56442. private _renderPipelines;
  56443. /**
  56444. * Initializes a PostProcessRenderPipelineManager
  56445. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56446. */
  56447. constructor();
  56448. /**
  56449. * Gets the list of supported render pipelines
  56450. */
  56451. readonly supportedPipelines: PostProcessRenderPipeline[];
  56452. /**
  56453. * Adds a pipeline to the manager
  56454. * @param renderPipeline The pipeline to add
  56455. */
  56456. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  56457. /**
  56458. * Attaches a camera to the pipeline
  56459. * @param renderPipelineName The name of the pipeline to attach to
  56460. * @param cameras the camera to attach
  56461. * @param unique if the camera can be attached multiple times to the pipeline
  56462. */
  56463. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  56464. /**
  56465. * Detaches a camera from the pipeline
  56466. * @param renderPipelineName The name of the pipeline to detach from
  56467. * @param cameras the camera to detach
  56468. */
  56469. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  56470. /**
  56471. * Enables an effect by name on a pipeline
  56472. * @param renderPipelineName the name of the pipeline to enable the effect in
  56473. * @param renderEffectName the name of the effect to enable
  56474. * @param cameras the cameras that the effect should be enabled on
  56475. */
  56476. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56477. /**
  56478. * Disables an effect by name on a pipeline
  56479. * @param renderPipelineName the name of the pipeline to disable the effect in
  56480. * @param renderEffectName the name of the effect to disable
  56481. * @param cameras the cameras that the effect should be disabled on
  56482. */
  56483. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56484. /**
  56485. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  56486. */
  56487. update(): void;
  56488. /** @hidden */
  56489. _rebuild(): void;
  56490. /**
  56491. * Disposes of the manager and pipelines
  56492. */
  56493. dispose(): void;
  56494. }
  56495. }
  56496. declare module BABYLON {
  56497. interface Scene {
  56498. /** @hidden (Backing field) */
  56499. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56500. /**
  56501. * Gets the postprocess render pipeline manager
  56502. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56503. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56504. */
  56505. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56506. }
  56507. /**
  56508. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56509. */
  56510. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56511. /**
  56512. * The component name helpfull to identify the component in the list of scene components.
  56513. */
  56514. readonly name: string;
  56515. /**
  56516. * The scene the component belongs to.
  56517. */
  56518. scene: Scene;
  56519. /**
  56520. * Creates a new instance of the component for the given scene
  56521. * @param scene Defines the scene to register the component in
  56522. */
  56523. constructor(scene: Scene);
  56524. /**
  56525. * Registers the component in a given scene
  56526. */
  56527. register(): void;
  56528. /**
  56529. * Rebuilds the elements related to this component in case of
  56530. * context lost for instance.
  56531. */
  56532. rebuild(): void;
  56533. /**
  56534. * Disposes the component and the associated ressources
  56535. */
  56536. dispose(): void;
  56537. private _gatherRenderTargets;
  56538. }
  56539. }
  56540. declare module BABYLON {
  56541. /**
  56542. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56543. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56544. */
  56545. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56546. private _scene;
  56547. private _camerasToBeAttached;
  56548. /**
  56549. * ID of the sharpen post process,
  56550. */
  56551. private readonly SharpenPostProcessId;
  56552. /**
  56553. * @ignore
  56554. * ID of the image processing post process;
  56555. */
  56556. readonly ImageProcessingPostProcessId: string;
  56557. /**
  56558. * @ignore
  56559. * ID of the Fast Approximate Anti-Aliasing post process;
  56560. */
  56561. readonly FxaaPostProcessId: string;
  56562. /**
  56563. * ID of the chromatic aberration post process,
  56564. */
  56565. private readonly ChromaticAberrationPostProcessId;
  56566. /**
  56567. * ID of the grain post process
  56568. */
  56569. private readonly GrainPostProcessId;
  56570. /**
  56571. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56572. */
  56573. sharpen: SharpenPostProcess;
  56574. private _sharpenEffect;
  56575. private bloom;
  56576. /**
  56577. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56578. */
  56579. depthOfField: DepthOfFieldEffect;
  56580. /**
  56581. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56582. */
  56583. fxaa: FxaaPostProcess;
  56584. /**
  56585. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56586. */
  56587. imageProcessing: ImageProcessingPostProcess;
  56588. /**
  56589. * Chromatic aberration post process which will shift rgb colors in the image
  56590. */
  56591. chromaticAberration: ChromaticAberrationPostProcess;
  56592. private _chromaticAberrationEffect;
  56593. /**
  56594. * Grain post process which add noise to the image
  56595. */
  56596. grain: GrainPostProcess;
  56597. private _grainEffect;
  56598. /**
  56599. * Glow post process which adds a glow to emissive areas of the image
  56600. */
  56601. private _glowLayer;
  56602. /**
  56603. * Animations which can be used to tweak settings over a period of time
  56604. */
  56605. animations: Animation[];
  56606. private _imageProcessingConfigurationObserver;
  56607. private _sharpenEnabled;
  56608. private _bloomEnabled;
  56609. private _depthOfFieldEnabled;
  56610. private _depthOfFieldBlurLevel;
  56611. private _fxaaEnabled;
  56612. private _imageProcessingEnabled;
  56613. private _defaultPipelineTextureType;
  56614. private _bloomScale;
  56615. private _chromaticAberrationEnabled;
  56616. private _grainEnabled;
  56617. private _buildAllowed;
  56618. /**
  56619. * Gets active scene
  56620. */
  56621. readonly scene: Scene;
  56622. /**
  56623. * Enable or disable the sharpen process from the pipeline
  56624. */
  56625. sharpenEnabled: boolean;
  56626. private _resizeObserver;
  56627. private _hardwareScaleLevel;
  56628. private _bloomKernel;
  56629. /**
  56630. * Specifies the size of the bloom blur kernel, relative to the final output size
  56631. */
  56632. bloomKernel: number;
  56633. /**
  56634. * Specifies the weight of the bloom in the final rendering
  56635. */
  56636. private _bloomWeight;
  56637. /**
  56638. * Specifies the luma threshold for the area that will be blurred by the bloom
  56639. */
  56640. private _bloomThreshold;
  56641. private _hdr;
  56642. /**
  56643. * The strength of the bloom.
  56644. */
  56645. bloomWeight: number;
  56646. /**
  56647. * The strength of the bloom.
  56648. */
  56649. bloomThreshold: number;
  56650. /**
  56651. * The scale of the bloom, lower value will provide better performance.
  56652. */
  56653. bloomScale: number;
  56654. /**
  56655. * Enable or disable the bloom from the pipeline
  56656. */
  56657. bloomEnabled: boolean;
  56658. private _rebuildBloom;
  56659. /**
  56660. * If the depth of field is enabled.
  56661. */
  56662. depthOfFieldEnabled: boolean;
  56663. /**
  56664. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56665. */
  56666. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56667. /**
  56668. * If the anti aliasing is enabled.
  56669. */
  56670. fxaaEnabled: boolean;
  56671. private _samples;
  56672. /**
  56673. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56674. */
  56675. samples: number;
  56676. /**
  56677. * If image processing is enabled.
  56678. */
  56679. imageProcessingEnabled: boolean;
  56680. /**
  56681. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56682. */
  56683. glowLayerEnabled: boolean;
  56684. /**
  56685. * Gets the glow layer (or null if not defined)
  56686. */
  56687. readonly glowLayer: Nullable<GlowLayer>;
  56688. /**
  56689. * Enable or disable the chromaticAberration process from the pipeline
  56690. */
  56691. chromaticAberrationEnabled: boolean;
  56692. /**
  56693. * Enable or disable the grain process from the pipeline
  56694. */
  56695. grainEnabled: boolean;
  56696. /**
  56697. * @constructor
  56698. * @param name - The rendering pipeline name (default: "")
  56699. * @param hdr - If high dynamic range textures should be used (default: true)
  56700. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56701. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56702. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56703. */
  56704. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56705. /**
  56706. * Get the class name
  56707. * @returns "DefaultRenderingPipeline"
  56708. */
  56709. getClassName(): string;
  56710. /**
  56711. * Force the compilation of the entire pipeline.
  56712. */
  56713. prepare(): void;
  56714. private _hasCleared;
  56715. private _prevPostProcess;
  56716. private _prevPrevPostProcess;
  56717. private _setAutoClearAndTextureSharing;
  56718. private _depthOfFieldSceneObserver;
  56719. private _buildPipeline;
  56720. private _disposePostProcesses;
  56721. /**
  56722. * Adds a camera to the pipeline
  56723. * @param camera the camera to be added
  56724. */
  56725. addCamera(camera: Camera): void;
  56726. /**
  56727. * Removes a camera from the pipeline
  56728. * @param camera the camera to remove
  56729. */
  56730. removeCamera(camera: Camera): void;
  56731. /**
  56732. * Dispose of the pipeline and stop all post processes
  56733. */
  56734. dispose(): void;
  56735. /**
  56736. * Serialize the rendering pipeline (Used when exporting)
  56737. * @returns the serialized object
  56738. */
  56739. serialize(): any;
  56740. /**
  56741. * Parse the serialized pipeline
  56742. * @param source Source pipeline.
  56743. * @param scene The scene to load the pipeline to.
  56744. * @param rootUrl The URL of the serialized pipeline.
  56745. * @returns An instantiated pipeline from the serialized object.
  56746. */
  56747. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56748. }
  56749. }
  56750. declare module BABYLON {
  56751. /** @hidden */
  56752. export var lensHighlightsPixelShader: {
  56753. name: string;
  56754. shader: string;
  56755. };
  56756. }
  56757. declare module BABYLON {
  56758. /** @hidden */
  56759. export var depthOfFieldPixelShader: {
  56760. name: string;
  56761. shader: string;
  56762. };
  56763. }
  56764. declare module BABYLON {
  56765. /**
  56766. * BABYLON.JS Chromatic Aberration GLSL Shader
  56767. * Author: Olivier Guyot
  56768. * Separates very slightly R, G and B colors on the edges of the screen
  56769. * Inspired by Francois Tarlier & Martins Upitis
  56770. */
  56771. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56772. /**
  56773. * @ignore
  56774. * The chromatic aberration PostProcess id in the pipeline
  56775. */
  56776. LensChromaticAberrationEffect: string;
  56777. /**
  56778. * @ignore
  56779. * The highlights enhancing PostProcess id in the pipeline
  56780. */
  56781. HighlightsEnhancingEffect: string;
  56782. /**
  56783. * @ignore
  56784. * The depth-of-field PostProcess id in the pipeline
  56785. */
  56786. LensDepthOfFieldEffect: string;
  56787. private _scene;
  56788. private _depthTexture;
  56789. private _grainTexture;
  56790. private _chromaticAberrationPostProcess;
  56791. private _highlightsPostProcess;
  56792. private _depthOfFieldPostProcess;
  56793. private _edgeBlur;
  56794. private _grainAmount;
  56795. private _chromaticAberration;
  56796. private _distortion;
  56797. private _highlightsGain;
  56798. private _highlightsThreshold;
  56799. private _dofDistance;
  56800. private _dofAperture;
  56801. private _dofDarken;
  56802. private _dofPentagon;
  56803. private _blurNoise;
  56804. /**
  56805. * @constructor
  56806. *
  56807. * Effect parameters are as follow:
  56808. * {
  56809. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56810. * edge_blur: number; // from 0 to x (1 for realism)
  56811. * distortion: number; // from 0 to x (1 for realism)
  56812. * grain_amount: number; // from 0 to 1
  56813. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56814. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56815. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56816. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56817. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56818. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56819. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56820. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56821. * }
  56822. * Note: if an effect parameter is unset, effect is disabled
  56823. *
  56824. * @param name The rendering pipeline name
  56825. * @param parameters - An object containing all parameters (see above)
  56826. * @param scene The scene linked to this pipeline
  56827. * @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)
  56828. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56829. */
  56830. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56831. /**
  56832. * Get the class name
  56833. * @returns "LensRenderingPipeline"
  56834. */
  56835. getClassName(): string;
  56836. /**
  56837. * Gets associated scene
  56838. */
  56839. readonly scene: Scene;
  56840. /**
  56841. * Gets or sets the edge blur
  56842. */
  56843. edgeBlur: number;
  56844. /**
  56845. * Gets or sets the grain amount
  56846. */
  56847. grainAmount: number;
  56848. /**
  56849. * Gets or sets the chromatic aberration amount
  56850. */
  56851. chromaticAberration: number;
  56852. /**
  56853. * Gets or sets the depth of field aperture
  56854. */
  56855. dofAperture: number;
  56856. /**
  56857. * Gets or sets the edge distortion
  56858. */
  56859. edgeDistortion: number;
  56860. /**
  56861. * Gets or sets the depth of field distortion
  56862. */
  56863. dofDistortion: number;
  56864. /**
  56865. * Gets or sets the darken out of focus amount
  56866. */
  56867. darkenOutOfFocus: number;
  56868. /**
  56869. * Gets or sets a boolean indicating if blur noise is enabled
  56870. */
  56871. blurNoise: boolean;
  56872. /**
  56873. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56874. */
  56875. pentagonBokeh: boolean;
  56876. /**
  56877. * Gets or sets the highlight grain amount
  56878. */
  56879. highlightsGain: number;
  56880. /**
  56881. * Gets or sets the highlight threshold
  56882. */
  56883. highlightsThreshold: number;
  56884. /**
  56885. * Sets the amount of blur at the edges
  56886. * @param amount blur amount
  56887. */
  56888. setEdgeBlur(amount: number): void;
  56889. /**
  56890. * Sets edge blur to 0
  56891. */
  56892. disableEdgeBlur(): void;
  56893. /**
  56894. * Sets the amout of grain
  56895. * @param amount Amount of grain
  56896. */
  56897. setGrainAmount(amount: number): void;
  56898. /**
  56899. * Set grain amount to 0
  56900. */
  56901. disableGrain(): void;
  56902. /**
  56903. * Sets the chromatic aberration amount
  56904. * @param amount amount of chromatic aberration
  56905. */
  56906. setChromaticAberration(amount: number): void;
  56907. /**
  56908. * Sets chromatic aberration amount to 0
  56909. */
  56910. disableChromaticAberration(): void;
  56911. /**
  56912. * Sets the EdgeDistortion amount
  56913. * @param amount amount of EdgeDistortion
  56914. */
  56915. setEdgeDistortion(amount: number): void;
  56916. /**
  56917. * Sets edge distortion to 0
  56918. */
  56919. disableEdgeDistortion(): void;
  56920. /**
  56921. * Sets the FocusDistance amount
  56922. * @param amount amount of FocusDistance
  56923. */
  56924. setFocusDistance(amount: number): void;
  56925. /**
  56926. * Disables depth of field
  56927. */
  56928. disableDepthOfField(): void;
  56929. /**
  56930. * Sets the Aperture amount
  56931. * @param amount amount of Aperture
  56932. */
  56933. setAperture(amount: number): void;
  56934. /**
  56935. * Sets the DarkenOutOfFocus amount
  56936. * @param amount amount of DarkenOutOfFocus
  56937. */
  56938. setDarkenOutOfFocus(amount: number): void;
  56939. private _pentagonBokehIsEnabled;
  56940. /**
  56941. * Creates a pentagon bokeh effect
  56942. */
  56943. enablePentagonBokeh(): void;
  56944. /**
  56945. * Disables the pentagon bokeh effect
  56946. */
  56947. disablePentagonBokeh(): void;
  56948. /**
  56949. * Enables noise blur
  56950. */
  56951. enableNoiseBlur(): void;
  56952. /**
  56953. * Disables noise blur
  56954. */
  56955. disableNoiseBlur(): void;
  56956. /**
  56957. * Sets the HighlightsGain amount
  56958. * @param amount amount of HighlightsGain
  56959. */
  56960. setHighlightsGain(amount: number): void;
  56961. /**
  56962. * Sets the HighlightsThreshold amount
  56963. * @param amount amount of HighlightsThreshold
  56964. */
  56965. setHighlightsThreshold(amount: number): void;
  56966. /**
  56967. * Disables highlights
  56968. */
  56969. disableHighlights(): void;
  56970. /**
  56971. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56972. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56973. */
  56974. dispose(disableDepthRender?: boolean): void;
  56975. private _createChromaticAberrationPostProcess;
  56976. private _createHighlightsPostProcess;
  56977. private _createDepthOfFieldPostProcess;
  56978. private _createGrainTexture;
  56979. }
  56980. }
  56981. declare module BABYLON {
  56982. /** @hidden */
  56983. export var ssao2PixelShader: {
  56984. name: string;
  56985. shader: string;
  56986. };
  56987. }
  56988. declare module BABYLON {
  56989. /** @hidden */
  56990. export var ssaoCombinePixelShader: {
  56991. name: string;
  56992. shader: string;
  56993. };
  56994. }
  56995. declare module BABYLON {
  56996. /**
  56997. * Render pipeline to produce ssao effect
  56998. */
  56999. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  57000. /**
  57001. * @ignore
  57002. * The PassPostProcess id in the pipeline that contains the original scene color
  57003. */
  57004. SSAOOriginalSceneColorEffect: string;
  57005. /**
  57006. * @ignore
  57007. * The SSAO PostProcess id in the pipeline
  57008. */
  57009. SSAORenderEffect: string;
  57010. /**
  57011. * @ignore
  57012. * The horizontal blur PostProcess id in the pipeline
  57013. */
  57014. SSAOBlurHRenderEffect: string;
  57015. /**
  57016. * @ignore
  57017. * The vertical blur PostProcess id in the pipeline
  57018. */
  57019. SSAOBlurVRenderEffect: string;
  57020. /**
  57021. * @ignore
  57022. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57023. */
  57024. SSAOCombineRenderEffect: string;
  57025. /**
  57026. * The output strength of the SSAO post-process. Default value is 1.0.
  57027. */
  57028. totalStrength: number;
  57029. /**
  57030. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  57031. */
  57032. maxZ: number;
  57033. /**
  57034. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  57035. */
  57036. minZAspect: number;
  57037. private _samples;
  57038. /**
  57039. * Number of samples used for the SSAO calculations. Default value is 8
  57040. */
  57041. samples: number;
  57042. private _textureSamples;
  57043. /**
  57044. * Number of samples to use for antialiasing
  57045. */
  57046. textureSamples: number;
  57047. /**
  57048. * Ratio object used for SSAO ratio and blur ratio
  57049. */
  57050. private _ratio;
  57051. /**
  57052. * Dynamically generated sphere sampler.
  57053. */
  57054. private _sampleSphere;
  57055. /**
  57056. * Blur filter offsets
  57057. */
  57058. private _samplerOffsets;
  57059. private _expensiveBlur;
  57060. /**
  57061. * If bilateral blur should be used
  57062. */
  57063. expensiveBlur: boolean;
  57064. /**
  57065. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  57066. */
  57067. radius: number;
  57068. /**
  57069. * The base color of the SSAO post-process
  57070. * The final result is "base + ssao" between [0, 1]
  57071. */
  57072. base: number;
  57073. /**
  57074. * Support test.
  57075. */
  57076. static readonly IsSupported: boolean;
  57077. private _scene;
  57078. private _depthTexture;
  57079. private _normalTexture;
  57080. private _randomTexture;
  57081. private _originalColorPostProcess;
  57082. private _ssaoPostProcess;
  57083. private _blurHPostProcess;
  57084. private _blurVPostProcess;
  57085. private _ssaoCombinePostProcess;
  57086. private _firstUpdate;
  57087. /**
  57088. * Gets active scene
  57089. */
  57090. readonly scene: Scene;
  57091. /**
  57092. * @constructor
  57093. * @param name The rendering pipeline name
  57094. * @param scene The scene linked to this pipeline
  57095. * @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 }
  57096. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57097. */
  57098. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57099. /**
  57100. * Get the class name
  57101. * @returns "SSAO2RenderingPipeline"
  57102. */
  57103. getClassName(): string;
  57104. /**
  57105. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57106. */
  57107. dispose(disableGeometryBufferRenderer?: boolean): void;
  57108. private _createBlurPostProcess;
  57109. /** @hidden */
  57110. _rebuild(): void;
  57111. private _bits;
  57112. private _radicalInverse_VdC;
  57113. private _hammersley;
  57114. private _hemisphereSample_uniform;
  57115. private _generateHemisphere;
  57116. private _createSSAOPostProcess;
  57117. private _createSSAOCombinePostProcess;
  57118. private _createRandomTexture;
  57119. /**
  57120. * Serialize the rendering pipeline (Used when exporting)
  57121. * @returns the serialized object
  57122. */
  57123. serialize(): any;
  57124. /**
  57125. * Parse the serialized pipeline
  57126. * @param source Source pipeline.
  57127. * @param scene The scene to load the pipeline to.
  57128. * @param rootUrl The URL of the serialized pipeline.
  57129. * @returns An instantiated pipeline from the serialized object.
  57130. */
  57131. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  57132. }
  57133. }
  57134. declare module BABYLON {
  57135. /** @hidden */
  57136. export var ssaoPixelShader: {
  57137. name: string;
  57138. shader: string;
  57139. };
  57140. }
  57141. declare module BABYLON {
  57142. /**
  57143. * Render pipeline to produce ssao effect
  57144. */
  57145. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  57146. /**
  57147. * @ignore
  57148. * The PassPostProcess id in the pipeline that contains the original scene color
  57149. */
  57150. SSAOOriginalSceneColorEffect: string;
  57151. /**
  57152. * @ignore
  57153. * The SSAO PostProcess id in the pipeline
  57154. */
  57155. SSAORenderEffect: string;
  57156. /**
  57157. * @ignore
  57158. * The horizontal blur PostProcess id in the pipeline
  57159. */
  57160. SSAOBlurHRenderEffect: string;
  57161. /**
  57162. * @ignore
  57163. * The vertical blur PostProcess id in the pipeline
  57164. */
  57165. SSAOBlurVRenderEffect: string;
  57166. /**
  57167. * @ignore
  57168. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57169. */
  57170. SSAOCombineRenderEffect: string;
  57171. /**
  57172. * The output strength of the SSAO post-process. Default value is 1.0.
  57173. */
  57174. totalStrength: number;
  57175. /**
  57176. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  57177. */
  57178. radius: number;
  57179. /**
  57180. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  57181. * Must not be equal to fallOff and superior to fallOff.
  57182. * Default value is 0.0075
  57183. */
  57184. area: number;
  57185. /**
  57186. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  57187. * Must not be equal to area and inferior to area.
  57188. * Default value is 0.000001
  57189. */
  57190. fallOff: number;
  57191. /**
  57192. * The base color of the SSAO post-process
  57193. * The final result is "base + ssao" between [0, 1]
  57194. */
  57195. base: number;
  57196. private _scene;
  57197. private _depthTexture;
  57198. private _randomTexture;
  57199. private _originalColorPostProcess;
  57200. private _ssaoPostProcess;
  57201. private _blurHPostProcess;
  57202. private _blurVPostProcess;
  57203. private _ssaoCombinePostProcess;
  57204. private _firstUpdate;
  57205. /**
  57206. * Gets active scene
  57207. */
  57208. readonly scene: Scene;
  57209. /**
  57210. * @constructor
  57211. * @param name - The rendering pipeline name
  57212. * @param scene - The scene linked to this pipeline
  57213. * @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 }
  57214. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  57215. */
  57216. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57217. /**
  57218. * Get the class name
  57219. * @returns "SSAORenderingPipeline"
  57220. */
  57221. getClassName(): string;
  57222. /**
  57223. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57224. */
  57225. dispose(disableDepthRender?: boolean): void;
  57226. private _createBlurPostProcess;
  57227. /** @hidden */
  57228. _rebuild(): void;
  57229. private _createSSAOPostProcess;
  57230. private _createSSAOCombinePostProcess;
  57231. private _createRandomTexture;
  57232. }
  57233. }
  57234. declare module BABYLON {
  57235. /** @hidden */
  57236. export var standardPixelShader: {
  57237. name: string;
  57238. shader: string;
  57239. };
  57240. }
  57241. declare module BABYLON {
  57242. /**
  57243. * Standard rendering pipeline
  57244. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57245. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  57246. */
  57247. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57248. /**
  57249. * Public members
  57250. */
  57251. /**
  57252. * Post-process which contains the original scene color before the pipeline applies all the effects
  57253. */
  57254. originalPostProcess: Nullable<PostProcess>;
  57255. /**
  57256. * Post-process used to down scale an image x4
  57257. */
  57258. downSampleX4PostProcess: Nullable<PostProcess>;
  57259. /**
  57260. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  57261. */
  57262. brightPassPostProcess: Nullable<PostProcess>;
  57263. /**
  57264. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  57265. */
  57266. blurHPostProcesses: PostProcess[];
  57267. /**
  57268. * Post-process array storing all the vertical blur post-processes used by the pipeline
  57269. */
  57270. blurVPostProcesses: PostProcess[];
  57271. /**
  57272. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  57273. */
  57274. textureAdderPostProcess: Nullable<PostProcess>;
  57275. /**
  57276. * Post-process used to create volumetric lighting effect
  57277. */
  57278. volumetricLightPostProcess: Nullable<PostProcess>;
  57279. /**
  57280. * Post-process used to smooth the previous volumetric light post-process on the X axis
  57281. */
  57282. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  57283. /**
  57284. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  57285. */
  57286. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  57287. /**
  57288. * Post-process used to merge the volumetric light effect and the real scene color
  57289. */
  57290. volumetricLightMergePostProces: Nullable<PostProcess>;
  57291. /**
  57292. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  57293. */
  57294. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  57295. /**
  57296. * Base post-process used to calculate the average luminance of the final image for HDR
  57297. */
  57298. luminancePostProcess: Nullable<PostProcess>;
  57299. /**
  57300. * Post-processes used to create down sample post-processes in order to get
  57301. * the average luminance of the final image for HDR
  57302. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  57303. */
  57304. luminanceDownSamplePostProcesses: PostProcess[];
  57305. /**
  57306. * Post-process used to create a HDR effect (light adaptation)
  57307. */
  57308. hdrPostProcess: Nullable<PostProcess>;
  57309. /**
  57310. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  57311. */
  57312. textureAdderFinalPostProcess: Nullable<PostProcess>;
  57313. /**
  57314. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  57315. */
  57316. lensFlareFinalPostProcess: Nullable<PostProcess>;
  57317. /**
  57318. * Post-process used to merge the final HDR post-process and the real scene color
  57319. */
  57320. hdrFinalPostProcess: Nullable<PostProcess>;
  57321. /**
  57322. * Post-process used to create a lens flare effect
  57323. */
  57324. lensFlarePostProcess: Nullable<PostProcess>;
  57325. /**
  57326. * Post-process that merges the result of the lens flare post-process and the real scene color
  57327. */
  57328. lensFlareComposePostProcess: Nullable<PostProcess>;
  57329. /**
  57330. * Post-process used to create a motion blur effect
  57331. */
  57332. motionBlurPostProcess: Nullable<PostProcess>;
  57333. /**
  57334. * Post-process used to create a depth of field effect
  57335. */
  57336. depthOfFieldPostProcess: Nullable<PostProcess>;
  57337. /**
  57338. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57339. */
  57340. fxaaPostProcess: Nullable<FxaaPostProcess>;
  57341. /**
  57342. * Represents the brightness threshold in order to configure the illuminated surfaces
  57343. */
  57344. brightThreshold: number;
  57345. /**
  57346. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  57347. */
  57348. blurWidth: number;
  57349. /**
  57350. * Sets if the blur for highlighted surfaces must be only horizontal
  57351. */
  57352. horizontalBlur: boolean;
  57353. /**
  57354. * Gets the overall exposure used by the pipeline
  57355. */
  57356. /**
  57357. * Sets the overall exposure used by the pipeline
  57358. */
  57359. exposure: number;
  57360. /**
  57361. * Texture used typically to simulate "dirty" on camera lens
  57362. */
  57363. lensTexture: Nullable<Texture>;
  57364. /**
  57365. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  57366. */
  57367. volumetricLightCoefficient: number;
  57368. /**
  57369. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  57370. */
  57371. volumetricLightPower: number;
  57372. /**
  57373. * Used the set the blur intensity to smooth the volumetric lights
  57374. */
  57375. volumetricLightBlurScale: number;
  57376. /**
  57377. * Light (spot or directional) used to generate the volumetric lights rays
  57378. * The source light must have a shadow generate so the pipeline can get its
  57379. * depth map
  57380. */
  57381. sourceLight: Nullable<SpotLight | DirectionalLight>;
  57382. /**
  57383. * For eye adaptation, represents the minimum luminance the eye can see
  57384. */
  57385. hdrMinimumLuminance: number;
  57386. /**
  57387. * For eye adaptation, represents the decrease luminance speed
  57388. */
  57389. hdrDecreaseRate: number;
  57390. /**
  57391. * For eye adaptation, represents the increase luminance speed
  57392. */
  57393. hdrIncreaseRate: number;
  57394. /**
  57395. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57396. */
  57397. /**
  57398. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57399. */
  57400. hdrAutoExposure: boolean;
  57401. /**
  57402. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  57403. */
  57404. lensColorTexture: Nullable<Texture>;
  57405. /**
  57406. * The overall strengh for the lens flare effect
  57407. */
  57408. lensFlareStrength: number;
  57409. /**
  57410. * Dispersion coefficient for lens flare ghosts
  57411. */
  57412. lensFlareGhostDispersal: number;
  57413. /**
  57414. * Main lens flare halo width
  57415. */
  57416. lensFlareHaloWidth: number;
  57417. /**
  57418. * Based on the lens distortion effect, defines how much the lens flare result
  57419. * is distorted
  57420. */
  57421. lensFlareDistortionStrength: number;
  57422. /**
  57423. * Lens star texture must be used to simulate rays on the flares and is available
  57424. * in the documentation
  57425. */
  57426. lensStarTexture: Nullable<Texture>;
  57427. /**
  57428. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  57429. * flare effect by taking account of the dirt texture
  57430. */
  57431. lensFlareDirtTexture: Nullable<Texture>;
  57432. /**
  57433. * Represents the focal length for the depth of field effect
  57434. */
  57435. depthOfFieldDistance: number;
  57436. /**
  57437. * Represents the blur intensity for the blurred part of the depth of field effect
  57438. */
  57439. depthOfFieldBlurWidth: number;
  57440. /**
  57441. * Gets how much the image is blurred by the movement while using the motion blur post-process
  57442. */
  57443. /**
  57444. * Sets how much the image is blurred by the movement while using the motion blur post-process
  57445. */
  57446. motionStrength: number;
  57447. /**
  57448. * Gets wether or not the motion blur post-process is object based or screen based.
  57449. */
  57450. /**
  57451. * Sets wether or not the motion blur post-process should be object based or screen based
  57452. */
  57453. objectBasedMotionBlur: boolean;
  57454. /**
  57455. * List of animations for the pipeline (IAnimatable implementation)
  57456. */
  57457. animations: Animation[];
  57458. /**
  57459. * Private members
  57460. */
  57461. private _scene;
  57462. private _currentDepthOfFieldSource;
  57463. private _basePostProcess;
  57464. private _fixedExposure;
  57465. private _currentExposure;
  57466. private _hdrAutoExposure;
  57467. private _hdrCurrentLuminance;
  57468. private _motionStrength;
  57469. private _isObjectBasedMotionBlur;
  57470. private _floatTextureType;
  57471. private _ratio;
  57472. private _bloomEnabled;
  57473. private _depthOfFieldEnabled;
  57474. private _vlsEnabled;
  57475. private _lensFlareEnabled;
  57476. private _hdrEnabled;
  57477. private _motionBlurEnabled;
  57478. private _fxaaEnabled;
  57479. private _motionBlurSamples;
  57480. private _volumetricLightStepsCount;
  57481. private _samples;
  57482. /**
  57483. * @ignore
  57484. * Specifies if the bloom pipeline is enabled
  57485. */
  57486. BloomEnabled: boolean;
  57487. /**
  57488. * @ignore
  57489. * Specifies if the depth of field pipeline is enabed
  57490. */
  57491. DepthOfFieldEnabled: boolean;
  57492. /**
  57493. * @ignore
  57494. * Specifies if the lens flare pipeline is enabed
  57495. */
  57496. LensFlareEnabled: boolean;
  57497. /**
  57498. * @ignore
  57499. * Specifies if the HDR pipeline is enabled
  57500. */
  57501. HDREnabled: boolean;
  57502. /**
  57503. * @ignore
  57504. * Specifies if the volumetric lights scattering effect is enabled
  57505. */
  57506. VLSEnabled: boolean;
  57507. /**
  57508. * @ignore
  57509. * Specifies if the motion blur effect is enabled
  57510. */
  57511. MotionBlurEnabled: boolean;
  57512. /**
  57513. * Specifies if anti-aliasing is enabled
  57514. */
  57515. fxaaEnabled: boolean;
  57516. /**
  57517. * Specifies the number of steps used to calculate the volumetric lights
  57518. * Typically in interval [50, 200]
  57519. */
  57520. volumetricLightStepsCount: number;
  57521. /**
  57522. * Specifies the number of samples used for the motion blur effect
  57523. * Typically in interval [16, 64]
  57524. */
  57525. motionBlurSamples: number;
  57526. /**
  57527. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57528. */
  57529. samples: number;
  57530. /**
  57531. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57532. * @constructor
  57533. * @param name The rendering pipeline name
  57534. * @param scene The scene linked to this pipeline
  57535. * @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)
  57536. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57537. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57538. */
  57539. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57540. private _buildPipeline;
  57541. private _createDownSampleX4PostProcess;
  57542. private _createBrightPassPostProcess;
  57543. private _createBlurPostProcesses;
  57544. private _createTextureAdderPostProcess;
  57545. private _createVolumetricLightPostProcess;
  57546. private _createLuminancePostProcesses;
  57547. private _createHdrPostProcess;
  57548. private _createLensFlarePostProcess;
  57549. private _createDepthOfFieldPostProcess;
  57550. private _createMotionBlurPostProcess;
  57551. private _getDepthTexture;
  57552. private _disposePostProcesses;
  57553. /**
  57554. * Dispose of the pipeline and stop all post processes
  57555. */
  57556. dispose(): void;
  57557. /**
  57558. * Serialize the rendering pipeline (Used when exporting)
  57559. * @returns the serialized object
  57560. */
  57561. serialize(): any;
  57562. /**
  57563. * Parse the serialized pipeline
  57564. * @param source Source pipeline.
  57565. * @param scene The scene to load the pipeline to.
  57566. * @param rootUrl The URL of the serialized pipeline.
  57567. * @returns An instantiated pipeline from the serialized object.
  57568. */
  57569. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57570. /**
  57571. * Luminance steps
  57572. */
  57573. static LuminanceSteps: number;
  57574. }
  57575. }
  57576. declare module BABYLON {
  57577. /** @hidden */
  57578. export var tonemapPixelShader: {
  57579. name: string;
  57580. shader: string;
  57581. };
  57582. }
  57583. declare module BABYLON {
  57584. /** Defines operator used for tonemapping */
  57585. export enum TonemappingOperator {
  57586. /** Hable */
  57587. Hable = 0,
  57588. /** Reinhard */
  57589. Reinhard = 1,
  57590. /** HejiDawson */
  57591. HejiDawson = 2,
  57592. /** Photographic */
  57593. Photographic = 3
  57594. }
  57595. /**
  57596. * Defines a post process to apply tone mapping
  57597. */
  57598. export class TonemapPostProcess extends PostProcess {
  57599. private _operator;
  57600. /** Defines the required exposure adjustement */
  57601. exposureAdjustment: number;
  57602. /**
  57603. * Creates a new TonemapPostProcess
  57604. * @param name defines the name of the postprocess
  57605. * @param _operator defines the operator to use
  57606. * @param exposureAdjustment defines the required exposure adjustement
  57607. * @param camera defines the camera to use (can be null)
  57608. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57609. * @param engine defines the hosting engine (can be ignore if camera is set)
  57610. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57611. */
  57612. constructor(name: string, _operator: TonemappingOperator,
  57613. /** Defines the required exposure adjustement */
  57614. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57615. }
  57616. }
  57617. declare module BABYLON {
  57618. /** @hidden */
  57619. export var depthVertexShader: {
  57620. name: string;
  57621. shader: string;
  57622. };
  57623. }
  57624. declare module BABYLON {
  57625. /** @hidden */
  57626. export var volumetricLightScatteringPixelShader: {
  57627. name: string;
  57628. shader: string;
  57629. };
  57630. }
  57631. declare module BABYLON {
  57632. /** @hidden */
  57633. export var volumetricLightScatteringPassPixelShader: {
  57634. name: string;
  57635. shader: string;
  57636. };
  57637. }
  57638. declare module BABYLON {
  57639. /**
  57640. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57641. */
  57642. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57643. private _volumetricLightScatteringPass;
  57644. private _volumetricLightScatteringRTT;
  57645. private _viewPort;
  57646. private _screenCoordinates;
  57647. private _cachedDefines;
  57648. /**
  57649. * If not undefined, the mesh position is computed from the attached node position
  57650. */
  57651. attachedNode: {
  57652. position: Vector3;
  57653. };
  57654. /**
  57655. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57656. */
  57657. customMeshPosition: Vector3;
  57658. /**
  57659. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57660. */
  57661. useCustomMeshPosition: boolean;
  57662. /**
  57663. * If the post-process should inverse the light scattering direction
  57664. */
  57665. invert: boolean;
  57666. /**
  57667. * The internal mesh used by the post-process
  57668. */
  57669. mesh: Mesh;
  57670. /**
  57671. * @hidden
  57672. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57673. */
  57674. useDiffuseColor: boolean;
  57675. /**
  57676. * Array containing the excluded meshes not rendered in the internal pass
  57677. */
  57678. excludedMeshes: AbstractMesh[];
  57679. /**
  57680. * Controls the overall intensity of the post-process
  57681. */
  57682. exposure: number;
  57683. /**
  57684. * Dissipates each sample's contribution in range [0, 1]
  57685. */
  57686. decay: number;
  57687. /**
  57688. * Controls the overall intensity of each sample
  57689. */
  57690. weight: number;
  57691. /**
  57692. * Controls the density of each sample
  57693. */
  57694. density: number;
  57695. /**
  57696. * @constructor
  57697. * @param name The post-process name
  57698. * @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)
  57699. * @param camera The camera that the post-process will be attached to
  57700. * @param mesh The mesh used to create the light scattering
  57701. * @param samples The post-process quality, default 100
  57702. * @param samplingModeThe post-process filtering mode
  57703. * @param engine The babylon engine
  57704. * @param reusable If the post-process is reusable
  57705. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57706. */
  57707. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57708. /**
  57709. * Returns the string "VolumetricLightScatteringPostProcess"
  57710. * @returns "VolumetricLightScatteringPostProcess"
  57711. */
  57712. getClassName(): string;
  57713. private _isReady;
  57714. /**
  57715. * Sets the new light position for light scattering effect
  57716. * @param position The new custom light position
  57717. */
  57718. setCustomMeshPosition(position: Vector3): void;
  57719. /**
  57720. * Returns the light position for light scattering effect
  57721. * @return Vector3 The custom light position
  57722. */
  57723. getCustomMeshPosition(): Vector3;
  57724. /**
  57725. * Disposes the internal assets and detaches the post-process from the camera
  57726. */
  57727. dispose(camera: Camera): void;
  57728. /**
  57729. * Returns the render target texture used by the post-process
  57730. * @return the render target texture used by the post-process
  57731. */
  57732. getPass(): RenderTargetTexture;
  57733. private _meshExcluded;
  57734. private _createPass;
  57735. private _updateMeshScreenCoordinates;
  57736. /**
  57737. * Creates a default mesh for the Volumeric Light Scattering post-process
  57738. * @param name The mesh name
  57739. * @param scene The scene where to create the mesh
  57740. * @return the default mesh
  57741. */
  57742. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57743. }
  57744. }
  57745. declare module BABYLON {
  57746. interface Scene {
  57747. /** @hidden (Backing field) */
  57748. _boundingBoxRenderer: BoundingBoxRenderer;
  57749. /** @hidden (Backing field) */
  57750. _forceShowBoundingBoxes: boolean;
  57751. /**
  57752. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57753. */
  57754. forceShowBoundingBoxes: boolean;
  57755. /**
  57756. * Gets the bounding box renderer associated with the scene
  57757. * @returns a BoundingBoxRenderer
  57758. */
  57759. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57760. }
  57761. interface AbstractMesh {
  57762. /** @hidden (Backing field) */
  57763. _showBoundingBox: boolean;
  57764. /**
  57765. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57766. */
  57767. showBoundingBox: boolean;
  57768. }
  57769. /**
  57770. * Component responsible of rendering the bounding box of the meshes in a scene.
  57771. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57772. */
  57773. export class BoundingBoxRenderer implements ISceneComponent {
  57774. /**
  57775. * The component name helpfull to identify the component in the list of scene components.
  57776. */
  57777. readonly name: string;
  57778. /**
  57779. * The scene the component belongs to.
  57780. */
  57781. scene: Scene;
  57782. /**
  57783. * Color of the bounding box lines placed in front of an object
  57784. */
  57785. frontColor: Color3;
  57786. /**
  57787. * Color of the bounding box lines placed behind an object
  57788. */
  57789. backColor: Color3;
  57790. /**
  57791. * Defines if the renderer should show the back lines or not
  57792. */
  57793. showBackLines: boolean;
  57794. /**
  57795. * @hidden
  57796. */
  57797. renderList: SmartArray<BoundingBox>;
  57798. private _colorShader;
  57799. private _vertexBuffers;
  57800. private _indexBuffer;
  57801. private _fillIndexBuffer;
  57802. private _fillIndexData;
  57803. /**
  57804. * Instantiates a new bounding box renderer in a scene.
  57805. * @param scene the scene the renderer renders in
  57806. */
  57807. constructor(scene: Scene);
  57808. /**
  57809. * Registers the component in a given scene
  57810. */
  57811. register(): void;
  57812. private _evaluateSubMesh;
  57813. private _activeMesh;
  57814. private _prepareRessources;
  57815. private _createIndexBuffer;
  57816. /**
  57817. * Rebuilds the elements related to this component in case of
  57818. * context lost for instance.
  57819. */
  57820. rebuild(): void;
  57821. /**
  57822. * @hidden
  57823. */
  57824. reset(): void;
  57825. /**
  57826. * Render the bounding boxes of a specific rendering group
  57827. * @param renderingGroupId defines the rendering group to render
  57828. */
  57829. render(renderingGroupId: number): void;
  57830. /**
  57831. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57832. * @param mesh Define the mesh to render the occlusion bounding box for
  57833. */
  57834. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57835. /**
  57836. * Dispose and release the resources attached to this renderer.
  57837. */
  57838. dispose(): void;
  57839. }
  57840. }
  57841. declare module BABYLON {
  57842. /** @hidden */
  57843. export var depthPixelShader: {
  57844. name: string;
  57845. shader: string;
  57846. };
  57847. }
  57848. declare module BABYLON {
  57849. /**
  57850. * This represents a depth renderer in Babylon.
  57851. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57852. */
  57853. export class DepthRenderer {
  57854. private _scene;
  57855. private _depthMap;
  57856. private _effect;
  57857. private readonly _storeNonLinearDepth;
  57858. private readonly _clearColor;
  57859. /** Get if the depth renderer is using packed depth or not */
  57860. readonly isPacked: boolean;
  57861. private _cachedDefines;
  57862. private _camera;
  57863. /**
  57864. * Specifiess that the depth renderer will only be used within
  57865. * the camera it is created for.
  57866. * This can help forcing its rendering during the camera processing.
  57867. */
  57868. useOnlyInActiveCamera: boolean;
  57869. /** @hidden */
  57870. static _SceneComponentInitialization: (scene: Scene) => void;
  57871. /**
  57872. * Instantiates a depth renderer
  57873. * @param scene The scene the renderer belongs to
  57874. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57875. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57876. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57877. */
  57878. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57879. /**
  57880. * Creates the depth rendering effect and checks if the effect is ready.
  57881. * @param subMesh The submesh to be used to render the depth map of
  57882. * @param useInstances If multiple world instances should be used
  57883. * @returns if the depth renderer is ready to render the depth map
  57884. */
  57885. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57886. /**
  57887. * Gets the texture which the depth map will be written to.
  57888. * @returns The depth map texture
  57889. */
  57890. getDepthMap(): RenderTargetTexture;
  57891. /**
  57892. * Disposes of the depth renderer.
  57893. */
  57894. dispose(): void;
  57895. }
  57896. }
  57897. declare module BABYLON {
  57898. interface Scene {
  57899. /** @hidden (Backing field) */
  57900. _depthRenderer: {
  57901. [id: string]: DepthRenderer;
  57902. };
  57903. /**
  57904. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57905. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57906. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57907. * @returns the created depth renderer
  57908. */
  57909. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  57910. /**
  57911. * Disables a depth renderer for a given camera
  57912. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57913. */
  57914. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57915. }
  57916. /**
  57917. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57918. * in several rendering techniques.
  57919. */
  57920. export class DepthRendererSceneComponent implements ISceneComponent {
  57921. /**
  57922. * The component name helpfull to identify the component in the list of scene components.
  57923. */
  57924. readonly name: string;
  57925. /**
  57926. * The scene the component belongs to.
  57927. */
  57928. scene: Scene;
  57929. /**
  57930. * Creates a new instance of the component for the given scene
  57931. * @param scene Defines the scene to register the component in
  57932. */
  57933. constructor(scene: Scene);
  57934. /**
  57935. * Registers the component in a given scene
  57936. */
  57937. register(): void;
  57938. /**
  57939. * Rebuilds the elements related to this component in case of
  57940. * context lost for instance.
  57941. */
  57942. rebuild(): void;
  57943. /**
  57944. * Disposes the component and the associated ressources
  57945. */
  57946. dispose(): void;
  57947. private _gatherRenderTargets;
  57948. private _gatherActiveCameraRenderTargets;
  57949. }
  57950. }
  57951. declare module BABYLON {
  57952. /** @hidden */
  57953. export var outlinePixelShader: {
  57954. name: string;
  57955. shader: string;
  57956. };
  57957. }
  57958. declare module BABYLON {
  57959. /** @hidden */
  57960. export var outlineVertexShader: {
  57961. name: string;
  57962. shader: string;
  57963. };
  57964. }
  57965. declare module BABYLON {
  57966. interface Scene {
  57967. /** @hidden */
  57968. _outlineRenderer: OutlineRenderer;
  57969. /**
  57970. * Gets the outline renderer associated with the scene
  57971. * @returns a OutlineRenderer
  57972. */
  57973. getOutlineRenderer(): OutlineRenderer;
  57974. }
  57975. interface AbstractMesh {
  57976. /** @hidden (Backing field) */
  57977. _renderOutline: boolean;
  57978. /**
  57979. * Gets or sets a boolean indicating if the outline must be rendered as well
  57980. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57981. */
  57982. renderOutline: boolean;
  57983. /** @hidden (Backing field) */
  57984. _renderOverlay: boolean;
  57985. /**
  57986. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57987. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57988. */
  57989. renderOverlay: boolean;
  57990. }
  57991. /**
  57992. * This class is responsible to draw bothe outline/overlay of meshes.
  57993. * It should not be used directly but through the available method on mesh.
  57994. */
  57995. export class OutlineRenderer implements ISceneComponent {
  57996. /**
  57997. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57998. */
  57999. private static _StencilReference;
  58000. /**
  58001. * The name of the component. Each component must have a unique name.
  58002. */
  58003. name: string;
  58004. /**
  58005. * The scene the component belongs to.
  58006. */
  58007. scene: Scene;
  58008. /**
  58009. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  58010. */
  58011. zOffset: number;
  58012. private _engine;
  58013. private _effect;
  58014. private _cachedDefines;
  58015. private _savedDepthWrite;
  58016. /**
  58017. * Instantiates a new outline renderer. (There could be only one per scene).
  58018. * @param scene Defines the scene it belongs to
  58019. */
  58020. constructor(scene: Scene);
  58021. /**
  58022. * Register the component to one instance of a scene.
  58023. */
  58024. register(): void;
  58025. /**
  58026. * Rebuilds the elements related to this component in case of
  58027. * context lost for instance.
  58028. */
  58029. rebuild(): void;
  58030. /**
  58031. * Disposes the component and the associated ressources.
  58032. */
  58033. dispose(): void;
  58034. /**
  58035. * Renders the outline in the canvas.
  58036. * @param subMesh Defines the sumesh to render
  58037. * @param batch Defines the batch of meshes in case of instances
  58038. * @param useOverlay Defines if the rendering is for the overlay or the outline
  58039. */
  58040. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  58041. /**
  58042. * Returns whether or not the outline renderer is ready for a given submesh.
  58043. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  58044. * @param subMesh Defines the submesh to check readyness for
  58045. * @param useInstances Defines wheter wee are trying to render instances or not
  58046. * @returns true if ready otherwise false
  58047. */
  58048. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58049. private _beforeRenderingMesh;
  58050. private _afterRenderingMesh;
  58051. }
  58052. }
  58053. declare module BABYLON {
  58054. /**
  58055. * Defines the list of states available for a task inside a AssetsManager
  58056. */
  58057. export enum AssetTaskState {
  58058. /**
  58059. * Initialization
  58060. */
  58061. INIT = 0,
  58062. /**
  58063. * Running
  58064. */
  58065. RUNNING = 1,
  58066. /**
  58067. * Done
  58068. */
  58069. DONE = 2,
  58070. /**
  58071. * Error
  58072. */
  58073. ERROR = 3
  58074. }
  58075. /**
  58076. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  58077. */
  58078. export abstract class AbstractAssetTask {
  58079. /**
  58080. * Task name
  58081. */ name: string;
  58082. /**
  58083. * Callback called when the task is successful
  58084. */
  58085. onSuccess: (task: any) => void;
  58086. /**
  58087. * Callback called when the task is not successful
  58088. */
  58089. onError: (task: any, message?: string, exception?: any) => void;
  58090. /**
  58091. * Creates a new AssetsManager
  58092. * @param name defines the name of the task
  58093. */
  58094. constructor(
  58095. /**
  58096. * Task name
  58097. */ name: string);
  58098. private _isCompleted;
  58099. private _taskState;
  58100. private _errorObject;
  58101. /**
  58102. * Get if the task is completed
  58103. */
  58104. readonly isCompleted: boolean;
  58105. /**
  58106. * Gets the current state of the task
  58107. */
  58108. readonly taskState: AssetTaskState;
  58109. /**
  58110. * Gets the current error object (if task is in error)
  58111. */
  58112. readonly errorObject: {
  58113. message?: string;
  58114. exception?: any;
  58115. };
  58116. /**
  58117. * Internal only
  58118. * @hidden
  58119. */
  58120. _setErrorObject(message?: string, exception?: any): void;
  58121. /**
  58122. * Execute the current task
  58123. * @param scene defines the scene where you want your assets to be loaded
  58124. * @param onSuccess is a callback called when the task is successfully executed
  58125. * @param onError is a callback called if an error occurs
  58126. */
  58127. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58128. /**
  58129. * Execute the current task
  58130. * @param scene defines the scene where you want your assets to be loaded
  58131. * @param onSuccess is a callback called when the task is successfully executed
  58132. * @param onError is a callback called if an error occurs
  58133. */
  58134. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58135. /**
  58136. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  58137. * This can be used with failed tasks that have the reason for failure fixed.
  58138. */
  58139. reset(): void;
  58140. private onErrorCallback;
  58141. private onDoneCallback;
  58142. }
  58143. /**
  58144. * Define the interface used by progress events raised during assets loading
  58145. */
  58146. export interface IAssetsProgressEvent {
  58147. /**
  58148. * Defines the number of remaining tasks to process
  58149. */
  58150. remainingCount: number;
  58151. /**
  58152. * Defines the total number of tasks
  58153. */
  58154. totalCount: number;
  58155. /**
  58156. * Defines the task that was just processed
  58157. */
  58158. task: AbstractAssetTask;
  58159. }
  58160. /**
  58161. * Class used to share progress information about assets loading
  58162. */
  58163. export class AssetsProgressEvent implements IAssetsProgressEvent {
  58164. /**
  58165. * Defines the number of remaining tasks to process
  58166. */
  58167. remainingCount: number;
  58168. /**
  58169. * Defines the total number of tasks
  58170. */
  58171. totalCount: number;
  58172. /**
  58173. * Defines the task that was just processed
  58174. */
  58175. task: AbstractAssetTask;
  58176. /**
  58177. * Creates a AssetsProgressEvent
  58178. * @param remainingCount defines the number of remaining tasks to process
  58179. * @param totalCount defines the total number of tasks
  58180. * @param task defines the task that was just processed
  58181. */
  58182. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  58183. }
  58184. /**
  58185. * Define a task used by AssetsManager to load meshes
  58186. */
  58187. export class MeshAssetTask extends AbstractAssetTask {
  58188. /**
  58189. * Defines the name of the task
  58190. */
  58191. name: string;
  58192. /**
  58193. * Defines the list of mesh's names you want to load
  58194. */
  58195. meshesNames: any;
  58196. /**
  58197. * Defines the root url to use as a base to load your meshes and associated resources
  58198. */
  58199. rootUrl: string;
  58200. /**
  58201. * Defines the filename of the scene to load from
  58202. */
  58203. sceneFilename: string;
  58204. /**
  58205. * Gets the list of loaded meshes
  58206. */
  58207. loadedMeshes: Array<AbstractMesh>;
  58208. /**
  58209. * Gets the list of loaded particle systems
  58210. */
  58211. loadedParticleSystems: Array<IParticleSystem>;
  58212. /**
  58213. * Gets the list of loaded skeletons
  58214. */
  58215. loadedSkeletons: Array<Skeleton>;
  58216. /**
  58217. * Gets the list of loaded animation groups
  58218. */
  58219. loadedAnimationGroups: Array<AnimationGroup>;
  58220. /**
  58221. * Callback called when the task is successful
  58222. */
  58223. onSuccess: (task: MeshAssetTask) => void;
  58224. /**
  58225. * Callback called when the task is successful
  58226. */
  58227. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  58228. /**
  58229. * Creates a new MeshAssetTask
  58230. * @param name defines the name of the task
  58231. * @param meshesNames defines the list of mesh's names you want to load
  58232. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  58233. * @param sceneFilename defines the filename of the scene to load from
  58234. */
  58235. constructor(
  58236. /**
  58237. * Defines the name of the task
  58238. */
  58239. name: string,
  58240. /**
  58241. * Defines the list of mesh's names you want to load
  58242. */
  58243. meshesNames: any,
  58244. /**
  58245. * Defines the root url to use as a base to load your meshes and associated resources
  58246. */
  58247. rootUrl: string,
  58248. /**
  58249. * Defines the filename of the scene to load from
  58250. */
  58251. sceneFilename: string);
  58252. /**
  58253. * Execute the current task
  58254. * @param scene defines the scene where you want your assets to be loaded
  58255. * @param onSuccess is a callback called when the task is successfully executed
  58256. * @param onError is a callback called if an error occurs
  58257. */
  58258. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58259. }
  58260. /**
  58261. * Define a task used by AssetsManager to load text content
  58262. */
  58263. export class TextFileAssetTask extends AbstractAssetTask {
  58264. /**
  58265. * Defines the name of the task
  58266. */
  58267. name: string;
  58268. /**
  58269. * Defines the location of the file to load
  58270. */
  58271. url: string;
  58272. /**
  58273. * Gets the loaded text string
  58274. */
  58275. text: string;
  58276. /**
  58277. * Callback called when the task is successful
  58278. */
  58279. onSuccess: (task: TextFileAssetTask) => void;
  58280. /**
  58281. * Callback called when the task is successful
  58282. */
  58283. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  58284. /**
  58285. * Creates a new TextFileAssetTask object
  58286. * @param name defines the name of the task
  58287. * @param url defines the location of the file to load
  58288. */
  58289. constructor(
  58290. /**
  58291. * Defines the name of the task
  58292. */
  58293. name: string,
  58294. /**
  58295. * Defines the location of the file to load
  58296. */
  58297. url: string);
  58298. /**
  58299. * Execute the current task
  58300. * @param scene defines the scene where you want your assets to be loaded
  58301. * @param onSuccess is a callback called when the task is successfully executed
  58302. * @param onError is a callback called if an error occurs
  58303. */
  58304. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58305. }
  58306. /**
  58307. * Define a task used by AssetsManager to load binary data
  58308. */
  58309. export class BinaryFileAssetTask extends AbstractAssetTask {
  58310. /**
  58311. * Defines the name of the task
  58312. */
  58313. name: string;
  58314. /**
  58315. * Defines the location of the file to load
  58316. */
  58317. url: string;
  58318. /**
  58319. * Gets the lodaded data (as an array buffer)
  58320. */
  58321. data: ArrayBuffer;
  58322. /**
  58323. * Callback called when the task is successful
  58324. */
  58325. onSuccess: (task: BinaryFileAssetTask) => void;
  58326. /**
  58327. * Callback called when the task is successful
  58328. */
  58329. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58330. /**
  58331. * Creates a new BinaryFileAssetTask object
  58332. * @param name defines the name of the new task
  58333. * @param url defines the location of the file to load
  58334. */
  58335. constructor(
  58336. /**
  58337. * Defines the name of the task
  58338. */
  58339. name: string,
  58340. /**
  58341. * Defines the location of the file to load
  58342. */
  58343. url: string);
  58344. /**
  58345. * Execute the current task
  58346. * @param scene defines the scene where you want your assets to be loaded
  58347. * @param onSuccess is a callback called when the task is successfully executed
  58348. * @param onError is a callback called if an error occurs
  58349. */
  58350. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58351. }
  58352. /**
  58353. * Define a task used by AssetsManager to load images
  58354. */
  58355. export class ImageAssetTask extends AbstractAssetTask {
  58356. /**
  58357. * Defines the name of the task
  58358. */
  58359. name: string;
  58360. /**
  58361. * Defines the location of the image to load
  58362. */
  58363. url: string;
  58364. /**
  58365. * Gets the loaded images
  58366. */
  58367. image: HTMLImageElement;
  58368. /**
  58369. * Callback called when the task is successful
  58370. */
  58371. onSuccess: (task: ImageAssetTask) => void;
  58372. /**
  58373. * Callback called when the task is successful
  58374. */
  58375. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58376. /**
  58377. * Creates a new ImageAssetTask
  58378. * @param name defines the name of the task
  58379. * @param url defines the location of the image to load
  58380. */
  58381. constructor(
  58382. /**
  58383. * Defines the name of the task
  58384. */
  58385. name: string,
  58386. /**
  58387. * Defines the location of the image to load
  58388. */
  58389. url: string);
  58390. /**
  58391. * Execute the current task
  58392. * @param scene defines the scene where you want your assets to be loaded
  58393. * @param onSuccess is a callback called when the task is successfully executed
  58394. * @param onError is a callback called if an error occurs
  58395. */
  58396. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58397. }
  58398. /**
  58399. * Defines the interface used by texture loading tasks
  58400. */
  58401. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58402. /**
  58403. * Gets the loaded texture
  58404. */
  58405. texture: TEX;
  58406. }
  58407. /**
  58408. * Define a task used by AssetsManager to load 2D textures
  58409. */
  58410. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58411. /**
  58412. * Defines the name of the task
  58413. */
  58414. name: string;
  58415. /**
  58416. * Defines the location of the file to load
  58417. */
  58418. url: string;
  58419. /**
  58420. * Defines if mipmap should not be generated (default is false)
  58421. */
  58422. noMipmap?: boolean | undefined;
  58423. /**
  58424. * Defines if texture must be inverted on Y axis (default is false)
  58425. */
  58426. invertY?: boolean | undefined;
  58427. /**
  58428. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58429. */
  58430. samplingMode: number;
  58431. /**
  58432. * Gets the loaded texture
  58433. */
  58434. texture: Texture;
  58435. /**
  58436. * Callback called when the task is successful
  58437. */
  58438. onSuccess: (task: TextureAssetTask) => void;
  58439. /**
  58440. * Callback called when the task is successful
  58441. */
  58442. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58443. /**
  58444. * Creates a new TextureAssetTask object
  58445. * @param name defines the name of the task
  58446. * @param url defines the location of the file to load
  58447. * @param noMipmap defines if mipmap should not be generated (default is false)
  58448. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58449. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58450. */
  58451. constructor(
  58452. /**
  58453. * Defines the name of the task
  58454. */
  58455. name: string,
  58456. /**
  58457. * Defines the location of the file to load
  58458. */
  58459. url: string,
  58460. /**
  58461. * Defines if mipmap should not be generated (default is false)
  58462. */
  58463. noMipmap?: boolean | undefined,
  58464. /**
  58465. * Defines if texture must be inverted on Y axis (default is false)
  58466. */
  58467. invertY?: boolean | undefined,
  58468. /**
  58469. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58470. */
  58471. samplingMode?: number);
  58472. /**
  58473. * Execute the current task
  58474. * @param scene defines the scene where you want your assets to be loaded
  58475. * @param onSuccess is a callback called when the task is successfully executed
  58476. * @param onError is a callback called if an error occurs
  58477. */
  58478. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58479. }
  58480. /**
  58481. * Define a task used by AssetsManager to load cube textures
  58482. */
  58483. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58484. /**
  58485. * Defines the name of the task
  58486. */
  58487. name: string;
  58488. /**
  58489. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58490. */
  58491. url: string;
  58492. /**
  58493. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58494. */
  58495. extensions?: string[] | undefined;
  58496. /**
  58497. * Defines if mipmaps should not be generated (default is false)
  58498. */
  58499. noMipmap?: boolean | undefined;
  58500. /**
  58501. * Defines the explicit list of files (undefined by default)
  58502. */
  58503. files?: string[] | undefined;
  58504. /**
  58505. * Gets the loaded texture
  58506. */
  58507. texture: CubeTexture;
  58508. /**
  58509. * Callback called when the task is successful
  58510. */
  58511. onSuccess: (task: CubeTextureAssetTask) => void;
  58512. /**
  58513. * Callback called when the task is successful
  58514. */
  58515. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58516. /**
  58517. * Creates a new CubeTextureAssetTask
  58518. * @param name defines the name of the task
  58519. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58520. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58521. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58522. * @param files defines the explicit list of files (undefined by default)
  58523. */
  58524. constructor(
  58525. /**
  58526. * Defines the name of the task
  58527. */
  58528. name: string,
  58529. /**
  58530. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58531. */
  58532. url: string,
  58533. /**
  58534. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58535. */
  58536. extensions?: string[] | undefined,
  58537. /**
  58538. * Defines if mipmaps should not be generated (default is false)
  58539. */
  58540. noMipmap?: boolean | undefined,
  58541. /**
  58542. * Defines the explicit list of files (undefined by default)
  58543. */
  58544. files?: string[] | undefined);
  58545. /**
  58546. * Execute the current task
  58547. * @param scene defines the scene where you want your assets to be loaded
  58548. * @param onSuccess is a callback called when the task is successfully executed
  58549. * @param onError is a callback called if an error occurs
  58550. */
  58551. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58552. }
  58553. /**
  58554. * Define a task used by AssetsManager to load HDR cube textures
  58555. */
  58556. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58557. /**
  58558. * Defines the name of the task
  58559. */
  58560. name: string;
  58561. /**
  58562. * Defines the location of the file to load
  58563. */
  58564. url: string;
  58565. /**
  58566. * Defines the desired size (the more it increases the longer the generation will be)
  58567. */
  58568. size: number;
  58569. /**
  58570. * Defines if mipmaps should not be generated (default is false)
  58571. */
  58572. noMipmap: boolean;
  58573. /**
  58574. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58575. */
  58576. generateHarmonics: boolean;
  58577. /**
  58578. * 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)
  58579. */
  58580. gammaSpace: boolean;
  58581. /**
  58582. * Internal Use Only
  58583. */
  58584. reserved: boolean;
  58585. /**
  58586. * Gets the loaded texture
  58587. */
  58588. texture: HDRCubeTexture;
  58589. /**
  58590. * Callback called when the task is successful
  58591. */
  58592. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58593. /**
  58594. * Callback called when the task is successful
  58595. */
  58596. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58597. /**
  58598. * Creates a new HDRCubeTextureAssetTask object
  58599. * @param name defines the name of the task
  58600. * @param url defines the location of the file to load
  58601. * @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.
  58602. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58603. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58604. * @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)
  58605. * @param reserved Internal use only
  58606. */
  58607. constructor(
  58608. /**
  58609. * Defines the name of the task
  58610. */
  58611. name: string,
  58612. /**
  58613. * Defines the location of the file to load
  58614. */
  58615. url: string,
  58616. /**
  58617. * Defines the desired size (the more it increases the longer the generation will be)
  58618. */
  58619. size: number,
  58620. /**
  58621. * Defines if mipmaps should not be generated (default is false)
  58622. */
  58623. noMipmap?: boolean,
  58624. /**
  58625. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58626. */
  58627. generateHarmonics?: boolean,
  58628. /**
  58629. * 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)
  58630. */
  58631. gammaSpace?: boolean,
  58632. /**
  58633. * Internal Use Only
  58634. */
  58635. reserved?: boolean);
  58636. /**
  58637. * Execute the current task
  58638. * @param scene defines the scene where you want your assets to be loaded
  58639. * @param onSuccess is a callback called when the task is successfully executed
  58640. * @param onError is a callback called if an error occurs
  58641. */
  58642. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58643. }
  58644. /**
  58645. * Define a task used by AssetsManager to load Equirectangular cube textures
  58646. */
  58647. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58648. /**
  58649. * Defines the name of the task
  58650. */
  58651. name: string;
  58652. /**
  58653. * Defines the location of the file to load
  58654. */
  58655. url: string;
  58656. /**
  58657. * Defines the desired size (the more it increases the longer the generation will be)
  58658. */
  58659. size: number;
  58660. /**
  58661. * Defines if mipmaps should not be generated (default is false)
  58662. */
  58663. noMipmap: boolean;
  58664. /**
  58665. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58666. * but the standard material would require them in Gamma space) (default is true)
  58667. */
  58668. gammaSpace: boolean;
  58669. /**
  58670. * Gets the loaded texture
  58671. */
  58672. texture: EquiRectangularCubeTexture;
  58673. /**
  58674. * Callback called when the task is successful
  58675. */
  58676. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58677. /**
  58678. * Callback called when the task is successful
  58679. */
  58680. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58681. /**
  58682. * Creates a new EquiRectangularCubeTextureAssetTask object
  58683. * @param name defines the name of the task
  58684. * @param url defines the location of the file to load
  58685. * @param size defines the desired size (the more it increases the longer the generation will be)
  58686. * If the size is omitted this implies you are using a preprocessed cubemap.
  58687. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58688. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58689. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58690. * (default is true)
  58691. */
  58692. constructor(
  58693. /**
  58694. * Defines the name of the task
  58695. */
  58696. name: string,
  58697. /**
  58698. * Defines the location of the file to load
  58699. */
  58700. url: string,
  58701. /**
  58702. * Defines the desired size (the more it increases the longer the generation will be)
  58703. */
  58704. size: number,
  58705. /**
  58706. * Defines if mipmaps should not be generated (default is false)
  58707. */
  58708. noMipmap?: boolean,
  58709. /**
  58710. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58711. * but the standard material would require them in Gamma space) (default is true)
  58712. */
  58713. gammaSpace?: boolean);
  58714. /**
  58715. * Execute the current task
  58716. * @param scene defines the scene where you want your assets to be loaded
  58717. * @param onSuccess is a callback called when the task is successfully executed
  58718. * @param onError is a callback called if an error occurs
  58719. */
  58720. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58721. }
  58722. /**
  58723. * This class can be used to easily import assets into a scene
  58724. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58725. */
  58726. export class AssetsManager {
  58727. private _scene;
  58728. private _isLoading;
  58729. protected _tasks: AbstractAssetTask[];
  58730. protected _waitingTasksCount: number;
  58731. protected _totalTasksCount: number;
  58732. /**
  58733. * Callback called when all tasks are processed
  58734. */
  58735. onFinish: (tasks: AbstractAssetTask[]) => void;
  58736. /**
  58737. * Callback called when a task is successful
  58738. */
  58739. onTaskSuccess: (task: AbstractAssetTask) => void;
  58740. /**
  58741. * Callback called when a task had an error
  58742. */
  58743. onTaskError: (task: AbstractAssetTask) => void;
  58744. /**
  58745. * Callback called when a task is done (whatever the result is)
  58746. */
  58747. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58748. /**
  58749. * Observable called when all tasks are processed
  58750. */
  58751. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58752. /**
  58753. * Observable called when a task had an error
  58754. */
  58755. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58756. /**
  58757. * Observable called when all tasks were executed
  58758. */
  58759. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58760. /**
  58761. * Observable called when a task is done (whatever the result is)
  58762. */
  58763. onProgressObservable: Observable<IAssetsProgressEvent>;
  58764. /**
  58765. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58766. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58767. */
  58768. useDefaultLoadingScreen: boolean;
  58769. /**
  58770. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  58771. * when all assets have been downloaded.
  58772. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  58773. */
  58774. autoHideLoadingUI: boolean;
  58775. /**
  58776. * Creates a new AssetsManager
  58777. * @param scene defines the scene to work on
  58778. */
  58779. constructor(scene: Scene);
  58780. /**
  58781. * Add a MeshAssetTask to the list of active tasks
  58782. * @param taskName defines the name of the new task
  58783. * @param meshesNames defines the name of meshes to load
  58784. * @param rootUrl defines the root url to use to locate files
  58785. * @param sceneFilename defines the filename of the scene file
  58786. * @returns a new MeshAssetTask object
  58787. */
  58788. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58789. /**
  58790. * Add a TextFileAssetTask to the list of active tasks
  58791. * @param taskName defines the name of the new task
  58792. * @param url defines the url of the file to load
  58793. * @returns a new TextFileAssetTask object
  58794. */
  58795. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58796. /**
  58797. * Add a BinaryFileAssetTask to the list of active tasks
  58798. * @param taskName defines the name of the new task
  58799. * @param url defines the url of the file to load
  58800. * @returns a new BinaryFileAssetTask object
  58801. */
  58802. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58803. /**
  58804. * Add a ImageAssetTask to the list of active tasks
  58805. * @param taskName defines the name of the new task
  58806. * @param url defines the url of the file to load
  58807. * @returns a new ImageAssetTask object
  58808. */
  58809. addImageTask(taskName: string, url: string): ImageAssetTask;
  58810. /**
  58811. * Add a TextureAssetTask to the list of active tasks
  58812. * @param taskName defines the name of the new task
  58813. * @param url defines the url of the file to load
  58814. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58815. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58816. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58817. * @returns a new TextureAssetTask object
  58818. */
  58819. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58820. /**
  58821. * Add a CubeTextureAssetTask to the list of active tasks
  58822. * @param taskName defines the name of the new task
  58823. * @param url defines the url of the file to load
  58824. * @param extensions defines the extension to use to load the cube map (can be null)
  58825. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58826. * @param files defines the list of files to load (can be null)
  58827. * @returns a new CubeTextureAssetTask object
  58828. */
  58829. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58830. /**
  58831. *
  58832. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58833. * @param taskName defines the name of the new task
  58834. * @param url defines the url of the file to load
  58835. * @param size defines the size you want for the cubemap (can be null)
  58836. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58837. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58838. * @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)
  58839. * @param reserved Internal use only
  58840. * @returns a new HDRCubeTextureAssetTask object
  58841. */
  58842. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58843. /**
  58844. *
  58845. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58846. * @param taskName defines the name of the new task
  58847. * @param url defines the url of the file to load
  58848. * @param size defines the size you want for the cubemap (can be null)
  58849. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58850. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58851. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58852. * @returns a new EquiRectangularCubeTextureAssetTask object
  58853. */
  58854. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58855. /**
  58856. * Remove a task from the assets manager.
  58857. * @param task the task to remove
  58858. */
  58859. removeTask(task: AbstractAssetTask): void;
  58860. private _decreaseWaitingTasksCount;
  58861. private _runTask;
  58862. /**
  58863. * Reset the AssetsManager and remove all tasks
  58864. * @return the current instance of the AssetsManager
  58865. */
  58866. reset(): AssetsManager;
  58867. /**
  58868. * Start the loading process
  58869. * @return the current instance of the AssetsManager
  58870. */
  58871. load(): AssetsManager;
  58872. /**
  58873. * Start the loading process as an async operation
  58874. * @return a promise returning the list of failed tasks
  58875. */
  58876. loadAsync(): Promise<void>;
  58877. }
  58878. }
  58879. declare module BABYLON {
  58880. /**
  58881. * Wrapper class for promise with external resolve and reject.
  58882. */
  58883. export class Deferred<T> {
  58884. /**
  58885. * The promise associated with this deferred object.
  58886. */
  58887. readonly promise: Promise<T>;
  58888. private _resolve;
  58889. private _reject;
  58890. /**
  58891. * The resolve method of the promise associated with this deferred object.
  58892. */
  58893. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58894. /**
  58895. * The reject method of the promise associated with this deferred object.
  58896. */
  58897. readonly reject: (reason?: any) => void;
  58898. /**
  58899. * Constructor for this deferred object.
  58900. */
  58901. constructor();
  58902. }
  58903. }
  58904. declare module BABYLON {
  58905. /**
  58906. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58907. */
  58908. export class MeshExploder {
  58909. private _centerMesh;
  58910. private _meshes;
  58911. private _meshesOrigins;
  58912. private _toCenterVectors;
  58913. private _scaledDirection;
  58914. private _newPosition;
  58915. private _centerPosition;
  58916. /**
  58917. * Explodes meshes from a center mesh.
  58918. * @param meshes The meshes to explode.
  58919. * @param centerMesh The mesh to be center of explosion.
  58920. */
  58921. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58922. private _setCenterMesh;
  58923. /**
  58924. * Get class name
  58925. * @returns "MeshExploder"
  58926. */
  58927. getClassName(): string;
  58928. /**
  58929. * "Exploded meshes"
  58930. * @returns Array of meshes with the centerMesh at index 0.
  58931. */
  58932. getMeshes(): Array<Mesh>;
  58933. /**
  58934. * Explodes meshes giving a specific direction
  58935. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58936. */
  58937. explode(direction?: number): void;
  58938. }
  58939. }
  58940. declare module BABYLON {
  58941. /**
  58942. * Class used to help managing file picking and drag'n'drop
  58943. */
  58944. export class FilesInput {
  58945. /**
  58946. * List of files ready to be loaded
  58947. */
  58948. static readonly FilesToLoad: {
  58949. [key: string]: File;
  58950. };
  58951. /**
  58952. * Callback called when a file is processed
  58953. */
  58954. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58955. private _engine;
  58956. private _currentScene;
  58957. private _sceneLoadedCallback;
  58958. private _progressCallback;
  58959. private _additionalRenderLoopLogicCallback;
  58960. private _textureLoadingCallback;
  58961. private _startingProcessingFilesCallback;
  58962. private _onReloadCallback;
  58963. private _errorCallback;
  58964. private _elementToMonitor;
  58965. private _sceneFileToLoad;
  58966. private _filesToLoad;
  58967. /**
  58968. * Creates a new FilesInput
  58969. * @param engine defines the rendering engine
  58970. * @param scene defines the hosting scene
  58971. * @param sceneLoadedCallback callback called when scene is loaded
  58972. * @param progressCallback callback called to track progress
  58973. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58974. * @param textureLoadingCallback callback called when a texture is loading
  58975. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58976. * @param onReloadCallback callback called when a reload is requested
  58977. * @param errorCallback callback call if an error occurs
  58978. */
  58979. 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);
  58980. private _dragEnterHandler;
  58981. private _dragOverHandler;
  58982. private _dropHandler;
  58983. /**
  58984. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58985. * @param elementToMonitor defines the DOM element to track
  58986. */
  58987. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58988. /**
  58989. * Release all associated resources
  58990. */
  58991. dispose(): void;
  58992. private renderFunction;
  58993. private drag;
  58994. private drop;
  58995. private _traverseFolder;
  58996. private _processFiles;
  58997. /**
  58998. * Load files from a drop event
  58999. * @param event defines the drop event to use as source
  59000. */
  59001. loadFiles(event: any): void;
  59002. private _processReload;
  59003. /**
  59004. * Reload the current scene from the loaded files
  59005. */
  59006. reload(): void;
  59007. }
  59008. }
  59009. declare module BABYLON {
  59010. /**
  59011. * Defines the root class used to create scene optimization to use with SceneOptimizer
  59012. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59013. */
  59014. export class SceneOptimization {
  59015. /**
  59016. * Defines the priority of this optimization (0 by default which means first in the list)
  59017. */
  59018. priority: number;
  59019. /**
  59020. * Gets a string describing the action executed by the current optimization
  59021. * @returns description string
  59022. */
  59023. getDescription(): string;
  59024. /**
  59025. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59026. * @param scene defines the current scene where to apply this optimization
  59027. * @param optimizer defines the current optimizer
  59028. * @returns true if everything that can be done was applied
  59029. */
  59030. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59031. /**
  59032. * Creates the SceneOptimization object
  59033. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59034. * @param desc defines the description associated with the optimization
  59035. */
  59036. constructor(
  59037. /**
  59038. * Defines the priority of this optimization (0 by default which means first in the list)
  59039. */
  59040. priority?: number);
  59041. }
  59042. /**
  59043. * Defines an optimization used to reduce the size of render target textures
  59044. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59045. */
  59046. export class TextureOptimization extends SceneOptimization {
  59047. /**
  59048. * Defines the priority of this optimization (0 by default which means first in the list)
  59049. */
  59050. priority: number;
  59051. /**
  59052. * 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
  59053. */
  59054. maximumSize: number;
  59055. /**
  59056. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59057. */
  59058. step: number;
  59059. /**
  59060. * Gets a string describing the action executed by the current optimization
  59061. * @returns description string
  59062. */
  59063. getDescription(): string;
  59064. /**
  59065. * Creates the TextureOptimization object
  59066. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59067. * @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
  59068. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59069. */
  59070. constructor(
  59071. /**
  59072. * Defines the priority of this optimization (0 by default which means first in the list)
  59073. */
  59074. priority?: number,
  59075. /**
  59076. * 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
  59077. */
  59078. maximumSize?: number,
  59079. /**
  59080. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59081. */
  59082. step?: number);
  59083. /**
  59084. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59085. * @param scene defines the current scene where to apply this optimization
  59086. * @param optimizer defines the current optimizer
  59087. * @returns true if everything that can be done was applied
  59088. */
  59089. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59090. }
  59091. /**
  59092. * Defines an optimization used to increase or decrease the rendering resolution
  59093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59094. */
  59095. export class HardwareScalingOptimization extends SceneOptimization {
  59096. /**
  59097. * Defines the priority of this optimization (0 by default which means first in the list)
  59098. */
  59099. priority: number;
  59100. /**
  59101. * Defines the maximum scale to use (2 by default)
  59102. */
  59103. maximumScale: number;
  59104. /**
  59105. * Defines the step to use between two passes (0.5 by default)
  59106. */
  59107. step: number;
  59108. private _currentScale;
  59109. private _directionOffset;
  59110. /**
  59111. * Gets a string describing the action executed by the current optimization
  59112. * @return description string
  59113. */
  59114. getDescription(): string;
  59115. /**
  59116. * Creates the HardwareScalingOptimization object
  59117. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59118. * @param maximumScale defines the maximum scale to use (2 by default)
  59119. * @param step defines the step to use between two passes (0.5 by default)
  59120. */
  59121. constructor(
  59122. /**
  59123. * Defines the priority of this optimization (0 by default which means first in the list)
  59124. */
  59125. priority?: number,
  59126. /**
  59127. * Defines the maximum scale to use (2 by default)
  59128. */
  59129. maximumScale?: number,
  59130. /**
  59131. * Defines the step to use between two passes (0.5 by default)
  59132. */
  59133. step?: number);
  59134. /**
  59135. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59136. * @param scene defines the current scene where to apply this optimization
  59137. * @param optimizer defines the current optimizer
  59138. * @returns true if everything that can be done was applied
  59139. */
  59140. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59141. }
  59142. /**
  59143. * Defines an optimization used to remove shadows
  59144. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59145. */
  59146. export class ShadowsOptimization extends SceneOptimization {
  59147. /**
  59148. * Gets a string describing the action executed by the current optimization
  59149. * @return description string
  59150. */
  59151. getDescription(): string;
  59152. /**
  59153. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59154. * @param scene defines the current scene where to apply this optimization
  59155. * @param optimizer defines the current optimizer
  59156. * @returns true if everything that can be done was applied
  59157. */
  59158. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59159. }
  59160. /**
  59161. * Defines an optimization used to turn post-processes off
  59162. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59163. */
  59164. export class PostProcessesOptimization extends SceneOptimization {
  59165. /**
  59166. * Gets a string describing the action executed by the current optimization
  59167. * @return description string
  59168. */
  59169. getDescription(): string;
  59170. /**
  59171. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59172. * @param scene defines the current scene where to apply this optimization
  59173. * @param optimizer defines the current optimizer
  59174. * @returns true if everything that can be done was applied
  59175. */
  59176. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59177. }
  59178. /**
  59179. * Defines an optimization used to turn lens flares off
  59180. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59181. */
  59182. export class LensFlaresOptimization extends SceneOptimization {
  59183. /**
  59184. * Gets a string describing the action executed by the current optimization
  59185. * @return description string
  59186. */
  59187. getDescription(): string;
  59188. /**
  59189. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59190. * @param scene defines the current scene where to apply this optimization
  59191. * @param optimizer defines the current optimizer
  59192. * @returns true if everything that can be done was applied
  59193. */
  59194. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59195. }
  59196. /**
  59197. * Defines an optimization based on user defined callback.
  59198. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59199. */
  59200. export class CustomOptimization extends SceneOptimization {
  59201. /**
  59202. * Callback called to apply the custom optimization.
  59203. */
  59204. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  59205. /**
  59206. * Callback called to get custom description
  59207. */
  59208. onGetDescription: () => string;
  59209. /**
  59210. * Gets a string describing the action executed by the current optimization
  59211. * @returns description string
  59212. */
  59213. getDescription(): string;
  59214. /**
  59215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59216. * @param scene defines the current scene where to apply this optimization
  59217. * @param optimizer defines the current optimizer
  59218. * @returns true if everything that can be done was applied
  59219. */
  59220. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59221. }
  59222. /**
  59223. * Defines an optimization used to turn particles off
  59224. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59225. */
  59226. export class ParticlesOptimization extends SceneOptimization {
  59227. /**
  59228. * Gets a string describing the action executed by the current optimization
  59229. * @return description string
  59230. */
  59231. getDescription(): string;
  59232. /**
  59233. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59234. * @param scene defines the current scene where to apply this optimization
  59235. * @param optimizer defines the current optimizer
  59236. * @returns true if everything that can be done was applied
  59237. */
  59238. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59239. }
  59240. /**
  59241. * Defines an optimization used to turn render targets off
  59242. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59243. */
  59244. export class RenderTargetsOptimization extends SceneOptimization {
  59245. /**
  59246. * Gets a string describing the action executed by the current optimization
  59247. * @return description string
  59248. */
  59249. getDescription(): string;
  59250. /**
  59251. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59252. * @param scene defines the current scene where to apply this optimization
  59253. * @param optimizer defines the current optimizer
  59254. * @returns true if everything that can be done was applied
  59255. */
  59256. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59257. }
  59258. /**
  59259. * Defines an optimization used to merge meshes with compatible materials
  59260. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59261. */
  59262. export class MergeMeshesOptimization extends SceneOptimization {
  59263. private static _UpdateSelectionTree;
  59264. /**
  59265. * Gets or sets a boolean which defines if optimization octree has to be updated
  59266. */
  59267. /**
  59268. * Gets or sets a boolean which defines if optimization octree has to be updated
  59269. */
  59270. static UpdateSelectionTree: boolean;
  59271. /**
  59272. * Gets a string describing the action executed by the current optimization
  59273. * @return description string
  59274. */
  59275. getDescription(): string;
  59276. private _canBeMerged;
  59277. /**
  59278. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59279. * @param scene defines the current scene where to apply this optimization
  59280. * @param optimizer defines the current optimizer
  59281. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  59282. * @returns true if everything that can be done was applied
  59283. */
  59284. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  59285. }
  59286. /**
  59287. * Defines a list of options used by SceneOptimizer
  59288. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59289. */
  59290. export class SceneOptimizerOptions {
  59291. /**
  59292. * Defines the target frame rate to reach (60 by default)
  59293. */
  59294. targetFrameRate: number;
  59295. /**
  59296. * Defines the interval between two checkes (2000ms by default)
  59297. */
  59298. trackerDuration: number;
  59299. /**
  59300. * Gets the list of optimizations to apply
  59301. */
  59302. optimizations: SceneOptimization[];
  59303. /**
  59304. * Creates a new list of options used by SceneOptimizer
  59305. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  59306. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  59307. */
  59308. constructor(
  59309. /**
  59310. * Defines the target frame rate to reach (60 by default)
  59311. */
  59312. targetFrameRate?: number,
  59313. /**
  59314. * Defines the interval between two checkes (2000ms by default)
  59315. */
  59316. trackerDuration?: number);
  59317. /**
  59318. * Add a new optimization
  59319. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59320. * @returns the current SceneOptimizerOptions
  59321. */
  59322. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59323. /**
  59324. * Add a new custom optimization
  59325. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59326. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59327. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59328. * @returns the current SceneOptimizerOptions
  59329. */
  59330. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59331. /**
  59332. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59333. * @param targetFrameRate defines the target frame rate (60 by default)
  59334. * @returns a SceneOptimizerOptions object
  59335. */
  59336. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59337. /**
  59338. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59339. * @param targetFrameRate defines the target frame rate (60 by default)
  59340. * @returns a SceneOptimizerOptions object
  59341. */
  59342. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59343. /**
  59344. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59345. * @param targetFrameRate defines the target frame rate (60 by default)
  59346. * @returns a SceneOptimizerOptions object
  59347. */
  59348. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59349. }
  59350. /**
  59351. * Class used to run optimizations in order to reach a target frame rate
  59352. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59353. */
  59354. export class SceneOptimizer implements IDisposable {
  59355. private _isRunning;
  59356. private _options;
  59357. private _scene;
  59358. private _currentPriorityLevel;
  59359. private _targetFrameRate;
  59360. private _trackerDuration;
  59361. private _currentFrameRate;
  59362. private _sceneDisposeObserver;
  59363. private _improvementMode;
  59364. /**
  59365. * Defines an observable called when the optimizer reaches the target frame rate
  59366. */
  59367. onSuccessObservable: Observable<SceneOptimizer>;
  59368. /**
  59369. * Defines an observable called when the optimizer enables an optimization
  59370. */
  59371. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59372. /**
  59373. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59374. */
  59375. onFailureObservable: Observable<SceneOptimizer>;
  59376. /**
  59377. * Gets a boolean indicating if the optimizer is in improvement mode
  59378. */
  59379. readonly isInImprovementMode: boolean;
  59380. /**
  59381. * Gets the current priority level (0 at start)
  59382. */
  59383. readonly currentPriorityLevel: number;
  59384. /**
  59385. * Gets the current frame rate checked by the SceneOptimizer
  59386. */
  59387. readonly currentFrameRate: number;
  59388. /**
  59389. * Gets or sets the current target frame rate (60 by default)
  59390. */
  59391. /**
  59392. * Gets or sets the current target frame rate (60 by default)
  59393. */
  59394. targetFrameRate: number;
  59395. /**
  59396. * Gets or sets the current interval between two checks (every 2000ms by default)
  59397. */
  59398. /**
  59399. * Gets or sets the current interval between two checks (every 2000ms by default)
  59400. */
  59401. trackerDuration: number;
  59402. /**
  59403. * Gets the list of active optimizations
  59404. */
  59405. readonly optimizations: SceneOptimization[];
  59406. /**
  59407. * Creates a new SceneOptimizer
  59408. * @param scene defines the scene to work on
  59409. * @param options defines the options to use with the SceneOptimizer
  59410. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59411. * @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)
  59412. */
  59413. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59414. /**
  59415. * Stops the current optimizer
  59416. */
  59417. stop(): void;
  59418. /**
  59419. * Reset the optimizer to initial step (current priority level = 0)
  59420. */
  59421. reset(): void;
  59422. /**
  59423. * Start the optimizer. By default it will try to reach a specific framerate
  59424. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59425. */
  59426. start(): void;
  59427. private _checkCurrentState;
  59428. /**
  59429. * Release all resources
  59430. */
  59431. dispose(): void;
  59432. /**
  59433. * Helper function to create a SceneOptimizer with one single line of code
  59434. * @param scene defines the scene to work on
  59435. * @param options defines the options to use with the SceneOptimizer
  59436. * @param onSuccess defines a callback to call on success
  59437. * @param onFailure defines a callback to call on failure
  59438. * @returns the new SceneOptimizer object
  59439. */
  59440. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59441. }
  59442. }
  59443. declare module BABYLON {
  59444. /**
  59445. * Class used to serialize a scene into a string
  59446. */
  59447. export class SceneSerializer {
  59448. /**
  59449. * Clear cache used by a previous serialization
  59450. */
  59451. static ClearCache(): void;
  59452. /**
  59453. * Serialize a scene into a JSON compatible object
  59454. * @param scene defines the scene to serialize
  59455. * @returns a JSON compatible object
  59456. */
  59457. static Serialize(scene: Scene): any;
  59458. /**
  59459. * Serialize a mesh into a JSON compatible object
  59460. * @param toSerialize defines the mesh to serialize
  59461. * @param withParents defines if parents must be serialized as well
  59462. * @param withChildren defines if children must be serialized as well
  59463. * @returns a JSON compatible object
  59464. */
  59465. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59466. }
  59467. }
  59468. declare module BABYLON {
  59469. /**
  59470. * Class used to host texture specific utilities
  59471. */
  59472. export class TextureTools {
  59473. /**
  59474. * Uses the GPU to create a copy texture rescaled at a given size
  59475. * @param texture Texture to copy from
  59476. * @param width defines the desired width
  59477. * @param height defines the desired height
  59478. * @param useBilinearMode defines if bilinear mode has to be used
  59479. * @return the generated texture
  59480. */
  59481. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59482. }
  59483. }
  59484. declare module BABYLON {
  59485. /**
  59486. * This represents the different options available for the video capture.
  59487. */
  59488. export interface VideoRecorderOptions {
  59489. /** Defines the mime type of the video. */
  59490. mimeType: string;
  59491. /** Defines the FPS the video should be recorded at. */
  59492. fps: number;
  59493. /** Defines the chunk size for the recording data. */
  59494. recordChunckSize: number;
  59495. /** The audio tracks to attach to the recording. */
  59496. audioTracks?: MediaStreamTrack[];
  59497. }
  59498. /**
  59499. * This can help with recording videos from BabylonJS.
  59500. * This is based on the available WebRTC functionalities of the browser.
  59501. *
  59502. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59503. */
  59504. export class VideoRecorder {
  59505. private static readonly _defaultOptions;
  59506. /**
  59507. * Returns whether or not the VideoRecorder is available in your browser.
  59508. * @param engine Defines the Babylon Engine.
  59509. * @returns true if supported otherwise false.
  59510. */
  59511. static IsSupported(engine: Engine): boolean;
  59512. private readonly _options;
  59513. private _canvas;
  59514. private _mediaRecorder;
  59515. private _recordedChunks;
  59516. private _fileName;
  59517. private _resolve;
  59518. private _reject;
  59519. /**
  59520. * True when a recording is already in progress.
  59521. */
  59522. readonly isRecording: boolean;
  59523. /**
  59524. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  59525. * @param engine Defines the BabylonJS Engine you wish to record.
  59526. * @param options Defines options that can be used to customize the capture.
  59527. */
  59528. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59529. /**
  59530. * Stops the current recording before the default capture timeout passed in the startRecording function.
  59531. */
  59532. stopRecording(): void;
  59533. /**
  59534. * Starts recording the canvas for a max duration specified in parameters.
  59535. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  59536. * If null no automatic download will start and you can rely on the promise to get the data back.
  59537. * @param maxDuration Defines the maximum recording time in seconds.
  59538. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59539. * @return A promise callback at the end of the recording with the video data in Blob.
  59540. */
  59541. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59542. /**
  59543. * Releases internal resources used during the recording.
  59544. */
  59545. dispose(): void;
  59546. private _handleDataAvailable;
  59547. private _handleError;
  59548. private _handleStop;
  59549. }
  59550. }
  59551. declare module BABYLON {
  59552. /**
  59553. * Class containing a set of static utilities functions for screenshots
  59554. */
  59555. export class ScreenshotTools {
  59556. /**
  59557. * Captures a screenshot of the current rendering
  59558. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59559. * @param engine defines the rendering engine
  59560. * @param camera defines the source camera
  59561. * @param size This parameter can be set to a single number or to an object with the
  59562. * following (optional) properties: precision, width, height. If a single number is passed,
  59563. * it will be used for both width and height. If an object is passed, the screenshot size
  59564. * will be derived from the parameters. The precision property is a multiplier allowing
  59565. * rendering at a higher or lower resolution
  59566. * @param successCallback defines the callback receives a single parameter which contains the
  59567. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59568. * src parameter of an <img> to display it
  59569. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59570. * Check your browser for supported MIME types
  59571. */
  59572. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59573. /**
  59574. * Generates an image screenshot from the specified camera.
  59575. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59576. * @param engine The engine to use for rendering
  59577. * @param camera The camera to use for rendering
  59578. * @param size This parameter can be set to a single number or to an object with the
  59579. * following (optional) properties: precision, width, height. If a single number is passed,
  59580. * it will be used for both width and height. If an object is passed, the screenshot size
  59581. * will be derived from the parameters. The precision property is a multiplier allowing
  59582. * rendering at a higher or lower resolution
  59583. * @param successCallback The callback receives a single parameter which contains the
  59584. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59585. * src parameter of an <img> to display it
  59586. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59587. * Check your browser for supported MIME types
  59588. * @param samples Texture samples (default: 1)
  59589. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59590. * @param fileName A name for for the downloaded file.
  59591. */
  59592. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59593. }
  59594. }
  59595. declare module BABYLON {
  59596. /**
  59597. * A cursor which tracks a point on a path
  59598. */
  59599. export class PathCursor {
  59600. private path;
  59601. /**
  59602. * Stores path cursor callbacks for when an onchange event is triggered
  59603. */
  59604. private _onchange;
  59605. /**
  59606. * The value of the path cursor
  59607. */
  59608. value: number;
  59609. /**
  59610. * The animation array of the path cursor
  59611. */
  59612. animations: Animation[];
  59613. /**
  59614. * Initializes the path cursor
  59615. * @param path The path to track
  59616. */
  59617. constructor(path: Path2);
  59618. /**
  59619. * Gets the cursor point on the path
  59620. * @returns A point on the path cursor at the cursor location
  59621. */
  59622. getPoint(): Vector3;
  59623. /**
  59624. * Moves the cursor ahead by the step amount
  59625. * @param step The amount to move the cursor forward
  59626. * @returns This path cursor
  59627. */
  59628. moveAhead(step?: number): PathCursor;
  59629. /**
  59630. * Moves the cursor behind by the step amount
  59631. * @param step The amount to move the cursor back
  59632. * @returns This path cursor
  59633. */
  59634. moveBack(step?: number): PathCursor;
  59635. /**
  59636. * Moves the cursor by the step amount
  59637. * If the step amount is greater than one, an exception is thrown
  59638. * @param step The amount to move the cursor
  59639. * @returns This path cursor
  59640. */
  59641. move(step: number): PathCursor;
  59642. /**
  59643. * Ensures that the value is limited between zero and one
  59644. * @returns This path cursor
  59645. */
  59646. private ensureLimits;
  59647. /**
  59648. * Runs onchange callbacks on change (used by the animation engine)
  59649. * @returns This path cursor
  59650. */
  59651. private raiseOnChange;
  59652. /**
  59653. * Executes a function on change
  59654. * @param f A path cursor onchange callback
  59655. * @returns This path cursor
  59656. */
  59657. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59658. }
  59659. }
  59660. declare module BABYLON {
  59661. /** @hidden */
  59662. export var blurPixelShader: {
  59663. name: string;
  59664. shader: string;
  59665. };
  59666. }
  59667. declare module BABYLON {
  59668. /** @hidden */
  59669. export var pointCloudVertexDeclaration: {
  59670. name: string;
  59671. shader: string;
  59672. };
  59673. }
  59674. // Mixins
  59675. interface Window {
  59676. mozIndexedDB: IDBFactory;
  59677. webkitIndexedDB: IDBFactory;
  59678. msIndexedDB: IDBFactory;
  59679. webkitURL: typeof URL;
  59680. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59681. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59682. WebGLRenderingContext: WebGLRenderingContext;
  59683. MSGesture: MSGesture;
  59684. CANNON: any;
  59685. AudioContext: AudioContext;
  59686. webkitAudioContext: AudioContext;
  59687. PointerEvent: any;
  59688. Math: Math;
  59689. Uint8Array: Uint8ArrayConstructor;
  59690. Float32Array: Float32ArrayConstructor;
  59691. mozURL: typeof URL;
  59692. msURL: typeof URL;
  59693. VRFrameData: any; // WebVR, from specs 1.1
  59694. DracoDecoderModule: any;
  59695. setImmediate(handler: (...args: any[]) => void): number;
  59696. }
  59697. interface HTMLCanvasElement {
  59698. requestPointerLock(): void;
  59699. msRequestPointerLock?(): void;
  59700. mozRequestPointerLock?(): void;
  59701. webkitRequestPointerLock?(): void;
  59702. /** Track wether a record is in progress */
  59703. isRecording: boolean;
  59704. /** Capture Stream method defined by some browsers */
  59705. captureStream(fps?: number): MediaStream;
  59706. }
  59707. interface CanvasRenderingContext2D {
  59708. msImageSmoothingEnabled: boolean;
  59709. }
  59710. interface MouseEvent {
  59711. mozMovementX: number;
  59712. mozMovementY: number;
  59713. webkitMovementX: number;
  59714. webkitMovementY: number;
  59715. msMovementX: number;
  59716. msMovementY: number;
  59717. }
  59718. interface Navigator {
  59719. mozGetVRDevices: (any: any) => any;
  59720. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59721. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59722. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59723. webkitGetGamepads(): Gamepad[];
  59724. msGetGamepads(): Gamepad[];
  59725. webkitGamepads(): Gamepad[];
  59726. }
  59727. interface HTMLVideoElement {
  59728. mozSrcObject: any;
  59729. }
  59730. interface Math {
  59731. fround(x: number): number;
  59732. imul(a: number, b: number): number;
  59733. }
  59734. interface WebGLRenderingContext {
  59735. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59736. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59737. vertexAttribDivisor(index: number, divisor: number): void;
  59738. createVertexArray(): any;
  59739. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59740. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59741. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59742. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59743. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59744. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59745. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59746. // Queries
  59747. createQuery(): WebGLQuery;
  59748. deleteQuery(query: WebGLQuery): void;
  59749. beginQuery(target: number, query: WebGLQuery): void;
  59750. endQuery(target: number): void;
  59751. getQueryParameter(query: WebGLQuery, pname: number): any;
  59752. getQuery(target: number, pname: number): any;
  59753. MAX_SAMPLES: number;
  59754. RGBA8: number;
  59755. READ_FRAMEBUFFER: number;
  59756. DRAW_FRAMEBUFFER: number;
  59757. UNIFORM_BUFFER: number;
  59758. HALF_FLOAT_OES: number;
  59759. RGBA16F: number;
  59760. RGBA32F: number;
  59761. R32F: number;
  59762. RG32F: number;
  59763. RGB32F: number;
  59764. R16F: number;
  59765. RG16F: number;
  59766. RGB16F: number;
  59767. RED: number;
  59768. RG: number;
  59769. R8: number;
  59770. RG8: number;
  59771. UNSIGNED_INT_24_8: number;
  59772. DEPTH24_STENCIL8: number;
  59773. /* Multiple Render Targets */
  59774. drawBuffers(buffers: number[]): void;
  59775. readBuffer(src: number): void;
  59776. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59777. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59778. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59779. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59780. // Occlusion Query
  59781. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59782. ANY_SAMPLES_PASSED: number;
  59783. QUERY_RESULT_AVAILABLE: number;
  59784. QUERY_RESULT: number;
  59785. }
  59786. interface WebGLProgram {
  59787. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59788. }
  59789. interface EXT_disjoint_timer_query {
  59790. QUERY_COUNTER_BITS_EXT: number;
  59791. TIME_ELAPSED_EXT: number;
  59792. TIMESTAMP_EXT: number;
  59793. GPU_DISJOINT_EXT: number;
  59794. QUERY_RESULT_EXT: number;
  59795. QUERY_RESULT_AVAILABLE_EXT: number;
  59796. queryCounterEXT(query: WebGLQuery, target: number): void;
  59797. createQueryEXT(): WebGLQuery;
  59798. beginQueryEXT(target: number, query: WebGLQuery): void;
  59799. endQueryEXT(target: number): void;
  59800. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59801. deleteQueryEXT(query: WebGLQuery): void;
  59802. }
  59803. interface WebGLUniformLocation {
  59804. _currentState: any;
  59805. }
  59806. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59807. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59808. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59809. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59810. interface WebGLRenderingContext {
  59811. readonly RASTERIZER_DISCARD: number;
  59812. readonly DEPTH_COMPONENT24: number;
  59813. readonly TEXTURE_3D: number;
  59814. readonly TEXTURE_2D_ARRAY: number;
  59815. readonly TEXTURE_COMPARE_FUNC: number;
  59816. readonly TEXTURE_COMPARE_MODE: number;
  59817. readonly COMPARE_REF_TO_TEXTURE: number;
  59818. readonly TEXTURE_WRAP_R: number;
  59819. readonly HALF_FLOAT: number;
  59820. readonly RGB8: number;
  59821. readonly RED_INTEGER: number;
  59822. readonly RG_INTEGER: number;
  59823. readonly RGB_INTEGER: number;
  59824. readonly RGBA_INTEGER: number;
  59825. readonly R8_SNORM: number;
  59826. readonly RG8_SNORM: number;
  59827. readonly RGB8_SNORM: number;
  59828. readonly RGBA8_SNORM: number;
  59829. readonly R8I: number;
  59830. readonly RG8I: number;
  59831. readonly RGB8I: number;
  59832. readonly RGBA8I: number;
  59833. readonly R8UI: number;
  59834. readonly RG8UI: number;
  59835. readonly RGB8UI: number;
  59836. readonly RGBA8UI: number;
  59837. readonly R16I: number;
  59838. readonly RG16I: number;
  59839. readonly RGB16I: number;
  59840. readonly RGBA16I: number;
  59841. readonly R16UI: number;
  59842. readonly RG16UI: number;
  59843. readonly RGB16UI: number;
  59844. readonly RGBA16UI: number;
  59845. readonly R32I: number;
  59846. readonly RG32I: number;
  59847. readonly RGB32I: number;
  59848. readonly RGBA32I: number;
  59849. readonly R32UI: number;
  59850. readonly RG32UI: number;
  59851. readonly RGB32UI: number;
  59852. readonly RGBA32UI: number;
  59853. readonly RGB10_A2UI: number;
  59854. readonly R11F_G11F_B10F: number;
  59855. readonly RGB9_E5: number;
  59856. readonly RGB10_A2: number;
  59857. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59858. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59859. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59860. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59861. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59862. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59863. 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;
  59864. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59865. readonly TRANSFORM_FEEDBACK: number;
  59866. readonly INTERLEAVED_ATTRIBS: number;
  59867. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59868. createTransformFeedback(): WebGLTransformFeedback;
  59869. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59870. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59871. beginTransformFeedback(primitiveMode: number): void;
  59872. endTransformFeedback(): void;
  59873. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59874. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59875. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59876. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59877. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59878. }
  59879. interface ImageBitmap {
  59880. readonly width: number;
  59881. readonly height: number;
  59882. close(): void;
  59883. }
  59884. interface WebGLQuery extends WebGLObject {
  59885. }
  59886. declare var WebGLQuery: {
  59887. prototype: WebGLQuery;
  59888. new(): WebGLQuery;
  59889. };
  59890. interface WebGLSampler extends WebGLObject {
  59891. }
  59892. declare var WebGLSampler: {
  59893. prototype: WebGLSampler;
  59894. new(): WebGLSampler;
  59895. };
  59896. interface WebGLSync extends WebGLObject {
  59897. }
  59898. declare var WebGLSync: {
  59899. prototype: WebGLSync;
  59900. new(): WebGLSync;
  59901. };
  59902. interface WebGLTransformFeedback extends WebGLObject {
  59903. }
  59904. declare var WebGLTransformFeedback: {
  59905. prototype: WebGLTransformFeedback;
  59906. new(): WebGLTransformFeedback;
  59907. };
  59908. interface WebGLVertexArrayObject extends WebGLObject {
  59909. }
  59910. declare var WebGLVertexArrayObject: {
  59911. prototype: WebGLVertexArrayObject;
  59912. new(): WebGLVertexArrayObject;
  59913. };
  59914. // Type definitions for WebVR API
  59915. // Project: https://w3c.github.io/webvr/
  59916. // Definitions by: six a <https://github.com/lostfictions>
  59917. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59918. interface VRDisplay extends EventTarget {
  59919. /**
  59920. * Dictionary of capabilities describing the VRDisplay.
  59921. */
  59922. readonly capabilities: VRDisplayCapabilities;
  59923. /**
  59924. * z-depth defining the far plane of the eye view frustum
  59925. * enables mapping of values in the render target depth
  59926. * attachment to scene coordinates. Initially set to 10000.0.
  59927. */
  59928. depthFar: number;
  59929. /**
  59930. * z-depth defining the near plane of the eye view frustum
  59931. * enables mapping of values in the render target depth
  59932. * attachment to scene coordinates. Initially set to 0.01.
  59933. */
  59934. depthNear: number;
  59935. /**
  59936. * An identifier for this distinct VRDisplay. Used as an
  59937. * association point in the Gamepad API.
  59938. */
  59939. readonly displayId: number;
  59940. /**
  59941. * A display name, a user-readable name identifying it.
  59942. */
  59943. readonly displayName: string;
  59944. readonly isConnected: boolean;
  59945. readonly isPresenting: boolean;
  59946. /**
  59947. * If this VRDisplay supports room-scale experiences, the optional
  59948. * stage attribute contains details on the room-scale parameters.
  59949. */
  59950. readonly stageParameters: VRStageParameters | null;
  59951. /**
  59952. * Passing the value returned by `requestAnimationFrame` to
  59953. * `cancelAnimationFrame` will unregister the callback.
  59954. * @param handle Define the hanle of the request to cancel
  59955. */
  59956. cancelAnimationFrame(handle: number): void;
  59957. /**
  59958. * Stops presenting to the VRDisplay.
  59959. * @returns a promise to know when it stopped
  59960. */
  59961. exitPresent(): Promise<void>;
  59962. /**
  59963. * Return the current VREyeParameters for the given eye.
  59964. * @param whichEye Define the eye we want the parameter for
  59965. * @returns the eye parameters
  59966. */
  59967. getEyeParameters(whichEye: string): VREyeParameters;
  59968. /**
  59969. * Populates the passed VRFrameData with the information required to render
  59970. * the current frame.
  59971. * @param frameData Define the data structure to populate
  59972. * @returns true if ok otherwise false
  59973. */
  59974. getFrameData(frameData: VRFrameData): boolean;
  59975. /**
  59976. * Get the layers currently being presented.
  59977. * @returns the list of VR layers
  59978. */
  59979. getLayers(): VRLayer[];
  59980. /**
  59981. * Return a VRPose containing the future predicted pose of the VRDisplay
  59982. * when the current frame will be presented. The value returned will not
  59983. * change until JavaScript has returned control to the browser.
  59984. *
  59985. * The VRPose will contain the position, orientation, velocity,
  59986. * and acceleration of each of these properties.
  59987. * @returns the pose object
  59988. */
  59989. getPose(): VRPose;
  59990. /**
  59991. * Return the current instantaneous pose of the VRDisplay, with no
  59992. * prediction applied.
  59993. * @returns the current instantaneous pose
  59994. */
  59995. getImmediatePose(): VRPose;
  59996. /**
  59997. * The callback passed to `requestAnimationFrame` will be called
  59998. * any time a new frame should be rendered. When the VRDisplay is
  59999. * presenting the callback will be called at the native refresh
  60000. * rate of the HMD. When not presenting this function acts
  60001. * identically to how window.requestAnimationFrame acts. Content should
  60002. * make no assumptions of frame rate or vsync behavior as the HMD runs
  60003. * asynchronously from other displays and at differing refresh rates.
  60004. * @param callback Define the eaction to run next frame
  60005. * @returns the request handle it
  60006. */
  60007. requestAnimationFrame(callback: FrameRequestCallback): number;
  60008. /**
  60009. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  60010. * Repeat calls while already presenting will update the VRLayers being displayed.
  60011. * @param layers Define the list of layer to present
  60012. * @returns a promise to know when the request has been fulfilled
  60013. */
  60014. requestPresent(layers: VRLayer[]): Promise<void>;
  60015. /**
  60016. * Reset the pose for this display, treating its current position and
  60017. * orientation as the "origin/zero" values. VRPose.position,
  60018. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  60019. * updated when calling resetPose(). This should be called in only
  60020. * sitting-space experiences.
  60021. */
  60022. resetPose(): void;
  60023. /**
  60024. * The VRLayer provided to the VRDisplay will be captured and presented
  60025. * in the HMD. Calling this function has the same effect on the source
  60026. * canvas as any other operation that uses its source image, and canvases
  60027. * created without preserveDrawingBuffer set to true will be cleared.
  60028. * @param pose Define the pose to submit
  60029. */
  60030. submitFrame(pose?: VRPose): void;
  60031. }
  60032. declare var VRDisplay: {
  60033. prototype: VRDisplay;
  60034. new(): VRDisplay;
  60035. };
  60036. interface VRLayer {
  60037. leftBounds?: number[] | Float32Array | null;
  60038. rightBounds?: number[] | Float32Array | null;
  60039. source?: HTMLCanvasElement | null;
  60040. }
  60041. interface VRDisplayCapabilities {
  60042. readonly canPresent: boolean;
  60043. readonly hasExternalDisplay: boolean;
  60044. readonly hasOrientation: boolean;
  60045. readonly hasPosition: boolean;
  60046. readonly maxLayers: number;
  60047. }
  60048. interface VREyeParameters {
  60049. /** @deprecated */
  60050. readonly fieldOfView: VRFieldOfView;
  60051. readonly offset: Float32Array;
  60052. readonly renderHeight: number;
  60053. readonly renderWidth: number;
  60054. }
  60055. interface VRFieldOfView {
  60056. readonly downDegrees: number;
  60057. readonly leftDegrees: number;
  60058. readonly rightDegrees: number;
  60059. readonly upDegrees: number;
  60060. }
  60061. interface VRFrameData {
  60062. readonly leftProjectionMatrix: Float32Array;
  60063. readonly leftViewMatrix: Float32Array;
  60064. readonly pose: VRPose;
  60065. readonly rightProjectionMatrix: Float32Array;
  60066. readonly rightViewMatrix: Float32Array;
  60067. readonly timestamp: number;
  60068. }
  60069. interface VRPose {
  60070. readonly angularAcceleration: Float32Array | null;
  60071. readonly angularVelocity: Float32Array | null;
  60072. readonly linearAcceleration: Float32Array | null;
  60073. readonly linearVelocity: Float32Array | null;
  60074. readonly orientation: Float32Array | null;
  60075. readonly position: Float32Array | null;
  60076. readonly timestamp: number;
  60077. }
  60078. interface VRStageParameters {
  60079. sittingToStandingTransform?: Float32Array;
  60080. sizeX?: number;
  60081. sizeY?: number;
  60082. }
  60083. interface Navigator {
  60084. getVRDisplays(): Promise<VRDisplay[]>;
  60085. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  60086. }
  60087. interface Window {
  60088. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  60089. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  60090. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  60091. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60092. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60093. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  60094. }
  60095. interface Gamepad {
  60096. readonly displayId: number;
  60097. }
  60098. type XRSessionMode =
  60099. | "inline"
  60100. | "immersive-vr"
  60101. | "immersive-ar";
  60102. type XRReferenceSpaceType =
  60103. | "viewer"
  60104. | "local"
  60105. | "local-floor"
  60106. | "bounded-floor"
  60107. | "unbounded";
  60108. type XREnvironmentBlendMode =
  60109. | "opaque"
  60110. | "additive"
  60111. | "alpha-blend";
  60112. type XRVisibilityState =
  60113. | "visible"
  60114. | "visible-blurred"
  60115. | "hidden";
  60116. type XRHandedness =
  60117. | "none"
  60118. | "left"
  60119. | "right";
  60120. type XRTargetRayMode =
  60121. | "gaze"
  60122. | "tracked-pointer"
  60123. | "screen";
  60124. type XREye =
  60125. | "none"
  60126. | "left"
  60127. | "right";
  60128. interface XRSpace extends EventTarget {
  60129. }
  60130. interface XRRenderState {
  60131. depthNear: number ;
  60132. depthFar: number ;
  60133. inlineVerticalFieldOfView: number | undefined;
  60134. baseLayer: XRWebGLLayer | undefined;
  60135. }
  60136. interface XRInputSource {
  60137. handedness: XRHandedness;
  60138. targetRayMode: XRTargetRayMode;
  60139. targetRaySpace: XRSpace;
  60140. gripSpace: XRSpace | undefined;
  60141. gamepad: Gamepad | undefined;
  60142. profiles: Array<string>;
  60143. }
  60144. interface XRSession {
  60145. addEventListener: Function;
  60146. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  60147. updateRenderState(XRRenderStateInit: any): Promise<void>;
  60148. requestAnimationFrame: Function;
  60149. end(): Promise<void>;
  60150. renderState: XRRenderState;
  60151. inputSources: Array<XRInputSource>;
  60152. }
  60153. interface XRReferenceSpace extends XRSpace {
  60154. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  60155. onreset: any;
  60156. }
  60157. interface XRFrame {
  60158. session: XRSession;
  60159. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  60160. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  60161. }
  60162. interface XRViewerPose extends XRPose {
  60163. views: Array<XRView>;
  60164. }
  60165. interface XRPose {
  60166. transform: XRRigidTransform;
  60167. emulatedPosition: boolean;
  60168. }
  60169. declare var XRWebGLLayer: {
  60170. prototype: XRWebGLLayer;
  60171. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  60172. };
  60173. interface XRWebGLLayer {
  60174. framebuffer: WebGLFramebuffer;
  60175. framebufferWidth: number;
  60176. framebufferHeight: number;
  60177. getViewport: Function;
  60178. }
  60179. interface XRRigidTransform {
  60180. position: DOMPointReadOnly;
  60181. orientation: DOMPointReadOnly;
  60182. matrix: Float32Array;
  60183. inverse: XRRigidTransform;
  60184. }
  60185. interface XRView {
  60186. eye: XREye;
  60187. projectionMatrix: Float32Array;
  60188. transform: XRRigidTransform;
  60189. }
  60190. interface XRInputSourceChangeEvent {
  60191. session: XRSession;
  60192. removed: Array<XRInputSource>;
  60193. added: Array<XRInputSource>;
  60194. }
  60195. declare module BABYLON.GUI {
  60196. /**
  60197. * Class used to specific a value and its associated unit
  60198. */
  60199. export class ValueAndUnit {
  60200. /** defines the unit to store */
  60201. unit: number;
  60202. /** defines a boolean indicating if the value can be negative */
  60203. negativeValueAllowed: boolean;
  60204. private _value;
  60205. private _originalUnit;
  60206. /**
  60207. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  60208. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60209. */
  60210. ignoreAdaptiveScaling: boolean;
  60211. /**
  60212. * Creates a new ValueAndUnit
  60213. * @param value defines the value to store
  60214. * @param unit defines the unit to store
  60215. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  60216. */
  60217. constructor(value: number,
  60218. /** defines the unit to store */
  60219. unit?: number,
  60220. /** defines a boolean indicating if the value can be negative */
  60221. negativeValueAllowed?: boolean);
  60222. /** Gets a boolean indicating if the value is a percentage */
  60223. readonly isPercentage: boolean;
  60224. /** Gets a boolean indicating if the value is store as pixel */
  60225. readonly isPixel: boolean;
  60226. /** Gets direct internal value */
  60227. readonly internalValue: number;
  60228. /**
  60229. * Gets value as pixel
  60230. * @param host defines the root host
  60231. * @param refValue defines the reference value for percentages
  60232. * @returns the value as pixel
  60233. */
  60234. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  60235. /**
  60236. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  60237. * @param value defines the value to store
  60238. * @param unit defines the unit to store
  60239. * @returns the current ValueAndUnit
  60240. */
  60241. updateInPlace(value: number, unit?: number): ValueAndUnit;
  60242. /**
  60243. * Gets the value accordingly to its unit
  60244. * @param host defines the root host
  60245. * @returns the value
  60246. */
  60247. getValue(host: AdvancedDynamicTexture): number;
  60248. /**
  60249. * Gets a string representation of the value
  60250. * @param host defines the root host
  60251. * @param decimals defines an optional number of decimals to display
  60252. * @returns a string
  60253. */
  60254. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  60255. /**
  60256. * Store a value parsed from a string
  60257. * @param source defines the source string
  60258. * @returns true if the value was successfully parsed
  60259. */
  60260. fromString(source: string | number): boolean;
  60261. private static _Regex;
  60262. private static _UNITMODE_PERCENTAGE;
  60263. private static _UNITMODE_PIXEL;
  60264. /** UNITMODE_PERCENTAGE */
  60265. static readonly UNITMODE_PERCENTAGE: number;
  60266. /** UNITMODE_PIXEL */
  60267. static readonly UNITMODE_PIXEL: number;
  60268. }
  60269. }
  60270. declare module BABYLON.GUI {
  60271. /**
  60272. * Define a style used by control to automatically setup properties based on a template.
  60273. * Only support font related properties so far
  60274. */
  60275. export class Style implements BABYLON.IDisposable {
  60276. private _fontFamily;
  60277. private _fontStyle;
  60278. private _fontWeight;
  60279. /** @hidden */
  60280. _host: AdvancedDynamicTexture;
  60281. /** @hidden */
  60282. _fontSize: ValueAndUnit;
  60283. /**
  60284. * BABYLON.Observable raised when the style values are changed
  60285. */
  60286. onChangedObservable: BABYLON.Observable<Style>;
  60287. /**
  60288. * Creates a new style object
  60289. * @param host defines the AdvancedDynamicTexture which hosts this style
  60290. */
  60291. constructor(host: AdvancedDynamicTexture);
  60292. /**
  60293. * Gets or sets the font size
  60294. */
  60295. fontSize: string | number;
  60296. /**
  60297. * Gets or sets the font family
  60298. */
  60299. fontFamily: string;
  60300. /**
  60301. * Gets or sets the font style
  60302. */
  60303. fontStyle: string;
  60304. /** Gets or sets font weight */
  60305. fontWeight: string;
  60306. /** Dispose all associated resources */
  60307. dispose(): void;
  60308. }
  60309. }
  60310. declare module BABYLON.GUI {
  60311. /**
  60312. * Class used to transport BABYLON.Vector2 information for pointer events
  60313. */
  60314. export class Vector2WithInfo extends BABYLON.Vector2 {
  60315. /** defines the current mouse button index */
  60316. buttonIndex: number;
  60317. /**
  60318. * Creates a new Vector2WithInfo
  60319. * @param source defines the vector2 data to transport
  60320. * @param buttonIndex defines the current mouse button index
  60321. */
  60322. constructor(source: BABYLON.Vector2,
  60323. /** defines the current mouse button index */
  60324. buttonIndex?: number);
  60325. }
  60326. /** Class used to provide 2D matrix features */
  60327. export class Matrix2D {
  60328. /** Gets the internal array of 6 floats used to store matrix data */
  60329. m: Float32Array;
  60330. /**
  60331. * Creates a new matrix
  60332. * @param m00 defines value for (0, 0)
  60333. * @param m01 defines value for (0, 1)
  60334. * @param m10 defines value for (1, 0)
  60335. * @param m11 defines value for (1, 1)
  60336. * @param m20 defines value for (2, 0)
  60337. * @param m21 defines value for (2, 1)
  60338. */
  60339. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  60340. /**
  60341. * Fills the matrix from direct values
  60342. * @param m00 defines value for (0, 0)
  60343. * @param m01 defines value for (0, 1)
  60344. * @param m10 defines value for (1, 0)
  60345. * @param m11 defines value for (1, 1)
  60346. * @param m20 defines value for (2, 0)
  60347. * @param m21 defines value for (2, 1)
  60348. * @returns the current modified matrix
  60349. */
  60350. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  60351. /**
  60352. * Gets matrix determinant
  60353. * @returns the determinant
  60354. */
  60355. determinant(): number;
  60356. /**
  60357. * Inverses the matrix and stores it in a target matrix
  60358. * @param result defines the target matrix
  60359. * @returns the current matrix
  60360. */
  60361. invertToRef(result: Matrix2D): Matrix2D;
  60362. /**
  60363. * Multiplies the current matrix with another one
  60364. * @param other defines the second operand
  60365. * @param result defines the target matrix
  60366. * @returns the current matrix
  60367. */
  60368. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  60369. /**
  60370. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  60371. * @param x defines the x coordinate to transform
  60372. * @param y defines the x coordinate to transform
  60373. * @param result defines the target vector2
  60374. * @returns the current matrix
  60375. */
  60376. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  60377. /**
  60378. * Creates an identity matrix
  60379. * @returns a new matrix
  60380. */
  60381. static Identity(): Matrix2D;
  60382. /**
  60383. * Creates a translation matrix and stores it in a target matrix
  60384. * @param x defines the x coordinate of the translation
  60385. * @param y defines the y coordinate of the translation
  60386. * @param result defines the target matrix
  60387. */
  60388. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  60389. /**
  60390. * Creates a scaling matrix and stores it in a target matrix
  60391. * @param x defines the x coordinate of the scaling
  60392. * @param y defines the y coordinate of the scaling
  60393. * @param result defines the target matrix
  60394. */
  60395. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  60396. /**
  60397. * Creates a rotation matrix and stores it in a target matrix
  60398. * @param angle defines the rotation angle
  60399. * @param result defines the target matrix
  60400. */
  60401. static RotationToRef(angle: number, result: Matrix2D): void;
  60402. private static _TempPreTranslationMatrix;
  60403. private static _TempPostTranslationMatrix;
  60404. private static _TempRotationMatrix;
  60405. private static _TempScalingMatrix;
  60406. private static _TempCompose0;
  60407. private static _TempCompose1;
  60408. private static _TempCompose2;
  60409. /**
  60410. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  60411. * @param tx defines the x coordinate of the translation
  60412. * @param ty defines the y coordinate of the translation
  60413. * @param angle defines the rotation angle
  60414. * @param scaleX defines the x coordinate of the scaling
  60415. * @param scaleY defines the y coordinate of the scaling
  60416. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  60417. * @param result defines the target matrix
  60418. */
  60419. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  60420. }
  60421. }
  60422. declare module BABYLON.GUI {
  60423. /**
  60424. * Class used to store 2D control sizes
  60425. */
  60426. export class Measure {
  60427. /** defines left coordinate */
  60428. left: number;
  60429. /** defines top coordinate */
  60430. top: number;
  60431. /** defines width dimension */
  60432. width: number;
  60433. /** defines height dimension */
  60434. height: number;
  60435. /**
  60436. * Creates a new measure
  60437. * @param left defines left coordinate
  60438. * @param top defines top coordinate
  60439. * @param width defines width dimension
  60440. * @param height defines height dimension
  60441. */
  60442. constructor(
  60443. /** defines left coordinate */
  60444. left: number,
  60445. /** defines top coordinate */
  60446. top: number,
  60447. /** defines width dimension */
  60448. width: number,
  60449. /** defines height dimension */
  60450. height: number);
  60451. /**
  60452. * Copy from another measure
  60453. * @param other defines the other measure to copy from
  60454. */
  60455. copyFrom(other: Measure): void;
  60456. /**
  60457. * Copy from a group of 4 floats
  60458. * @param left defines left coordinate
  60459. * @param top defines top coordinate
  60460. * @param width defines width dimension
  60461. * @param height defines height dimension
  60462. */
  60463. copyFromFloats(left: number, top: number, width: number, height: number): void;
  60464. /**
  60465. * Computes the axis aligned bounding box measure for two given measures
  60466. * @param a Input measure
  60467. * @param b Input measure
  60468. * @param result the resulting bounding measure
  60469. */
  60470. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  60471. /**
  60472. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  60473. * @param transform the matrix to transform the measure before computing the AABB
  60474. * @param result the resulting AABB
  60475. */
  60476. transformToRef(transform: Matrix2D, result: Measure): void;
  60477. /**
  60478. * Check equality between this measure and another one
  60479. * @param other defines the other measures
  60480. * @returns true if both measures are equals
  60481. */
  60482. isEqualsTo(other: Measure): boolean;
  60483. /**
  60484. * Creates an empty measure
  60485. * @returns a new measure
  60486. */
  60487. static Empty(): Measure;
  60488. }
  60489. }
  60490. declare module BABYLON.GUI {
  60491. /**
  60492. * Interface used to define a control that can receive focus
  60493. */
  60494. export interface IFocusableControl {
  60495. /**
  60496. * Function called when the control receives the focus
  60497. */
  60498. onFocus(): void;
  60499. /**
  60500. * Function called when the control loses the focus
  60501. */
  60502. onBlur(): void;
  60503. /**
  60504. * Function called to let the control handle keyboard events
  60505. * @param evt defines the current keyboard event
  60506. */
  60507. processKeyboard(evt: KeyboardEvent): void;
  60508. /**
  60509. * Function called to get the list of controls that should not steal the focus from this control
  60510. * @returns an array of controls
  60511. */
  60512. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60513. }
  60514. /**
  60515. * Class used to create texture to support 2D GUI elements
  60516. * @see http://doc.babylonjs.com/how_to/gui
  60517. */
  60518. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  60519. private _isDirty;
  60520. private _renderObserver;
  60521. private _resizeObserver;
  60522. private _preKeyboardObserver;
  60523. private _pointerMoveObserver;
  60524. private _pointerObserver;
  60525. private _canvasPointerOutObserver;
  60526. private _background;
  60527. /** @hidden */
  60528. _rootContainer: Container;
  60529. /** @hidden */
  60530. _lastPickedControl: Control;
  60531. /** @hidden */
  60532. _lastControlOver: {
  60533. [pointerId: number]: Control;
  60534. };
  60535. /** @hidden */
  60536. _lastControlDown: {
  60537. [pointerId: number]: Control;
  60538. };
  60539. /** @hidden */
  60540. _capturingControl: {
  60541. [pointerId: number]: Control;
  60542. };
  60543. /** @hidden */
  60544. _shouldBlockPointer: boolean;
  60545. /** @hidden */
  60546. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  60547. /** @hidden */
  60548. _linkedControls: Control[];
  60549. private _isFullscreen;
  60550. private _fullscreenViewport;
  60551. private _idealWidth;
  60552. private _idealHeight;
  60553. private _useSmallestIdeal;
  60554. private _renderAtIdealSize;
  60555. private _focusedControl;
  60556. private _blockNextFocusCheck;
  60557. private _renderScale;
  60558. private _rootCanvas;
  60559. private _cursorChanged;
  60560. /**
  60561. * Define type to string to ensure compatibility across browsers
  60562. * Safari doesn't support DataTransfer constructor
  60563. */
  60564. private _clipboardData;
  60565. /**
  60566. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  60567. */
  60568. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  60569. /**
  60570. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  60571. */
  60572. onControlPickedObservable: BABYLON.Observable<Control>;
  60573. /**
  60574. * BABYLON.Observable event triggered before layout is evaluated
  60575. */
  60576. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60577. /**
  60578. * BABYLON.Observable event triggered after the layout was evaluated
  60579. */
  60580. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60581. /**
  60582. * BABYLON.Observable event triggered before the texture is rendered
  60583. */
  60584. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60585. /**
  60586. * BABYLON.Observable event triggered after the texture was rendered
  60587. */
  60588. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60589. /**
  60590. * Gets or sets a boolean defining if alpha is stored as premultiplied
  60591. */
  60592. premulAlpha: boolean;
  60593. /**
  60594. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  60595. * Useful when you want more antialiasing
  60596. */
  60597. renderScale: number;
  60598. /** Gets or sets the background color */
  60599. background: string;
  60600. /**
  60601. * Gets or sets the ideal width used to design controls.
  60602. * The GUI will then rescale everything accordingly
  60603. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60604. */
  60605. idealWidth: number;
  60606. /**
  60607. * Gets or sets the ideal height used to design controls.
  60608. * The GUI will then rescale everything accordingly
  60609. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60610. */
  60611. idealHeight: number;
  60612. /**
  60613. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  60614. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60615. */
  60616. useSmallestIdeal: boolean;
  60617. /**
  60618. * Gets or sets a boolean indicating if adaptive scaling must be used
  60619. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60620. */
  60621. renderAtIdealSize: boolean;
  60622. /**
  60623. * Gets the underlying layer used to render the texture when in fullscreen mode
  60624. */
  60625. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  60626. /**
  60627. * Gets the root container control
  60628. */
  60629. readonly rootContainer: Container;
  60630. /**
  60631. * Returns an array containing the root container.
  60632. * This is mostly used to let the Inspector introspects the ADT
  60633. * @returns an array containing the rootContainer
  60634. */
  60635. getChildren(): Array<Container>;
  60636. /**
  60637. * Will return all controls that are inside this texture
  60638. * @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
  60639. * @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
  60640. * @return all child controls
  60641. */
  60642. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60643. /**
  60644. * Gets or sets the current focused control
  60645. */
  60646. focusedControl: BABYLON.Nullable<IFocusableControl>;
  60647. /**
  60648. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  60649. */
  60650. isForeground: boolean;
  60651. /**
  60652. * Gets or set information about clipboardData
  60653. */
  60654. clipboardData: string;
  60655. /**
  60656. * Creates a new AdvancedDynamicTexture
  60657. * @param name defines the name of the texture
  60658. * @param width defines the width of the texture
  60659. * @param height defines the height of the texture
  60660. * @param scene defines the hosting scene
  60661. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  60662. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  60663. */
  60664. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  60665. /**
  60666. * Get the current class name of the texture useful for serialization or dynamic coding.
  60667. * @returns "AdvancedDynamicTexture"
  60668. */
  60669. getClassName(): string;
  60670. /**
  60671. * Function used to execute a function on all controls
  60672. * @param func defines the function to execute
  60673. * @param container defines the container where controls belong. If null the root container will be used
  60674. */
  60675. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  60676. private _useInvalidateRectOptimization;
  60677. /**
  60678. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  60679. */
  60680. useInvalidateRectOptimization: boolean;
  60681. private _invalidatedRectangle;
  60682. /**
  60683. * Invalidates a rectangle area on the gui texture
  60684. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  60685. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  60686. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  60687. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  60688. */
  60689. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  60690. /**
  60691. * Marks the texture as dirty forcing a complete update
  60692. */
  60693. markAsDirty(): void;
  60694. /**
  60695. * Helper function used to create a new style
  60696. * @returns a new style
  60697. * @see http://doc.babylonjs.com/how_to/gui#styles
  60698. */
  60699. createStyle(): Style;
  60700. /**
  60701. * Adds a new control to the root container
  60702. * @param control defines the control to add
  60703. * @returns the current texture
  60704. */
  60705. addControl(control: Control): AdvancedDynamicTexture;
  60706. /**
  60707. * Removes a control from the root container
  60708. * @param control defines the control to remove
  60709. * @returns the current texture
  60710. */
  60711. removeControl(control: Control): AdvancedDynamicTexture;
  60712. /**
  60713. * Release all resources
  60714. */
  60715. dispose(): void;
  60716. private _onResize;
  60717. /** @hidden */
  60718. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  60719. /**
  60720. * Get screen coordinates for a vector3
  60721. * @param position defines the position to project
  60722. * @param worldMatrix defines the world matrix to use
  60723. * @returns the projected position
  60724. */
  60725. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  60726. private _checkUpdate;
  60727. private _clearMeasure;
  60728. private _render;
  60729. /** @hidden */
  60730. _changeCursor(cursor: string): void;
  60731. /** @hidden */
  60732. _registerLastControlDown(control: Control, pointerId: number): void;
  60733. private _doPicking;
  60734. /** @hidden */
  60735. _cleanControlAfterRemovalFromList(list: {
  60736. [pointerId: number]: Control;
  60737. }, control: Control): void;
  60738. /** @hidden */
  60739. _cleanControlAfterRemoval(control: Control): void;
  60740. /** Attach to all scene events required to support pointer events */
  60741. attach(): void;
  60742. /** @hidden */
  60743. private onClipboardCopy;
  60744. /** @hidden */
  60745. private onClipboardCut;
  60746. /** @hidden */
  60747. private onClipboardPaste;
  60748. /**
  60749. * Register the clipboard Events onto the canvas
  60750. */
  60751. registerClipboardEvents(): void;
  60752. /**
  60753. * Unregister the clipboard Events from the canvas
  60754. */
  60755. unRegisterClipboardEvents(): void;
  60756. /**
  60757. * Connect the texture to a hosting mesh to enable interactions
  60758. * @param mesh defines the mesh to attach to
  60759. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  60760. */
  60761. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  60762. /**
  60763. * Move the focus to a specific control
  60764. * @param control defines the control which will receive the focus
  60765. */
  60766. moveFocusToControl(control: IFocusableControl): void;
  60767. private _manageFocus;
  60768. private _attachToOnPointerOut;
  60769. /**
  60770. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  60771. * @param mesh defines the mesh which will receive the texture
  60772. * @param width defines the texture width (1024 by default)
  60773. * @param height defines the texture height (1024 by default)
  60774. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  60775. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  60776. * @returns a new AdvancedDynamicTexture
  60777. */
  60778. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  60779. /**
  60780. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  60781. * In this mode the texture will rely on a layer for its rendering.
  60782. * This allows it to be treated like any other layer.
  60783. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  60784. * LayerMask is set through advancedTexture.layer.layerMask
  60785. * @param name defines name for the texture
  60786. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  60787. * @param scene defines the hsoting scene
  60788. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  60789. * @returns a new AdvancedDynamicTexture
  60790. */
  60791. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  60792. }
  60793. }
  60794. declare module BABYLON.GUI {
  60795. /**
  60796. * Root class used for all 2D controls
  60797. * @see http://doc.babylonjs.com/how_to/gui#controls
  60798. */
  60799. export class Control {
  60800. /** defines the name of the control */
  60801. name?: string | undefined;
  60802. /**
  60803. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  60804. */
  60805. static AllowAlphaInheritance: boolean;
  60806. private _alpha;
  60807. private _alphaSet;
  60808. private _zIndex;
  60809. /** @hidden */
  60810. _host: AdvancedDynamicTexture;
  60811. /** Gets or sets the control parent */
  60812. parent: BABYLON.Nullable<Container>;
  60813. /** @hidden */
  60814. _currentMeasure: Measure;
  60815. private _fontFamily;
  60816. private _fontStyle;
  60817. private _fontWeight;
  60818. private _fontSize;
  60819. private _font;
  60820. /** @hidden */
  60821. _width: ValueAndUnit;
  60822. /** @hidden */
  60823. _height: ValueAndUnit;
  60824. /** @hidden */
  60825. protected _fontOffset: {
  60826. ascent: number;
  60827. height: number;
  60828. descent: number;
  60829. };
  60830. private _color;
  60831. private _style;
  60832. private _styleObserver;
  60833. /** @hidden */
  60834. protected _horizontalAlignment: number;
  60835. /** @hidden */
  60836. protected _verticalAlignment: number;
  60837. /** @hidden */
  60838. protected _isDirty: boolean;
  60839. /** @hidden */
  60840. protected _wasDirty: boolean;
  60841. /** @hidden */
  60842. _tempParentMeasure: Measure;
  60843. /** @hidden */
  60844. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  60845. /** @hidden */
  60846. protected _cachedParentMeasure: Measure;
  60847. private _paddingLeft;
  60848. private _paddingRight;
  60849. private _paddingTop;
  60850. private _paddingBottom;
  60851. /** @hidden */
  60852. _left: ValueAndUnit;
  60853. /** @hidden */
  60854. _top: ValueAndUnit;
  60855. private _scaleX;
  60856. private _scaleY;
  60857. private _rotation;
  60858. private _transformCenterX;
  60859. private _transformCenterY;
  60860. /** @hidden */
  60861. _transformMatrix: Matrix2D;
  60862. /** @hidden */
  60863. protected _invertTransformMatrix: Matrix2D;
  60864. /** @hidden */
  60865. protected _transformedPosition: BABYLON.Vector2;
  60866. private _isMatrixDirty;
  60867. private _cachedOffsetX;
  60868. private _cachedOffsetY;
  60869. private _isVisible;
  60870. private _isHighlighted;
  60871. /** @hidden */
  60872. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60873. private _fontSet;
  60874. private _dummyVector2;
  60875. private _downCount;
  60876. private _enterCount;
  60877. private _doNotRender;
  60878. private _downPointerIds;
  60879. protected _isEnabled: boolean;
  60880. protected _disabledColor: string;
  60881. /** @hidden */
  60882. protected _rebuildLayout: boolean;
  60883. /** @hidden */
  60884. _isClipped: boolean;
  60885. /** @hidden */
  60886. _tag: any;
  60887. /**
  60888. * 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
  60889. */
  60890. uniqueId: number;
  60891. /**
  60892. * Gets or sets an object used to store user defined information for the node
  60893. */
  60894. metadata: any;
  60895. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  60896. isHitTestVisible: boolean;
  60897. /** Gets or sets a boolean indicating if the control can block pointer events */
  60898. isPointerBlocker: boolean;
  60899. /** Gets or sets a boolean indicating if the control can be focusable */
  60900. isFocusInvisible: boolean;
  60901. /**
  60902. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  60903. * 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
  60904. */
  60905. clipChildren: boolean;
  60906. /**
  60907. * Gets or sets a boolean indicating that control content must be clipped
  60908. * 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
  60909. */
  60910. clipContent: boolean;
  60911. /**
  60912. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  60913. */
  60914. useBitmapCache: boolean;
  60915. private _cacheData;
  60916. private _shadowOffsetX;
  60917. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  60918. shadowOffsetX: number;
  60919. private _shadowOffsetY;
  60920. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  60921. shadowOffsetY: number;
  60922. private _shadowBlur;
  60923. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  60924. shadowBlur: number;
  60925. private _shadowColor;
  60926. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  60927. shadowColor: string;
  60928. /** Gets or sets the cursor to use when the control is hovered */
  60929. hoverCursor: string;
  60930. /** @hidden */
  60931. protected _linkOffsetX: ValueAndUnit;
  60932. /** @hidden */
  60933. protected _linkOffsetY: ValueAndUnit;
  60934. /** Gets the control type name */
  60935. readonly typeName: string;
  60936. /**
  60937. * Get the current class name of the control.
  60938. * @returns current class name
  60939. */
  60940. getClassName(): string;
  60941. /**
  60942. * An event triggered when the pointer move over the control.
  60943. */
  60944. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  60945. /**
  60946. * An event triggered when the pointer move out of the control.
  60947. */
  60948. onPointerOutObservable: BABYLON.Observable<Control>;
  60949. /**
  60950. * An event triggered when the pointer taps the control
  60951. */
  60952. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  60953. /**
  60954. * An event triggered when pointer up
  60955. */
  60956. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  60957. /**
  60958. * An event triggered when a control is clicked on
  60959. */
  60960. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  60961. /**
  60962. * An event triggered when pointer enters the control
  60963. */
  60964. onPointerEnterObservable: BABYLON.Observable<Control>;
  60965. /**
  60966. * An event triggered when the control is marked as dirty
  60967. */
  60968. onDirtyObservable: BABYLON.Observable<Control>;
  60969. /**
  60970. * An event triggered before drawing the control
  60971. */
  60972. onBeforeDrawObservable: BABYLON.Observable<Control>;
  60973. /**
  60974. * An event triggered after the control was drawn
  60975. */
  60976. onAfterDrawObservable: BABYLON.Observable<Control>;
  60977. /**
  60978. * Get the hosting AdvancedDynamicTexture
  60979. */
  60980. readonly host: AdvancedDynamicTexture;
  60981. /** Gets or set information about font offsets (used to render and align text) */
  60982. fontOffset: {
  60983. ascent: number;
  60984. height: number;
  60985. descent: number;
  60986. };
  60987. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  60988. alpha: number;
  60989. /**
  60990. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  60991. */
  60992. isHighlighted: boolean;
  60993. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  60994. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60995. */
  60996. scaleX: number;
  60997. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  60998. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60999. */
  61000. scaleY: number;
  61001. /** Gets or sets the rotation angle (0 by default)
  61002. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61003. */
  61004. rotation: number;
  61005. /** Gets or sets the transformation center on Y axis (0 by default)
  61006. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61007. */
  61008. transformCenterY: number;
  61009. /** Gets or sets the transformation center on X axis (0 by default)
  61010. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61011. */
  61012. transformCenterX: number;
  61013. /**
  61014. * Gets or sets the horizontal alignment
  61015. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61016. */
  61017. horizontalAlignment: number;
  61018. /**
  61019. * Gets or sets the vertical alignment
  61020. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61021. */
  61022. verticalAlignment: number;
  61023. /**
  61024. * Gets or sets control width
  61025. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61026. */
  61027. width: string | number;
  61028. /**
  61029. * Gets or sets the control width in pixel
  61030. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61031. */
  61032. widthInPixels: number;
  61033. /**
  61034. * Gets or sets control height
  61035. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61036. */
  61037. height: string | number;
  61038. /**
  61039. * Gets or sets control height in pixel
  61040. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61041. */
  61042. heightInPixels: number;
  61043. /** Gets or set font family */
  61044. fontFamily: string;
  61045. /** Gets or sets font style */
  61046. fontStyle: string;
  61047. /** Gets or sets font weight */
  61048. fontWeight: string;
  61049. /**
  61050. * Gets or sets style
  61051. * @see http://doc.babylonjs.com/how_to/gui#styles
  61052. */
  61053. style: BABYLON.Nullable<Style>;
  61054. /** @hidden */
  61055. readonly _isFontSizeInPercentage: boolean;
  61056. /** Gets or sets font size in pixels */
  61057. fontSizeInPixels: number;
  61058. /** Gets or sets font size */
  61059. fontSize: string | number;
  61060. /** Gets or sets foreground color */
  61061. color: string;
  61062. /** Gets or sets z index which is used to reorder controls on the z axis */
  61063. zIndex: number;
  61064. /** Gets or sets a boolean indicating if the control can be rendered */
  61065. notRenderable: boolean;
  61066. /** Gets or sets a boolean indicating if the control is visible */
  61067. isVisible: boolean;
  61068. /** Gets a boolean indicating that the control needs to update its rendering */
  61069. readonly isDirty: boolean;
  61070. /**
  61071. * Gets the current linked mesh (or null if none)
  61072. */
  61073. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61074. /**
  61075. * Gets or sets a value indicating the padding to use on the left of the control
  61076. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61077. */
  61078. paddingLeft: string | number;
  61079. /**
  61080. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  61081. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61082. */
  61083. paddingLeftInPixels: number;
  61084. /**
  61085. * Gets or sets a value indicating the padding to use on the right of the control
  61086. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61087. */
  61088. paddingRight: string | number;
  61089. /**
  61090. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  61091. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61092. */
  61093. paddingRightInPixels: number;
  61094. /**
  61095. * Gets or sets a value indicating the padding to use on the top of the control
  61096. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61097. */
  61098. paddingTop: string | number;
  61099. /**
  61100. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  61101. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61102. */
  61103. paddingTopInPixels: number;
  61104. /**
  61105. * Gets or sets a value indicating the padding to use on the bottom of the control
  61106. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61107. */
  61108. paddingBottom: string | number;
  61109. /**
  61110. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  61111. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61112. */
  61113. paddingBottomInPixels: number;
  61114. /**
  61115. * Gets or sets a value indicating the left coordinate of the control
  61116. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61117. */
  61118. left: string | number;
  61119. /**
  61120. * Gets or sets a value indicating the left coordinate in pixels of the control
  61121. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61122. */
  61123. leftInPixels: number;
  61124. /**
  61125. * Gets or sets a value indicating the top coordinate of the control
  61126. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61127. */
  61128. top: string | number;
  61129. /**
  61130. * Gets or sets a value indicating the top coordinate in pixels of the control
  61131. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61132. */
  61133. topInPixels: number;
  61134. /**
  61135. * Gets or sets a value indicating the offset on X axis to the linked mesh
  61136. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61137. */
  61138. linkOffsetX: string | number;
  61139. /**
  61140. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  61141. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61142. */
  61143. linkOffsetXInPixels: number;
  61144. /**
  61145. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  61146. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61147. */
  61148. linkOffsetY: string | number;
  61149. /**
  61150. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  61151. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61152. */
  61153. linkOffsetYInPixels: number;
  61154. /** Gets the center coordinate on X axis */
  61155. readonly centerX: number;
  61156. /** Gets the center coordinate on Y axis */
  61157. readonly centerY: number;
  61158. /** Gets or sets if control is Enabled*/
  61159. isEnabled: boolean;
  61160. /** Gets or sets background color of control if it's disabled*/
  61161. disabledColor: string;
  61162. /**
  61163. * Creates a new control
  61164. * @param name defines the name of the control
  61165. */
  61166. constructor(
  61167. /** defines the name of the control */
  61168. name?: string | undefined);
  61169. /** @hidden */
  61170. protected _getTypeName(): string;
  61171. /**
  61172. * Gets the first ascendant in the hierarchy of the given type
  61173. * @param className defines the required type
  61174. * @returns the ascendant or null if not found
  61175. */
  61176. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  61177. /** @hidden */
  61178. _resetFontCache(): void;
  61179. /**
  61180. * Determines if a container is an ascendant of the current control
  61181. * @param container defines the container to look for
  61182. * @returns true if the container is one of the ascendant of the control
  61183. */
  61184. isAscendant(container: Control): boolean;
  61185. /**
  61186. * Gets coordinates in local control space
  61187. * @param globalCoordinates defines the coordinates to transform
  61188. * @returns the new coordinates in local space
  61189. */
  61190. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61191. /**
  61192. * Gets coordinates in local control space
  61193. * @param globalCoordinates defines the coordinates to transform
  61194. * @param result defines the target vector2 where to store the result
  61195. * @returns the current control
  61196. */
  61197. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  61198. /**
  61199. * Gets coordinates in parent local control space
  61200. * @param globalCoordinates defines the coordinates to transform
  61201. * @returns the new coordinates in parent local space
  61202. */
  61203. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61204. /**
  61205. * Move the current control to a vector3 position projected onto the screen.
  61206. * @param position defines the target position
  61207. * @param scene defines the hosting scene
  61208. */
  61209. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  61210. /** @hidden */
  61211. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61212. /**
  61213. * Will return all controls that have this control as ascendant
  61214. * @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
  61215. * @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
  61216. * @return all child controls
  61217. */
  61218. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  61219. /**
  61220. * Link current control with a target mesh
  61221. * @param mesh defines the mesh to link with
  61222. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61223. */
  61224. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  61225. /** @hidden */
  61226. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  61227. /** @hidden */
  61228. _offsetLeft(offset: number): void;
  61229. /** @hidden */
  61230. _offsetTop(offset: number): void;
  61231. /** @hidden */
  61232. _markMatrixAsDirty(): void;
  61233. /** @hidden */
  61234. _flagDescendantsAsMatrixDirty(): void;
  61235. /** @hidden */
  61236. _intersectsRect(rect: Measure): boolean;
  61237. /** @hidden */
  61238. protected invalidateRect(): void;
  61239. /** @hidden */
  61240. _markAsDirty(force?: boolean): void;
  61241. /** @hidden */
  61242. _markAllAsDirty(): void;
  61243. /** @hidden */
  61244. _link(host: AdvancedDynamicTexture): void;
  61245. /** @hidden */
  61246. protected _transform(context?: CanvasRenderingContext2D): void;
  61247. /** @hidden */
  61248. _renderHighlight(context: CanvasRenderingContext2D): void;
  61249. /** @hidden */
  61250. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61251. /** @hidden */
  61252. protected _applyStates(context: CanvasRenderingContext2D): void;
  61253. /** @hidden */
  61254. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61255. /** @hidden */
  61256. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61257. protected _evaluateClippingState(parentMeasure: Measure): void;
  61258. /** @hidden */
  61259. _measure(): void;
  61260. /** @hidden */
  61261. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61262. /** @hidden */
  61263. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61264. /** @hidden */
  61265. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61266. /** @hidden */
  61267. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61268. private static _ClipMeasure;
  61269. private _tmpMeasureA;
  61270. private _clip;
  61271. /** @hidden */
  61272. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  61273. /** @hidden */
  61274. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  61275. /**
  61276. * Tests if a given coordinates belong to the current control
  61277. * @param x defines x coordinate to test
  61278. * @param y defines y coordinate to test
  61279. * @returns true if the coordinates are inside the control
  61280. */
  61281. contains(x: number, y: number): boolean;
  61282. /** @hidden */
  61283. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61284. /** @hidden */
  61285. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61286. /** @hidden */
  61287. _onPointerEnter(target: Control): boolean;
  61288. /** @hidden */
  61289. _onPointerOut(target: Control, force?: boolean): void;
  61290. /** @hidden */
  61291. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61292. /** @hidden */
  61293. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61294. /** @hidden */
  61295. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  61296. /** @hidden */
  61297. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  61298. private _prepareFont;
  61299. /** Releases associated resources */
  61300. dispose(): void;
  61301. private static _HORIZONTAL_ALIGNMENT_LEFT;
  61302. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  61303. private static _HORIZONTAL_ALIGNMENT_CENTER;
  61304. private static _VERTICAL_ALIGNMENT_TOP;
  61305. private static _VERTICAL_ALIGNMENT_BOTTOM;
  61306. private static _VERTICAL_ALIGNMENT_CENTER;
  61307. /** HORIZONTAL_ALIGNMENT_LEFT */
  61308. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  61309. /** HORIZONTAL_ALIGNMENT_RIGHT */
  61310. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  61311. /** HORIZONTAL_ALIGNMENT_CENTER */
  61312. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  61313. /** VERTICAL_ALIGNMENT_TOP */
  61314. static readonly VERTICAL_ALIGNMENT_TOP: number;
  61315. /** VERTICAL_ALIGNMENT_BOTTOM */
  61316. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  61317. /** VERTICAL_ALIGNMENT_CENTER */
  61318. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  61319. private static _FontHeightSizes;
  61320. /** @hidden */
  61321. static _GetFontOffset(font: string): {
  61322. ascent: number;
  61323. height: number;
  61324. descent: number;
  61325. };
  61326. /**
  61327. * Creates a stack panel that can be used to render headers
  61328. * @param control defines the control to associate with the header
  61329. * @param text defines the text of the header
  61330. * @param size defines the size of the header
  61331. * @param options defines options used to configure the header
  61332. * @returns a new StackPanel
  61333. * @ignore
  61334. * @hidden
  61335. */
  61336. static AddHeader: (control: Control, text: string, size: string | number, options: {
  61337. isHorizontal: boolean;
  61338. controlFirst: boolean;
  61339. }) => any;
  61340. /** @hidden */
  61341. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  61342. }
  61343. }
  61344. declare module BABYLON.GUI {
  61345. /**
  61346. * Root class for 2D containers
  61347. * @see http://doc.babylonjs.com/how_to/gui#containers
  61348. */
  61349. export class Container extends Control {
  61350. name?: string | undefined;
  61351. /** @hidden */
  61352. protected _children: Control[];
  61353. /** @hidden */
  61354. protected _measureForChildren: Measure;
  61355. /** @hidden */
  61356. protected _background: string;
  61357. /** @hidden */
  61358. protected _adaptWidthToChildren: boolean;
  61359. /** @hidden */
  61360. protected _adaptHeightToChildren: boolean;
  61361. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  61362. adaptHeightToChildren: boolean;
  61363. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  61364. adaptWidthToChildren: boolean;
  61365. /** Gets or sets background color */
  61366. background: string;
  61367. /** Gets the list of children */
  61368. readonly children: Control[];
  61369. /**
  61370. * Creates a new Container
  61371. * @param name defines the name of the container
  61372. */
  61373. constructor(name?: string | undefined);
  61374. protected _getTypeName(): string;
  61375. _flagDescendantsAsMatrixDirty(): void;
  61376. /**
  61377. * Gets a child using its name
  61378. * @param name defines the child name to look for
  61379. * @returns the child control if found
  61380. */
  61381. getChildByName(name: string): BABYLON.Nullable<Control>;
  61382. /**
  61383. * Gets a child using its type and its name
  61384. * @param name defines the child name to look for
  61385. * @param type defines the child type to look for
  61386. * @returns the child control if found
  61387. */
  61388. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  61389. /**
  61390. * Search for a specific control in children
  61391. * @param control defines the control to look for
  61392. * @returns true if the control is in child list
  61393. */
  61394. containsControl(control: Control): boolean;
  61395. /**
  61396. * Adds a new control to the current container
  61397. * @param control defines the control to add
  61398. * @returns the current container
  61399. */
  61400. addControl(control: BABYLON.Nullable<Control>): Container;
  61401. /**
  61402. * Removes all controls from the current container
  61403. * @returns the current container
  61404. */
  61405. clearControls(): Container;
  61406. /**
  61407. * Removes a control from the current container
  61408. * @param control defines the control to remove
  61409. * @returns the current container
  61410. */
  61411. removeControl(control: Control): Container;
  61412. /** @hidden */
  61413. _reOrderControl(control: Control): void;
  61414. /** @hidden */
  61415. _offsetLeft(offset: number): void;
  61416. /** @hidden */
  61417. _offsetTop(offset: number): void;
  61418. /** @hidden */
  61419. _markAllAsDirty(): void;
  61420. /** @hidden */
  61421. protected _localDraw(context: CanvasRenderingContext2D): void;
  61422. /** @hidden */
  61423. _link(host: AdvancedDynamicTexture): void;
  61424. /** @hidden */
  61425. protected _beforeLayout(): void;
  61426. /** @hidden */
  61427. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61428. /** @hidden */
  61429. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61430. protected _postMeasure(): void;
  61431. /** @hidden */
  61432. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  61433. /** @hidden */
  61434. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61435. /** @hidden */
  61436. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61437. /** @hidden */
  61438. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61439. /** Releases associated resources */
  61440. dispose(): void;
  61441. }
  61442. }
  61443. declare module BABYLON.GUI {
  61444. /** Class used to create rectangle container */
  61445. export class Rectangle extends Container {
  61446. name?: string | undefined;
  61447. private _thickness;
  61448. private _cornerRadius;
  61449. /** Gets or sets border thickness */
  61450. thickness: number;
  61451. /** Gets or sets the corner radius angle */
  61452. cornerRadius: number;
  61453. /**
  61454. * Creates a new Rectangle
  61455. * @param name defines the control name
  61456. */
  61457. constructor(name?: string | undefined);
  61458. protected _getTypeName(): string;
  61459. protected _localDraw(context: CanvasRenderingContext2D): void;
  61460. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61461. private _drawRoundedRect;
  61462. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61463. }
  61464. }
  61465. declare module BABYLON.GUI {
  61466. /**
  61467. * Enum that determines the text-wrapping mode to use.
  61468. */
  61469. export enum TextWrapping {
  61470. /**
  61471. * Clip the text when it's larger than Control.width; this is the default mode.
  61472. */
  61473. Clip = 0,
  61474. /**
  61475. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  61476. */
  61477. WordWrap = 1,
  61478. /**
  61479. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  61480. */
  61481. Ellipsis = 2
  61482. }
  61483. /**
  61484. * Class used to create text block control
  61485. */
  61486. export class TextBlock extends Control {
  61487. /**
  61488. * Defines the name of the control
  61489. */
  61490. name?: string | undefined;
  61491. private _text;
  61492. private _textWrapping;
  61493. private _textHorizontalAlignment;
  61494. private _textVerticalAlignment;
  61495. private _lines;
  61496. private _resizeToFit;
  61497. private _lineSpacing;
  61498. private _outlineWidth;
  61499. private _outlineColor;
  61500. /**
  61501. * An event triggered after the text is changed
  61502. */
  61503. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  61504. /**
  61505. * An event triggered after the text was broken up into lines
  61506. */
  61507. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  61508. /**
  61509. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  61510. */
  61511. readonly lines: any[];
  61512. /**
  61513. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61514. */
  61515. /**
  61516. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61517. */
  61518. resizeToFit: boolean;
  61519. /**
  61520. * Gets or sets a boolean indicating if text must be wrapped
  61521. */
  61522. /**
  61523. * Gets or sets a boolean indicating if text must be wrapped
  61524. */
  61525. textWrapping: TextWrapping | boolean;
  61526. /**
  61527. * Gets or sets text to display
  61528. */
  61529. /**
  61530. * Gets or sets text to display
  61531. */
  61532. text: string;
  61533. /**
  61534. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61535. */
  61536. /**
  61537. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61538. */
  61539. textHorizontalAlignment: number;
  61540. /**
  61541. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61542. */
  61543. /**
  61544. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61545. */
  61546. textVerticalAlignment: number;
  61547. /**
  61548. * Gets or sets line spacing value
  61549. */
  61550. /**
  61551. * Gets or sets line spacing value
  61552. */
  61553. lineSpacing: string | number;
  61554. /**
  61555. * Gets or sets outlineWidth of the text to display
  61556. */
  61557. /**
  61558. * Gets or sets outlineWidth of the text to display
  61559. */
  61560. outlineWidth: number;
  61561. /**
  61562. * Gets or sets outlineColor of the text to display
  61563. */
  61564. /**
  61565. * Gets or sets outlineColor of the text to display
  61566. */
  61567. outlineColor: string;
  61568. /**
  61569. * Creates a new TextBlock object
  61570. * @param name defines the name of the control
  61571. * @param text defines the text to display (emptry string by default)
  61572. */
  61573. constructor(
  61574. /**
  61575. * Defines the name of the control
  61576. */
  61577. name?: string | undefined, text?: string);
  61578. protected _getTypeName(): string;
  61579. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61580. private _drawText;
  61581. /** @hidden */
  61582. _draw(context: CanvasRenderingContext2D): void;
  61583. protected _applyStates(context: CanvasRenderingContext2D): void;
  61584. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  61585. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  61586. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  61587. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  61588. protected _renderLines(context: CanvasRenderingContext2D): void;
  61589. /**
  61590. * Given a width constraint applied on the text block, find the expected height
  61591. * @returns expected height
  61592. */
  61593. computeExpectedHeight(): number;
  61594. dispose(): void;
  61595. }
  61596. }
  61597. declare module BABYLON.GUI {
  61598. /**
  61599. * Class used to create 2D images
  61600. */
  61601. export class Image extends Control {
  61602. name?: string | undefined;
  61603. private static _WorkingCanvas;
  61604. private _domImage;
  61605. private _imageWidth;
  61606. private _imageHeight;
  61607. private _loaded;
  61608. private _stretch;
  61609. private _source;
  61610. private _autoScale;
  61611. private _sourceLeft;
  61612. private _sourceTop;
  61613. private _sourceWidth;
  61614. private _sourceHeight;
  61615. private _cellWidth;
  61616. private _cellHeight;
  61617. private _cellId;
  61618. private _populateNinePatchSlicesFromImage;
  61619. private _sliceLeft;
  61620. private _sliceRight;
  61621. private _sliceTop;
  61622. private _sliceBottom;
  61623. private _detectPointerOnOpaqueOnly;
  61624. /**
  61625. * BABYLON.Observable notified when the content is loaded
  61626. */
  61627. onImageLoadedObservable: BABYLON.Observable<Image>;
  61628. /**
  61629. * Gets a boolean indicating that the content is loaded
  61630. */
  61631. readonly isLoaded: boolean;
  61632. /**
  61633. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  61634. */
  61635. populateNinePatchSlicesFromImage: boolean;
  61636. /**
  61637. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  61638. * Beware using this as this will comsume more memory as the image has to be stored twice
  61639. */
  61640. detectPointerOnOpaqueOnly: boolean;
  61641. /**
  61642. * Gets or sets the left value for slicing (9-patch)
  61643. */
  61644. sliceLeft: number;
  61645. /**
  61646. * Gets or sets the right value for slicing (9-patch)
  61647. */
  61648. sliceRight: number;
  61649. /**
  61650. * Gets or sets the top value for slicing (9-patch)
  61651. */
  61652. sliceTop: number;
  61653. /**
  61654. * Gets or sets the bottom value for slicing (9-patch)
  61655. */
  61656. sliceBottom: number;
  61657. /**
  61658. * Gets or sets the left coordinate in the source image
  61659. */
  61660. sourceLeft: number;
  61661. /**
  61662. * Gets or sets the top coordinate in the source image
  61663. */
  61664. sourceTop: number;
  61665. /**
  61666. * Gets or sets the width to capture in the source image
  61667. */
  61668. sourceWidth: number;
  61669. /**
  61670. * Gets or sets the height to capture in the source image
  61671. */
  61672. sourceHeight: number;
  61673. /**
  61674. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  61675. * @see http://doc.babylonjs.com/how_to/gui#image
  61676. */
  61677. autoScale: boolean;
  61678. /** Gets or sets the streching mode used by the image */
  61679. stretch: number;
  61680. /**
  61681. * Gets or sets the internal DOM image used to render the control
  61682. */
  61683. domImage: HTMLImageElement;
  61684. private _onImageLoaded;
  61685. private _extractNinePatchSliceDataFromImage;
  61686. /**
  61687. * Gets or sets image source url
  61688. */
  61689. source: BABYLON.Nullable<string>;
  61690. /**
  61691. * Gets or sets the cell width to use when animation sheet is enabled
  61692. * @see http://doc.babylonjs.com/how_to/gui#image
  61693. */
  61694. cellWidth: number;
  61695. /**
  61696. * Gets or sets the cell height to use when animation sheet is enabled
  61697. * @see http://doc.babylonjs.com/how_to/gui#image
  61698. */
  61699. cellHeight: number;
  61700. /**
  61701. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  61702. * @see http://doc.babylonjs.com/how_to/gui#image
  61703. */
  61704. cellId: number;
  61705. /**
  61706. * Creates a new Image
  61707. * @param name defines the control name
  61708. * @param url defines the image url
  61709. */
  61710. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  61711. /**
  61712. * Tests if a given coordinates belong to the current control
  61713. * @param x defines x coordinate to test
  61714. * @param y defines y coordinate to test
  61715. * @returns true if the coordinates are inside the control
  61716. */
  61717. contains(x: number, y: number): boolean;
  61718. protected _getTypeName(): string;
  61719. /** Force the control to synchronize with its content */
  61720. synchronizeSizeWithContent(): void;
  61721. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61722. private _prepareWorkingCanvasForOpaqueDetection;
  61723. private _drawImage;
  61724. _draw(context: CanvasRenderingContext2D): void;
  61725. private _renderCornerPatch;
  61726. private _renderNinePatch;
  61727. dispose(): void;
  61728. /** STRETCH_NONE */
  61729. static readonly STRETCH_NONE: number;
  61730. /** STRETCH_FILL */
  61731. static readonly STRETCH_FILL: number;
  61732. /** STRETCH_UNIFORM */
  61733. static readonly STRETCH_UNIFORM: number;
  61734. /** STRETCH_EXTEND */
  61735. static readonly STRETCH_EXTEND: number;
  61736. /** NINE_PATCH */
  61737. static readonly STRETCH_NINE_PATCH: number;
  61738. }
  61739. }
  61740. declare module BABYLON.GUI {
  61741. /**
  61742. * Class used to create 2D buttons
  61743. */
  61744. export class Button extends Rectangle {
  61745. name?: string | undefined;
  61746. /**
  61747. * Function called to generate a pointer enter animation
  61748. */
  61749. pointerEnterAnimation: () => void;
  61750. /**
  61751. * Function called to generate a pointer out animation
  61752. */
  61753. pointerOutAnimation: () => void;
  61754. /**
  61755. * Function called to generate a pointer down animation
  61756. */
  61757. pointerDownAnimation: () => void;
  61758. /**
  61759. * Function called to generate a pointer up animation
  61760. */
  61761. pointerUpAnimation: () => void;
  61762. private _image;
  61763. /**
  61764. * Returns the image part of the button (if any)
  61765. */
  61766. readonly image: BABYLON.Nullable<Image>;
  61767. private _textBlock;
  61768. /**
  61769. * Returns the image part of the button (if any)
  61770. */
  61771. readonly textBlock: BABYLON.Nullable<TextBlock>;
  61772. /**
  61773. * Creates a new Button
  61774. * @param name defines the name of the button
  61775. */
  61776. constructor(name?: string | undefined);
  61777. protected _getTypeName(): string;
  61778. /** @hidden */
  61779. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61780. /** @hidden */
  61781. _onPointerEnter(target: Control): boolean;
  61782. /** @hidden */
  61783. _onPointerOut(target: Control, force?: boolean): void;
  61784. /** @hidden */
  61785. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61786. /** @hidden */
  61787. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61788. /**
  61789. * Creates a new button made with an image and a text
  61790. * @param name defines the name of the button
  61791. * @param text defines the text of the button
  61792. * @param imageUrl defines the url of the image
  61793. * @returns a new Button
  61794. */
  61795. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  61796. /**
  61797. * Creates a new button made with an image
  61798. * @param name defines the name of the button
  61799. * @param imageUrl defines the url of the image
  61800. * @returns a new Button
  61801. */
  61802. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  61803. /**
  61804. * Creates a new button made with a text
  61805. * @param name defines the name of the button
  61806. * @param text defines the text of the button
  61807. * @returns a new Button
  61808. */
  61809. static CreateSimpleButton(name: string, text: string): Button;
  61810. /**
  61811. * Creates a new button made with an image and a centered text
  61812. * @param name defines the name of the button
  61813. * @param text defines the text of the button
  61814. * @param imageUrl defines the url of the image
  61815. * @returns a new Button
  61816. */
  61817. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  61818. }
  61819. }
  61820. declare module BABYLON.GUI {
  61821. /**
  61822. * Class used to create a 2D stack panel container
  61823. */
  61824. export class StackPanel extends Container {
  61825. name?: string | undefined;
  61826. private _isVertical;
  61827. private _manualWidth;
  61828. private _manualHeight;
  61829. private _doNotTrackManualChanges;
  61830. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  61831. isVertical: boolean;
  61832. /**
  61833. * Gets or sets panel width.
  61834. * This value should not be set when in horizontal mode as it will be computed automatically
  61835. */
  61836. width: string | number;
  61837. /**
  61838. * Gets or sets panel height.
  61839. * This value should not be set when in vertical mode as it will be computed automatically
  61840. */
  61841. height: string | number;
  61842. /**
  61843. * Creates a new StackPanel
  61844. * @param name defines control name
  61845. */
  61846. constructor(name?: string | undefined);
  61847. protected _getTypeName(): string;
  61848. /** @hidden */
  61849. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61850. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61851. protected _postMeasure(): void;
  61852. }
  61853. }
  61854. declare module BABYLON.GUI {
  61855. /**
  61856. * Class used to represent a 2D checkbox
  61857. */
  61858. export class Checkbox extends Control {
  61859. name?: string | undefined;
  61860. private _isChecked;
  61861. private _background;
  61862. private _checkSizeRatio;
  61863. private _thickness;
  61864. /** Gets or sets border thickness */
  61865. thickness: number;
  61866. /**
  61867. * BABYLON.Observable raised when isChecked property changes
  61868. */
  61869. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61870. /** Gets or sets a value indicating the ratio between overall size and check size */
  61871. checkSizeRatio: number;
  61872. /** Gets or sets background color */
  61873. background: string;
  61874. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61875. isChecked: boolean;
  61876. /**
  61877. * Creates a new CheckBox
  61878. * @param name defines the control name
  61879. */
  61880. constructor(name?: string | undefined);
  61881. protected _getTypeName(): string;
  61882. /** @hidden */
  61883. _draw(context: CanvasRenderingContext2D): void;
  61884. /** @hidden */
  61885. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61886. /**
  61887. * Utility function to easily create a checkbox with a header
  61888. * @param title defines the label to use for the header
  61889. * @param onValueChanged defines the callback to call when value changes
  61890. * @returns a StackPanel containing the checkbox and a textBlock
  61891. */
  61892. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  61893. }
  61894. }
  61895. declare module BABYLON.GUI {
  61896. /**
  61897. * Class used to store key control properties
  61898. */
  61899. export class KeyPropertySet {
  61900. /** Width */
  61901. width?: string;
  61902. /** Height */
  61903. height?: string;
  61904. /** Left padding */
  61905. paddingLeft?: string;
  61906. /** Right padding */
  61907. paddingRight?: string;
  61908. /** Top padding */
  61909. paddingTop?: string;
  61910. /** Bottom padding */
  61911. paddingBottom?: string;
  61912. /** Foreground color */
  61913. color?: string;
  61914. /** Background color */
  61915. background?: string;
  61916. }
  61917. /**
  61918. * Class used to create virtual keyboard
  61919. */
  61920. export class VirtualKeyboard extends StackPanel {
  61921. /** BABYLON.Observable raised when a key is pressed */
  61922. onKeyPressObservable: BABYLON.Observable<string>;
  61923. /** Gets or sets default key button width */
  61924. defaultButtonWidth: string;
  61925. /** Gets or sets default key button height */
  61926. defaultButtonHeight: string;
  61927. /** Gets or sets default key button left padding */
  61928. defaultButtonPaddingLeft: string;
  61929. /** Gets or sets default key button right padding */
  61930. defaultButtonPaddingRight: string;
  61931. /** Gets or sets default key button top padding */
  61932. defaultButtonPaddingTop: string;
  61933. /** Gets or sets default key button bottom padding */
  61934. defaultButtonPaddingBottom: string;
  61935. /** Gets or sets default key button foreground color */
  61936. defaultButtonColor: string;
  61937. /** Gets or sets default key button background color */
  61938. defaultButtonBackground: string;
  61939. /** Gets or sets shift button foreground color */
  61940. shiftButtonColor: string;
  61941. /** Gets or sets shift button thickness*/
  61942. selectedShiftThickness: number;
  61943. /** Gets shift key state */
  61944. shiftState: number;
  61945. protected _getTypeName(): string;
  61946. private _createKey;
  61947. /**
  61948. * Adds a new row of keys
  61949. * @param keys defines the list of keys to add
  61950. * @param propertySets defines the associated property sets
  61951. */
  61952. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  61953. /**
  61954. * Set the shift key to a specific state
  61955. * @param shiftState defines the new shift state
  61956. */
  61957. applyShiftState(shiftState: number): void;
  61958. private _currentlyConnectedInputText;
  61959. private _connectedInputTexts;
  61960. private _onKeyPressObserver;
  61961. /** Gets the input text control currently attached to the keyboard */
  61962. readonly connectedInputText: BABYLON.Nullable<InputText>;
  61963. /**
  61964. * Connects the keyboard with an input text control
  61965. *
  61966. * @param input defines the target control
  61967. */
  61968. connect(input: InputText): void;
  61969. /**
  61970. * Disconnects the keyboard from connected InputText controls
  61971. *
  61972. * @param input optionally defines a target control, otherwise all are disconnected
  61973. */
  61974. disconnect(input?: InputText): void;
  61975. private _removeConnectedInputObservables;
  61976. /**
  61977. * Release all resources
  61978. */
  61979. dispose(): void;
  61980. /**
  61981. * Creates a new keyboard using a default layout
  61982. *
  61983. * @param name defines control name
  61984. * @returns a new VirtualKeyboard
  61985. */
  61986. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  61987. }
  61988. }
  61989. declare module BABYLON.GUI {
  61990. /**
  61991. * Class used to create input text control
  61992. */
  61993. export class InputText extends Control implements IFocusableControl {
  61994. name?: string | undefined;
  61995. private _text;
  61996. private _placeholderText;
  61997. private _background;
  61998. private _focusedBackground;
  61999. private _focusedColor;
  62000. private _placeholderColor;
  62001. private _thickness;
  62002. private _margin;
  62003. private _autoStretchWidth;
  62004. private _maxWidth;
  62005. private _isFocused;
  62006. private _blinkTimeout;
  62007. private _blinkIsEven;
  62008. private _cursorOffset;
  62009. private _scrollLeft;
  62010. private _textWidth;
  62011. private _clickedCoordinate;
  62012. private _deadKey;
  62013. private _addKey;
  62014. private _currentKey;
  62015. private _isTextHighlightOn;
  62016. private _textHighlightColor;
  62017. private _highligherOpacity;
  62018. private _highlightedText;
  62019. private _startHighlightIndex;
  62020. private _endHighlightIndex;
  62021. private _cursorIndex;
  62022. private _onFocusSelectAll;
  62023. private _isPointerDown;
  62024. private _onClipboardObserver;
  62025. private _onPointerDblTapObserver;
  62026. /** @hidden */
  62027. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  62028. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  62029. promptMessage: string;
  62030. /** BABYLON.Observable raised when the text changes */
  62031. onTextChangedObservable: BABYLON.Observable<InputText>;
  62032. /** BABYLON.Observable raised just before an entered character is to be added */
  62033. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  62034. /** BABYLON.Observable raised when the control gets the focus */
  62035. onFocusObservable: BABYLON.Observable<InputText>;
  62036. /** BABYLON.Observable raised when the control loses the focus */
  62037. onBlurObservable: BABYLON.Observable<InputText>;
  62038. /**Observable raised when the text is highlighted */
  62039. onTextHighlightObservable: BABYLON.Observable<InputText>;
  62040. /**Observable raised when copy event is triggered */
  62041. onTextCopyObservable: BABYLON.Observable<InputText>;
  62042. /** BABYLON.Observable raised when cut event is triggered */
  62043. onTextCutObservable: BABYLON.Observable<InputText>;
  62044. /** BABYLON.Observable raised when paste event is triggered */
  62045. onTextPasteObservable: BABYLON.Observable<InputText>;
  62046. /** BABYLON.Observable raised when a key event was processed */
  62047. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  62048. /** Gets or sets the maximum width allowed by the control */
  62049. maxWidth: string | number;
  62050. /** Gets the maximum width allowed by the control in pixels */
  62051. readonly maxWidthInPixels: number;
  62052. /** Gets or sets the text highlighter transparency; default: 0.4 */
  62053. highligherOpacity: number;
  62054. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  62055. onFocusSelectAll: boolean;
  62056. /** Gets or sets the text hightlight color */
  62057. textHighlightColor: string;
  62058. /** Gets or sets control margin */
  62059. margin: string;
  62060. /** Gets control margin in pixels */
  62061. readonly marginInPixels: number;
  62062. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  62063. autoStretchWidth: boolean;
  62064. /** Gets or sets border thickness */
  62065. thickness: number;
  62066. /** Gets or sets the background color when focused */
  62067. focusedBackground: string;
  62068. /** Gets or sets the background color when focused */
  62069. focusedColor: string;
  62070. /** Gets or sets the background color */
  62071. background: string;
  62072. /** Gets or sets the placeholder color */
  62073. placeholderColor: string;
  62074. /** Gets or sets the text displayed when the control is empty */
  62075. placeholderText: string;
  62076. /** Gets or sets the dead key flag */
  62077. deadKey: boolean;
  62078. /** Gets or sets the highlight text */
  62079. highlightedText: string;
  62080. /** Gets or sets if the current key should be added */
  62081. addKey: boolean;
  62082. /** Gets or sets the value of the current key being entered */
  62083. currentKey: string;
  62084. /** Gets or sets the text displayed in the control */
  62085. text: string;
  62086. /** Gets or sets control width */
  62087. width: string | number;
  62088. /**
  62089. * Creates a new InputText
  62090. * @param name defines the control name
  62091. * @param text defines the text of the control
  62092. */
  62093. constructor(name?: string | undefined, text?: string);
  62094. /** @hidden */
  62095. onBlur(): void;
  62096. /** @hidden */
  62097. onFocus(): void;
  62098. protected _getTypeName(): string;
  62099. /**
  62100. * Function called to get the list of controls that should not steal the focus from this control
  62101. * @returns an array of controls
  62102. */
  62103. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62104. /** @hidden */
  62105. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  62106. /** @hidden */
  62107. private _updateValueFromCursorIndex;
  62108. /** @hidden */
  62109. private _processDblClick;
  62110. /** @hidden */
  62111. private _selectAllText;
  62112. /**
  62113. * Handles the keyboard event
  62114. * @param evt Defines the KeyboardEvent
  62115. */
  62116. processKeyboard(evt: KeyboardEvent): void;
  62117. /** @hidden */
  62118. private _onCopyText;
  62119. /** @hidden */
  62120. private _onCutText;
  62121. /** @hidden */
  62122. private _onPasteText;
  62123. _draw(context: CanvasRenderingContext2D): void;
  62124. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62125. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62126. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62127. protected _beforeRenderText(text: string): string;
  62128. dispose(): void;
  62129. }
  62130. }
  62131. declare module BABYLON.GUI {
  62132. /**
  62133. * Class used to create a 2D grid container
  62134. */
  62135. export class Grid extends Container {
  62136. name?: string | undefined;
  62137. private _rowDefinitions;
  62138. private _columnDefinitions;
  62139. private _cells;
  62140. private _childControls;
  62141. /**
  62142. * Gets the number of columns
  62143. */
  62144. readonly columnCount: number;
  62145. /**
  62146. * Gets the number of rows
  62147. */
  62148. readonly rowCount: number;
  62149. /** Gets the list of children */
  62150. readonly children: Control[];
  62151. /** Gets the list of cells (e.g. the containers) */
  62152. readonly cells: {
  62153. [key: string]: Container;
  62154. };
  62155. /**
  62156. * Gets the definition of a specific row
  62157. * @param index defines the index of the row
  62158. * @returns the row definition
  62159. */
  62160. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62161. /**
  62162. * Gets the definition of a specific column
  62163. * @param index defines the index of the column
  62164. * @returns the column definition
  62165. */
  62166. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62167. /**
  62168. * Adds a new row to the grid
  62169. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62170. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  62171. * @returns the current grid
  62172. */
  62173. addRowDefinition(height: number, isPixel?: boolean): Grid;
  62174. /**
  62175. * Adds a new column to the grid
  62176. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62177. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62178. * @returns the current grid
  62179. */
  62180. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  62181. /**
  62182. * Update a row definition
  62183. * @param index defines the index of the row to update
  62184. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62185. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  62186. * @returns the current grid
  62187. */
  62188. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  62189. /**
  62190. * Update a column definition
  62191. * @param index defines the index of the column to update
  62192. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62193. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62194. * @returns the current grid
  62195. */
  62196. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  62197. /**
  62198. * Gets the list of children stored in a specific cell
  62199. * @param row defines the row to check
  62200. * @param column defines the column to check
  62201. * @returns the list of controls
  62202. */
  62203. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  62204. /**
  62205. * Gets a string representing the child cell info (row x column)
  62206. * @param child defines the control to get info from
  62207. * @returns a string containing the child cell info (row x column)
  62208. */
  62209. getChildCellInfo(child: Control): string;
  62210. private _removeCell;
  62211. private _offsetCell;
  62212. /**
  62213. * Remove a column definition at specified index
  62214. * @param index defines the index of the column to remove
  62215. * @returns the current grid
  62216. */
  62217. removeColumnDefinition(index: number): Grid;
  62218. /**
  62219. * Remove a row definition at specified index
  62220. * @param index defines the index of the row to remove
  62221. * @returns the current grid
  62222. */
  62223. removeRowDefinition(index: number): Grid;
  62224. /**
  62225. * Adds a new control to the current grid
  62226. * @param control defines the control to add
  62227. * @param row defines the row where to add the control (0 by default)
  62228. * @param column defines the column where to add the control (0 by default)
  62229. * @returns the current grid
  62230. */
  62231. addControl(control: Control, row?: number, column?: number): Grid;
  62232. /**
  62233. * Removes a control from the current container
  62234. * @param control defines the control to remove
  62235. * @returns the current container
  62236. */
  62237. removeControl(control: Control): Container;
  62238. /**
  62239. * Creates a new Grid
  62240. * @param name defines control name
  62241. */
  62242. constructor(name?: string | undefined);
  62243. protected _getTypeName(): string;
  62244. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  62245. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62246. _flagDescendantsAsMatrixDirty(): void;
  62247. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62248. /** Releases associated resources */
  62249. dispose(): void;
  62250. }
  62251. }
  62252. declare module BABYLON.GUI {
  62253. /** Class used to create color pickers */
  62254. export class ColorPicker extends Control {
  62255. name?: string | undefined;
  62256. private static _Epsilon;
  62257. private _colorWheelCanvas;
  62258. private _value;
  62259. private _tmpColor;
  62260. private _pointerStartedOnSquare;
  62261. private _pointerStartedOnWheel;
  62262. private _squareLeft;
  62263. private _squareTop;
  62264. private _squareSize;
  62265. private _h;
  62266. private _s;
  62267. private _v;
  62268. private _lastPointerDownID;
  62269. /**
  62270. * BABYLON.Observable raised when the value changes
  62271. */
  62272. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  62273. /** Gets or sets the color of the color picker */
  62274. value: BABYLON.Color3;
  62275. /**
  62276. * Gets or sets control width
  62277. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62278. */
  62279. width: string | number;
  62280. /**
  62281. * Gets or sets control height
  62282. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62283. */
  62284. /** Gets or sets control height */
  62285. height: string | number;
  62286. /** Gets or sets control size */
  62287. size: string | number;
  62288. /**
  62289. * Creates a new ColorPicker
  62290. * @param name defines the control name
  62291. */
  62292. constructor(name?: string | undefined);
  62293. protected _getTypeName(): string;
  62294. /** @hidden */
  62295. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62296. private _updateSquareProps;
  62297. private _drawGradientSquare;
  62298. private _drawCircle;
  62299. private _createColorWheelCanvas;
  62300. /** @hidden */
  62301. _draw(context: CanvasRenderingContext2D): void;
  62302. private _pointerIsDown;
  62303. private _updateValueFromPointer;
  62304. private _isPointOnSquare;
  62305. private _isPointOnWheel;
  62306. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62307. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62308. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62309. /**
  62310. * This function expands the color picker by creating a color picker dialog with manual
  62311. * color value input and the ability to save colors into an array to be used later in
  62312. * subsequent launches of the dialogue.
  62313. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  62314. * @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.
  62315. * @returns picked color as a hex string and the saved colors array as hex strings.
  62316. */
  62317. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  62318. pickerWidth?: string;
  62319. pickerHeight?: string;
  62320. headerHeight?: string;
  62321. lastColor?: string;
  62322. swatchLimit?: number;
  62323. numSwatchesPerLine?: number;
  62324. savedColors?: Array<string>;
  62325. }): Promise<{
  62326. savedColors?: string[];
  62327. pickedColor: string;
  62328. }>;
  62329. }
  62330. }
  62331. declare module BABYLON.GUI {
  62332. /** Class used to create 2D ellipse containers */
  62333. export class Ellipse extends Container {
  62334. name?: string | undefined;
  62335. private _thickness;
  62336. /** Gets or sets border thickness */
  62337. thickness: number;
  62338. /**
  62339. * Creates a new Ellipse
  62340. * @param name defines the control name
  62341. */
  62342. constructor(name?: string | undefined);
  62343. protected _getTypeName(): string;
  62344. protected _localDraw(context: CanvasRenderingContext2D): void;
  62345. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62346. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62347. }
  62348. }
  62349. declare module BABYLON.GUI {
  62350. /**
  62351. * Class used to create a password control
  62352. */
  62353. export class InputPassword extends InputText {
  62354. protected _beforeRenderText(text: string): string;
  62355. }
  62356. }
  62357. declare module BABYLON.GUI {
  62358. /** Class used to render 2D lines */
  62359. export class Line extends Control {
  62360. name?: string | undefined;
  62361. private _lineWidth;
  62362. private _x1;
  62363. private _y1;
  62364. private _x2;
  62365. private _y2;
  62366. private _dash;
  62367. private _connectedControl;
  62368. private _connectedControlDirtyObserver;
  62369. /** Gets or sets the dash pattern */
  62370. dash: Array<number>;
  62371. /** Gets or sets the control connected with the line end */
  62372. connectedControl: Control;
  62373. /** Gets or sets start coordinates on X axis */
  62374. x1: string | number;
  62375. /** Gets or sets start coordinates on Y axis */
  62376. y1: string | number;
  62377. /** Gets or sets end coordinates on X axis */
  62378. x2: string | number;
  62379. /** Gets or sets end coordinates on Y axis */
  62380. y2: string | number;
  62381. /** Gets or sets line width */
  62382. lineWidth: number;
  62383. /** Gets or sets horizontal alignment */
  62384. horizontalAlignment: number;
  62385. /** Gets or sets vertical alignment */
  62386. verticalAlignment: number;
  62387. private readonly _effectiveX2;
  62388. private readonly _effectiveY2;
  62389. /**
  62390. * Creates a new Line
  62391. * @param name defines the control name
  62392. */
  62393. constructor(name?: string | undefined);
  62394. protected _getTypeName(): string;
  62395. _draw(context: CanvasRenderingContext2D): void;
  62396. _measure(): void;
  62397. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62398. /**
  62399. * Move one end of the line given 3D cartesian coordinates.
  62400. * @param position Targeted world position
  62401. * @param scene BABYLON.Scene
  62402. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62403. */
  62404. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  62405. /**
  62406. * Move one end of the line to a position in screen absolute space.
  62407. * @param projectedPosition Position in screen absolute space (X, Y)
  62408. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62409. */
  62410. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  62411. }
  62412. }
  62413. declare module BABYLON.GUI {
  62414. /**
  62415. * Class used to store a point for a MultiLine object.
  62416. * The point can be pure 2D coordinates, a mesh or a control
  62417. */
  62418. export class MultiLinePoint {
  62419. private _multiLine;
  62420. private _x;
  62421. private _y;
  62422. private _control;
  62423. private _mesh;
  62424. private _controlObserver;
  62425. private _meshObserver;
  62426. /** @hidden */
  62427. _point: BABYLON.Vector2;
  62428. /**
  62429. * Creates a new MultiLinePoint
  62430. * @param multiLine defines the source MultiLine object
  62431. */
  62432. constructor(multiLine: MultiLine);
  62433. /** Gets or sets x coordinate */
  62434. x: string | number;
  62435. /** Gets or sets y coordinate */
  62436. y: string | number;
  62437. /** Gets or sets the control associated with this point */
  62438. control: BABYLON.Nullable<Control>;
  62439. /** Gets or sets the mesh associated with this point */
  62440. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62441. /** Resets links */
  62442. resetLinks(): void;
  62443. /**
  62444. * Gets a translation vector
  62445. * @returns the translation vector
  62446. */
  62447. translate(): BABYLON.Vector2;
  62448. private _translatePoint;
  62449. /** Release associated resources */
  62450. dispose(): void;
  62451. }
  62452. }
  62453. declare module BABYLON.GUI {
  62454. /**
  62455. * Class used to create multi line control
  62456. */
  62457. export class MultiLine extends Control {
  62458. name?: string | undefined;
  62459. private _lineWidth;
  62460. private _dash;
  62461. private _points;
  62462. private _minX;
  62463. private _minY;
  62464. private _maxX;
  62465. private _maxY;
  62466. /**
  62467. * Creates a new MultiLine
  62468. * @param name defines the control name
  62469. */
  62470. constructor(name?: string | undefined);
  62471. /** Gets or sets dash pattern */
  62472. dash: Array<number>;
  62473. /**
  62474. * Gets point stored at specified index
  62475. * @param index defines the index to look for
  62476. * @returns the requested point if found
  62477. */
  62478. getAt(index: number): MultiLinePoint;
  62479. /** Function called when a point is updated */
  62480. onPointUpdate: () => void;
  62481. /**
  62482. * Adds new points to the point collection
  62483. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  62484. * @returns the list of created MultiLinePoint
  62485. */
  62486. add(...items: (AbstractMesh | Control | {
  62487. x: string | number;
  62488. y: string | number;
  62489. })[]): MultiLinePoint[];
  62490. /**
  62491. * Adds a new point to the point collection
  62492. * @param item defines the item (mesh, control or 2d coordiantes) to add
  62493. * @returns the created MultiLinePoint
  62494. */
  62495. push(item?: (AbstractMesh | Control | {
  62496. x: string | number;
  62497. y: string | number;
  62498. })): MultiLinePoint;
  62499. /**
  62500. * Remove a specific value or point from the active point collection
  62501. * @param value defines the value or point to remove
  62502. */
  62503. remove(value: number | MultiLinePoint): void;
  62504. /**
  62505. * Resets this object to initial state (no point)
  62506. */
  62507. reset(): void;
  62508. /**
  62509. * Resets all links
  62510. */
  62511. resetLinks(): void;
  62512. /** Gets or sets line width */
  62513. lineWidth: number;
  62514. horizontalAlignment: number;
  62515. verticalAlignment: number;
  62516. protected _getTypeName(): string;
  62517. _draw(context: CanvasRenderingContext2D): void;
  62518. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62519. _measure(): void;
  62520. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62521. dispose(): void;
  62522. }
  62523. }
  62524. declare module BABYLON.GUI {
  62525. /**
  62526. * Class used to create radio button controls
  62527. */
  62528. export class RadioButton extends Control {
  62529. name?: string | undefined;
  62530. private _isChecked;
  62531. private _background;
  62532. private _checkSizeRatio;
  62533. private _thickness;
  62534. /** Gets or sets border thickness */
  62535. thickness: number;
  62536. /** Gets or sets group name */
  62537. group: string;
  62538. /** BABYLON.Observable raised when isChecked is changed */
  62539. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62540. /** Gets or sets a value indicating the ratio between overall size and check size */
  62541. checkSizeRatio: number;
  62542. /** Gets or sets background color */
  62543. background: string;
  62544. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62545. isChecked: boolean;
  62546. /**
  62547. * Creates a new RadioButton
  62548. * @param name defines the control name
  62549. */
  62550. constructor(name?: string | undefined);
  62551. protected _getTypeName(): string;
  62552. _draw(context: CanvasRenderingContext2D): void;
  62553. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62554. /**
  62555. * Utility function to easily create a radio button with a header
  62556. * @param title defines the label to use for the header
  62557. * @param group defines the group to use for the radio button
  62558. * @param isChecked defines the initial state of the radio button
  62559. * @param onValueChanged defines the callback to call when value changes
  62560. * @returns a StackPanel containing the radio button and a textBlock
  62561. */
  62562. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  62563. }
  62564. }
  62565. declare module BABYLON.GUI {
  62566. /**
  62567. * Class used to create slider controls
  62568. */
  62569. export class BaseSlider extends Control {
  62570. name?: string | undefined;
  62571. protected _thumbWidth: ValueAndUnit;
  62572. private _minimum;
  62573. private _maximum;
  62574. private _value;
  62575. private _isVertical;
  62576. protected _barOffset: ValueAndUnit;
  62577. private _isThumbClamped;
  62578. protected _displayThumb: boolean;
  62579. private _step;
  62580. private _lastPointerDownID;
  62581. protected _effectiveBarOffset: number;
  62582. protected _renderLeft: number;
  62583. protected _renderTop: number;
  62584. protected _renderWidth: number;
  62585. protected _renderHeight: number;
  62586. protected _backgroundBoxLength: number;
  62587. protected _backgroundBoxThickness: number;
  62588. protected _effectiveThumbThickness: number;
  62589. /** BABYLON.Observable raised when the sldier value changes */
  62590. onValueChangedObservable: BABYLON.Observable<number>;
  62591. /** Gets or sets a boolean indicating if the thumb must be rendered */
  62592. displayThumb: boolean;
  62593. /** Gets or sets a step to apply to values (0 by default) */
  62594. step: number;
  62595. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  62596. barOffset: string | number;
  62597. /** Gets main bar offset in pixels*/
  62598. readonly barOffsetInPixels: number;
  62599. /** Gets or sets thumb width */
  62600. thumbWidth: string | number;
  62601. /** Gets thumb width in pixels */
  62602. readonly thumbWidthInPixels: number;
  62603. /** Gets or sets minimum value */
  62604. minimum: number;
  62605. /** Gets or sets maximum value */
  62606. maximum: number;
  62607. /** Gets or sets current value */
  62608. value: number;
  62609. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  62610. isVertical: boolean;
  62611. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  62612. isThumbClamped: boolean;
  62613. /**
  62614. * Creates a new BaseSlider
  62615. * @param name defines the control name
  62616. */
  62617. constructor(name?: string | undefined);
  62618. protected _getTypeName(): string;
  62619. protected _getThumbPosition(): number;
  62620. protected _getThumbThickness(type: string): number;
  62621. protected _prepareRenderingData(type: string): void;
  62622. private _pointerIsDown;
  62623. /** @hidden */
  62624. protected _updateValueFromPointer(x: number, y: number): void;
  62625. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62626. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62627. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62628. }
  62629. }
  62630. declare module BABYLON.GUI {
  62631. /**
  62632. * Class used to create slider controls
  62633. */
  62634. export class Slider extends BaseSlider {
  62635. name?: string | undefined;
  62636. private _background;
  62637. private _borderColor;
  62638. private _isThumbCircle;
  62639. protected _displayValueBar: boolean;
  62640. /** Gets or sets a boolean indicating if the value bar must be rendered */
  62641. displayValueBar: boolean;
  62642. /** Gets or sets border color */
  62643. borderColor: string;
  62644. /** Gets or sets background color */
  62645. background: string;
  62646. /** Gets or sets a boolean indicating if the thumb should be round or square */
  62647. isThumbCircle: boolean;
  62648. /**
  62649. * Creates a new Slider
  62650. * @param name defines the control name
  62651. */
  62652. constructor(name?: string | undefined);
  62653. protected _getTypeName(): string;
  62654. _draw(context: CanvasRenderingContext2D): void;
  62655. }
  62656. }
  62657. declare module BABYLON.GUI {
  62658. /** Class used to create a RadioGroup
  62659. * which contains groups of radio buttons
  62660. */
  62661. export class SelectorGroup {
  62662. /** name of SelectorGroup */
  62663. name: string;
  62664. private _groupPanel;
  62665. private _selectors;
  62666. private _groupHeader;
  62667. /**
  62668. * Creates a new SelectorGroup
  62669. * @param name of group, used as a group heading
  62670. */
  62671. constructor(
  62672. /** name of SelectorGroup */
  62673. name: string);
  62674. /** Gets the groupPanel of the SelectorGroup */
  62675. readonly groupPanel: StackPanel;
  62676. /** Gets the selectors array */
  62677. readonly selectors: StackPanel[];
  62678. /** Gets and sets the group header */
  62679. header: string;
  62680. /** @hidden */
  62681. private _addGroupHeader;
  62682. /** @hidden*/
  62683. _getSelector(selectorNb: number): StackPanel | undefined;
  62684. /** Removes the selector at the given position
  62685. * @param selectorNb the position of the selector within the group
  62686. */
  62687. removeSelector(selectorNb: number): void;
  62688. }
  62689. /** Class used to create a CheckboxGroup
  62690. * which contains groups of checkbox buttons
  62691. */
  62692. export class CheckboxGroup extends SelectorGroup {
  62693. /** Adds a checkbox as a control
  62694. * @param text is the label for the selector
  62695. * @param func is the function called when the Selector is checked
  62696. * @param checked is true when Selector is checked
  62697. */
  62698. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  62699. /** @hidden */
  62700. _setSelectorLabel(selectorNb: number, label: string): void;
  62701. /** @hidden */
  62702. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62703. /** @hidden */
  62704. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62705. /** @hidden */
  62706. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62707. }
  62708. /** Class used to create a RadioGroup
  62709. * which contains groups of radio buttons
  62710. */
  62711. export class RadioGroup extends SelectorGroup {
  62712. private _selectNb;
  62713. /** Adds a radio button as a control
  62714. * @param label is the label for the selector
  62715. * @param func is the function called when the Selector is checked
  62716. * @param checked is true when Selector is checked
  62717. */
  62718. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  62719. /** @hidden */
  62720. _setSelectorLabel(selectorNb: number, label: string): void;
  62721. /** @hidden */
  62722. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62723. /** @hidden */
  62724. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62725. /** @hidden */
  62726. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62727. }
  62728. /** Class used to create a SliderGroup
  62729. * which contains groups of slider buttons
  62730. */
  62731. export class SliderGroup extends SelectorGroup {
  62732. /**
  62733. * Adds a slider to the SelectorGroup
  62734. * @param label is the label for the SliderBar
  62735. * @param func is the function called when the Slider moves
  62736. * @param unit is a string describing the units used, eg degrees or metres
  62737. * @param min is the minimum value for the Slider
  62738. * @param max is the maximum value for the Slider
  62739. * @param value is the start value for the Slider between min and max
  62740. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  62741. */
  62742. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  62743. /** @hidden */
  62744. _setSelectorLabel(selectorNb: number, label: string): void;
  62745. /** @hidden */
  62746. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62747. /** @hidden */
  62748. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62749. /** @hidden */
  62750. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62751. }
  62752. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  62753. * @see http://doc.babylonjs.com/how_to/selector
  62754. */
  62755. export class SelectionPanel extends Rectangle {
  62756. /** name of SelectionPanel */
  62757. name: string;
  62758. /** an array of SelectionGroups */
  62759. groups: SelectorGroup[];
  62760. private _panel;
  62761. private _buttonColor;
  62762. private _buttonBackground;
  62763. private _headerColor;
  62764. private _barColor;
  62765. private _barHeight;
  62766. private _spacerHeight;
  62767. private _labelColor;
  62768. private _groups;
  62769. private _bars;
  62770. /**
  62771. * Creates a new SelectionPanel
  62772. * @param name of SelectionPanel
  62773. * @param groups is an array of SelectionGroups
  62774. */
  62775. constructor(
  62776. /** name of SelectionPanel */
  62777. name: string,
  62778. /** an array of SelectionGroups */
  62779. groups?: SelectorGroup[]);
  62780. protected _getTypeName(): string;
  62781. /** Gets or sets the headerColor */
  62782. headerColor: string;
  62783. private _setHeaderColor;
  62784. /** Gets or sets the button color */
  62785. buttonColor: string;
  62786. private _setbuttonColor;
  62787. /** Gets or sets the label color */
  62788. labelColor: string;
  62789. private _setLabelColor;
  62790. /** Gets or sets the button background */
  62791. buttonBackground: string;
  62792. private _setButtonBackground;
  62793. /** Gets or sets the color of separator bar */
  62794. barColor: string;
  62795. private _setBarColor;
  62796. /** Gets or sets the height of separator bar */
  62797. barHeight: string;
  62798. private _setBarHeight;
  62799. /** Gets or sets the height of spacers*/
  62800. spacerHeight: string;
  62801. private _setSpacerHeight;
  62802. /** Adds a bar between groups */
  62803. private _addSpacer;
  62804. /** Add a group to the selection panel
  62805. * @param group is the selector group to add
  62806. */
  62807. addGroup(group: SelectorGroup): void;
  62808. /** Remove the group from the given position
  62809. * @param groupNb is the position of the group in the list
  62810. */
  62811. removeGroup(groupNb: number): void;
  62812. /** Change a group header label
  62813. * @param label is the new group header label
  62814. * @param groupNb is the number of the group to relabel
  62815. * */
  62816. setHeaderName(label: string, groupNb: number): void;
  62817. /** Change selector label to the one given
  62818. * @param label is the new selector label
  62819. * @param groupNb is the number of the groupcontaining the selector
  62820. * @param selectorNb is the number of the selector within a group to relabel
  62821. * */
  62822. relabel(label: string, groupNb: number, selectorNb: number): void;
  62823. /** For a given group position remove the selector at the given position
  62824. * @param groupNb is the number of the group to remove the selector from
  62825. * @param selectorNb is the number of the selector within the group
  62826. */
  62827. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  62828. /** For a given group position of correct type add a checkbox button
  62829. * @param groupNb is the number of the group to remove the selector from
  62830. * @param label is the label for the selector
  62831. * @param func is the function called when the Selector is checked
  62832. * @param checked is true when Selector is checked
  62833. */
  62834. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62835. /** For a given group position of correct type add a radio button
  62836. * @param groupNb is the number of the group to remove the selector from
  62837. * @param label is the label for the selector
  62838. * @param func is the function called when the Selector is checked
  62839. * @param checked is true when Selector is checked
  62840. */
  62841. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62842. /**
  62843. * For a given slider group add a slider
  62844. * @param groupNb is the number of the group to add the slider to
  62845. * @param label is the label for the Slider
  62846. * @param func is the function called when the Slider moves
  62847. * @param unit is a string describing the units used, eg degrees or metres
  62848. * @param min is the minimum value for the Slider
  62849. * @param max is the maximum value for the Slider
  62850. * @param value is the start value for the Slider between min and max
  62851. * @param onVal is the function used to format the value displayed, eg radians to degrees
  62852. */
  62853. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  62854. }
  62855. }
  62856. declare module BABYLON.GUI {
  62857. /**
  62858. * Class used to hold a the container for ScrollViewer
  62859. * @hidden
  62860. */
  62861. export class _ScrollViewerWindow extends Container {
  62862. parentClientWidth: number;
  62863. parentClientHeight: number;
  62864. /**
  62865. * Creates a new ScrollViewerWindow
  62866. * @param name of ScrollViewerWindow
  62867. */
  62868. constructor(name?: string);
  62869. protected _getTypeName(): string;
  62870. /** @hidden */
  62871. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62872. protected _postMeasure(): void;
  62873. }
  62874. }
  62875. declare module BABYLON.GUI {
  62876. /**
  62877. * Class used to create slider controls
  62878. */
  62879. export class ScrollBar extends BaseSlider {
  62880. name?: string | undefined;
  62881. private _background;
  62882. private _borderColor;
  62883. private _thumbMeasure;
  62884. /** Gets or sets border color */
  62885. borderColor: string;
  62886. /** Gets or sets background color */
  62887. background: string;
  62888. /**
  62889. * Creates a new Slider
  62890. * @param name defines the control name
  62891. */
  62892. constructor(name?: string | undefined);
  62893. protected _getTypeName(): string;
  62894. protected _getThumbThickness(): number;
  62895. _draw(context: CanvasRenderingContext2D): void;
  62896. private _first;
  62897. private _originX;
  62898. private _originY;
  62899. /** @hidden */
  62900. protected _updateValueFromPointer(x: number, y: number): void;
  62901. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62902. }
  62903. }
  62904. declare module BABYLON.GUI {
  62905. /**
  62906. * Class used to hold a viewer window and sliders in a grid
  62907. */
  62908. export class ScrollViewer extends Rectangle {
  62909. private _grid;
  62910. private _horizontalBarSpace;
  62911. private _verticalBarSpace;
  62912. private _dragSpace;
  62913. private _horizontalBar;
  62914. private _verticalBar;
  62915. private _barColor;
  62916. private _barBackground;
  62917. private _barSize;
  62918. private _endLeft;
  62919. private _endTop;
  62920. private _window;
  62921. private _pointerIsOver;
  62922. private _wheelPrecision;
  62923. private _onPointerObserver;
  62924. private _clientWidth;
  62925. private _clientHeight;
  62926. /**
  62927. * Gets the horizontal scrollbar
  62928. */
  62929. readonly horizontalBar: ScrollBar;
  62930. /**
  62931. * Gets the vertical scrollbar
  62932. */
  62933. readonly verticalBar: ScrollBar;
  62934. /**
  62935. * Adds a new control to the current container
  62936. * @param control defines the control to add
  62937. * @returns the current container
  62938. */
  62939. addControl(control: BABYLON.Nullable<Control>): Container;
  62940. /**
  62941. * Removes a control from the current container
  62942. * @param control defines the control to remove
  62943. * @returns the current container
  62944. */
  62945. removeControl(control: Control): Container;
  62946. /** Gets the list of children */
  62947. readonly children: Control[];
  62948. _flagDescendantsAsMatrixDirty(): void;
  62949. /**
  62950. * Creates a new ScrollViewer
  62951. * @param name of ScrollViewer
  62952. */
  62953. constructor(name?: string);
  62954. /** Reset the scroll viewer window to initial size */
  62955. resetWindow(): void;
  62956. protected _getTypeName(): string;
  62957. private _buildClientSizes;
  62958. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62959. protected _postMeasure(): void;
  62960. /**
  62961. * Gets or sets the mouse wheel precision
  62962. * from 0 to 1 with a default value of 0.05
  62963. * */
  62964. wheelPrecision: number;
  62965. /** Gets or sets the bar color */
  62966. barColor: string;
  62967. /** Gets or sets the size of the bar */
  62968. barSize: number;
  62969. /** Gets or sets the bar background */
  62970. barBackground: string;
  62971. /** @hidden */
  62972. private _updateScroller;
  62973. _link(host: AdvancedDynamicTexture): void;
  62974. /** @hidden */
  62975. private _attachWheel;
  62976. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62977. /** Releases associated resources */
  62978. dispose(): void;
  62979. }
  62980. }
  62981. declare module BABYLON.GUI {
  62982. /** Class used to render a grid */
  62983. export class DisplayGrid extends Control {
  62984. name?: string | undefined;
  62985. private _cellWidth;
  62986. private _cellHeight;
  62987. private _minorLineTickness;
  62988. private _minorLineColor;
  62989. private _majorLineTickness;
  62990. private _majorLineColor;
  62991. private _majorLineFrequency;
  62992. private _background;
  62993. private _displayMajorLines;
  62994. private _displayMinorLines;
  62995. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  62996. displayMinorLines: boolean;
  62997. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  62998. displayMajorLines: boolean;
  62999. /** Gets or sets background color (Black by default) */
  63000. background: string;
  63001. /** Gets or sets the width of each cell (20 by default) */
  63002. cellWidth: number;
  63003. /** Gets or sets the height of each cell (20 by default) */
  63004. cellHeight: number;
  63005. /** Gets or sets the tickness of minor lines (1 by default) */
  63006. minorLineTickness: number;
  63007. /** Gets or sets the color of minor lines (DarkGray by default) */
  63008. minorLineColor: string;
  63009. /** Gets or sets the tickness of major lines (2 by default) */
  63010. majorLineTickness: number;
  63011. /** Gets or sets the color of major lines (White by default) */
  63012. majorLineColor: string;
  63013. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  63014. majorLineFrequency: number;
  63015. /**
  63016. * Creates a new GridDisplayRectangle
  63017. * @param name defines the control name
  63018. */
  63019. constructor(name?: string | undefined);
  63020. _draw(context: CanvasRenderingContext2D): void;
  63021. protected _getTypeName(): string;
  63022. }
  63023. }
  63024. declare module BABYLON.GUI {
  63025. /**
  63026. * Class used to create slider controls based on images
  63027. */
  63028. export class ImageBasedSlider extends BaseSlider {
  63029. name?: string | undefined;
  63030. private _backgroundImage;
  63031. private _thumbImage;
  63032. private _valueBarImage;
  63033. private _tempMeasure;
  63034. displayThumb: boolean;
  63035. /**
  63036. * Gets or sets the image used to render the background
  63037. */
  63038. backgroundImage: Image;
  63039. /**
  63040. * Gets or sets the image used to render the value bar
  63041. */
  63042. valueBarImage: Image;
  63043. /**
  63044. * Gets or sets the image used to render the thumb
  63045. */
  63046. thumbImage: Image;
  63047. /**
  63048. * Creates a new ImageBasedSlider
  63049. * @param name defines the control name
  63050. */
  63051. constructor(name?: string | undefined);
  63052. protected _getTypeName(): string;
  63053. _draw(context: CanvasRenderingContext2D): void;
  63054. }
  63055. }
  63056. declare module BABYLON.GUI {
  63057. /**
  63058. * Forcing an export so that this code will execute
  63059. * @hidden
  63060. */
  63061. const name = "Statics";
  63062. }
  63063. declare module BABYLON.GUI {
  63064. /**
  63065. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  63066. */
  63067. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  63068. /**
  63069. * Define the instrumented AdvancedDynamicTexture.
  63070. */
  63071. texture: AdvancedDynamicTexture;
  63072. private _captureRenderTime;
  63073. private _renderTime;
  63074. private _captureLayoutTime;
  63075. private _layoutTime;
  63076. private _onBeginRenderObserver;
  63077. private _onEndRenderObserver;
  63078. private _onBeginLayoutObserver;
  63079. private _onEndLayoutObserver;
  63080. /**
  63081. * Gets the perf counter used to capture render time
  63082. */
  63083. readonly renderTimeCounter: BABYLON.PerfCounter;
  63084. /**
  63085. * Gets the perf counter used to capture layout time
  63086. */
  63087. readonly layoutTimeCounter: BABYLON.PerfCounter;
  63088. /**
  63089. * Enable or disable the render time capture
  63090. */
  63091. captureRenderTime: boolean;
  63092. /**
  63093. * Enable or disable the layout time capture
  63094. */
  63095. captureLayoutTime: boolean;
  63096. /**
  63097. * Instantiates a new advanced dynamic texture instrumentation.
  63098. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  63099. * @param texture Defines the AdvancedDynamicTexture to instrument
  63100. */
  63101. constructor(
  63102. /**
  63103. * Define the instrumented AdvancedDynamicTexture.
  63104. */
  63105. texture: AdvancedDynamicTexture);
  63106. /**
  63107. * Dispose and release associated resources.
  63108. */
  63109. dispose(): void;
  63110. }
  63111. }
  63112. declare module BABYLON.GUI {
  63113. /**
  63114. * Class used to create containers for controls
  63115. */
  63116. export class Container3D extends Control3D {
  63117. private _blockLayout;
  63118. /**
  63119. * Gets the list of child controls
  63120. */
  63121. protected _children: Control3D[];
  63122. /**
  63123. * Gets the list of child controls
  63124. */
  63125. readonly children: Array<Control3D>;
  63126. /**
  63127. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  63128. * This is helpful to optimize layout operation when adding multiple children in a row
  63129. */
  63130. blockLayout: boolean;
  63131. /**
  63132. * Creates a new container
  63133. * @param name defines the container name
  63134. */
  63135. constructor(name?: string);
  63136. /**
  63137. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  63138. * @returns the current container
  63139. */
  63140. updateLayout(): Container3D;
  63141. /**
  63142. * Gets a boolean indicating if the given control is in the children of this control
  63143. * @param control defines the control to check
  63144. * @returns true if the control is in the child list
  63145. */
  63146. containsControl(control: Control3D): boolean;
  63147. /**
  63148. * Adds a control to the children of this control
  63149. * @param control defines the control to add
  63150. * @returns the current container
  63151. */
  63152. addControl(control: Control3D): Container3D;
  63153. /**
  63154. * This function will be called everytime a new control is added
  63155. */
  63156. protected _arrangeChildren(): void;
  63157. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63158. /**
  63159. * Removes a control from the children of this control
  63160. * @param control defines the control to remove
  63161. * @returns the current container
  63162. */
  63163. removeControl(control: Control3D): Container3D;
  63164. protected _getTypeName(): string;
  63165. /**
  63166. * Releases all associated resources
  63167. */
  63168. dispose(): void;
  63169. /** Control rotation will remain unchanged */
  63170. static readonly UNSET_ORIENTATION: number;
  63171. /** Control will rotate to make it look at sphere central axis */
  63172. static readonly FACEORIGIN_ORIENTATION: number;
  63173. /** Control will rotate to make it look back at sphere central axis */
  63174. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  63175. /** Control will rotate to look at z axis (0, 0, 1) */
  63176. static readonly FACEFORWARD_ORIENTATION: number;
  63177. /** Control will rotate to look at negative z axis (0, 0, -1) */
  63178. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  63179. }
  63180. }
  63181. declare module BABYLON.GUI {
  63182. /**
  63183. * Class used to manage 3D user interface
  63184. * @see http://doc.babylonjs.com/how_to/gui3d
  63185. */
  63186. export class GUI3DManager implements BABYLON.IDisposable {
  63187. private _scene;
  63188. private _sceneDisposeObserver;
  63189. private _utilityLayer;
  63190. private _rootContainer;
  63191. private _pointerObserver;
  63192. private _pointerOutObserver;
  63193. /** @hidden */
  63194. _lastPickedControl: Control3D;
  63195. /** @hidden */
  63196. _lastControlOver: {
  63197. [pointerId: number]: Control3D;
  63198. };
  63199. /** @hidden */
  63200. _lastControlDown: {
  63201. [pointerId: number]: Control3D;
  63202. };
  63203. /**
  63204. * BABYLON.Observable raised when the point picked by the pointer events changed
  63205. */
  63206. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  63207. /** @hidden */
  63208. _sharedMaterials: {
  63209. [key: string]: BABYLON.Material;
  63210. };
  63211. /** Gets the hosting scene */
  63212. readonly scene: BABYLON.Scene;
  63213. /** Gets associated utility layer */
  63214. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  63215. /**
  63216. * Creates a new GUI3DManager
  63217. * @param scene
  63218. */
  63219. constructor(scene?: BABYLON.Scene);
  63220. private _handlePointerOut;
  63221. private _doPicking;
  63222. /**
  63223. * Gets the root container
  63224. */
  63225. readonly rootContainer: Container3D;
  63226. /**
  63227. * Gets a boolean indicating if the given control is in the root child list
  63228. * @param control defines the control to check
  63229. * @returns true if the control is in the root child list
  63230. */
  63231. containsControl(control: Control3D): boolean;
  63232. /**
  63233. * Adds a control to the root child list
  63234. * @param control defines the control to add
  63235. * @returns the current manager
  63236. */
  63237. addControl(control: Control3D): GUI3DManager;
  63238. /**
  63239. * Removes a control from the root child list
  63240. * @param control defines the control to remove
  63241. * @returns the current container
  63242. */
  63243. removeControl(control: Control3D): GUI3DManager;
  63244. /**
  63245. * Releases all associated resources
  63246. */
  63247. dispose(): void;
  63248. }
  63249. }
  63250. declare module BABYLON.GUI {
  63251. /**
  63252. * Class used to transport BABYLON.Vector3 information for pointer events
  63253. */
  63254. export class Vector3WithInfo extends BABYLON.Vector3 {
  63255. /** defines the current mouse button index */
  63256. buttonIndex: number;
  63257. /**
  63258. * Creates a new Vector3WithInfo
  63259. * @param source defines the vector3 data to transport
  63260. * @param buttonIndex defines the current mouse button index
  63261. */
  63262. constructor(source: BABYLON.Vector3,
  63263. /** defines the current mouse button index */
  63264. buttonIndex?: number);
  63265. }
  63266. }
  63267. declare module BABYLON.GUI {
  63268. /**
  63269. * Class used as base class for controls
  63270. */
  63271. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  63272. /** Defines the control name */
  63273. name?: string | undefined;
  63274. /** @hidden */
  63275. _host: GUI3DManager;
  63276. private _node;
  63277. private _downCount;
  63278. private _enterCount;
  63279. private _downPointerIds;
  63280. private _isVisible;
  63281. /** Gets or sets the control position in world space */
  63282. position: BABYLON.Vector3;
  63283. /** Gets or sets the control scaling in world space */
  63284. scaling: BABYLON.Vector3;
  63285. /** Callback used to start pointer enter animation */
  63286. pointerEnterAnimation: () => void;
  63287. /** Callback used to start pointer out animation */
  63288. pointerOutAnimation: () => void;
  63289. /** Callback used to start pointer down animation */
  63290. pointerDownAnimation: () => void;
  63291. /** Callback used to start pointer up animation */
  63292. pointerUpAnimation: () => void;
  63293. /**
  63294. * An event triggered when the pointer move over the control
  63295. */
  63296. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  63297. /**
  63298. * An event triggered when the pointer move out of the control
  63299. */
  63300. onPointerOutObservable: BABYLON.Observable<Control3D>;
  63301. /**
  63302. * An event triggered when the pointer taps the control
  63303. */
  63304. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  63305. /**
  63306. * An event triggered when pointer is up
  63307. */
  63308. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  63309. /**
  63310. * An event triggered when a control is clicked on (with a mouse)
  63311. */
  63312. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  63313. /**
  63314. * An event triggered when pointer enters the control
  63315. */
  63316. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  63317. /**
  63318. * Gets or sets the parent container
  63319. */
  63320. parent: BABYLON.Nullable<Container3D>;
  63321. private _behaviors;
  63322. /**
  63323. * Gets the list of attached behaviors
  63324. * @see http://doc.babylonjs.com/features/behaviour
  63325. */
  63326. readonly behaviors: BABYLON.Behavior<Control3D>[];
  63327. /**
  63328. * Attach a behavior to the control
  63329. * @see http://doc.babylonjs.com/features/behaviour
  63330. * @param behavior defines the behavior to attach
  63331. * @returns the current control
  63332. */
  63333. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  63334. /**
  63335. * Remove an attached behavior
  63336. * @see http://doc.babylonjs.com/features/behaviour
  63337. * @param behavior defines the behavior to attach
  63338. * @returns the current control
  63339. */
  63340. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  63341. /**
  63342. * Gets an attached behavior by name
  63343. * @param name defines the name of the behavior to look for
  63344. * @see http://doc.babylonjs.com/features/behaviour
  63345. * @returns null if behavior was not found else the requested behavior
  63346. */
  63347. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  63348. /** Gets or sets a boolean indicating if the control is visible */
  63349. isVisible: boolean;
  63350. /**
  63351. * Creates a new control
  63352. * @param name defines the control name
  63353. */
  63354. constructor(
  63355. /** Defines the control name */
  63356. name?: string | undefined);
  63357. /**
  63358. * Gets a string representing the class name
  63359. */
  63360. readonly typeName: string;
  63361. /**
  63362. * Get the current class name of the control.
  63363. * @returns current class name
  63364. */
  63365. getClassName(): string;
  63366. protected _getTypeName(): string;
  63367. /**
  63368. * Gets the transform node used by this control
  63369. */
  63370. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  63371. /**
  63372. * Gets the mesh used to render this control
  63373. */
  63374. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63375. /**
  63376. * Link the control as child of the given node
  63377. * @param node defines the node to link to. Use null to unlink the control
  63378. * @returns the current control
  63379. */
  63380. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  63381. /** @hidden **/
  63382. _prepareNode(scene: BABYLON.Scene): void;
  63383. /**
  63384. * Node creation.
  63385. * Can be overriden by children
  63386. * @param scene defines the scene where the node must be attached
  63387. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  63388. */
  63389. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63390. /**
  63391. * Affect a material to the given mesh
  63392. * @param mesh defines the mesh which will represent the control
  63393. */
  63394. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63395. /** @hidden */
  63396. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  63397. /** @hidden */
  63398. _onPointerEnter(target: Control3D): boolean;
  63399. /** @hidden */
  63400. _onPointerOut(target: Control3D): void;
  63401. /** @hidden */
  63402. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63403. /** @hidden */
  63404. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63405. /** @hidden */
  63406. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63407. /** @hidden */
  63408. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63409. /** @hidden */
  63410. _disposeNode(): void;
  63411. /**
  63412. * Releases all associated resources
  63413. */
  63414. dispose(): void;
  63415. }
  63416. }
  63417. declare module BABYLON.GUI {
  63418. /**
  63419. * Class used as a root to all buttons
  63420. */
  63421. export class AbstractButton3D extends Control3D {
  63422. /**
  63423. * Creates a new button
  63424. * @param name defines the control name
  63425. */
  63426. constructor(name?: string);
  63427. protected _getTypeName(): string;
  63428. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63429. }
  63430. }
  63431. declare module BABYLON.GUI {
  63432. /**
  63433. * Class used to create a button in 3D
  63434. */
  63435. export class Button3D extends AbstractButton3D {
  63436. /** @hidden */
  63437. protected _currentMaterial: BABYLON.Material;
  63438. private _facadeTexture;
  63439. private _content;
  63440. private _contentResolution;
  63441. private _contentScaleRatio;
  63442. /**
  63443. * Gets or sets the texture resolution used to render content (512 by default)
  63444. */
  63445. contentResolution: BABYLON.int;
  63446. /**
  63447. * Gets or sets the texture scale ratio used to render content (2 by default)
  63448. */
  63449. contentScaleRatio: number;
  63450. protected _disposeFacadeTexture(): void;
  63451. protected _resetContent(): void;
  63452. /**
  63453. * Creates a new button
  63454. * @param name defines the control name
  63455. */
  63456. constructor(name?: string);
  63457. /**
  63458. * Gets or sets the GUI 2D content used to display the button's facade
  63459. */
  63460. content: Control;
  63461. /**
  63462. * Apply the facade texture (created from the content property).
  63463. * This function can be overloaded by child classes
  63464. * @param facadeTexture defines the AdvancedDynamicTexture to use
  63465. */
  63466. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63467. protected _getTypeName(): string;
  63468. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63469. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63470. /**
  63471. * Releases all associated resources
  63472. */
  63473. dispose(): void;
  63474. }
  63475. }
  63476. declare module BABYLON.GUI {
  63477. /**
  63478. * Abstract class used to create a container panel deployed on the surface of a volume
  63479. */
  63480. export abstract class VolumeBasedPanel extends Container3D {
  63481. private _columns;
  63482. private _rows;
  63483. private _rowThenColum;
  63484. private _orientation;
  63485. protected _cellWidth: number;
  63486. protected _cellHeight: number;
  63487. /**
  63488. * Gets or sets the distance between elements
  63489. */
  63490. margin: number;
  63491. /**
  63492. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  63493. * | Value | Type | Description |
  63494. * | ----- | ----------------------------------- | ----------- |
  63495. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  63496. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  63497. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  63498. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  63499. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  63500. */
  63501. orientation: number;
  63502. /**
  63503. * Gets or sets the number of columns requested (10 by default).
  63504. * The panel will automatically compute the number of rows based on number of child controls.
  63505. */
  63506. columns: BABYLON.int;
  63507. /**
  63508. * Gets or sets a the number of rows requested.
  63509. * The panel will automatically compute the number of columns based on number of child controls.
  63510. */
  63511. rows: BABYLON.int;
  63512. /**
  63513. * Creates new VolumeBasedPanel
  63514. */
  63515. constructor();
  63516. protected _arrangeChildren(): void;
  63517. /** Child classes must implement this function to provide correct control positioning */
  63518. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63519. /** Child classes can implement this function to provide additional processing */
  63520. protected _finalProcessing(): void;
  63521. }
  63522. }
  63523. declare module BABYLON.GUI {
  63524. /**
  63525. * Class used to create a container panel deployed on the surface of a cylinder
  63526. */
  63527. export class CylinderPanel extends VolumeBasedPanel {
  63528. private _radius;
  63529. /**
  63530. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  63531. */
  63532. radius: BABYLON.float;
  63533. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63534. private _cylindricalMapping;
  63535. }
  63536. }
  63537. declare module BABYLON.GUI {
  63538. /** @hidden */
  63539. export var fluentVertexShader: {
  63540. name: string;
  63541. shader: string;
  63542. };
  63543. }
  63544. declare module BABYLON.GUI {
  63545. /** @hidden */
  63546. export var fluentPixelShader: {
  63547. name: string;
  63548. shader: string;
  63549. };
  63550. }
  63551. declare module BABYLON.GUI {
  63552. /** @hidden */
  63553. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  63554. INNERGLOW: boolean;
  63555. BORDER: boolean;
  63556. HOVERLIGHT: boolean;
  63557. TEXTURE: boolean;
  63558. constructor();
  63559. }
  63560. /**
  63561. * Class used to render controls with fluent desgin
  63562. */
  63563. export class FluentMaterial extends BABYLON.PushMaterial {
  63564. /**
  63565. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  63566. */
  63567. innerGlowColorIntensity: number;
  63568. /**
  63569. * Gets or sets the inner glow color (white by default)
  63570. */
  63571. innerGlowColor: BABYLON.Color3;
  63572. /**
  63573. * Gets or sets alpha value (default is 1.0)
  63574. */
  63575. alpha: number;
  63576. /**
  63577. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  63578. */
  63579. albedoColor: BABYLON.Color3;
  63580. /**
  63581. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  63582. */
  63583. renderBorders: boolean;
  63584. /**
  63585. * Gets or sets border width (default is 0.5)
  63586. */
  63587. borderWidth: number;
  63588. /**
  63589. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  63590. */
  63591. edgeSmoothingValue: number;
  63592. /**
  63593. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  63594. */
  63595. borderMinValue: number;
  63596. /**
  63597. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  63598. */
  63599. renderHoverLight: boolean;
  63600. /**
  63601. * Gets or sets the radius used to render the hover light (default is 1.0)
  63602. */
  63603. hoverRadius: number;
  63604. /**
  63605. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  63606. */
  63607. hoverColor: BABYLON.Color4;
  63608. /**
  63609. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  63610. */
  63611. hoverPosition: BABYLON.Vector3;
  63612. private _albedoTexture;
  63613. /** Gets or sets the texture to use for albedo color */
  63614. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63615. /**
  63616. * Creates a new Fluent material
  63617. * @param name defines the name of the material
  63618. * @param scene defines the hosting scene
  63619. */
  63620. constructor(name: string, scene: BABYLON.Scene);
  63621. needAlphaBlending(): boolean;
  63622. needAlphaTesting(): boolean;
  63623. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63624. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63625. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63626. getActiveTextures(): BABYLON.BaseTexture[];
  63627. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63628. dispose(forceDisposeEffect?: boolean): void;
  63629. clone(name: string): FluentMaterial;
  63630. serialize(): any;
  63631. getClassName(): string;
  63632. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  63633. }
  63634. }
  63635. declare module BABYLON.GUI {
  63636. /**
  63637. * Class used to create a holographic button in 3D
  63638. */
  63639. export class HolographicButton extends Button3D {
  63640. private _backPlate;
  63641. private _textPlate;
  63642. private _frontPlate;
  63643. private _text;
  63644. private _imageUrl;
  63645. private _shareMaterials;
  63646. private _frontMaterial;
  63647. private _backMaterial;
  63648. private _plateMaterial;
  63649. private _pickedPointObserver;
  63650. private _tooltipFade;
  63651. private _tooltipTextBlock;
  63652. private _tooltipTexture;
  63653. private _tooltipMesh;
  63654. private _tooltipHoverObserver;
  63655. private _tooltipOutObserver;
  63656. private _disposeTooltip;
  63657. /**
  63658. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  63659. */
  63660. tooltipText: BABYLON.Nullable<string>;
  63661. /**
  63662. * Gets or sets text for the button
  63663. */
  63664. text: string;
  63665. /**
  63666. * Gets or sets the image url for the button
  63667. */
  63668. imageUrl: string;
  63669. /**
  63670. * Gets the back material used by this button
  63671. */
  63672. readonly backMaterial: FluentMaterial;
  63673. /**
  63674. * Gets the front material used by this button
  63675. */
  63676. readonly frontMaterial: FluentMaterial;
  63677. /**
  63678. * Gets the plate material used by this button
  63679. */
  63680. readonly plateMaterial: BABYLON.StandardMaterial;
  63681. /**
  63682. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  63683. */
  63684. readonly shareMaterials: boolean;
  63685. /**
  63686. * Creates a new button
  63687. * @param name defines the control name
  63688. */
  63689. constructor(name?: string, shareMaterials?: boolean);
  63690. protected _getTypeName(): string;
  63691. private _rebuildContent;
  63692. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63693. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63694. private _createBackMaterial;
  63695. private _createFrontMaterial;
  63696. private _createPlateMaterial;
  63697. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  63698. /**
  63699. * Releases all associated resources
  63700. */
  63701. dispose(): void;
  63702. }
  63703. }
  63704. declare module BABYLON.GUI {
  63705. /**
  63706. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  63707. */
  63708. export class MeshButton3D extends Button3D {
  63709. /** @hidden */
  63710. protected _currentMesh: BABYLON.Mesh;
  63711. /**
  63712. * Creates a new 3D button based on a mesh
  63713. * @param mesh mesh to become a 3D button
  63714. * @param name defines the control name
  63715. */
  63716. constructor(mesh: BABYLON.Mesh, name?: string);
  63717. protected _getTypeName(): string;
  63718. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63719. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63720. }
  63721. }
  63722. declare module BABYLON.GUI {
  63723. /**
  63724. * Class used to create a container panel deployed on the surface of a plane
  63725. */
  63726. export class PlanePanel extends VolumeBasedPanel {
  63727. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63728. }
  63729. }
  63730. declare module BABYLON.GUI {
  63731. /**
  63732. * Class used to create a container panel where items get randomized planar mapping
  63733. */
  63734. export class ScatterPanel extends VolumeBasedPanel {
  63735. private _iteration;
  63736. /**
  63737. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  63738. */
  63739. iteration: BABYLON.float;
  63740. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63741. private _scatterMapping;
  63742. protected _finalProcessing(): void;
  63743. }
  63744. }
  63745. declare module BABYLON.GUI {
  63746. /**
  63747. * Class used to create a container panel deployed on the surface of a sphere
  63748. */
  63749. export class SpherePanel extends VolumeBasedPanel {
  63750. private _radius;
  63751. /**
  63752. * Gets or sets the radius of the sphere where to project controls (5 by default)
  63753. */
  63754. radius: BABYLON.float;
  63755. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63756. private _sphericalMapping;
  63757. }
  63758. }
  63759. declare module BABYLON.GUI {
  63760. /**
  63761. * Class used to create a stack panel in 3D on XY plane
  63762. */
  63763. export class StackPanel3D extends Container3D {
  63764. private _isVertical;
  63765. /**
  63766. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  63767. */
  63768. isVertical: boolean;
  63769. /**
  63770. * Gets or sets the distance between elements
  63771. */
  63772. margin: number;
  63773. /**
  63774. * Creates new StackPanel
  63775. * @param isVertical
  63776. */
  63777. constructor(isVertical?: boolean);
  63778. protected _arrangeChildren(): void;
  63779. }
  63780. }
  63781. declare module BABYLON {
  63782. /**
  63783. * Mode that determines the coordinate system to use.
  63784. */
  63785. export enum GLTFLoaderCoordinateSystemMode {
  63786. /**
  63787. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  63788. */
  63789. AUTO = 0,
  63790. /**
  63791. * Sets the useRightHandedSystem flag on the scene.
  63792. */
  63793. FORCE_RIGHT_HANDED = 1
  63794. }
  63795. /**
  63796. * Mode that determines what animations will start.
  63797. */
  63798. export enum GLTFLoaderAnimationStartMode {
  63799. /**
  63800. * No animation will start.
  63801. */
  63802. NONE = 0,
  63803. /**
  63804. * The first animation will start.
  63805. */
  63806. FIRST = 1,
  63807. /**
  63808. * All animations will start.
  63809. */
  63810. ALL = 2
  63811. }
  63812. /**
  63813. * Interface that contains the data for the glTF asset.
  63814. */
  63815. export interface IGLTFLoaderData {
  63816. /**
  63817. * Object that represents the glTF JSON.
  63818. */
  63819. json: Object;
  63820. /**
  63821. * The BIN chunk of a binary glTF.
  63822. */
  63823. bin: Nullable<ArrayBufferView>;
  63824. }
  63825. /**
  63826. * Interface for extending the loader.
  63827. */
  63828. export interface IGLTFLoaderExtension {
  63829. /**
  63830. * The name of this extension.
  63831. */
  63832. readonly name: string;
  63833. /**
  63834. * Defines whether this extension is enabled.
  63835. */
  63836. enabled: boolean;
  63837. }
  63838. /**
  63839. * Loader state.
  63840. */
  63841. export enum GLTFLoaderState {
  63842. /**
  63843. * The asset is loading.
  63844. */
  63845. LOADING = 0,
  63846. /**
  63847. * The asset is ready for rendering.
  63848. */
  63849. READY = 1,
  63850. /**
  63851. * The asset is completely loaded.
  63852. */
  63853. COMPLETE = 2
  63854. }
  63855. /** @hidden */
  63856. export interface IGLTFLoader extends IDisposable {
  63857. readonly state: Nullable<GLTFLoaderState>;
  63858. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  63859. meshes: AbstractMesh[];
  63860. particleSystems: IParticleSystem[];
  63861. skeletons: Skeleton[];
  63862. animationGroups: AnimationGroup[];
  63863. }>;
  63864. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  63865. }
  63866. /**
  63867. * File loader for loading glTF files into a scene.
  63868. */
  63869. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  63870. /** @hidden */
  63871. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63872. /** @hidden */
  63873. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63874. /**
  63875. * Raised when the asset has been parsed
  63876. */
  63877. onParsedObservable: Observable<IGLTFLoaderData>;
  63878. private _onParsedObserver;
  63879. /**
  63880. * Raised when the asset has been parsed
  63881. */
  63882. onParsed: (loaderData: IGLTFLoaderData) => void;
  63883. /**
  63884. * 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.
  63885. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  63886. * Defaults to true.
  63887. * @hidden
  63888. */
  63889. static IncrementalLoading: boolean;
  63890. /**
  63891. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  63892. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  63893. * @hidden
  63894. */
  63895. static HomogeneousCoordinates: boolean;
  63896. /**
  63897. * The coordinate system mode. Defaults to AUTO.
  63898. */
  63899. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  63900. /**
  63901. * The animation start mode. Defaults to FIRST.
  63902. */
  63903. animationStartMode: GLTFLoaderAnimationStartMode;
  63904. /**
  63905. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  63906. */
  63907. compileMaterials: boolean;
  63908. /**
  63909. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  63910. */
  63911. useClipPlane: boolean;
  63912. /**
  63913. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  63914. */
  63915. compileShadowGenerators: boolean;
  63916. /**
  63917. * Defines if the Alpha blended materials are only applied as coverage.
  63918. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  63919. * If true, no extra effects are applied to transparent pixels.
  63920. */
  63921. transparencyAsCoverage: boolean;
  63922. /**
  63923. * Function called before loading a url referenced by the asset.
  63924. */
  63925. preprocessUrlAsync: (url: string) => Promise<string>;
  63926. /**
  63927. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63928. */
  63929. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  63930. private _onMeshLoadedObserver;
  63931. /**
  63932. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63933. */
  63934. onMeshLoaded: (mesh: AbstractMesh) => void;
  63935. /**
  63936. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  63937. */
  63938. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  63939. private _onTextureLoadedObserver;
  63940. /**
  63941. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  63942. */
  63943. onTextureLoaded: (texture: BaseTexture) => void;
  63944. /**
  63945. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  63946. */
  63947. readonly onMaterialLoadedObservable: Observable<Material>;
  63948. private _onMaterialLoadedObserver;
  63949. /**
  63950. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  63951. */
  63952. onMaterialLoaded: (material: Material) => void;
  63953. /**
  63954. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  63955. */
  63956. readonly onCameraLoadedObservable: Observable<Camera>;
  63957. private _onCameraLoadedObserver;
  63958. /**
  63959. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  63960. */
  63961. onCameraLoaded: (camera: Camera) => void;
  63962. /**
  63963. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  63964. * For assets with LODs, raised when all of the LODs are complete.
  63965. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63966. */
  63967. readonly onCompleteObservable: Observable<void>;
  63968. private _onCompleteObserver;
  63969. /**
  63970. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  63971. * For assets with LODs, raised when all of the LODs are complete.
  63972. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63973. */
  63974. onComplete: () => void;
  63975. /**
  63976. * Observable raised when an error occurs.
  63977. */
  63978. readonly onErrorObservable: Observable<any>;
  63979. private _onErrorObserver;
  63980. /**
  63981. * Callback raised when an error occurs.
  63982. */
  63983. onError: (reason: any) => void;
  63984. /**
  63985. * Observable raised after the loader is disposed.
  63986. */
  63987. readonly onDisposeObservable: Observable<void>;
  63988. private _onDisposeObserver;
  63989. /**
  63990. * Callback raised after the loader is disposed.
  63991. */
  63992. onDispose: () => void;
  63993. /**
  63994. * Observable raised after a loader extension is created.
  63995. * Set additional options for a loader extension in this event.
  63996. */
  63997. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  63998. private _onExtensionLoadedObserver;
  63999. /**
  64000. * Callback raised after a loader extension is created.
  64001. */
  64002. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  64003. /**
  64004. * Defines if the loader logging is enabled.
  64005. */
  64006. loggingEnabled: boolean;
  64007. /**
  64008. * Defines if the loader should capture performance counters.
  64009. */
  64010. capturePerformanceCounters: boolean;
  64011. /**
  64012. * Defines if the loader should validate the asset.
  64013. */
  64014. validate: boolean;
  64015. /**
  64016. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  64017. */
  64018. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  64019. private _onValidatedObserver;
  64020. /**
  64021. * Callback raised after a loader extension is created.
  64022. */
  64023. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  64024. private _loader;
  64025. /**
  64026. * Name of the loader ("gltf")
  64027. */
  64028. name: string;
  64029. /**
  64030. * Supported file extensions of the loader (.gltf, .glb)
  64031. */
  64032. extensions: ISceneLoaderPluginExtensions;
  64033. /**
  64034. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  64035. */
  64036. dispose(): void;
  64037. /** @hidden */
  64038. _clear(): void;
  64039. /**
  64040. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  64041. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64042. * @param scene the scene the meshes should be added to
  64043. * @param data the glTF data to load
  64044. * @param rootUrl root url to load from
  64045. * @param onProgress event that fires when loading progress has occured
  64046. * @param fileName Defines the name of the file to load
  64047. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64048. */
  64049. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64050. meshes: AbstractMesh[];
  64051. particleSystems: IParticleSystem[];
  64052. skeletons: Skeleton[];
  64053. animationGroups: AnimationGroup[];
  64054. }>;
  64055. /**
  64056. * Imports all objects from the loaded glTF data and adds them to the scene
  64057. * @param scene the scene the objects should be added to
  64058. * @param data the glTF data to load
  64059. * @param rootUrl root url to load from
  64060. * @param onProgress event that fires when loading progress has occured
  64061. * @param fileName Defines the name of the file to load
  64062. * @returns a promise which completes when objects have been loaded to the scene
  64063. */
  64064. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64065. /**
  64066. * Load into an asset container.
  64067. * @param scene The scene to load into
  64068. * @param data The data to import
  64069. * @param rootUrl The root url for scene and resources
  64070. * @param onProgress The callback when the load progresses
  64071. * @param fileName Defines the name of the file to load
  64072. * @returns The loaded asset container
  64073. */
  64074. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64075. /**
  64076. * If the data string can be loaded directly.
  64077. * @param data string contianing the file data
  64078. * @returns if the data can be loaded directly
  64079. */
  64080. canDirectLoad(data: string): boolean;
  64081. /**
  64082. * Rewrites a url by combining a root url and response url.
  64083. */
  64084. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  64085. /**
  64086. * Instantiates a glTF file loader plugin.
  64087. * @returns the created plugin
  64088. */
  64089. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  64090. /**
  64091. * The loader state or null if the loader is not active.
  64092. */
  64093. readonly loaderState: Nullable<GLTFLoaderState>;
  64094. /**
  64095. * Returns a promise that resolves when the asset is completely loaded.
  64096. * @returns a promise that resolves when the asset is completely loaded.
  64097. */
  64098. whenCompleteAsync(): Promise<void>;
  64099. private _parseAsync;
  64100. private _validateAsync;
  64101. private _getLoader;
  64102. private _unpackBinary;
  64103. private _unpackBinaryV1;
  64104. private _unpackBinaryV2;
  64105. private static _parseVersion;
  64106. private static _compareVersion;
  64107. private static _decodeBufferToText;
  64108. private static readonly _logSpaces;
  64109. private _logIndentLevel;
  64110. private _loggingEnabled;
  64111. /** @hidden */
  64112. _log: (message: string) => void;
  64113. /** @hidden */
  64114. _logOpen(message: string): void;
  64115. /** @hidden */
  64116. _logClose(): void;
  64117. private _logEnabled;
  64118. private _logDisabled;
  64119. private _capturePerformanceCounters;
  64120. /** @hidden */
  64121. _startPerformanceCounter: (counterName: string) => void;
  64122. /** @hidden */
  64123. _endPerformanceCounter: (counterName: string) => void;
  64124. private _startPerformanceCounterEnabled;
  64125. private _startPerformanceCounterDisabled;
  64126. private _endPerformanceCounterEnabled;
  64127. private _endPerformanceCounterDisabled;
  64128. }
  64129. }
  64130. declare module BABYLON.GLTF1 {
  64131. /**
  64132. * Enums
  64133. * @hidden
  64134. */
  64135. export enum EComponentType {
  64136. BYTE = 5120,
  64137. UNSIGNED_BYTE = 5121,
  64138. SHORT = 5122,
  64139. UNSIGNED_SHORT = 5123,
  64140. FLOAT = 5126
  64141. }
  64142. /** @hidden */
  64143. export enum EShaderType {
  64144. FRAGMENT = 35632,
  64145. VERTEX = 35633
  64146. }
  64147. /** @hidden */
  64148. export enum EParameterType {
  64149. BYTE = 5120,
  64150. UNSIGNED_BYTE = 5121,
  64151. SHORT = 5122,
  64152. UNSIGNED_SHORT = 5123,
  64153. INT = 5124,
  64154. UNSIGNED_INT = 5125,
  64155. FLOAT = 5126,
  64156. FLOAT_VEC2 = 35664,
  64157. FLOAT_VEC3 = 35665,
  64158. FLOAT_VEC4 = 35666,
  64159. INT_VEC2 = 35667,
  64160. INT_VEC3 = 35668,
  64161. INT_VEC4 = 35669,
  64162. BOOL = 35670,
  64163. BOOL_VEC2 = 35671,
  64164. BOOL_VEC3 = 35672,
  64165. BOOL_VEC4 = 35673,
  64166. FLOAT_MAT2 = 35674,
  64167. FLOAT_MAT3 = 35675,
  64168. FLOAT_MAT4 = 35676,
  64169. SAMPLER_2D = 35678
  64170. }
  64171. /** @hidden */
  64172. export enum ETextureWrapMode {
  64173. CLAMP_TO_EDGE = 33071,
  64174. MIRRORED_REPEAT = 33648,
  64175. REPEAT = 10497
  64176. }
  64177. /** @hidden */
  64178. export enum ETextureFilterType {
  64179. NEAREST = 9728,
  64180. LINEAR = 9728,
  64181. NEAREST_MIPMAP_NEAREST = 9984,
  64182. LINEAR_MIPMAP_NEAREST = 9985,
  64183. NEAREST_MIPMAP_LINEAR = 9986,
  64184. LINEAR_MIPMAP_LINEAR = 9987
  64185. }
  64186. /** @hidden */
  64187. export enum ETextureFormat {
  64188. ALPHA = 6406,
  64189. RGB = 6407,
  64190. RGBA = 6408,
  64191. LUMINANCE = 6409,
  64192. LUMINANCE_ALPHA = 6410
  64193. }
  64194. /** @hidden */
  64195. export enum ECullingType {
  64196. FRONT = 1028,
  64197. BACK = 1029,
  64198. FRONT_AND_BACK = 1032
  64199. }
  64200. /** @hidden */
  64201. export enum EBlendingFunction {
  64202. ZERO = 0,
  64203. ONE = 1,
  64204. SRC_COLOR = 768,
  64205. ONE_MINUS_SRC_COLOR = 769,
  64206. DST_COLOR = 774,
  64207. ONE_MINUS_DST_COLOR = 775,
  64208. SRC_ALPHA = 770,
  64209. ONE_MINUS_SRC_ALPHA = 771,
  64210. DST_ALPHA = 772,
  64211. ONE_MINUS_DST_ALPHA = 773,
  64212. CONSTANT_COLOR = 32769,
  64213. ONE_MINUS_CONSTANT_COLOR = 32770,
  64214. CONSTANT_ALPHA = 32771,
  64215. ONE_MINUS_CONSTANT_ALPHA = 32772,
  64216. SRC_ALPHA_SATURATE = 776
  64217. }
  64218. /** @hidden */
  64219. export interface IGLTFProperty {
  64220. extensions?: {
  64221. [key: string]: any;
  64222. };
  64223. extras?: Object;
  64224. }
  64225. /** @hidden */
  64226. export interface IGLTFChildRootProperty extends IGLTFProperty {
  64227. name?: string;
  64228. }
  64229. /** @hidden */
  64230. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  64231. bufferView: string;
  64232. byteOffset: number;
  64233. byteStride: number;
  64234. count: number;
  64235. type: string;
  64236. componentType: EComponentType;
  64237. max?: number[];
  64238. min?: number[];
  64239. name?: string;
  64240. }
  64241. /** @hidden */
  64242. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  64243. buffer: string;
  64244. byteOffset: number;
  64245. byteLength: number;
  64246. byteStride: number;
  64247. target?: number;
  64248. }
  64249. /** @hidden */
  64250. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  64251. uri: string;
  64252. byteLength?: number;
  64253. type?: string;
  64254. }
  64255. /** @hidden */
  64256. export interface IGLTFShader extends IGLTFChildRootProperty {
  64257. uri: string;
  64258. type: EShaderType;
  64259. }
  64260. /** @hidden */
  64261. export interface IGLTFProgram extends IGLTFChildRootProperty {
  64262. attributes: string[];
  64263. fragmentShader: string;
  64264. vertexShader: string;
  64265. }
  64266. /** @hidden */
  64267. export interface IGLTFTechniqueParameter {
  64268. type: number;
  64269. count?: number;
  64270. semantic?: string;
  64271. node?: string;
  64272. value?: number | boolean | string | Array<any>;
  64273. source?: string;
  64274. babylonValue?: any;
  64275. }
  64276. /** @hidden */
  64277. export interface IGLTFTechniqueCommonProfile {
  64278. lightingModel: string;
  64279. texcoordBindings: Object;
  64280. parameters?: Array<any>;
  64281. }
  64282. /** @hidden */
  64283. export interface IGLTFTechniqueStatesFunctions {
  64284. blendColor?: number[];
  64285. blendEquationSeparate?: number[];
  64286. blendFuncSeparate?: number[];
  64287. colorMask: boolean[];
  64288. cullFace: number[];
  64289. }
  64290. /** @hidden */
  64291. export interface IGLTFTechniqueStates {
  64292. enable: number[];
  64293. functions: IGLTFTechniqueStatesFunctions;
  64294. }
  64295. /** @hidden */
  64296. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  64297. parameters: {
  64298. [key: string]: IGLTFTechniqueParameter;
  64299. };
  64300. program: string;
  64301. attributes: {
  64302. [key: string]: string;
  64303. };
  64304. uniforms: {
  64305. [key: string]: string;
  64306. };
  64307. states: IGLTFTechniqueStates;
  64308. }
  64309. /** @hidden */
  64310. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  64311. technique?: string;
  64312. values: string[];
  64313. }
  64314. /** @hidden */
  64315. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  64316. attributes: {
  64317. [key: string]: string;
  64318. };
  64319. indices: string;
  64320. material: string;
  64321. mode?: number;
  64322. }
  64323. /** @hidden */
  64324. export interface IGLTFMesh extends IGLTFChildRootProperty {
  64325. primitives: IGLTFMeshPrimitive[];
  64326. }
  64327. /** @hidden */
  64328. export interface IGLTFImage extends IGLTFChildRootProperty {
  64329. uri: string;
  64330. }
  64331. /** @hidden */
  64332. export interface IGLTFSampler extends IGLTFChildRootProperty {
  64333. magFilter?: number;
  64334. minFilter?: number;
  64335. wrapS?: number;
  64336. wrapT?: number;
  64337. }
  64338. /** @hidden */
  64339. export interface IGLTFTexture extends IGLTFChildRootProperty {
  64340. sampler: string;
  64341. source: string;
  64342. format?: ETextureFormat;
  64343. internalFormat?: ETextureFormat;
  64344. target?: number;
  64345. type?: number;
  64346. babylonTexture?: Texture;
  64347. }
  64348. /** @hidden */
  64349. export interface IGLTFAmbienLight {
  64350. color?: number[];
  64351. }
  64352. /** @hidden */
  64353. export interface IGLTFDirectionalLight {
  64354. color?: number[];
  64355. }
  64356. /** @hidden */
  64357. export interface IGLTFPointLight {
  64358. color?: number[];
  64359. constantAttenuation?: number;
  64360. linearAttenuation?: number;
  64361. quadraticAttenuation?: number;
  64362. }
  64363. /** @hidden */
  64364. export interface IGLTFSpotLight {
  64365. color?: number[];
  64366. constantAttenuation?: number;
  64367. fallOfAngle?: number;
  64368. fallOffExponent?: number;
  64369. linearAttenuation?: number;
  64370. quadraticAttenuation?: number;
  64371. }
  64372. /** @hidden */
  64373. export interface IGLTFLight extends IGLTFChildRootProperty {
  64374. type: string;
  64375. }
  64376. /** @hidden */
  64377. export interface IGLTFCameraOrthographic {
  64378. xmag: number;
  64379. ymag: number;
  64380. zfar: number;
  64381. znear: number;
  64382. }
  64383. /** @hidden */
  64384. export interface IGLTFCameraPerspective {
  64385. aspectRatio: number;
  64386. yfov: number;
  64387. zfar: number;
  64388. znear: number;
  64389. }
  64390. /** @hidden */
  64391. export interface IGLTFCamera extends IGLTFChildRootProperty {
  64392. type: string;
  64393. }
  64394. /** @hidden */
  64395. export interface IGLTFAnimationChannelTarget {
  64396. id: string;
  64397. path: string;
  64398. }
  64399. /** @hidden */
  64400. export interface IGLTFAnimationChannel {
  64401. sampler: string;
  64402. target: IGLTFAnimationChannelTarget;
  64403. }
  64404. /** @hidden */
  64405. export interface IGLTFAnimationSampler {
  64406. input: string;
  64407. output: string;
  64408. interpolation?: string;
  64409. }
  64410. /** @hidden */
  64411. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  64412. channels?: IGLTFAnimationChannel[];
  64413. parameters?: {
  64414. [key: string]: string;
  64415. };
  64416. samplers?: {
  64417. [key: string]: IGLTFAnimationSampler;
  64418. };
  64419. }
  64420. /** @hidden */
  64421. export interface IGLTFNodeInstanceSkin {
  64422. skeletons: string[];
  64423. skin: string;
  64424. meshes: string[];
  64425. }
  64426. /** @hidden */
  64427. export interface IGLTFSkins extends IGLTFChildRootProperty {
  64428. bindShapeMatrix: number[];
  64429. inverseBindMatrices: string;
  64430. jointNames: string[];
  64431. babylonSkeleton?: Skeleton;
  64432. }
  64433. /** @hidden */
  64434. export interface IGLTFNode extends IGLTFChildRootProperty {
  64435. camera?: string;
  64436. children: string[];
  64437. skin?: string;
  64438. jointName?: string;
  64439. light?: string;
  64440. matrix: number[];
  64441. mesh?: string;
  64442. meshes?: string[];
  64443. rotation?: number[];
  64444. scale?: number[];
  64445. translation?: number[];
  64446. babylonNode?: Node;
  64447. }
  64448. /** @hidden */
  64449. export interface IGLTFScene extends IGLTFChildRootProperty {
  64450. nodes: string[];
  64451. }
  64452. /** @hidden */
  64453. export interface IGLTFRuntime {
  64454. extensions: {
  64455. [key: string]: any;
  64456. };
  64457. accessors: {
  64458. [key: string]: IGLTFAccessor;
  64459. };
  64460. buffers: {
  64461. [key: string]: IGLTFBuffer;
  64462. };
  64463. bufferViews: {
  64464. [key: string]: IGLTFBufferView;
  64465. };
  64466. meshes: {
  64467. [key: string]: IGLTFMesh;
  64468. };
  64469. lights: {
  64470. [key: string]: IGLTFLight;
  64471. };
  64472. cameras: {
  64473. [key: string]: IGLTFCamera;
  64474. };
  64475. nodes: {
  64476. [key: string]: IGLTFNode;
  64477. };
  64478. images: {
  64479. [key: string]: IGLTFImage;
  64480. };
  64481. textures: {
  64482. [key: string]: IGLTFTexture;
  64483. };
  64484. shaders: {
  64485. [key: string]: IGLTFShader;
  64486. };
  64487. programs: {
  64488. [key: string]: IGLTFProgram;
  64489. };
  64490. samplers: {
  64491. [key: string]: IGLTFSampler;
  64492. };
  64493. techniques: {
  64494. [key: string]: IGLTFTechnique;
  64495. };
  64496. materials: {
  64497. [key: string]: IGLTFMaterial;
  64498. };
  64499. animations: {
  64500. [key: string]: IGLTFAnimation;
  64501. };
  64502. skins: {
  64503. [key: string]: IGLTFSkins;
  64504. };
  64505. currentScene?: Object;
  64506. scenes: {
  64507. [key: string]: IGLTFScene;
  64508. };
  64509. extensionsUsed: string[];
  64510. extensionsRequired?: string[];
  64511. buffersCount: number;
  64512. shaderscount: number;
  64513. scene: Scene;
  64514. rootUrl: string;
  64515. loadedBufferCount: number;
  64516. loadedBufferViews: {
  64517. [name: string]: ArrayBufferView;
  64518. };
  64519. loadedShaderCount: number;
  64520. importOnlyMeshes: boolean;
  64521. importMeshesNames?: string[];
  64522. dummyNodes: Node[];
  64523. }
  64524. /** @hidden */
  64525. export interface INodeToRoot {
  64526. bone: Bone;
  64527. node: IGLTFNode;
  64528. id: string;
  64529. }
  64530. /** @hidden */
  64531. export interface IJointNode {
  64532. node: IGLTFNode;
  64533. id: string;
  64534. }
  64535. }
  64536. declare module BABYLON.GLTF1 {
  64537. /**
  64538. * Utils functions for GLTF
  64539. * @hidden
  64540. */
  64541. export class GLTFUtils {
  64542. /**
  64543. * Sets the given "parameter" matrix
  64544. * @param scene: the Scene object
  64545. * @param source: the source node where to pick the matrix
  64546. * @param parameter: the GLTF technique parameter
  64547. * @param uniformName: the name of the shader's uniform
  64548. * @param shaderMaterial: the shader material
  64549. */
  64550. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  64551. /**
  64552. * Sets the given "parameter" matrix
  64553. * @param shaderMaterial: the shader material
  64554. * @param uniform: the name of the shader's uniform
  64555. * @param value: the value of the uniform
  64556. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  64557. */
  64558. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  64559. /**
  64560. * Returns the wrap mode of the texture
  64561. * @param mode: the mode value
  64562. */
  64563. static GetWrapMode(mode: number): number;
  64564. /**
  64565. * Returns the byte stride giving an accessor
  64566. * @param accessor: the GLTF accessor objet
  64567. */
  64568. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  64569. /**
  64570. * Returns the texture filter mode giving a mode value
  64571. * @param mode: the filter mode value
  64572. */
  64573. static GetTextureFilterMode(mode: number): ETextureFilterType;
  64574. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  64575. /**
  64576. * Returns a buffer from its accessor
  64577. * @param gltfRuntime: the GLTF runtime
  64578. * @param accessor: the GLTF accessor
  64579. */
  64580. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  64581. /**
  64582. * Decodes a buffer view into a string
  64583. * @param view: the buffer view
  64584. */
  64585. static DecodeBufferToText(view: ArrayBufferView): string;
  64586. /**
  64587. * Returns the default material of gltf. Related to
  64588. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  64589. * @param scene: the Babylon.js scene
  64590. */
  64591. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  64592. private static _DefaultMaterial;
  64593. }
  64594. }
  64595. declare module BABYLON.GLTF1 {
  64596. /**
  64597. * Implementation of the base glTF spec
  64598. * @hidden
  64599. */
  64600. export class GLTFLoaderBase {
  64601. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  64602. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64603. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  64604. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64605. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  64606. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64607. }
  64608. /**
  64609. * glTF V1 Loader
  64610. * @hidden
  64611. */
  64612. export class GLTFLoader implements IGLTFLoader {
  64613. static Extensions: {
  64614. [name: string]: GLTFLoaderExtension;
  64615. };
  64616. static RegisterExtension(extension: GLTFLoaderExtension): void;
  64617. state: Nullable<GLTFLoaderState>;
  64618. dispose(): void;
  64619. private _importMeshAsync;
  64620. /**
  64621. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  64622. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64623. * @param scene the scene the meshes should be added to
  64624. * @param data gltf data containing information of the meshes in a loaded file
  64625. * @param rootUrl root url to load from
  64626. * @param onProgress event that fires when loading progress has occured
  64627. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64628. */
  64629. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  64630. meshes: AbstractMesh[];
  64631. particleSystems: IParticleSystem[];
  64632. skeletons: Skeleton[];
  64633. animationGroups: AnimationGroup[];
  64634. }>;
  64635. private _loadAsync;
  64636. /**
  64637. * Imports all objects from a loaded gltf file and adds them to the scene
  64638. * @param scene the scene the objects should be added to
  64639. * @param data gltf data containing information of the meshes in a loaded file
  64640. * @param rootUrl root url to load from
  64641. * @param onProgress event that fires when loading progress has occured
  64642. * @returns a promise which completes when objects have been loaded to the scene
  64643. */
  64644. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  64645. private _loadShadersAsync;
  64646. private _loadBuffersAsync;
  64647. private _createNodes;
  64648. }
  64649. /** @hidden */
  64650. export abstract class GLTFLoaderExtension {
  64651. private _name;
  64652. constructor(name: string);
  64653. readonly name: string;
  64654. /**
  64655. * Defines an override for loading the runtime
  64656. * Return true to stop further extensions from loading the runtime
  64657. */
  64658. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  64659. /**
  64660. * Defines an onverride for creating gltf runtime
  64661. * Return true to stop further extensions from creating the runtime
  64662. */
  64663. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  64664. /**
  64665. * Defines an override for loading buffers
  64666. * Return true to stop further extensions from loading this buffer
  64667. */
  64668. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  64669. /**
  64670. * Defines an override for loading texture buffers
  64671. * Return true to stop further extensions from loading this texture data
  64672. */
  64673. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64674. /**
  64675. * Defines an override for creating textures
  64676. * Return true to stop further extensions from loading this texture
  64677. */
  64678. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  64679. /**
  64680. * Defines an override for loading shader strings
  64681. * Return true to stop further extensions from loading this shader data
  64682. */
  64683. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64684. /**
  64685. * Defines an override for loading materials
  64686. * Return true to stop further extensions from loading this material
  64687. */
  64688. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64689. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  64690. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  64691. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64692. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64693. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  64694. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64695. private static LoadTextureBufferAsync;
  64696. private static CreateTextureAsync;
  64697. private static ApplyExtensions;
  64698. }
  64699. }
  64700. declare module BABYLON.GLTF1 {
  64701. /** @hidden */
  64702. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  64703. private _bin;
  64704. constructor();
  64705. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  64706. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64707. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64708. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64709. }
  64710. }
  64711. declare module BABYLON.GLTF1 {
  64712. /** @hidden */
  64713. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  64714. constructor();
  64715. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  64716. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64717. private _loadTexture;
  64718. }
  64719. }
  64720. declare module BABYLON.GLTF2.Loader {
  64721. /**
  64722. * Loader interface with an index field.
  64723. */
  64724. export interface IArrayItem {
  64725. /**
  64726. * The index of this item in the array.
  64727. */
  64728. index: number;
  64729. }
  64730. /**
  64731. * Loader interface with additional members.
  64732. */
  64733. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  64734. /** @hidden */
  64735. _data?: Promise<ArrayBufferView>;
  64736. /** @hidden */
  64737. _babylonVertexBuffer?: Promise<VertexBuffer>;
  64738. }
  64739. /**
  64740. * Loader interface with additional members.
  64741. */
  64742. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  64743. }
  64744. /** @hidden */
  64745. export interface _IAnimationSamplerData {
  64746. input: Float32Array;
  64747. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  64748. output: Float32Array;
  64749. }
  64750. /**
  64751. * Loader interface with additional members.
  64752. */
  64753. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  64754. /** @hidden */
  64755. _data?: Promise<_IAnimationSamplerData>;
  64756. }
  64757. /**
  64758. * Loader interface with additional members.
  64759. */
  64760. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  64761. channels: IAnimationChannel[];
  64762. samplers: IAnimationSampler[];
  64763. /** @hidden */
  64764. _babylonAnimationGroup?: AnimationGroup;
  64765. }
  64766. /**
  64767. * Loader interface with additional members.
  64768. */
  64769. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  64770. /** @hidden */
  64771. _data?: Promise<ArrayBufferView>;
  64772. }
  64773. /**
  64774. * Loader interface with additional members.
  64775. */
  64776. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  64777. /** @hidden */
  64778. _data?: Promise<ArrayBufferView>;
  64779. /** @hidden */
  64780. _babylonBuffer?: Promise<Buffer>;
  64781. }
  64782. /**
  64783. * Loader interface with additional members.
  64784. */
  64785. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  64786. }
  64787. /**
  64788. * Loader interface with additional members.
  64789. */
  64790. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  64791. /** @hidden */
  64792. _data?: Promise<ArrayBufferView>;
  64793. }
  64794. /**
  64795. * Loader interface with additional members.
  64796. */
  64797. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  64798. }
  64799. /**
  64800. * Loader interface with additional members.
  64801. */
  64802. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  64803. }
  64804. /**
  64805. * Loader interface with additional members.
  64806. */
  64807. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  64808. baseColorTexture?: ITextureInfo;
  64809. metallicRoughnessTexture?: ITextureInfo;
  64810. }
  64811. /**
  64812. * Loader interface with additional members.
  64813. */
  64814. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  64815. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  64816. normalTexture?: IMaterialNormalTextureInfo;
  64817. occlusionTexture?: IMaterialOcclusionTextureInfo;
  64818. emissiveTexture?: ITextureInfo;
  64819. /** @hidden */
  64820. _data?: {
  64821. [babylonDrawMode: number]: {
  64822. babylonMaterial: Material;
  64823. babylonMeshes: AbstractMesh[];
  64824. promise: Promise<void>;
  64825. };
  64826. };
  64827. }
  64828. /**
  64829. * Loader interface with additional members.
  64830. */
  64831. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  64832. primitives: IMeshPrimitive[];
  64833. }
  64834. /**
  64835. * Loader interface with additional members.
  64836. */
  64837. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  64838. /** @hidden */
  64839. _instanceData?: {
  64840. babylonSourceMesh: Mesh;
  64841. promise: Promise<any>;
  64842. };
  64843. }
  64844. /**
  64845. * Loader interface with additional members.
  64846. */
  64847. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  64848. /**
  64849. * The parent glTF node.
  64850. */
  64851. parent?: INode;
  64852. /** @hidden */
  64853. _babylonTransformNode?: TransformNode;
  64854. /** @hidden */
  64855. _primitiveBabylonMeshes?: AbstractMesh[];
  64856. /** @hidden */
  64857. _babylonBones?: Bone[];
  64858. /** @hidden */
  64859. _numMorphTargets?: number;
  64860. }
  64861. /** @hidden */
  64862. export interface _ISamplerData {
  64863. noMipMaps: boolean;
  64864. samplingMode: number;
  64865. wrapU: number;
  64866. wrapV: number;
  64867. }
  64868. /**
  64869. * Loader interface with additional members.
  64870. */
  64871. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  64872. /** @hidden */
  64873. _data?: _ISamplerData;
  64874. }
  64875. /**
  64876. * Loader interface with additional members.
  64877. */
  64878. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  64879. }
  64880. /**
  64881. * Loader interface with additional members.
  64882. */
  64883. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  64884. /** @hidden */
  64885. _data?: {
  64886. babylonSkeleton: Skeleton;
  64887. promise: Promise<void>;
  64888. };
  64889. }
  64890. /**
  64891. * Loader interface with additional members.
  64892. */
  64893. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  64894. }
  64895. /**
  64896. * Loader interface with additional members.
  64897. */
  64898. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  64899. }
  64900. /**
  64901. * Loader interface with additional members.
  64902. */
  64903. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  64904. accessors?: IAccessor[];
  64905. animations?: IAnimation[];
  64906. buffers?: IBuffer[];
  64907. bufferViews?: IBufferView[];
  64908. cameras?: ICamera[];
  64909. images?: IImage[];
  64910. materials?: IMaterial[];
  64911. meshes?: IMesh[];
  64912. nodes?: INode[];
  64913. samplers?: ISampler[];
  64914. scenes?: IScene[];
  64915. skins?: ISkin[];
  64916. textures?: ITexture[];
  64917. }
  64918. }
  64919. declare module BABYLON.GLTF2 {
  64920. /**
  64921. * Interface for a glTF loader extension.
  64922. */
  64923. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  64924. /**
  64925. * Called after the loader state changes to LOADING.
  64926. */
  64927. onLoading?(): void;
  64928. /**
  64929. * Called after the loader state changes to READY.
  64930. */
  64931. onReady?(): void;
  64932. /**
  64933. * Define this method to modify the default behavior when loading scenes.
  64934. * @param context The context when loading the asset
  64935. * @param scene The glTF scene property
  64936. * @returns A promise that resolves when the load is complete or null if not handled
  64937. */
  64938. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  64939. /**
  64940. * Define this method to modify the default behavior when loading nodes.
  64941. * @param context The context when loading the asset
  64942. * @param node The glTF node property
  64943. * @param assign A function called synchronously after parsing the glTF properties
  64944. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  64945. */
  64946. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64947. /**
  64948. * Define this method to modify the default behavior when loading cameras.
  64949. * @param context The context when loading the asset
  64950. * @param camera The glTF camera property
  64951. * @param assign A function called synchronously after parsing the glTF properties
  64952. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  64953. */
  64954. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  64955. /**
  64956. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  64957. * @param context The context when loading the asset
  64958. * @param primitive The glTF mesh primitive property
  64959. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  64960. */
  64961. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64962. /**
  64963. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64964. * @param context The context when loading the asset
  64965. * @param name The mesh name when loading the asset
  64966. * @param node The glTF node when loading the asset
  64967. * @param mesh The glTF mesh when loading the asset
  64968. * @param primitive The glTF mesh primitive property
  64969. * @param assign A function called synchronously after parsing the glTF properties
  64970. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64971. */
  64972. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64973. /**
  64974. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  64975. * @param context The context when loading the asset
  64976. * @param material The glTF material property
  64977. * @param assign A function called synchronously after parsing the glTF properties
  64978. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  64979. */
  64980. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64981. /**
  64982. * Define this method to modify the default behavior when creating materials.
  64983. * @param context The context when loading the asset
  64984. * @param material The glTF material property
  64985. * @param babylonDrawMode The draw mode for the Babylon material
  64986. * @returns The Babylon material or null if not handled
  64987. */
  64988. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  64989. /**
  64990. * Define this method to modify the default behavior when loading material properties.
  64991. * @param context The context when loading the asset
  64992. * @param material The glTF material property
  64993. * @param babylonMaterial The Babylon material
  64994. * @returns A promise that resolves when the load is complete or null if not handled
  64995. */
  64996. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64997. /**
  64998. * Define this method to modify the default behavior when loading texture infos.
  64999. * @param context The context when loading the asset
  65000. * @param textureInfo The glTF texture info property
  65001. * @param assign A function called synchronously after parsing the glTF properties
  65002. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  65003. */
  65004. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65005. /**
  65006. * Define this method to modify the default behavior when loading animations.
  65007. * @param context The context when loading the asset
  65008. * @param animation The glTF animation property
  65009. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  65010. */
  65011. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65012. /**
  65013. * @hidden Define this method to modify the default behavior when loading skins.
  65014. * @param context The context when loading the asset
  65015. * @param node The glTF node property
  65016. * @param skin The glTF skin property
  65017. * @returns A promise that resolves when the load is complete or null if not handled
  65018. */
  65019. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  65020. /**
  65021. * @hidden Define this method to modify the default behavior when loading uris.
  65022. * @param context The context when loading the asset
  65023. * @param property The glTF property associated with the uri
  65024. * @param uri The uri to load
  65025. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  65026. */
  65027. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65028. }
  65029. }
  65030. declare module BABYLON.GLTF2 {
  65031. /**
  65032. * Helper class for working with arrays when loading the glTF asset
  65033. */
  65034. export class ArrayItem {
  65035. /**
  65036. * Gets an item from the given array.
  65037. * @param context The context when loading the asset
  65038. * @param array The array to get the item from
  65039. * @param index The index to the array
  65040. * @returns The array item
  65041. */
  65042. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  65043. /**
  65044. * Assign an `index` field to each item of the given array.
  65045. * @param array The array of items
  65046. */
  65047. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  65048. }
  65049. /**
  65050. * The glTF 2.0 loader
  65051. */
  65052. export class GLTFLoader implements IGLTFLoader {
  65053. /** @hidden */
  65054. _completePromises: Promise<any>[];
  65055. private _disposed;
  65056. private _parent;
  65057. private _state;
  65058. private _extensions;
  65059. private _rootUrl;
  65060. private _fileName;
  65061. private _uniqueRootUrl;
  65062. private _gltf;
  65063. private _babylonScene;
  65064. private _rootBabylonMesh;
  65065. private _defaultBabylonMaterialData;
  65066. private _progressCallback?;
  65067. private _requests;
  65068. private static readonly _DefaultSampler;
  65069. private static _ExtensionNames;
  65070. private static _ExtensionFactories;
  65071. /**
  65072. * Registers a loader extension.
  65073. * @param name The name of the loader extension.
  65074. * @param factory The factory function that creates the loader extension.
  65075. */
  65076. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  65077. /**
  65078. * Unregisters a loader extension.
  65079. * @param name The name of the loader extenion.
  65080. * @returns A boolean indicating whether the extension has been unregistered
  65081. */
  65082. static UnregisterExtension(name: string): boolean;
  65083. /**
  65084. * Gets the loader state.
  65085. */
  65086. readonly state: Nullable<GLTFLoaderState>;
  65087. /**
  65088. * The glTF object parsed from the JSON.
  65089. */
  65090. readonly gltf: IGLTF;
  65091. /**
  65092. * The Babylon scene when loading the asset.
  65093. */
  65094. readonly babylonScene: Scene;
  65095. /**
  65096. * The root Babylon mesh when loading the asset.
  65097. */
  65098. readonly rootBabylonMesh: Mesh;
  65099. /** @hidden */
  65100. constructor(parent: GLTFFileLoader);
  65101. /** @hidden */
  65102. dispose(): void;
  65103. /** @hidden */
  65104. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65105. meshes: AbstractMesh[];
  65106. particleSystems: IParticleSystem[];
  65107. skeletons: Skeleton[];
  65108. animationGroups: AnimationGroup[];
  65109. }>;
  65110. /** @hidden */
  65111. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65112. private _loadAsync;
  65113. private _loadData;
  65114. private _setupData;
  65115. private _loadExtensions;
  65116. private _checkExtensions;
  65117. private _setState;
  65118. private _createRootNode;
  65119. /**
  65120. * Loads a glTF scene.
  65121. * @param context The context when loading the asset
  65122. * @param scene The glTF scene property
  65123. * @returns A promise that resolves when the load is complete
  65124. */
  65125. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  65126. private _forEachPrimitive;
  65127. private _getMeshes;
  65128. private _getSkeletons;
  65129. private _getAnimationGroups;
  65130. private _startAnimations;
  65131. /**
  65132. * Loads a glTF node.
  65133. * @param context The context when loading the asset
  65134. * @param node The glTF node property
  65135. * @param assign A function called synchronously after parsing the glTF properties
  65136. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  65137. */
  65138. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  65139. private _loadMeshAsync;
  65140. /**
  65141. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65142. * @param context The context when loading the asset
  65143. * @param name The mesh name when loading the asset
  65144. * @param node The glTF node when loading the asset
  65145. * @param mesh The glTF mesh when loading the asset
  65146. * @param primitive The glTF mesh primitive property
  65147. * @param assign A function called synchronously after parsing the glTF properties
  65148. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65149. */
  65150. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65151. private _loadVertexDataAsync;
  65152. private _createMorphTargets;
  65153. private _loadMorphTargetsAsync;
  65154. private _loadMorphTargetVertexDataAsync;
  65155. private static _LoadTransform;
  65156. private _loadSkinAsync;
  65157. private _loadBones;
  65158. private _loadBone;
  65159. private _loadSkinInverseBindMatricesDataAsync;
  65160. private _updateBoneMatrices;
  65161. private _getNodeMatrix;
  65162. /**
  65163. * Loads a glTF camera.
  65164. * @param context The context when loading the asset
  65165. * @param camera The glTF camera property
  65166. * @param assign A function called synchronously after parsing the glTF properties
  65167. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  65168. */
  65169. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  65170. private _loadAnimationsAsync;
  65171. /**
  65172. * Loads a glTF animation.
  65173. * @param context The context when loading the asset
  65174. * @param animation The glTF animation property
  65175. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  65176. */
  65177. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  65178. /**
  65179. * @hidden Loads a glTF animation channel.
  65180. * @param context The context when loading the asset
  65181. * @param animationContext The context of the animation when loading the asset
  65182. * @param animation The glTF animation property
  65183. * @param channel The glTF animation channel property
  65184. * @param babylonAnimationGroup The babylon animation group property
  65185. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  65186. * @returns A void promise when the channel load is complete
  65187. */
  65188. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  65189. private _loadAnimationSamplerAsync;
  65190. private _loadBufferAsync;
  65191. /**
  65192. * Loads a glTF buffer view.
  65193. * @param context The context when loading the asset
  65194. * @param bufferView The glTF buffer view property
  65195. * @returns A promise that resolves with the loaded data when the load is complete
  65196. */
  65197. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  65198. private _loadIndicesAccessorAsync;
  65199. private _loadFloatAccessorAsync;
  65200. private _loadVertexBufferViewAsync;
  65201. private _loadVertexAccessorAsync;
  65202. private _loadMaterialMetallicRoughnessPropertiesAsync;
  65203. /** @hidden */
  65204. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  65205. private _createDefaultMaterial;
  65206. /**
  65207. * Creates a Babylon material from a glTF material.
  65208. * @param context The context when loading the asset
  65209. * @param material The glTF material property
  65210. * @param babylonDrawMode The draw mode for the Babylon material
  65211. * @returns The Babylon material
  65212. */
  65213. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  65214. /**
  65215. * Loads properties from a glTF material into a Babylon material.
  65216. * @param context The context when loading the asset
  65217. * @param material The glTF material property
  65218. * @param babylonMaterial The Babylon material
  65219. * @returns A promise that resolves when the load is complete
  65220. */
  65221. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65222. /**
  65223. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  65224. * @param context The context when loading the asset
  65225. * @param material The glTF material property
  65226. * @param babylonMaterial The Babylon material
  65227. * @returns A promise that resolves when the load is complete
  65228. */
  65229. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65230. /**
  65231. * Loads the alpha properties from a glTF material into a Babylon material.
  65232. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  65233. * @param context The context when loading the asset
  65234. * @param material The glTF material property
  65235. * @param babylonMaterial The Babylon material
  65236. */
  65237. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  65238. /**
  65239. * Loads a glTF texture info.
  65240. * @param context The context when loading the asset
  65241. * @param textureInfo The glTF texture info property
  65242. * @param assign A function called synchronously after parsing the glTF properties
  65243. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  65244. */
  65245. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  65246. private _loadTextureAsync;
  65247. private _loadSampler;
  65248. /**
  65249. * Loads a glTF image.
  65250. * @param context The context when loading the asset
  65251. * @param image The glTF image property
  65252. * @returns A promise that resolves with the loaded data when the load is complete
  65253. */
  65254. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  65255. /**
  65256. * Loads a glTF uri.
  65257. * @param context The context when loading the asset
  65258. * @param property The glTF property associated with the uri
  65259. * @param uri The base64 or relative uri
  65260. * @returns A promise that resolves with the loaded data when the load is complete
  65261. */
  65262. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  65263. private _onProgress;
  65264. /**
  65265. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  65266. * @param babylonObject the Babylon object with metadata
  65267. * @param pointer the JSON pointer
  65268. */
  65269. static AddPointerMetadata(babylonObject: {
  65270. metadata: any;
  65271. }, pointer: string): void;
  65272. private static _GetTextureWrapMode;
  65273. private static _GetTextureSamplingMode;
  65274. private static _GetTypedArray;
  65275. private static _GetNumComponents;
  65276. private static _ValidateUri;
  65277. private static _GetDrawMode;
  65278. private _compileMaterialsAsync;
  65279. private _compileShadowGeneratorsAsync;
  65280. private _forEachExtensions;
  65281. private _applyExtensions;
  65282. private _extensionsOnLoading;
  65283. private _extensionsOnReady;
  65284. private _extensionsLoadSceneAsync;
  65285. private _extensionsLoadNodeAsync;
  65286. private _extensionsLoadCameraAsync;
  65287. private _extensionsLoadVertexDataAsync;
  65288. private _extensionsLoadMeshPrimitiveAsync;
  65289. private _extensionsLoadMaterialAsync;
  65290. private _extensionsCreateMaterial;
  65291. private _extensionsLoadMaterialPropertiesAsync;
  65292. private _extensionsLoadTextureInfoAsync;
  65293. private _extensionsLoadAnimationAsync;
  65294. private _extensionsLoadSkinAsync;
  65295. private _extensionsLoadUriAsync;
  65296. /**
  65297. * Helper method called by a loader extension to load an glTF extension.
  65298. * @param context The context when loading the asset
  65299. * @param property The glTF property to load the extension from
  65300. * @param extensionName The name of the extension to load
  65301. * @param actionAsync The action to run
  65302. * @returns The promise returned by actionAsync or null if the extension does not exist
  65303. */
  65304. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  65305. /**
  65306. * Helper method called by a loader extension to load a glTF extra.
  65307. * @param context The context when loading the asset
  65308. * @param property The glTF property to load the extra from
  65309. * @param extensionName The name of the extension to load
  65310. * @param actionAsync The action to run
  65311. * @returns The promise returned by actionAsync or null if the extra does not exist
  65312. */
  65313. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  65314. /**
  65315. * Increments the indentation level and logs a message.
  65316. * @param message The message to log
  65317. */
  65318. logOpen(message: string): void;
  65319. /**
  65320. * Decrements the indentation level.
  65321. */
  65322. logClose(): void;
  65323. /**
  65324. * Logs a message
  65325. * @param message The message to log
  65326. */
  65327. log(message: string): void;
  65328. /**
  65329. * Starts a performance counter.
  65330. * @param counterName The name of the performance counter
  65331. */
  65332. startPerformanceCounter(counterName: string): void;
  65333. /**
  65334. * Ends a performance counter.
  65335. * @param counterName The name of the performance counter
  65336. */
  65337. endPerformanceCounter(counterName: string): void;
  65338. }
  65339. }
  65340. declare module BABYLON.GLTF2.Loader.Extensions {
  65341. /**
  65342. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  65343. */
  65344. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  65345. /** The name of this extension. */
  65346. readonly name: string;
  65347. /** Defines whether this extension is enabled. */
  65348. enabled: boolean;
  65349. private _loader;
  65350. private _lights?;
  65351. /** @hidden */
  65352. constructor(loader: GLTFLoader);
  65353. /** @hidden */
  65354. dispose(): void;
  65355. /** @hidden */
  65356. onLoading(): void;
  65357. /** @hidden */
  65358. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65359. private _loadLightAsync;
  65360. }
  65361. }
  65362. declare module BABYLON.GLTF2.Loader.Extensions {
  65363. /**
  65364. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  65365. */
  65366. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  65367. /** The name of this extension. */
  65368. readonly name: string;
  65369. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  65370. dracoCompression?: DracoCompression;
  65371. /** Defines whether this extension is enabled. */
  65372. enabled: boolean;
  65373. private _loader;
  65374. /** @hidden */
  65375. constructor(loader: GLTFLoader);
  65376. /** @hidden */
  65377. dispose(): void;
  65378. /** @hidden */
  65379. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65380. }
  65381. }
  65382. declare module BABYLON.GLTF2.Loader.Extensions {
  65383. /**
  65384. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  65385. */
  65386. export class KHR_lights implements IGLTFLoaderExtension {
  65387. /** The name of this extension. */
  65388. readonly name: string;
  65389. /** Defines whether this extension is enabled. */
  65390. enabled: boolean;
  65391. private _loader;
  65392. private _lights?;
  65393. /** @hidden */
  65394. constructor(loader: GLTFLoader);
  65395. /** @hidden */
  65396. dispose(): void;
  65397. /** @hidden */
  65398. onLoading(): void;
  65399. /** @hidden */
  65400. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65401. }
  65402. }
  65403. declare module BABYLON.GLTF2.Loader.Extensions {
  65404. /**
  65405. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  65406. */
  65407. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  65408. /** The name of this extension. */
  65409. readonly name: string;
  65410. /** Defines whether this extension is enabled. */
  65411. enabled: boolean;
  65412. private _loader;
  65413. /** @hidden */
  65414. constructor(loader: GLTFLoader);
  65415. /** @hidden */
  65416. dispose(): void;
  65417. /** @hidden */
  65418. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65419. private _loadSpecularGlossinessPropertiesAsync;
  65420. }
  65421. }
  65422. declare module BABYLON.GLTF2.Loader.Extensions {
  65423. /**
  65424. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  65425. */
  65426. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  65427. /** The name of this extension. */
  65428. readonly name: string;
  65429. /** Defines whether this extension is enabled. */
  65430. enabled: boolean;
  65431. private _loader;
  65432. /** @hidden */
  65433. constructor(loader: GLTFLoader);
  65434. /** @hidden */
  65435. dispose(): void;
  65436. /** @hidden */
  65437. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65438. private _loadUnlitPropertiesAsync;
  65439. }
  65440. }
  65441. declare module BABYLON.GLTF2.Loader.Extensions {
  65442. /**
  65443. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  65444. */
  65445. export class KHR_texture_transform implements IGLTFLoaderExtension {
  65446. /** The name of this extension. */
  65447. readonly name: string;
  65448. /** Defines whether this extension is enabled. */
  65449. enabled: boolean;
  65450. private _loader;
  65451. /** @hidden */
  65452. constructor(loader: GLTFLoader);
  65453. /** @hidden */
  65454. dispose(): void;
  65455. /** @hidden */
  65456. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65457. }
  65458. }
  65459. declare module BABYLON.GLTF2.Loader.Extensions {
  65460. /**
  65461. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  65462. */
  65463. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  65464. /** The name of this extension. */
  65465. readonly name: string;
  65466. /** Defines whether this extension is enabled. */
  65467. enabled: boolean;
  65468. private _loader;
  65469. private _clips;
  65470. private _emitters;
  65471. /** @hidden */
  65472. constructor(loader: GLTFLoader);
  65473. /** @hidden */
  65474. dispose(): void;
  65475. /** @hidden */
  65476. onLoading(): void;
  65477. /** @hidden */
  65478. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65479. /** @hidden */
  65480. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65481. /** @hidden */
  65482. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65483. private _loadClipAsync;
  65484. private _loadEmitterAsync;
  65485. private _getEventAction;
  65486. private _loadAnimationEventAsync;
  65487. }
  65488. }
  65489. declare module BABYLON.GLTF2.Loader.Extensions {
  65490. /**
  65491. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  65492. */
  65493. export class MSFT_lod implements IGLTFLoaderExtension {
  65494. /** The name of this extension. */
  65495. readonly name: string;
  65496. /** Defines whether this extension is enabled. */
  65497. enabled: boolean;
  65498. /**
  65499. * Maximum number of LODs to load, starting from the lowest LOD.
  65500. */
  65501. maxLODsToLoad: number;
  65502. /**
  65503. * Observable raised when all node LODs of one level are loaded.
  65504. * The event data is the index of the loaded LOD starting from zero.
  65505. * Dispose the loader to cancel the loading of the next level of LODs.
  65506. */
  65507. onNodeLODsLoadedObservable: Observable<number>;
  65508. /**
  65509. * Observable raised when all material LODs of one level are loaded.
  65510. * The event data is the index of the loaded LOD starting from zero.
  65511. * Dispose the loader to cancel the loading of the next level of LODs.
  65512. */
  65513. onMaterialLODsLoadedObservable: Observable<number>;
  65514. private _loader;
  65515. private _nodeIndexLOD;
  65516. private _nodeSignalLODs;
  65517. private _nodePromiseLODs;
  65518. private _materialIndexLOD;
  65519. private _materialSignalLODs;
  65520. private _materialPromiseLODs;
  65521. /** @hidden */
  65522. constructor(loader: GLTFLoader);
  65523. /** @hidden */
  65524. dispose(): void;
  65525. /** @hidden */
  65526. onReady(): void;
  65527. /** @hidden */
  65528. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65529. /** @hidden */
  65530. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65531. /** @hidden */
  65532. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65533. /**
  65534. * Gets an array of LOD properties from lowest to highest.
  65535. */
  65536. private _getLODs;
  65537. private _disposeUnusedMaterials;
  65538. }
  65539. }
  65540. declare module BABYLON.GLTF2.Loader.Extensions {
  65541. /** @hidden */
  65542. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  65543. readonly name: string;
  65544. enabled: boolean;
  65545. private _loader;
  65546. constructor(loader: GLTFLoader);
  65547. dispose(): void;
  65548. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65549. }
  65550. }
  65551. declare module BABYLON.GLTF2.Loader.Extensions {
  65552. /** @hidden */
  65553. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  65554. readonly name: string;
  65555. enabled: boolean;
  65556. private _loader;
  65557. constructor(loader: GLTFLoader);
  65558. dispose(): void;
  65559. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65560. }
  65561. }
  65562. declare module BABYLON.GLTF2.Loader.Extensions {
  65563. /**
  65564. * Store glTF extras (if present) in BJS objects' metadata
  65565. */
  65566. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  65567. /** The name of this extension. */
  65568. readonly name: string;
  65569. /** Defines whether this extension is enabled. */
  65570. enabled: boolean;
  65571. private _loader;
  65572. private _assignExtras;
  65573. /** @hidden */
  65574. constructor(loader: GLTFLoader);
  65575. /** @hidden */
  65576. dispose(): void;
  65577. /** @hidden */
  65578. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65579. /** @hidden */
  65580. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  65581. /** @hidden */
  65582. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  65583. }
  65584. }
  65585. declare module BABYLON {
  65586. /**
  65587. * Class reading and parsing the MTL file bundled with the obj file.
  65588. */
  65589. export class MTLFileLoader {
  65590. /**
  65591. * All material loaded from the mtl will be set here
  65592. */
  65593. materials: StandardMaterial[];
  65594. /**
  65595. * This function will read the mtl file and create each material described inside
  65596. * This function could be improve by adding :
  65597. * -some component missing (Ni, Tf...)
  65598. * -including the specific options available
  65599. *
  65600. * @param scene defines the scene the material will be created in
  65601. * @param data defines the mtl data to parse
  65602. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  65603. */
  65604. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  65605. /**
  65606. * Gets the texture for the material.
  65607. *
  65608. * If the material is imported from input file,
  65609. * We sanitize the url to ensure it takes the textre from aside the material.
  65610. *
  65611. * @param rootUrl The root url to load from
  65612. * @param value The value stored in the mtl
  65613. * @return The Texture
  65614. */
  65615. private static _getTexture;
  65616. }
  65617. /**
  65618. * Options for loading OBJ/MTL files
  65619. */
  65620. type MeshLoadOptions = {
  65621. /**
  65622. * Defines if UVs are optimized by default during load.
  65623. */
  65624. OptimizeWithUV: boolean;
  65625. /**
  65626. * Defines custom scaling of UV coordinates of loaded meshes.
  65627. */
  65628. UVScaling: Vector2;
  65629. /**
  65630. * Invert model on y-axis (does a model scaling inversion)
  65631. */
  65632. InvertY: boolean;
  65633. /**
  65634. * Invert Y-Axis of referenced textures on load
  65635. */
  65636. InvertTextureY: boolean;
  65637. /**
  65638. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65639. */
  65640. ImportVertexColors: boolean;
  65641. /**
  65642. * Compute the normals for the model, even if normals are present in the file.
  65643. */
  65644. ComputeNormals: boolean;
  65645. /**
  65646. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65647. */
  65648. SkipMaterials: boolean;
  65649. /**
  65650. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65651. */
  65652. MaterialLoadingFailsSilently: boolean;
  65653. };
  65654. /**
  65655. * OBJ file type loader.
  65656. * This is a babylon scene loader plugin.
  65657. */
  65658. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65659. /**
  65660. * Defines if UVs are optimized by default during load.
  65661. */
  65662. static OPTIMIZE_WITH_UV: boolean;
  65663. /**
  65664. * Invert model on y-axis (does a model scaling inversion)
  65665. */
  65666. static INVERT_Y: boolean;
  65667. /**
  65668. * Invert Y-Axis of referenced textures on load
  65669. */
  65670. static INVERT_TEXTURE_Y: boolean;
  65671. /**
  65672. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65673. */
  65674. static IMPORT_VERTEX_COLORS: boolean;
  65675. /**
  65676. * Compute the normals for the model, even if normals are present in the file.
  65677. */
  65678. static COMPUTE_NORMALS: boolean;
  65679. /**
  65680. * Defines custom scaling of UV coordinates of loaded meshes.
  65681. */
  65682. static UV_SCALING: Vector2;
  65683. /**
  65684. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65685. */
  65686. static SKIP_MATERIALS: boolean;
  65687. /**
  65688. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65689. *
  65690. * Defaults to true for backwards compatibility.
  65691. */
  65692. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  65693. /**
  65694. * Defines the name of the plugin.
  65695. */
  65696. name: string;
  65697. /**
  65698. * Defines the extension the plugin is able to load.
  65699. */
  65700. extensions: string;
  65701. /** @hidden */
  65702. obj: RegExp;
  65703. /** @hidden */
  65704. group: RegExp;
  65705. /** @hidden */
  65706. mtllib: RegExp;
  65707. /** @hidden */
  65708. usemtl: RegExp;
  65709. /** @hidden */
  65710. smooth: RegExp;
  65711. /** @hidden */
  65712. vertexPattern: RegExp;
  65713. /** @hidden */
  65714. normalPattern: RegExp;
  65715. /** @hidden */
  65716. uvPattern: RegExp;
  65717. /** @hidden */
  65718. facePattern1: RegExp;
  65719. /** @hidden */
  65720. facePattern2: RegExp;
  65721. /** @hidden */
  65722. facePattern3: RegExp;
  65723. /** @hidden */
  65724. facePattern4: RegExp;
  65725. /** @hidden */
  65726. facePattern5: RegExp;
  65727. private _meshLoadOptions;
  65728. /**
  65729. * Creates loader for .OBJ files
  65730. *
  65731. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  65732. */
  65733. constructor(meshLoadOptions?: MeshLoadOptions);
  65734. private static readonly currentMeshLoadOptions;
  65735. /**
  65736. * Calls synchronously the MTL file attached to this obj.
  65737. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  65738. * Without this function materials are not displayed in the first frame (but displayed after).
  65739. * In consequence it is impossible to get material information in your HTML file
  65740. *
  65741. * @param url The URL of the MTL file
  65742. * @param rootUrl
  65743. * @param onSuccess Callback function to be called when the MTL file is loaded
  65744. * @private
  65745. */
  65746. private _loadMTL;
  65747. /**
  65748. * Instantiates a OBJ file loader plugin.
  65749. * @returns the created plugin
  65750. */
  65751. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  65752. /**
  65753. * If the data string can be loaded directly.
  65754. *
  65755. * @param data string containing the file data
  65756. * @returns if the data can be loaded directly
  65757. */
  65758. canDirectLoad(data: string): boolean;
  65759. /**
  65760. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  65761. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65762. * @param scene the scene the meshes should be added to
  65763. * @param data the OBJ data to load
  65764. * @param rootUrl root url to load from
  65765. * @param onProgress event that fires when loading progress has occured
  65766. * @param fileName Defines the name of the file to load
  65767. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65768. */
  65769. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65770. meshes: AbstractMesh[];
  65771. particleSystems: IParticleSystem[];
  65772. skeletons: Skeleton[];
  65773. animationGroups: AnimationGroup[];
  65774. }>;
  65775. /**
  65776. * Imports all objects from the loaded OBJ data and adds them to the scene
  65777. * @param scene the scene the objects should be added to
  65778. * @param data the OBJ data to load
  65779. * @param rootUrl root url to load from
  65780. * @param onProgress event that fires when loading progress has occured
  65781. * @param fileName Defines the name of the file to load
  65782. * @returns a promise which completes when objects have been loaded to the scene
  65783. */
  65784. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65785. /**
  65786. * Load into an asset container.
  65787. * @param scene The scene to load into
  65788. * @param data The data to import
  65789. * @param rootUrl The root url for scene and resources
  65790. * @param onProgress The callback when the load progresses
  65791. * @param fileName Defines the name of the file to load
  65792. * @returns The loaded asset container
  65793. */
  65794. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65795. /**
  65796. * Read the OBJ file and create an Array of meshes.
  65797. * Each mesh contains all information given by the OBJ and the MTL file.
  65798. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  65799. *
  65800. * @param meshesNames
  65801. * @param scene Scene The scene where are displayed the data
  65802. * @param data String The content of the obj file
  65803. * @param rootUrl String The path to the folder
  65804. * @returns Array<AbstractMesh>
  65805. * @private
  65806. */
  65807. private _parseSolid;
  65808. }
  65809. }
  65810. declare module BABYLON {
  65811. /**
  65812. * STL file type loader.
  65813. * This is a babylon scene loader plugin.
  65814. */
  65815. export class STLFileLoader implements ISceneLoaderPlugin {
  65816. /** @hidden */
  65817. solidPattern: RegExp;
  65818. /** @hidden */
  65819. facetsPattern: RegExp;
  65820. /** @hidden */
  65821. normalPattern: RegExp;
  65822. /** @hidden */
  65823. vertexPattern: RegExp;
  65824. /**
  65825. * Defines the name of the plugin.
  65826. */
  65827. name: string;
  65828. /**
  65829. * Defines the extensions the stl loader is able to load.
  65830. * force data to come in as an ArrayBuffer
  65831. * we'll convert to string if it looks like it's an ASCII .stl
  65832. */
  65833. extensions: ISceneLoaderPluginExtensions;
  65834. /**
  65835. * Import meshes into a scene.
  65836. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  65837. * @param scene The scene to import into
  65838. * @param data The data to import
  65839. * @param rootUrl The root url for scene and resources
  65840. * @param meshes The meshes array to import into
  65841. * @param particleSystems The particle systems array to import into
  65842. * @param skeletons The skeletons array to import into
  65843. * @param onError The callback when import fails
  65844. * @returns True if successful or false otherwise
  65845. */
  65846. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  65847. /**
  65848. * Load into a scene.
  65849. * @param scene The scene to load into
  65850. * @param data The data to import
  65851. * @param rootUrl The root url for scene and resources
  65852. * @param onError The callback when import fails
  65853. * @returns true if successful or false otherwise
  65854. */
  65855. load(scene: Scene, data: any, rootUrl: string): boolean;
  65856. /**
  65857. * Load into an asset container.
  65858. * @param scene The scene to load into
  65859. * @param data The data to import
  65860. * @param rootUrl The root url for scene and resources
  65861. * @param onError The callback when import fails
  65862. * @returns The loaded asset container
  65863. */
  65864. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  65865. private _isBinary;
  65866. private _parseBinary;
  65867. private _parseASCII;
  65868. }
  65869. }
  65870. declare module BABYLON {
  65871. /**
  65872. * Class for generating OBJ data from a Babylon scene.
  65873. */
  65874. export class OBJExport {
  65875. /**
  65876. * Exports the geometry of a Mesh array in .OBJ file format (text)
  65877. * @param mesh defines the list of meshes to serialize
  65878. * @param materials defines if materials should be exported
  65879. * @param matlibname defines the name of the associated mtl file
  65880. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  65881. * @returns the OBJ content
  65882. */
  65883. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  65884. /**
  65885. * Exports the material(s) of a mesh in .MTL file format (text)
  65886. * @param mesh defines the mesh to extract the material from
  65887. * @returns the mtl content
  65888. */
  65889. static MTL(mesh: Mesh): string;
  65890. }
  65891. }
  65892. declare module BABYLON {
  65893. /** @hidden */
  65894. export var __IGLTFExporterExtension: number;
  65895. /**
  65896. * Interface for extending the exporter
  65897. * @hidden
  65898. */
  65899. export interface IGLTFExporterExtension {
  65900. /**
  65901. * The name of this extension
  65902. */
  65903. readonly name: string;
  65904. /**
  65905. * Defines whether this extension is enabled
  65906. */
  65907. enabled: boolean;
  65908. /**
  65909. * Defines whether this extension is required
  65910. */
  65911. required: boolean;
  65912. }
  65913. }
  65914. declare module BABYLON.GLTF2.Exporter {
  65915. /** @hidden */
  65916. export var __IGLTFExporterExtensionV2: number;
  65917. /**
  65918. * Interface for a glTF exporter extension
  65919. * @hidden
  65920. */
  65921. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  65922. /**
  65923. * Define this method to modify the default behavior before exporting a texture
  65924. * @param context The context when loading the asset
  65925. * @param babylonTexture The glTF texture info property
  65926. * @param mimeType The mime-type of the generated image
  65927. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  65928. */
  65929. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65930. /**
  65931. * Define this method to modify the default behavior when exporting texture info
  65932. * @param context The context when loading the asset
  65933. * @param meshPrimitive glTF mesh primitive
  65934. * @param babylonSubMesh Babylon submesh
  65935. * @param binaryWriter glTF serializer binary writer instance
  65936. * @returns nullable IMeshPrimitive promise
  65937. */
  65938. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65939. /**
  65940. * Define this method to modify the default behavior when exporting a node
  65941. * @param context The context when exporting the node
  65942. * @param node glTF node
  65943. * @param babylonNode BabylonJS node
  65944. * @returns nullable INode promise
  65945. */
  65946. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65947. /**
  65948. * Called after the exporter state changes to EXPORTING
  65949. */
  65950. onExporting?(): void;
  65951. }
  65952. }
  65953. declare module BABYLON.GLTF2.Exporter {
  65954. /**
  65955. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  65956. * @hidden
  65957. */
  65958. export class _GLTFMaterialExporter {
  65959. /**
  65960. * Represents the dielectric specular values for R, G and B
  65961. */
  65962. private static readonly _DielectricSpecular;
  65963. /**
  65964. * Allows the maximum specular power to be defined for material calculations
  65965. */
  65966. private static readonly _MaxSpecularPower;
  65967. /**
  65968. * Mapping to store textures
  65969. */
  65970. private _textureMap;
  65971. /**
  65972. * Numeric tolerance value
  65973. */
  65974. private static readonly _Epsilon;
  65975. /**
  65976. * Reference to the glTF Exporter
  65977. */
  65978. private _exporter;
  65979. constructor(exporter: _Exporter);
  65980. /**
  65981. * Specifies if two colors are approximately equal in value
  65982. * @param color1 first color to compare to
  65983. * @param color2 second color to compare to
  65984. * @param epsilon threshold value
  65985. */
  65986. private static FuzzyEquals;
  65987. /**
  65988. * Gets the materials from a Babylon scene and converts them to glTF materials
  65989. * @param scene babylonjs scene
  65990. * @param mimeType texture mime type
  65991. * @param images array of images
  65992. * @param textures array of textures
  65993. * @param materials array of materials
  65994. * @param imageData mapping of texture names to base64 textures
  65995. * @param hasTextureCoords specifies if texture coordinates are present on the material
  65996. */
  65997. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65998. /**
  65999. * Makes a copy of the glTF material without the texture parameters
  66000. * @param originalMaterial original glTF material
  66001. * @returns glTF material without texture parameters
  66002. */
  66003. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  66004. /**
  66005. * Specifies if the material has any texture parameters present
  66006. * @param material glTF Material
  66007. * @returns boolean specifying if texture parameters are present
  66008. */
  66009. _hasTexturesPresent(material: IMaterial): boolean;
  66010. /**
  66011. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  66012. * @param babylonStandardMaterial
  66013. * @returns glTF Metallic Roughness Material representation
  66014. */
  66015. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  66016. /**
  66017. * Computes the metallic factor
  66018. * @param diffuse diffused value
  66019. * @param specular specular value
  66020. * @param oneMinusSpecularStrength one minus the specular strength
  66021. * @returns metallic value
  66022. */
  66023. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  66024. /**
  66025. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  66026. * @param glTFMaterial glTF material
  66027. * @param babylonMaterial Babylon material
  66028. */
  66029. private static _SetAlphaMode;
  66030. /**
  66031. * Converts a Babylon Standard Material to a glTF Material
  66032. * @param babylonStandardMaterial BJS Standard Material
  66033. * @param mimeType mime type to use for the textures
  66034. * @param images array of glTF image interfaces
  66035. * @param textures array of glTF texture interfaces
  66036. * @param materials array of glTF material interfaces
  66037. * @param imageData map of image file name to data
  66038. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66039. */
  66040. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66041. /**
  66042. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66043. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  66044. * @param mimeType mime type to use for the textures
  66045. * @param images array of glTF image interfaces
  66046. * @param textures array of glTF texture interfaces
  66047. * @param materials array of glTF material interfaces
  66048. * @param imageData map of image file name to data
  66049. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66050. */
  66051. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66052. /**
  66053. * Converts an image typed array buffer to a base64 image
  66054. * @param buffer typed array buffer
  66055. * @param width width of the image
  66056. * @param height height of the image
  66057. * @param mimeType mimetype of the image
  66058. * @returns base64 image string
  66059. */
  66060. private _createBase64FromCanvasAsync;
  66061. /**
  66062. * Generates a white texture based on the specified width and height
  66063. * @param width width of the texture in pixels
  66064. * @param height height of the texture in pixels
  66065. * @param scene babylonjs scene
  66066. * @returns white texture
  66067. */
  66068. private _createWhiteTexture;
  66069. /**
  66070. * 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
  66071. * @param texture1 first texture to resize
  66072. * @param texture2 second texture to resize
  66073. * @param scene babylonjs scene
  66074. * @returns resized textures or null
  66075. */
  66076. private _resizeTexturesToSameDimensions;
  66077. /**
  66078. * Converts an array of pixels to a Float32Array
  66079. * Throws an error if the pixel format is not supported
  66080. * @param pixels - array buffer containing pixel values
  66081. * @returns Float32 of pixels
  66082. */
  66083. private _convertPixelArrayToFloat32;
  66084. /**
  66085. * Convert Specular Glossiness Textures to Metallic Roughness
  66086. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  66087. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  66088. * @param diffuseTexture texture used to store diffuse information
  66089. * @param specularGlossinessTexture texture used to store specular and glossiness information
  66090. * @param factors specular glossiness material factors
  66091. * @param mimeType the mime type to use for the texture
  66092. * @returns pbr metallic roughness interface or null
  66093. */
  66094. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  66095. /**
  66096. * Converts specular glossiness material properties to metallic roughness
  66097. * @param specularGlossiness interface with specular glossiness material properties
  66098. * @returns interface with metallic roughness material properties
  66099. */
  66100. private _convertSpecularGlossinessToMetallicRoughness;
  66101. /**
  66102. * Calculates the surface reflectance, independent of lighting conditions
  66103. * @param color Color source to calculate brightness from
  66104. * @returns number representing the perceived brightness, or zero if color is undefined
  66105. */
  66106. private _getPerceivedBrightness;
  66107. /**
  66108. * Returns the maximum color component value
  66109. * @param color
  66110. * @returns maximum color component value, or zero if color is null or undefined
  66111. */
  66112. private _getMaxComponent;
  66113. /**
  66114. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  66115. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66116. * @param mimeType mime type to use for the textures
  66117. * @param images array of glTF image interfaces
  66118. * @param textures array of glTF texture interfaces
  66119. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66120. * @param imageData map of image file name to data
  66121. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66122. * @returns glTF PBR Metallic Roughness factors
  66123. */
  66124. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  66125. private _getGLTFTextureSampler;
  66126. private _getGLTFTextureWrapMode;
  66127. private _getGLTFTextureWrapModesSampler;
  66128. /**
  66129. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  66130. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66131. * @param mimeType mime type to use for the textures
  66132. * @param images array of glTF image interfaces
  66133. * @param textures array of glTF texture interfaces
  66134. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66135. * @param imageData map of image file name to data
  66136. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66137. * @returns glTF PBR Metallic Roughness factors
  66138. */
  66139. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  66140. /**
  66141. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66142. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66143. * @param mimeType mime type to use for the textures
  66144. * @param images array of glTF image interfaces
  66145. * @param textures array of glTF texture interfaces
  66146. * @param materials array of glTF material interfaces
  66147. * @param imageData map of image file name to data
  66148. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66149. */
  66150. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66151. private setMetallicRoughnessPbrMaterial;
  66152. private getPixelsFromTexture;
  66153. /**
  66154. * Extracts a texture from a Babylon texture into file data and glTF data
  66155. * @param babylonTexture Babylon texture to extract
  66156. * @param mimeType Mime Type of the babylonTexture
  66157. * @return glTF texture info, or null if the texture format is not supported
  66158. */
  66159. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  66160. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  66161. /**
  66162. * Builds a texture from base64 string
  66163. * @param base64Texture base64 texture string
  66164. * @param baseTextureName Name to use for the texture
  66165. * @param mimeType image mime type for the texture
  66166. * @param images array of images
  66167. * @param textures array of textures
  66168. * @param imageData map of image data
  66169. * @returns glTF texture info, or null if the texture format is not supported
  66170. */
  66171. private _getTextureInfoFromBase64;
  66172. }
  66173. }
  66174. declare module BABYLON {
  66175. /**
  66176. * Class for holding and downloading glTF file data
  66177. */
  66178. export class GLTFData {
  66179. /**
  66180. * Object which contains the file name as the key and its data as the value
  66181. */
  66182. glTFFiles: {
  66183. [fileName: string]: string | Blob;
  66184. };
  66185. /**
  66186. * Initializes the glTF file object
  66187. */
  66188. constructor();
  66189. /**
  66190. * Downloads the glTF data as files based on their names and data
  66191. */
  66192. downloadFiles(): void;
  66193. }
  66194. }
  66195. declare module BABYLON {
  66196. /**
  66197. * Holds a collection of exporter options and parameters
  66198. */
  66199. export interface IExportOptions {
  66200. /**
  66201. * Function which indicates whether a babylon node should be exported or not
  66202. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  66203. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  66204. */
  66205. shouldExportNode?(node: Node): boolean;
  66206. /**
  66207. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  66208. * @param metadata source metadata to read from
  66209. * @returns the data to store to glTF node extras
  66210. */
  66211. metadataSelector?(metadata: any): any;
  66212. /**
  66213. * The sample rate to bake animation curves
  66214. */
  66215. animationSampleRate?: number;
  66216. /**
  66217. * Begin serialization without waiting for the scene to be ready
  66218. */
  66219. exportWithoutWaitingForScene?: boolean;
  66220. }
  66221. /**
  66222. * Class for generating glTF data from a Babylon scene.
  66223. */
  66224. export class GLTF2Export {
  66225. /**
  66226. * Exports the geometry of the scene to .gltf file format asynchronously
  66227. * @param scene Babylon scene with scene hierarchy information
  66228. * @param filePrefix File prefix to use when generating the glTF file
  66229. * @param options Exporter options
  66230. * @returns Returns an object with a .gltf file and associates texture names
  66231. * as keys and their data and paths as values
  66232. */
  66233. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66234. private static _PreExportAsync;
  66235. private static _PostExportAsync;
  66236. /**
  66237. * Exports the geometry of the scene to .glb file format asychronously
  66238. * @param scene Babylon scene with scene hierarchy information
  66239. * @param filePrefix File prefix to use when generating glb file
  66240. * @param options Exporter options
  66241. * @returns Returns an object with a .glb filename as key and data as value
  66242. */
  66243. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66244. }
  66245. }
  66246. declare module BABYLON.GLTF2.Exporter {
  66247. /**
  66248. * @hidden
  66249. */
  66250. export class _GLTFUtilities {
  66251. /**
  66252. * Creates a buffer view based on the supplied arguments
  66253. * @param bufferIndex index value of the specified buffer
  66254. * @param byteOffset byte offset value
  66255. * @param byteLength byte length of the bufferView
  66256. * @param byteStride byte distance between conequential elements
  66257. * @param name name of the buffer view
  66258. * @returns bufferView for glTF
  66259. */
  66260. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  66261. /**
  66262. * Creates an accessor based on the supplied arguments
  66263. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  66264. * @param name The name of the accessor
  66265. * @param type The type of the accessor
  66266. * @param componentType The datatype of components in the attribute
  66267. * @param count The number of attributes referenced by this accessor
  66268. * @param byteOffset The offset relative to the start of the bufferView in bytes
  66269. * @param min Minimum value of each component in this attribute
  66270. * @param max Maximum value of each component in this attribute
  66271. * @returns accessor for glTF
  66272. */
  66273. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  66274. /**
  66275. * Calculates the minimum and maximum values of an array of position floats
  66276. * @param positions Positions array of a mesh
  66277. * @param vertexStart Starting vertex offset to calculate min and max values
  66278. * @param vertexCount Number of vertices to check for min and max values
  66279. * @returns min number array and max number array
  66280. */
  66281. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  66282. min: number[];
  66283. max: number[];
  66284. };
  66285. /**
  66286. * Converts a new right-handed Vector3
  66287. * @param vector vector3 array
  66288. * @returns right-handed Vector3
  66289. */
  66290. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  66291. /**
  66292. * Converts a Vector3 to right-handed
  66293. * @param vector Vector3 to convert to right-handed
  66294. */
  66295. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  66296. /**
  66297. * Converts a three element number array to right-handed
  66298. * @param vector number array to convert to right-handed
  66299. */
  66300. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  66301. /**
  66302. * Converts a new right-handed Vector3
  66303. * @param vector vector3 array
  66304. * @returns right-handed Vector3
  66305. */
  66306. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  66307. /**
  66308. * Converts a Vector3 to right-handed
  66309. * @param vector Vector3 to convert to right-handed
  66310. */
  66311. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  66312. /**
  66313. * Converts a three element number array to right-handed
  66314. * @param vector number array to convert to right-handed
  66315. */
  66316. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  66317. /**
  66318. * Converts a Vector4 to right-handed
  66319. * @param vector Vector4 to convert to right-handed
  66320. */
  66321. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  66322. /**
  66323. * Converts a Vector4 to right-handed
  66324. * @param vector Vector4 to convert to right-handed
  66325. */
  66326. static _GetRightHandedArray4FromRef(vector: number[]): void;
  66327. /**
  66328. * Converts a Quaternion to right-handed
  66329. * @param quaternion Source quaternion to convert to right-handed
  66330. */
  66331. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  66332. /**
  66333. * Converts a Quaternion to right-handed
  66334. * @param quaternion Source quaternion to convert to right-handed
  66335. */
  66336. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  66337. static _NormalizeTangentFromRef(tangent: Vector4): void;
  66338. }
  66339. }
  66340. declare module BABYLON.GLTF2.Exporter {
  66341. /**
  66342. * Converts Babylon Scene into glTF 2.0.
  66343. * @hidden
  66344. */
  66345. export class _Exporter {
  66346. /**
  66347. * Stores the glTF to export
  66348. */
  66349. _glTF: IGLTF;
  66350. /**
  66351. * Stores all generated buffer views, which represents views into the main glTF buffer data
  66352. */
  66353. _bufferViews: IBufferView[];
  66354. /**
  66355. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  66356. */
  66357. _accessors: IAccessor[];
  66358. /**
  66359. * Stores all the generated nodes, which contains transform and/or mesh information per node
  66360. */
  66361. private _nodes;
  66362. /**
  66363. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  66364. */
  66365. private _scenes;
  66366. /**
  66367. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  66368. */
  66369. private _meshes;
  66370. /**
  66371. * Stores all the generated material information, which represents the appearance of each primitive
  66372. */
  66373. _materials: IMaterial[];
  66374. _materialMap: {
  66375. [materialID: number]: number;
  66376. };
  66377. /**
  66378. * Stores all the generated texture information, which is referenced by glTF materials
  66379. */
  66380. _textures: ITexture[];
  66381. /**
  66382. * Stores all the generated image information, which is referenced by glTF textures
  66383. */
  66384. _images: IImage[];
  66385. /**
  66386. * Stores all the texture samplers
  66387. */
  66388. _samplers: ISampler[];
  66389. /**
  66390. * Stores all the generated animation samplers, which is referenced by glTF animations
  66391. */
  66392. /**
  66393. * Stores the animations for glTF models
  66394. */
  66395. private _animations;
  66396. /**
  66397. * Stores the total amount of bytes stored in the glTF buffer
  66398. */
  66399. private _totalByteLength;
  66400. /**
  66401. * Stores a reference to the Babylon scene containing the source geometry and material information
  66402. */
  66403. _babylonScene: Scene;
  66404. /**
  66405. * Stores a map of the image data, where the key is the file name and the value
  66406. * is the image data
  66407. */
  66408. _imageData: {
  66409. [fileName: string]: {
  66410. data: Uint8Array;
  66411. mimeType: ImageMimeType;
  66412. };
  66413. };
  66414. /**
  66415. * Stores a map of the unique id of a node to its index in the node array
  66416. */
  66417. private _nodeMap;
  66418. /**
  66419. * Specifies if the Babylon scene should be converted to right-handed on export
  66420. */
  66421. _convertToRightHandedSystem: boolean;
  66422. /**
  66423. * Baked animation sample rate
  66424. */
  66425. private _animationSampleRate;
  66426. private _options;
  66427. private _localEngine;
  66428. _glTFMaterialExporter: _GLTFMaterialExporter;
  66429. private _extensions;
  66430. private static _ExtensionNames;
  66431. private static _ExtensionFactories;
  66432. private _applyExtensions;
  66433. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  66434. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66435. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66436. private _forEachExtensions;
  66437. private _extensionsOnExporting;
  66438. /**
  66439. * Load glTF serializer extensions
  66440. */
  66441. private _loadExtensions;
  66442. /**
  66443. * Creates a glTF Exporter instance, which can accept optional exporter options
  66444. * @param babylonScene Babylon scene object
  66445. * @param options Options to modify the behavior of the exporter
  66446. */
  66447. constructor(babylonScene: Scene, options?: IExportOptions);
  66448. /**
  66449. * Registers a glTF exporter extension
  66450. * @param name Name of the extension to export
  66451. * @param factory The factory function that creates the exporter extension
  66452. */
  66453. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  66454. /**
  66455. * Un-registers an exporter extension
  66456. * @param name The name fo the exporter extension
  66457. * @returns A boolean indicating whether the extension has been un-registered
  66458. */
  66459. static UnregisterExtension(name: string): boolean;
  66460. /**
  66461. * Lazy load a local engine with premultiplied alpha set to false
  66462. */
  66463. _getLocalEngine(): Engine;
  66464. private reorderIndicesBasedOnPrimitiveMode;
  66465. /**
  66466. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  66467. * clock-wise during export to glTF
  66468. * @param submesh BabylonJS submesh
  66469. * @param primitiveMode Primitive mode of the mesh
  66470. * @param sideOrientation the winding order of the submesh
  66471. * @param vertexBufferKind The type of vertex attribute
  66472. * @param meshAttributeArray The vertex attribute data
  66473. * @param byteOffset The offset to the binary data
  66474. * @param binaryWriter The binary data for the glTF file
  66475. */
  66476. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  66477. /**
  66478. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  66479. * clock-wise during export to glTF
  66480. * @param submesh BabylonJS submesh
  66481. * @param primitiveMode Primitive mode of the mesh
  66482. * @param sideOrientation the winding order of the submesh
  66483. * @param vertexBufferKind The type of vertex attribute
  66484. * @param meshAttributeArray The vertex attribute data
  66485. * @param byteOffset The offset to the binary data
  66486. * @param binaryWriter The binary data for the glTF file
  66487. */
  66488. private reorderTriangleFillMode;
  66489. /**
  66490. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  66491. * clock-wise during export to glTF
  66492. * @param submesh BabylonJS submesh
  66493. * @param primitiveMode Primitive mode of the mesh
  66494. * @param sideOrientation the winding order of the submesh
  66495. * @param vertexBufferKind The type of vertex attribute
  66496. * @param meshAttributeArray The vertex attribute data
  66497. * @param byteOffset The offset to the binary data
  66498. * @param binaryWriter The binary data for the glTF file
  66499. */
  66500. private reorderTriangleStripDrawMode;
  66501. /**
  66502. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  66503. * clock-wise during export to glTF
  66504. * @param submesh BabylonJS submesh
  66505. * @param primitiveMode Primitive mode of the mesh
  66506. * @param sideOrientation the winding order of the submesh
  66507. * @param vertexBufferKind The type of vertex attribute
  66508. * @param meshAttributeArray The vertex attribute data
  66509. * @param byteOffset The offset to the binary data
  66510. * @param binaryWriter The binary data for the glTF file
  66511. */
  66512. private reorderTriangleFanMode;
  66513. /**
  66514. * Writes the vertex attribute data to binary
  66515. * @param vertices The vertices to write to the binary writer
  66516. * @param byteOffset The offset into the binary writer to overwrite binary data
  66517. * @param vertexAttributeKind The vertex attribute type
  66518. * @param meshAttributeArray The vertex attribute data
  66519. * @param binaryWriter The writer containing the binary data
  66520. */
  66521. private writeVertexAttributeData;
  66522. /**
  66523. * Writes mesh attribute data to a data buffer
  66524. * Returns the bytelength of the data
  66525. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  66526. * @param meshAttributeArray Array containing the attribute data
  66527. * @param binaryWriter The buffer to write the binary data to
  66528. * @param indices Used to specify the order of the vertex data
  66529. */
  66530. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  66531. /**
  66532. * Generates glTF json data
  66533. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  66534. * @param glTFPrefix Text to use when prefixing a glTF file
  66535. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  66536. * @returns json data as string
  66537. */
  66538. private generateJSON;
  66539. /**
  66540. * Generates data for .gltf and .bin files based on the glTF prefix string
  66541. * @param glTFPrefix Text to use when prefixing a glTF file
  66542. * @returns GLTFData with glTF file data
  66543. */
  66544. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  66545. /**
  66546. * Creates a binary buffer for glTF
  66547. * @returns array buffer for binary data
  66548. */
  66549. private _generateBinaryAsync;
  66550. /**
  66551. * Pads the number to a multiple of 4
  66552. * @param num number to pad
  66553. * @returns padded number
  66554. */
  66555. private _getPadding;
  66556. /**
  66557. * Generates a glb file from the json and binary data
  66558. * Returns an object with the glb file name as the key and data as the value
  66559. * @param glTFPrefix
  66560. * @returns object with glb filename as key and data as value
  66561. */
  66562. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  66563. /**
  66564. * Sets the TRS for each node
  66565. * @param node glTF Node for storing the transformation data
  66566. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  66567. */
  66568. private setNodeTransformation;
  66569. private getVertexBufferFromMesh;
  66570. /**
  66571. * Creates a bufferview based on the vertices type for the Babylon mesh
  66572. * @param kind Indicates the type of vertices data
  66573. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  66574. * @param binaryWriter The buffer to write the bufferview data to
  66575. */
  66576. private createBufferViewKind;
  66577. /**
  66578. * The primitive mode of the Babylon mesh
  66579. * @param babylonMesh The BabylonJS mesh
  66580. */
  66581. private getMeshPrimitiveMode;
  66582. /**
  66583. * Sets the primitive mode of the glTF mesh primitive
  66584. * @param meshPrimitive glTF mesh primitive
  66585. * @param primitiveMode The primitive mode
  66586. */
  66587. private setPrimitiveMode;
  66588. /**
  66589. * Sets the vertex attribute accessor based of the glTF mesh primitive
  66590. * @param meshPrimitive glTF mesh primitive
  66591. * @param attributeKind vertex attribute
  66592. * @returns boolean specifying if uv coordinates are present
  66593. */
  66594. private setAttributeKind;
  66595. /**
  66596. * Sets data for the primitive attributes of each submesh
  66597. * @param mesh glTF Mesh object to store the primitive attribute information
  66598. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  66599. * @param binaryWriter Buffer to write the attribute data to
  66600. */
  66601. private setPrimitiveAttributesAsync;
  66602. /**
  66603. * Creates a glTF scene based on the array of meshes
  66604. * Returns the the total byte offset
  66605. * @param babylonScene Babylon scene to get the mesh data from
  66606. * @param binaryWriter Buffer to write binary data to
  66607. */
  66608. private createSceneAsync;
  66609. /**
  66610. * Creates a mapping of Node unique id to node index and handles animations
  66611. * @param babylonScene Babylon Scene
  66612. * @param nodes Babylon transform nodes
  66613. * @param binaryWriter Buffer to write binary data to
  66614. * @returns Node mapping of unique id to index
  66615. */
  66616. private createNodeMapAndAnimationsAsync;
  66617. /**
  66618. * Creates a glTF node from a Babylon mesh
  66619. * @param babylonMesh Source Babylon mesh
  66620. * @param binaryWriter Buffer for storing geometry data
  66621. * @returns glTF node
  66622. */
  66623. private createNodeAsync;
  66624. }
  66625. /**
  66626. * @hidden
  66627. *
  66628. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  66629. */
  66630. export class _BinaryWriter {
  66631. /**
  66632. * Array buffer which stores all binary data
  66633. */
  66634. private _arrayBuffer;
  66635. /**
  66636. * View of the array buffer
  66637. */
  66638. private _dataView;
  66639. /**
  66640. * byte offset of data in array buffer
  66641. */
  66642. private _byteOffset;
  66643. /**
  66644. * Initialize binary writer with an initial byte length
  66645. * @param byteLength Initial byte length of the array buffer
  66646. */
  66647. constructor(byteLength: number);
  66648. /**
  66649. * Resize the array buffer to the specified byte length
  66650. * @param byteLength
  66651. */
  66652. private resizeBuffer;
  66653. /**
  66654. * Get an array buffer with the length of the byte offset
  66655. * @returns ArrayBuffer resized to the byte offset
  66656. */
  66657. getArrayBuffer(): ArrayBuffer;
  66658. /**
  66659. * Get the byte offset of the array buffer
  66660. * @returns byte offset
  66661. */
  66662. getByteOffset(): number;
  66663. /**
  66664. * Stores an UInt8 in the array buffer
  66665. * @param entry
  66666. * @param byteOffset If defined, specifies where to set the value as an offset.
  66667. */
  66668. setUInt8(entry: number, byteOffset?: number): void;
  66669. /**
  66670. * Gets an UInt32 in the array buffer
  66671. * @param entry
  66672. * @param byteOffset If defined, specifies where to set the value as an offset.
  66673. */
  66674. getUInt32(byteOffset: number): number;
  66675. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66676. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66677. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66678. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66679. /**
  66680. * Stores a Float32 in the array buffer
  66681. * @param entry
  66682. */
  66683. setFloat32(entry: number, byteOffset?: number): void;
  66684. /**
  66685. * Stores an UInt32 in the array buffer
  66686. * @param entry
  66687. * @param byteOffset If defined, specifies where to set the value as an offset.
  66688. */
  66689. setUInt32(entry: number, byteOffset?: number): void;
  66690. }
  66691. }
  66692. declare module BABYLON.GLTF2.Exporter {
  66693. /**
  66694. * @hidden
  66695. * Interface to store animation data.
  66696. */
  66697. export interface _IAnimationData {
  66698. /**
  66699. * Keyframe data.
  66700. */
  66701. inputs: number[];
  66702. /**
  66703. * Value data.
  66704. */
  66705. outputs: number[][];
  66706. /**
  66707. * Animation interpolation data.
  66708. */
  66709. samplerInterpolation: AnimationSamplerInterpolation;
  66710. /**
  66711. * Minimum keyframe value.
  66712. */
  66713. inputsMin: number;
  66714. /**
  66715. * Maximum keyframe value.
  66716. */
  66717. inputsMax: number;
  66718. }
  66719. /**
  66720. * @hidden
  66721. */
  66722. export interface _IAnimationInfo {
  66723. /**
  66724. * The target channel for the animation
  66725. */
  66726. animationChannelTargetPath: AnimationChannelTargetPath;
  66727. /**
  66728. * The glTF accessor type for the data.
  66729. */
  66730. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  66731. /**
  66732. * Specifies if quaternions should be used.
  66733. */
  66734. useQuaternion: boolean;
  66735. }
  66736. /**
  66737. * @hidden
  66738. * Utility class for generating glTF animation data from BabylonJS.
  66739. */
  66740. export class _GLTFAnimation {
  66741. /**
  66742. * @ignore
  66743. *
  66744. * Creates glTF channel animation from BabylonJS animation.
  66745. * @param babylonTransformNode - BabylonJS mesh.
  66746. * @param animation - animation.
  66747. * @param animationChannelTargetPath - The target animation channel.
  66748. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  66749. * @param useQuaternion - Specifies if quaternions are used.
  66750. * @returns nullable IAnimationData
  66751. */
  66752. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  66753. private static _DeduceAnimationInfo;
  66754. /**
  66755. * @ignore
  66756. * Create node animations from the transform node animations
  66757. * @param babylonNode
  66758. * @param runtimeGLTFAnimation
  66759. * @param idleGLTFAnimations
  66760. * @param nodeMap
  66761. * @param nodes
  66762. * @param binaryWriter
  66763. * @param bufferViews
  66764. * @param accessors
  66765. * @param convertToRightHandedSystem
  66766. */
  66767. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  66768. [key: number]: number;
  66769. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66770. /**
  66771. * @ignore
  66772. * Create node animations from the animation groups
  66773. * @param babylonScene
  66774. * @param glTFAnimations
  66775. * @param nodeMap
  66776. * @param nodes
  66777. * @param binaryWriter
  66778. * @param bufferViews
  66779. * @param accessors
  66780. * @param convertToRightHandedSystem
  66781. */
  66782. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  66783. [key: number]: number;
  66784. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66785. private static AddAnimation;
  66786. /**
  66787. * Create a baked animation
  66788. * @param babylonTransformNode BabylonJS mesh
  66789. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  66790. * @param animationChannelTargetPath animation target channel
  66791. * @param minFrame minimum animation frame
  66792. * @param maxFrame maximum animation frame
  66793. * @param fps frames per second of the animation
  66794. * @param inputs input key frames of the animation
  66795. * @param outputs output key frame data of the animation
  66796. * @param convertToRightHandedSystem converts the values to right-handed
  66797. * @param useQuaternion specifies if quaternions should be used
  66798. */
  66799. private static _CreateBakedAnimation;
  66800. private static _ConvertFactorToVector3OrQuaternion;
  66801. private static _SetInterpolatedValue;
  66802. /**
  66803. * Creates linear animation from the animation key frames
  66804. * @param babylonTransformNode BabylonJS mesh
  66805. * @param animation BabylonJS animation
  66806. * @param animationChannelTargetPath The target animation channel
  66807. * @param frameDelta The difference between the last and first frame of the animation
  66808. * @param inputs Array to store the key frame times
  66809. * @param outputs Array to store the key frame data
  66810. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66811. * @param useQuaternion Specifies if quaternions are used in the animation
  66812. */
  66813. private static _CreateLinearOrStepAnimation;
  66814. /**
  66815. * Creates cubic spline animation from the animation key frames
  66816. * @param babylonTransformNode BabylonJS mesh
  66817. * @param animation BabylonJS animation
  66818. * @param animationChannelTargetPath The target animation channel
  66819. * @param frameDelta The difference between the last and first frame of the animation
  66820. * @param inputs Array to store the key frame times
  66821. * @param outputs Array to store the key frame data
  66822. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66823. * @param useQuaternion Specifies if quaternions are used in the animation
  66824. */
  66825. private static _CreateCubicSplineAnimation;
  66826. private static _GetBasePositionRotationOrScale;
  66827. /**
  66828. * Adds a key frame value
  66829. * @param keyFrame
  66830. * @param animation
  66831. * @param outputs
  66832. * @param animationChannelTargetPath
  66833. * @param basePositionRotationOrScale
  66834. * @param convertToRightHandedSystem
  66835. * @param useQuaternion
  66836. */
  66837. private static _AddKeyframeValue;
  66838. /**
  66839. * Determine the interpolation based on the key frames
  66840. * @param keyFrames
  66841. * @param animationChannelTargetPath
  66842. * @param useQuaternion
  66843. */
  66844. private static _DeduceInterpolation;
  66845. /**
  66846. * Adds an input tangent or output tangent to the output data
  66847. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  66848. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  66849. * @param outputs The animation data by keyframe
  66850. * @param animationChannelTargetPath The target animation channel
  66851. * @param interpolation The interpolation type
  66852. * @param keyFrame The key frame with the animation data
  66853. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  66854. * @param useQuaternion Specifies if quaternions are used
  66855. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  66856. */
  66857. private static AddSplineTangent;
  66858. /**
  66859. * Get the minimum and maximum key frames' frame values
  66860. * @param keyFrames animation key frames
  66861. * @returns the minimum and maximum key frame value
  66862. */
  66863. private static calculateMinMaxKeyFrames;
  66864. }
  66865. }
  66866. declare module BABYLON.GLTF2.Exporter {
  66867. /** @hidden */
  66868. export var textureTransformPixelShader: {
  66869. name: string;
  66870. shader: string;
  66871. };
  66872. }
  66873. declare module BABYLON.GLTF2.Exporter.Extensions {
  66874. /**
  66875. * @hidden
  66876. */
  66877. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  66878. /** Name of this extension */
  66879. readonly name: string;
  66880. /** Defines whether this extension is enabled */
  66881. enabled: boolean;
  66882. /** Defines whether this extension is required */
  66883. required: boolean;
  66884. /** Reference to the glTF exporter */
  66885. private _exporter;
  66886. constructor(exporter: _Exporter);
  66887. dispose(): void;
  66888. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66889. /**
  66890. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  66891. * @param babylonTexture
  66892. * @param offset
  66893. * @param rotation
  66894. * @param scale
  66895. * @param scene
  66896. */
  66897. private _textureTransformTextureAsync;
  66898. }
  66899. }
  66900. declare module BABYLON.GLTF2.Exporter.Extensions {
  66901. /**
  66902. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  66903. */
  66904. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  66905. /** The name of this extension. */
  66906. readonly name: string;
  66907. /** Defines whether this extension is enabled. */
  66908. enabled: boolean;
  66909. /** Defines whether this extension is required */
  66910. required: boolean;
  66911. /** Reference to the glTF exporter */
  66912. private _exporter;
  66913. private _lights;
  66914. /** @hidden */
  66915. constructor(exporter: _Exporter);
  66916. /** @hidden */
  66917. dispose(): void;
  66918. /** @hidden */
  66919. onExporting(): void;
  66920. /**
  66921. * Define this method to modify the default behavior when exporting a node
  66922. * @param context The context when exporting the node
  66923. * @param node glTF node
  66924. * @param babylonNode BabylonJS node
  66925. * @returns nullable INode promise
  66926. */
  66927. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66928. }
  66929. }
  66930. declare module BABYLON {
  66931. /**
  66932. * Class for generating STL data from a Babylon scene.
  66933. */
  66934. export class STLExport {
  66935. /**
  66936. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  66937. * @param meshes list defines the mesh to serialize
  66938. * @param download triggers the automatic download of the file.
  66939. * @param fileName changes the downloads fileName.
  66940. * @param binary changes the STL to a binary type.
  66941. * @param isLittleEndian toggle for binary type exporter.
  66942. * @returns the STL as UTF8 string
  66943. */
  66944. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  66945. }
  66946. }
  66947. /**
  66948. * @ignoreChildren
  66949. * @ignore
  66950. */
  66951. declare module "babylonjs-gltf2interface" {
  66952. export = BABYLON.GLTF2;
  66953. }
  66954. /**
  66955. * Module for glTF 2.0 Interface
  66956. * @ignoreChildren
  66957. * @ignore
  66958. */
  66959. declare module BABYLON.GLTF2 {
  66960. /**
  66961. * The datatype of the components in the attribute
  66962. */
  66963. const enum AccessorComponentType {
  66964. /**
  66965. * Byte
  66966. */
  66967. BYTE = 5120,
  66968. /**
  66969. * Unsigned Byte
  66970. */
  66971. UNSIGNED_BYTE = 5121,
  66972. /**
  66973. * Short
  66974. */
  66975. SHORT = 5122,
  66976. /**
  66977. * Unsigned Short
  66978. */
  66979. UNSIGNED_SHORT = 5123,
  66980. /**
  66981. * Unsigned Int
  66982. */
  66983. UNSIGNED_INT = 5125,
  66984. /**
  66985. * Float
  66986. */
  66987. FLOAT = 5126,
  66988. }
  66989. /**
  66990. * Specifies if the attirbute is a scalar, vector, or matrix
  66991. */
  66992. const enum AccessorType {
  66993. /**
  66994. * Scalar
  66995. */
  66996. SCALAR = "SCALAR",
  66997. /**
  66998. * Vector2
  66999. */
  67000. VEC2 = "VEC2",
  67001. /**
  67002. * Vector3
  67003. */
  67004. VEC3 = "VEC3",
  67005. /**
  67006. * Vector4
  67007. */
  67008. VEC4 = "VEC4",
  67009. /**
  67010. * Matrix2x2
  67011. */
  67012. MAT2 = "MAT2",
  67013. /**
  67014. * Matrix3x3
  67015. */
  67016. MAT3 = "MAT3",
  67017. /**
  67018. * Matrix4x4
  67019. */
  67020. MAT4 = "MAT4",
  67021. }
  67022. /**
  67023. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67024. */
  67025. const enum AnimationChannelTargetPath {
  67026. /**
  67027. * Translation
  67028. */
  67029. TRANSLATION = "translation",
  67030. /**
  67031. * Rotation
  67032. */
  67033. ROTATION = "rotation",
  67034. /**
  67035. * Scale
  67036. */
  67037. SCALE = "scale",
  67038. /**
  67039. * Weights
  67040. */
  67041. WEIGHTS = "weights",
  67042. }
  67043. /**
  67044. * Interpolation algorithm
  67045. */
  67046. const enum AnimationSamplerInterpolation {
  67047. /**
  67048. * The animated values are linearly interpolated between keyframes
  67049. */
  67050. LINEAR = "LINEAR",
  67051. /**
  67052. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  67053. */
  67054. STEP = "STEP",
  67055. /**
  67056. * The animation's interpolation is computed using a cubic spline with specified tangents
  67057. */
  67058. CUBICSPLINE = "CUBICSPLINE",
  67059. }
  67060. /**
  67061. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67062. */
  67063. const enum CameraType {
  67064. /**
  67065. * A perspective camera containing properties to create a perspective projection matrix
  67066. */
  67067. PERSPECTIVE = "perspective",
  67068. /**
  67069. * An orthographic camera containing properties to create an orthographic projection matrix
  67070. */
  67071. ORTHOGRAPHIC = "orthographic",
  67072. }
  67073. /**
  67074. * The mime-type of the image
  67075. */
  67076. const enum ImageMimeType {
  67077. /**
  67078. * JPEG Mime-type
  67079. */
  67080. JPEG = "image/jpeg",
  67081. /**
  67082. * PNG Mime-type
  67083. */
  67084. PNG = "image/png",
  67085. }
  67086. /**
  67087. * The alpha rendering mode of the material
  67088. */
  67089. const enum MaterialAlphaMode {
  67090. /**
  67091. * The alpha value is ignored and the rendered output is fully opaque
  67092. */
  67093. OPAQUE = "OPAQUE",
  67094. /**
  67095. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  67096. */
  67097. MASK = "MASK",
  67098. /**
  67099. * 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)
  67100. */
  67101. BLEND = "BLEND",
  67102. }
  67103. /**
  67104. * The type of the primitives to render
  67105. */
  67106. const enum MeshPrimitiveMode {
  67107. /**
  67108. * Points
  67109. */
  67110. POINTS = 0,
  67111. /**
  67112. * Lines
  67113. */
  67114. LINES = 1,
  67115. /**
  67116. * Line Loop
  67117. */
  67118. LINE_LOOP = 2,
  67119. /**
  67120. * Line Strip
  67121. */
  67122. LINE_STRIP = 3,
  67123. /**
  67124. * Triangles
  67125. */
  67126. TRIANGLES = 4,
  67127. /**
  67128. * Triangle Strip
  67129. */
  67130. TRIANGLE_STRIP = 5,
  67131. /**
  67132. * Triangle Fan
  67133. */
  67134. TRIANGLE_FAN = 6,
  67135. }
  67136. /**
  67137. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67138. */
  67139. const enum TextureMagFilter {
  67140. /**
  67141. * Nearest
  67142. */
  67143. NEAREST = 9728,
  67144. /**
  67145. * Linear
  67146. */
  67147. LINEAR = 9729,
  67148. }
  67149. /**
  67150. * Minification filter. All valid values correspond to WebGL enums
  67151. */
  67152. const enum TextureMinFilter {
  67153. /**
  67154. * Nearest
  67155. */
  67156. NEAREST = 9728,
  67157. /**
  67158. * Linear
  67159. */
  67160. LINEAR = 9729,
  67161. /**
  67162. * Nearest Mip-Map Nearest
  67163. */
  67164. NEAREST_MIPMAP_NEAREST = 9984,
  67165. /**
  67166. * Linear Mipmap Nearest
  67167. */
  67168. LINEAR_MIPMAP_NEAREST = 9985,
  67169. /**
  67170. * Nearest Mipmap Linear
  67171. */
  67172. NEAREST_MIPMAP_LINEAR = 9986,
  67173. /**
  67174. * Linear Mipmap Linear
  67175. */
  67176. LINEAR_MIPMAP_LINEAR = 9987,
  67177. }
  67178. /**
  67179. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67180. */
  67181. const enum TextureWrapMode {
  67182. /**
  67183. * Clamp to Edge
  67184. */
  67185. CLAMP_TO_EDGE = 33071,
  67186. /**
  67187. * Mirrored Repeat
  67188. */
  67189. MIRRORED_REPEAT = 33648,
  67190. /**
  67191. * Repeat
  67192. */
  67193. REPEAT = 10497,
  67194. }
  67195. /**
  67196. * glTF Property
  67197. */
  67198. interface IProperty {
  67199. /**
  67200. * Dictionary object with extension-specific objects
  67201. */
  67202. extensions?: {
  67203. [key: string]: any;
  67204. };
  67205. /**
  67206. * Application-Specific data
  67207. */
  67208. extras?: any;
  67209. }
  67210. /**
  67211. * glTF Child of Root Property
  67212. */
  67213. interface IChildRootProperty extends IProperty {
  67214. /**
  67215. * The user-defined name of this object
  67216. */
  67217. name?: string;
  67218. }
  67219. /**
  67220. * Indices of those attributes that deviate from their initialization value
  67221. */
  67222. interface IAccessorSparseIndices extends IProperty {
  67223. /**
  67224. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67225. */
  67226. bufferView: number;
  67227. /**
  67228. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67229. */
  67230. byteOffset?: number;
  67231. /**
  67232. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  67233. */
  67234. componentType: AccessorComponentType;
  67235. }
  67236. /**
  67237. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  67238. */
  67239. interface IAccessorSparseValues extends IProperty {
  67240. /**
  67241. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67242. */
  67243. bufferView: number;
  67244. /**
  67245. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67246. */
  67247. byteOffset?: number;
  67248. }
  67249. /**
  67250. * Sparse storage of attributes that deviate from their initialization value
  67251. */
  67252. interface IAccessorSparse extends IProperty {
  67253. /**
  67254. * The number of attributes encoded in this sparse accessor
  67255. */
  67256. count: number;
  67257. /**
  67258. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  67259. */
  67260. indices: IAccessorSparseIndices;
  67261. /**
  67262. * 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
  67263. */
  67264. values: IAccessorSparseValues;
  67265. }
  67266. /**
  67267. * 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
  67268. */
  67269. interface IAccessor extends IChildRootProperty {
  67270. /**
  67271. * The index of the bufferview
  67272. */
  67273. bufferView?: number;
  67274. /**
  67275. * The offset relative to the start of the bufferView in bytes
  67276. */
  67277. byteOffset?: number;
  67278. /**
  67279. * The datatype of components in the attribute
  67280. */
  67281. componentType: AccessorComponentType;
  67282. /**
  67283. * Specifies whether integer data values should be normalized
  67284. */
  67285. normalized?: boolean;
  67286. /**
  67287. * The number of attributes referenced by this accessor
  67288. */
  67289. count: number;
  67290. /**
  67291. * Specifies if the attribute is a scalar, vector, or matrix
  67292. */
  67293. type: AccessorType;
  67294. /**
  67295. * Maximum value of each component in this attribute
  67296. */
  67297. max?: number[];
  67298. /**
  67299. * Minimum value of each component in this attribute
  67300. */
  67301. min?: number[];
  67302. /**
  67303. * Sparse storage of attributes that deviate from their initialization value
  67304. */
  67305. sparse?: IAccessorSparse;
  67306. }
  67307. /**
  67308. * Targets an animation's sampler at a node's property
  67309. */
  67310. interface IAnimationChannel extends IProperty {
  67311. /**
  67312. * The index of a sampler in this animation used to compute the value for the target
  67313. */
  67314. sampler: number;
  67315. /**
  67316. * The index of the node and TRS property to target
  67317. */
  67318. target: IAnimationChannelTarget;
  67319. }
  67320. /**
  67321. * The index of the node and TRS property that an animation channel targets
  67322. */
  67323. interface IAnimationChannelTarget extends IProperty {
  67324. /**
  67325. * The index of the node to target
  67326. */
  67327. node: number;
  67328. /**
  67329. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67330. */
  67331. path: AnimationChannelTargetPath;
  67332. }
  67333. /**
  67334. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67335. */
  67336. interface IAnimationSampler extends IProperty {
  67337. /**
  67338. * The index of an accessor containing keyframe input values, e.g., time
  67339. */
  67340. input: number;
  67341. /**
  67342. * Interpolation algorithm
  67343. */
  67344. interpolation?: AnimationSamplerInterpolation;
  67345. /**
  67346. * The index of an accessor, containing keyframe output values
  67347. */
  67348. output: number;
  67349. }
  67350. /**
  67351. * A keyframe animation
  67352. */
  67353. interface IAnimation extends IChildRootProperty {
  67354. /**
  67355. * An array of channels, each of which targets an animation's sampler at a node's property
  67356. */
  67357. channels: IAnimationChannel[];
  67358. /**
  67359. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67360. */
  67361. samplers: IAnimationSampler[];
  67362. }
  67363. /**
  67364. * Metadata about the glTF asset
  67365. */
  67366. interface IAsset extends IChildRootProperty {
  67367. /**
  67368. * A copyright message suitable for display to credit the content creator
  67369. */
  67370. copyright?: string;
  67371. /**
  67372. * Tool that generated this glTF model. Useful for debugging
  67373. */
  67374. generator?: string;
  67375. /**
  67376. * The glTF version that this asset targets
  67377. */
  67378. version: string;
  67379. /**
  67380. * The minimum glTF version that this asset targets
  67381. */
  67382. minVersion?: string;
  67383. }
  67384. /**
  67385. * A buffer points to binary geometry, animation, or skins
  67386. */
  67387. interface IBuffer extends IChildRootProperty {
  67388. /**
  67389. * 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
  67390. */
  67391. uri?: string;
  67392. /**
  67393. * The length of the buffer in bytes
  67394. */
  67395. byteLength: number;
  67396. }
  67397. /**
  67398. * A view into a buffer generally representing a subset of the buffer
  67399. */
  67400. interface IBufferView extends IChildRootProperty {
  67401. /**
  67402. * The index of the buffer
  67403. */
  67404. buffer: number;
  67405. /**
  67406. * The offset into the buffer in bytes
  67407. */
  67408. byteOffset?: number;
  67409. /**
  67410. * The lenth of the bufferView in bytes
  67411. */
  67412. byteLength: number;
  67413. /**
  67414. * The stride, in bytes
  67415. */
  67416. byteStride?: number;
  67417. }
  67418. /**
  67419. * An orthographic camera containing properties to create an orthographic projection matrix
  67420. */
  67421. interface ICameraOrthographic extends IProperty {
  67422. /**
  67423. * The floating-point horizontal magnification of the view. Must not be zero
  67424. */
  67425. xmag: number;
  67426. /**
  67427. * The floating-point vertical magnification of the view. Must not be zero
  67428. */
  67429. ymag: number;
  67430. /**
  67431. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  67432. */
  67433. zfar: number;
  67434. /**
  67435. * The floating-point distance to the near clipping plane
  67436. */
  67437. znear: number;
  67438. }
  67439. /**
  67440. * A perspective camera containing properties to create a perspective projection matrix
  67441. */
  67442. interface ICameraPerspective extends IProperty {
  67443. /**
  67444. * The floating-point aspect ratio of the field of view
  67445. */
  67446. aspectRatio?: number;
  67447. /**
  67448. * The floating-point vertical field of view in radians
  67449. */
  67450. yfov: number;
  67451. /**
  67452. * The floating-point distance to the far clipping plane
  67453. */
  67454. zfar?: number;
  67455. /**
  67456. * The floating-point distance to the near clipping plane
  67457. */
  67458. znear: number;
  67459. }
  67460. /**
  67461. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67462. */
  67463. interface ICamera extends IChildRootProperty {
  67464. /**
  67465. * An orthographic camera containing properties to create an orthographic projection matrix
  67466. */
  67467. orthographic?: ICameraOrthographic;
  67468. /**
  67469. * A perspective camera containing properties to create a perspective projection matrix
  67470. */
  67471. perspective?: ICameraPerspective;
  67472. /**
  67473. * Specifies if the camera uses a perspective or orthographic projection
  67474. */
  67475. type: CameraType;
  67476. }
  67477. /**
  67478. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  67479. */
  67480. interface IImage extends IChildRootProperty {
  67481. /**
  67482. * 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
  67483. */
  67484. uri?: string;
  67485. /**
  67486. * The image's MIME type
  67487. */
  67488. mimeType?: ImageMimeType;
  67489. /**
  67490. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  67491. */
  67492. bufferView?: number;
  67493. }
  67494. /**
  67495. * Material Normal Texture Info
  67496. */
  67497. interface IMaterialNormalTextureInfo extends ITextureInfo {
  67498. /**
  67499. * The scalar multiplier applied to each normal vector of the normal texture
  67500. */
  67501. scale?: number;
  67502. }
  67503. /**
  67504. * Material Occlusion Texture Info
  67505. */
  67506. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  67507. /**
  67508. * A scalar multiplier controlling the amount of occlusion applied
  67509. */
  67510. strength?: number;
  67511. }
  67512. /**
  67513. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  67514. */
  67515. interface IMaterialPbrMetallicRoughness {
  67516. /**
  67517. * The material's base color factor
  67518. */
  67519. baseColorFactor?: number[];
  67520. /**
  67521. * The base color texture
  67522. */
  67523. baseColorTexture?: ITextureInfo;
  67524. /**
  67525. * The metalness of the material
  67526. */
  67527. metallicFactor?: number;
  67528. /**
  67529. * The roughness of the material
  67530. */
  67531. roughnessFactor?: number;
  67532. /**
  67533. * The metallic-roughness texture
  67534. */
  67535. metallicRoughnessTexture?: ITextureInfo;
  67536. }
  67537. /**
  67538. * The material appearance of a primitive
  67539. */
  67540. interface IMaterial extends IChildRootProperty {
  67541. /**
  67542. * 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
  67543. */
  67544. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67545. /**
  67546. * The normal map texture
  67547. */
  67548. normalTexture?: IMaterialNormalTextureInfo;
  67549. /**
  67550. * The occlusion map texture
  67551. */
  67552. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67553. /**
  67554. * The emissive map texture
  67555. */
  67556. emissiveTexture?: ITextureInfo;
  67557. /**
  67558. * 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
  67559. */
  67560. emissiveFactor?: number[];
  67561. /**
  67562. * The alpha rendering mode of the material
  67563. */
  67564. alphaMode?: MaterialAlphaMode;
  67565. /**
  67566. * The alpha cutoff value of the material
  67567. */
  67568. alphaCutoff?: number;
  67569. /**
  67570. * Specifies whether the material is double sided
  67571. */
  67572. doubleSided?: boolean;
  67573. }
  67574. /**
  67575. * Geometry to be rendered with the given material
  67576. */
  67577. interface IMeshPrimitive extends IProperty {
  67578. /**
  67579. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  67580. */
  67581. attributes: {
  67582. [name: string]: number;
  67583. };
  67584. /**
  67585. * The index of the accessor that contains the indices
  67586. */
  67587. indices?: number;
  67588. /**
  67589. * The index of the material to apply to this primitive when rendering
  67590. */
  67591. material?: number;
  67592. /**
  67593. * The type of primitives to render. All valid values correspond to WebGL enums
  67594. */
  67595. mode?: MeshPrimitiveMode;
  67596. /**
  67597. * 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
  67598. */
  67599. targets?: {
  67600. [name: string]: number;
  67601. }[];
  67602. }
  67603. /**
  67604. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  67605. */
  67606. interface IMesh extends IChildRootProperty {
  67607. /**
  67608. * An array of primitives, each defining geometry to be rendered with a material
  67609. */
  67610. primitives: IMeshPrimitive[];
  67611. /**
  67612. * Array of weights to be applied to the Morph Targets
  67613. */
  67614. weights?: number[];
  67615. }
  67616. /**
  67617. * A node in the node hierarchy
  67618. */
  67619. interface INode extends IChildRootProperty {
  67620. /**
  67621. * The index of the camera referenced by this node
  67622. */
  67623. camera?: number;
  67624. /**
  67625. * The indices of this node's children
  67626. */
  67627. children?: number[];
  67628. /**
  67629. * The index of the skin referenced by this node
  67630. */
  67631. skin?: number;
  67632. /**
  67633. * A floating-point 4x4 transformation matrix stored in column-major order
  67634. */
  67635. matrix?: number[];
  67636. /**
  67637. * The index of the mesh in this node
  67638. */
  67639. mesh?: number;
  67640. /**
  67641. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  67642. */
  67643. rotation?: number[];
  67644. /**
  67645. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  67646. */
  67647. scale?: number[];
  67648. /**
  67649. * The node's translation along the x, y, and z axes
  67650. */
  67651. translation?: number[];
  67652. /**
  67653. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  67654. */
  67655. weights?: number[];
  67656. }
  67657. /**
  67658. * Texture sampler properties for filtering and wrapping modes
  67659. */
  67660. interface ISampler extends IChildRootProperty {
  67661. /**
  67662. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67663. */
  67664. magFilter?: TextureMagFilter;
  67665. /**
  67666. * Minification filter. All valid values correspond to WebGL enums
  67667. */
  67668. minFilter?: TextureMinFilter;
  67669. /**
  67670. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67671. */
  67672. wrapS?: TextureWrapMode;
  67673. /**
  67674. * T (V) wrapping mode. All valid values correspond to WebGL enums
  67675. */
  67676. wrapT?: TextureWrapMode;
  67677. }
  67678. /**
  67679. * The root nodes of a scene
  67680. */
  67681. interface IScene extends IChildRootProperty {
  67682. /**
  67683. * The indices of each root node
  67684. */
  67685. nodes: number[];
  67686. }
  67687. /**
  67688. * Joints and matrices defining a skin
  67689. */
  67690. interface ISkin extends IChildRootProperty {
  67691. /**
  67692. * 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
  67693. */
  67694. inverseBindMatrices?: number;
  67695. /**
  67696. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  67697. */
  67698. skeleton?: number;
  67699. /**
  67700. * 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)
  67701. */
  67702. joints: number[];
  67703. }
  67704. /**
  67705. * A texture and its sampler
  67706. */
  67707. interface ITexture extends IChildRootProperty {
  67708. /**
  67709. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  67710. */
  67711. sampler?: number;
  67712. /**
  67713. * The index of the image used by this texture
  67714. */
  67715. source: number;
  67716. }
  67717. /**
  67718. * Reference to a texture
  67719. */
  67720. interface ITextureInfo extends IProperty {
  67721. /**
  67722. * The index of the texture
  67723. */
  67724. index: number;
  67725. /**
  67726. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  67727. */
  67728. texCoord?: number;
  67729. }
  67730. /**
  67731. * The root object for a glTF asset
  67732. */
  67733. interface IGLTF extends IProperty {
  67734. /**
  67735. * An array of accessors. An accessor is a typed view into a bufferView
  67736. */
  67737. accessors?: IAccessor[];
  67738. /**
  67739. * An array of keyframe animations
  67740. */
  67741. animations?: IAnimation[];
  67742. /**
  67743. * Metadata about the glTF asset
  67744. */
  67745. asset: IAsset;
  67746. /**
  67747. * An array of buffers. A buffer points to binary geometry, animation, or skins
  67748. */
  67749. buffers?: IBuffer[];
  67750. /**
  67751. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  67752. */
  67753. bufferViews?: IBufferView[];
  67754. /**
  67755. * An array of cameras
  67756. */
  67757. cameras?: ICamera[];
  67758. /**
  67759. * Names of glTF extensions used somewhere in this asset
  67760. */
  67761. extensionsUsed?: string[];
  67762. /**
  67763. * Names of glTF extensions required to properly load this asset
  67764. */
  67765. extensionsRequired?: string[];
  67766. /**
  67767. * An array of images. An image defines data used to create a texture
  67768. */
  67769. images?: IImage[];
  67770. /**
  67771. * An array of materials. A material defines the appearance of a primitive
  67772. */
  67773. materials?: IMaterial[];
  67774. /**
  67775. * An array of meshes. A mesh is a set of primitives to be rendered
  67776. */
  67777. meshes?: IMesh[];
  67778. /**
  67779. * An array of nodes
  67780. */
  67781. nodes?: INode[];
  67782. /**
  67783. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  67784. */
  67785. samplers?: ISampler[];
  67786. /**
  67787. * The index of the default scene
  67788. */
  67789. scene?: number;
  67790. /**
  67791. * An array of scenes
  67792. */
  67793. scenes?: IScene[];
  67794. /**
  67795. * An array of skins. A skin is defined by joints and matrices
  67796. */
  67797. skins?: ISkin[];
  67798. /**
  67799. * An array of textures
  67800. */
  67801. textures?: ITexture[];
  67802. }
  67803. /**
  67804. * The glTF validation results
  67805. */
  67806. interface IGLTFValidationResults {
  67807. info: {
  67808. generator: string;
  67809. hasAnimations: boolean;
  67810. hasDefaultScene: boolean;
  67811. hasMaterials: boolean;
  67812. hasMorphTargets: boolean;
  67813. hasSkins: boolean;
  67814. hasTextures: boolean;
  67815. maxAttributesUsed: number;
  67816. primitivesCount: number
  67817. };
  67818. issues: {
  67819. messages: Array<string>;
  67820. numErrors: number;
  67821. numHints: number;
  67822. numInfos: number;
  67823. numWarnings: number;
  67824. truncated: boolean
  67825. };
  67826. mimeType: string;
  67827. uri: string;
  67828. validatedAt: string;
  67829. validatorVersion: string;
  67830. }
  67831. /**
  67832. * The glTF validation options
  67833. */
  67834. interface IGLTFValidationOptions {
  67835. uri?: string;
  67836. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  67837. validateAccessorData?: boolean;
  67838. maxIssues?: number;
  67839. ignoredIssues?: Array<string>;
  67840. severityOverrides?: Object;
  67841. }
  67842. /**
  67843. * The glTF validator object
  67844. */
  67845. interface IGLTFValidator {
  67846. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67847. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67848. }
  67849. }
  67850. declare module BABYLON {
  67851. /** @hidden */
  67852. export var cellPixelShader: {
  67853. name: string;
  67854. shader: string;
  67855. };
  67856. }
  67857. declare module BABYLON {
  67858. /** @hidden */
  67859. export var cellVertexShader: {
  67860. name: string;
  67861. shader: string;
  67862. };
  67863. }
  67864. declare module BABYLON {
  67865. export class CellMaterial extends BABYLON.PushMaterial {
  67866. private _diffuseTexture;
  67867. diffuseTexture: BABYLON.BaseTexture;
  67868. diffuseColor: BABYLON.Color3;
  67869. _computeHighLevel: boolean;
  67870. computeHighLevel: boolean;
  67871. private _disableLighting;
  67872. disableLighting: boolean;
  67873. private _maxSimultaneousLights;
  67874. maxSimultaneousLights: number;
  67875. private _renderId;
  67876. constructor(name: string, scene: BABYLON.Scene);
  67877. needAlphaBlending(): boolean;
  67878. needAlphaTesting(): boolean;
  67879. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67880. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67881. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67882. getAnimatables(): BABYLON.IAnimatable[];
  67883. getActiveTextures(): BABYLON.BaseTexture[];
  67884. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67885. dispose(forceDisposeEffect?: boolean): void;
  67886. getClassName(): string;
  67887. clone(name: string): CellMaterial;
  67888. serialize(): any;
  67889. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  67890. }
  67891. }
  67892. declare module BABYLON {
  67893. export class CustomShaderStructure {
  67894. FragmentStore: string;
  67895. VertexStore: string;
  67896. constructor();
  67897. }
  67898. export class ShaderSpecialParts {
  67899. constructor();
  67900. Fragment_Begin: string;
  67901. Fragment_Definitions: string;
  67902. Fragment_MainBegin: string;
  67903. Fragment_Custom_Diffuse: string;
  67904. Fragment_Before_Lights: string;
  67905. Fragment_Before_Fog: string;
  67906. Fragment_Custom_Alpha: string;
  67907. Fragment_Before_FragColor: string;
  67908. Vertex_Begin: string;
  67909. Vertex_Definitions: string;
  67910. Vertex_MainBegin: string;
  67911. Vertex_Before_PositionUpdated: string;
  67912. Vertex_Before_NormalUpdated: string;
  67913. Vertex_MainEnd: string;
  67914. }
  67915. export class CustomMaterial extends BABYLON.StandardMaterial {
  67916. static ShaderIndexer: number;
  67917. CustomParts: ShaderSpecialParts;
  67918. _isCreatedShader: boolean;
  67919. _createdShaderName: string;
  67920. _customUniform: string[];
  67921. _newUniforms: string[];
  67922. _newUniformInstances: any[];
  67923. _newSamplerInstances: BABYLON.Texture[];
  67924. FragmentShader: string;
  67925. VertexShader: string;
  67926. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67927. ReviewUniform(name: string, arr: string[]): string[];
  67928. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  67929. constructor(name: string, scene: BABYLON.Scene);
  67930. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  67931. Fragment_Begin(shaderPart: string): CustomMaterial;
  67932. Fragment_Definitions(shaderPart: string): CustomMaterial;
  67933. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  67934. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  67935. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  67936. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  67937. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  67938. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  67939. Vertex_Begin(shaderPart: string): CustomMaterial;
  67940. Vertex_Definitions(shaderPart: string): CustomMaterial;
  67941. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  67942. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  67943. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  67944. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  67945. }
  67946. }
  67947. declare module BABYLON {
  67948. export class ShaderAlebdoParts {
  67949. constructor();
  67950. Fragment_Begin: string;
  67951. Fragment_Definitions: string;
  67952. Fragment_MainBegin: string;
  67953. Fragment_Custom_Albedo: string;
  67954. Fragment_Before_Lights: string;
  67955. Fragment_Custom_MetallicRoughness: string;
  67956. Fragment_Custom_MicroSurface: string;
  67957. Fragment_Before_Fog: string;
  67958. Fragment_Custom_Alpha: string;
  67959. Fragment_Before_FragColor: string;
  67960. Vertex_Begin: string;
  67961. Vertex_Definitions: string;
  67962. Vertex_MainBegin: string;
  67963. Vertex_Before_PositionUpdated: string;
  67964. Vertex_Before_NormalUpdated: string;
  67965. Vertex_MainEnd: string;
  67966. }
  67967. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  67968. static ShaderIndexer: number;
  67969. CustomParts: ShaderAlebdoParts;
  67970. _isCreatedShader: boolean;
  67971. _createdShaderName: string;
  67972. _customUniform: string[];
  67973. _newUniforms: string[];
  67974. _newUniformInstances: any[];
  67975. _newSamplerInstances: BABYLON.Texture[];
  67976. FragmentShader: string;
  67977. VertexShader: string;
  67978. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67979. ReviewUniform(name: string, arr: string[]): string[];
  67980. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  67981. constructor(name: string, scene: BABYLON.Scene);
  67982. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  67983. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  67984. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  67985. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  67986. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  67987. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  67988. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  67989. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  67990. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  67991. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  67992. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  67993. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  67994. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  67995. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  67996. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  67997. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  67998. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  67999. }
  68000. }
  68001. declare module BABYLON {
  68002. /** @hidden */
  68003. export var firePixelShader: {
  68004. name: string;
  68005. shader: string;
  68006. };
  68007. }
  68008. declare module BABYLON {
  68009. /** @hidden */
  68010. export var fireVertexShader: {
  68011. name: string;
  68012. shader: string;
  68013. };
  68014. }
  68015. declare module BABYLON {
  68016. export class FireMaterial extends BABYLON.PushMaterial {
  68017. private _diffuseTexture;
  68018. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68019. private _distortionTexture;
  68020. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68021. private _opacityTexture;
  68022. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68023. diffuseColor: BABYLON.Color3;
  68024. speed: number;
  68025. private _scaledDiffuse;
  68026. private _renderId;
  68027. private _lastTime;
  68028. constructor(name: string, scene: BABYLON.Scene);
  68029. needAlphaBlending(): boolean;
  68030. needAlphaTesting(): boolean;
  68031. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68032. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68033. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68034. getAnimatables(): BABYLON.IAnimatable[];
  68035. getActiveTextures(): BABYLON.BaseTexture[];
  68036. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68037. getClassName(): string;
  68038. dispose(forceDisposeEffect?: boolean): void;
  68039. clone(name: string): FireMaterial;
  68040. serialize(): any;
  68041. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  68042. }
  68043. }
  68044. declare module BABYLON {
  68045. /** @hidden */
  68046. export var furPixelShader: {
  68047. name: string;
  68048. shader: string;
  68049. };
  68050. }
  68051. declare module BABYLON {
  68052. /** @hidden */
  68053. export var furVertexShader: {
  68054. name: string;
  68055. shader: string;
  68056. };
  68057. }
  68058. declare module BABYLON {
  68059. export class FurMaterial extends BABYLON.PushMaterial {
  68060. private _diffuseTexture;
  68061. diffuseTexture: BABYLON.BaseTexture;
  68062. private _heightTexture;
  68063. heightTexture: BABYLON.BaseTexture;
  68064. diffuseColor: BABYLON.Color3;
  68065. furLength: number;
  68066. furAngle: number;
  68067. furColor: BABYLON.Color3;
  68068. furOffset: number;
  68069. furSpacing: number;
  68070. furGravity: BABYLON.Vector3;
  68071. furSpeed: number;
  68072. furDensity: number;
  68073. furOcclusion: number;
  68074. furTexture: BABYLON.DynamicTexture;
  68075. private _disableLighting;
  68076. disableLighting: boolean;
  68077. private _maxSimultaneousLights;
  68078. maxSimultaneousLights: number;
  68079. highLevelFur: boolean;
  68080. _meshes: BABYLON.AbstractMesh[];
  68081. private _renderId;
  68082. private _furTime;
  68083. constructor(name: string, scene: BABYLON.Scene);
  68084. furTime: number;
  68085. needAlphaBlending(): boolean;
  68086. needAlphaTesting(): boolean;
  68087. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68088. updateFur(): void;
  68089. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68090. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68091. getAnimatables(): BABYLON.IAnimatable[];
  68092. getActiveTextures(): BABYLON.BaseTexture[];
  68093. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68094. dispose(forceDisposeEffect?: boolean): void;
  68095. clone(name: string): FurMaterial;
  68096. serialize(): any;
  68097. getClassName(): string;
  68098. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  68099. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  68100. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  68101. }
  68102. }
  68103. declare module BABYLON {
  68104. /** @hidden */
  68105. export var gradientPixelShader: {
  68106. name: string;
  68107. shader: string;
  68108. };
  68109. }
  68110. declare module BABYLON {
  68111. /** @hidden */
  68112. export var gradientVertexShader: {
  68113. name: string;
  68114. shader: string;
  68115. };
  68116. }
  68117. declare module BABYLON {
  68118. export class GradientMaterial extends BABYLON.PushMaterial {
  68119. private _maxSimultaneousLights;
  68120. maxSimultaneousLights: number;
  68121. topColor: BABYLON.Color3;
  68122. topColorAlpha: number;
  68123. bottomColor: BABYLON.Color3;
  68124. bottomColorAlpha: number;
  68125. offset: number;
  68126. scale: number;
  68127. smoothness: number;
  68128. private _disableLighting;
  68129. disableLighting: boolean;
  68130. private _renderId;
  68131. constructor(name: string, scene: BABYLON.Scene);
  68132. needAlphaBlending(): boolean;
  68133. needAlphaTesting(): boolean;
  68134. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68135. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68136. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68137. getAnimatables(): BABYLON.IAnimatable[];
  68138. dispose(forceDisposeEffect?: boolean): void;
  68139. clone(name: string): GradientMaterial;
  68140. serialize(): any;
  68141. getClassName(): string;
  68142. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  68143. }
  68144. }
  68145. declare module BABYLON {
  68146. /** @hidden */
  68147. export var gridPixelShader: {
  68148. name: string;
  68149. shader: string;
  68150. };
  68151. }
  68152. declare module BABYLON {
  68153. /** @hidden */
  68154. export var gridVertexShader: {
  68155. name: string;
  68156. shader: string;
  68157. };
  68158. }
  68159. declare module BABYLON {
  68160. /**
  68161. * The grid materials allows you to wrap any shape with a grid.
  68162. * Colors are customizable.
  68163. */
  68164. export class GridMaterial extends BABYLON.PushMaterial {
  68165. /**
  68166. * Main color of the grid (e.g. between lines)
  68167. */
  68168. mainColor: BABYLON.Color3;
  68169. /**
  68170. * Color of the grid lines.
  68171. */
  68172. lineColor: BABYLON.Color3;
  68173. /**
  68174. * The scale of the grid compared to unit.
  68175. */
  68176. gridRatio: number;
  68177. /**
  68178. * Allows setting an offset for the grid lines.
  68179. */
  68180. gridOffset: BABYLON.Vector3;
  68181. /**
  68182. * The frequency of thicker lines.
  68183. */
  68184. majorUnitFrequency: number;
  68185. /**
  68186. * The visibility of minor units in the grid.
  68187. */
  68188. minorUnitVisibility: number;
  68189. /**
  68190. * The grid opacity outside of the lines.
  68191. */
  68192. opacity: number;
  68193. /**
  68194. * Determine RBG output is premultiplied by alpha value.
  68195. */
  68196. preMultiplyAlpha: boolean;
  68197. private _opacityTexture;
  68198. opacityTexture: BABYLON.BaseTexture;
  68199. private _gridControl;
  68200. private _renderId;
  68201. /**
  68202. * constructor
  68203. * @param name The name given to the material in order to identify it afterwards.
  68204. * @param scene The scene the material is used in.
  68205. */
  68206. constructor(name: string, scene: BABYLON.Scene);
  68207. /**
  68208. * Returns wehter or not the grid requires alpha blending.
  68209. */
  68210. needAlphaBlending(): boolean;
  68211. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68212. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68213. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68214. /**
  68215. * Dispose the material and its associated resources.
  68216. * @param forceDisposeEffect will also dispose the used effect when true
  68217. */
  68218. dispose(forceDisposeEffect?: boolean): void;
  68219. clone(name: string): GridMaterial;
  68220. serialize(): any;
  68221. getClassName(): string;
  68222. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  68223. }
  68224. }
  68225. declare module BABYLON {
  68226. /** @hidden */
  68227. export var lavaPixelShader: {
  68228. name: string;
  68229. shader: string;
  68230. };
  68231. }
  68232. declare module BABYLON {
  68233. /** @hidden */
  68234. export var lavaVertexShader: {
  68235. name: string;
  68236. shader: string;
  68237. };
  68238. }
  68239. declare module BABYLON {
  68240. export class LavaMaterial extends BABYLON.PushMaterial {
  68241. private _diffuseTexture;
  68242. diffuseTexture: BABYLON.BaseTexture;
  68243. noiseTexture: BABYLON.BaseTexture;
  68244. fogColor: BABYLON.Color3;
  68245. speed: number;
  68246. movingSpeed: number;
  68247. lowFrequencySpeed: number;
  68248. fogDensity: number;
  68249. private _lastTime;
  68250. diffuseColor: BABYLON.Color3;
  68251. private _disableLighting;
  68252. disableLighting: boolean;
  68253. private _unlit;
  68254. unlit: boolean;
  68255. private _maxSimultaneousLights;
  68256. maxSimultaneousLights: number;
  68257. private _scaledDiffuse;
  68258. private _renderId;
  68259. constructor(name: string, scene: BABYLON.Scene);
  68260. needAlphaBlending(): boolean;
  68261. needAlphaTesting(): boolean;
  68262. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68263. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68264. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68265. getAnimatables(): BABYLON.IAnimatable[];
  68266. getActiveTextures(): BABYLON.BaseTexture[];
  68267. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68268. dispose(forceDisposeEffect?: boolean): void;
  68269. clone(name: string): LavaMaterial;
  68270. serialize(): any;
  68271. getClassName(): string;
  68272. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  68273. }
  68274. }
  68275. declare module BABYLON {
  68276. /** @hidden */
  68277. export var mixPixelShader: {
  68278. name: string;
  68279. shader: string;
  68280. };
  68281. }
  68282. declare module BABYLON {
  68283. /** @hidden */
  68284. export var mixVertexShader: {
  68285. name: string;
  68286. shader: string;
  68287. };
  68288. }
  68289. declare module BABYLON {
  68290. export class MixMaterial extends BABYLON.PushMaterial {
  68291. /**
  68292. * Mix textures
  68293. */
  68294. private _mixTexture1;
  68295. mixTexture1: BABYLON.BaseTexture;
  68296. private _mixTexture2;
  68297. mixTexture2: BABYLON.BaseTexture;
  68298. /**
  68299. * Diffuse textures
  68300. */
  68301. private _diffuseTexture1;
  68302. diffuseTexture1: BABYLON.Texture;
  68303. private _diffuseTexture2;
  68304. diffuseTexture2: BABYLON.Texture;
  68305. private _diffuseTexture3;
  68306. diffuseTexture3: BABYLON.Texture;
  68307. private _diffuseTexture4;
  68308. diffuseTexture4: BABYLON.Texture;
  68309. private _diffuseTexture5;
  68310. diffuseTexture5: BABYLON.Texture;
  68311. private _diffuseTexture6;
  68312. diffuseTexture6: BABYLON.Texture;
  68313. private _diffuseTexture7;
  68314. diffuseTexture7: BABYLON.Texture;
  68315. private _diffuseTexture8;
  68316. diffuseTexture8: BABYLON.Texture;
  68317. /**
  68318. * Uniforms
  68319. */
  68320. diffuseColor: BABYLON.Color3;
  68321. specularColor: BABYLON.Color3;
  68322. specularPower: number;
  68323. private _disableLighting;
  68324. disableLighting: boolean;
  68325. private _maxSimultaneousLights;
  68326. maxSimultaneousLights: number;
  68327. private _renderId;
  68328. constructor(name: string, scene: BABYLON.Scene);
  68329. needAlphaBlending(): boolean;
  68330. needAlphaTesting(): boolean;
  68331. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68332. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68333. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68334. getAnimatables(): BABYLON.IAnimatable[];
  68335. getActiveTextures(): BABYLON.BaseTexture[];
  68336. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68337. dispose(forceDisposeEffect?: boolean): void;
  68338. clone(name: string): MixMaterial;
  68339. serialize(): any;
  68340. getClassName(): string;
  68341. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  68342. }
  68343. }
  68344. declare module BABYLON {
  68345. /** @hidden */
  68346. export var normalPixelShader: {
  68347. name: string;
  68348. shader: string;
  68349. };
  68350. }
  68351. declare module BABYLON {
  68352. /** @hidden */
  68353. export var normalVertexShader: {
  68354. name: string;
  68355. shader: string;
  68356. };
  68357. }
  68358. declare module BABYLON {
  68359. export class NormalMaterial extends BABYLON.PushMaterial {
  68360. private _diffuseTexture;
  68361. diffuseTexture: BABYLON.BaseTexture;
  68362. diffuseColor: BABYLON.Color3;
  68363. private _disableLighting;
  68364. disableLighting: boolean;
  68365. private _maxSimultaneousLights;
  68366. maxSimultaneousLights: number;
  68367. private _renderId;
  68368. constructor(name: string, scene: BABYLON.Scene);
  68369. needAlphaBlending(): boolean;
  68370. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68371. needAlphaTesting(): boolean;
  68372. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68373. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68374. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68375. getAnimatables(): BABYLON.IAnimatable[];
  68376. getActiveTextures(): BABYLON.BaseTexture[];
  68377. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68378. dispose(forceDisposeEffect?: boolean): void;
  68379. clone(name: string): NormalMaterial;
  68380. serialize(): any;
  68381. getClassName(): string;
  68382. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  68383. }
  68384. }
  68385. declare module BABYLON {
  68386. /** @hidden */
  68387. export var shadowOnlyPixelShader: {
  68388. name: string;
  68389. shader: string;
  68390. };
  68391. }
  68392. declare module BABYLON {
  68393. /** @hidden */
  68394. export var shadowOnlyVertexShader: {
  68395. name: string;
  68396. shader: string;
  68397. };
  68398. }
  68399. declare module BABYLON {
  68400. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  68401. private _renderId;
  68402. private _activeLight;
  68403. constructor(name: string, scene: BABYLON.Scene);
  68404. shadowColor: BABYLON.Color3;
  68405. needAlphaBlending(): boolean;
  68406. needAlphaTesting(): boolean;
  68407. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68408. activeLight: BABYLON.IShadowLight;
  68409. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68410. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68411. clone(name: string): ShadowOnlyMaterial;
  68412. serialize(): any;
  68413. getClassName(): string;
  68414. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  68415. }
  68416. }
  68417. declare module BABYLON {
  68418. /** @hidden */
  68419. export var simplePixelShader: {
  68420. name: string;
  68421. shader: string;
  68422. };
  68423. }
  68424. declare module BABYLON {
  68425. /** @hidden */
  68426. export var simpleVertexShader: {
  68427. name: string;
  68428. shader: string;
  68429. };
  68430. }
  68431. declare module BABYLON {
  68432. export class SimpleMaterial extends BABYLON.PushMaterial {
  68433. private _diffuseTexture;
  68434. diffuseTexture: BABYLON.BaseTexture;
  68435. diffuseColor: BABYLON.Color3;
  68436. private _disableLighting;
  68437. disableLighting: boolean;
  68438. private _maxSimultaneousLights;
  68439. maxSimultaneousLights: number;
  68440. private _renderId;
  68441. constructor(name: string, scene: BABYLON.Scene);
  68442. needAlphaBlending(): boolean;
  68443. needAlphaTesting(): boolean;
  68444. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68445. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68446. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68447. getAnimatables(): BABYLON.IAnimatable[];
  68448. getActiveTextures(): BABYLON.BaseTexture[];
  68449. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68450. dispose(forceDisposeEffect?: boolean): void;
  68451. clone(name: string): SimpleMaterial;
  68452. serialize(): any;
  68453. getClassName(): string;
  68454. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  68455. }
  68456. }
  68457. declare module BABYLON {
  68458. /** @hidden */
  68459. export var skyPixelShader: {
  68460. name: string;
  68461. shader: string;
  68462. };
  68463. }
  68464. declare module BABYLON {
  68465. /** @hidden */
  68466. export var skyVertexShader: {
  68467. name: string;
  68468. shader: string;
  68469. };
  68470. }
  68471. declare module BABYLON {
  68472. /**
  68473. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  68474. * @see https://doc.babylonjs.com/extensions/sky
  68475. */
  68476. export class SkyMaterial extends BABYLON.PushMaterial {
  68477. /**
  68478. * Defines the overall luminance of sky in interval ]0, 1[.
  68479. */
  68480. luminance: number;
  68481. /**
  68482. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  68483. */
  68484. turbidity: number;
  68485. /**
  68486. * Defines the sky appearance (light intensity).
  68487. */
  68488. rayleigh: number;
  68489. /**
  68490. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  68491. */
  68492. mieCoefficient: number;
  68493. /**
  68494. * Defines the amount of haze particles following the Mie scattering theory.
  68495. */
  68496. mieDirectionalG: number;
  68497. /**
  68498. * Defines the distance of the sun according to the active scene camera.
  68499. */
  68500. distance: number;
  68501. /**
  68502. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  68503. * "inclined".
  68504. */
  68505. inclination: number;
  68506. /**
  68507. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  68508. * an object direction and a reference direction.
  68509. */
  68510. azimuth: number;
  68511. /**
  68512. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  68513. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  68514. */
  68515. sunPosition: BABYLON.Vector3;
  68516. /**
  68517. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  68518. * .sunPosition property.
  68519. */
  68520. useSunPosition: boolean;
  68521. /**
  68522. * Defines an offset vector used to get a horizon offset.
  68523. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  68524. */
  68525. cameraOffset: BABYLON.Vector3;
  68526. private _cameraPosition;
  68527. private _renderId;
  68528. /**
  68529. * Instantiates a new sky material.
  68530. * This material allows to create dynamic and texture free
  68531. * effects for skyboxes by taking care of the atmosphere state.
  68532. * @see https://doc.babylonjs.com/extensions/sky
  68533. * @param name Define the name of the material in the scene
  68534. * @param scene Define the scene the material belong to
  68535. */
  68536. constructor(name: string, scene: BABYLON.Scene);
  68537. /**
  68538. * Specifies if the material will require alpha blending
  68539. * @returns a boolean specifying if alpha blending is needed
  68540. */
  68541. needAlphaBlending(): boolean;
  68542. /**
  68543. * Specifies if this material should be rendered in alpha test mode
  68544. * @returns false as the sky material doesn't need alpha testing.
  68545. */
  68546. needAlphaTesting(): boolean;
  68547. /**
  68548. * Get the texture used for alpha test purpose.
  68549. * @returns null as the sky material has no texture.
  68550. */
  68551. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68552. /**
  68553. * Get if the submesh is ready to be used and all its information available.
  68554. * Child classes can use it to update shaders
  68555. * @param mesh defines the mesh to check
  68556. * @param subMesh defines which submesh to check
  68557. * @param useInstances specifies that instances should be used
  68558. * @returns a boolean indicating that the submesh is ready or not
  68559. */
  68560. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68561. /**
  68562. * Binds the submesh to this material by preparing the effect and shader to draw
  68563. * @param world defines the world transformation matrix
  68564. * @param mesh defines the mesh containing the submesh
  68565. * @param subMesh defines the submesh to bind the material to
  68566. */
  68567. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68568. /**
  68569. * Get the list of animatables in the material.
  68570. * @returns the list of animatables object used in the material
  68571. */
  68572. getAnimatables(): BABYLON.IAnimatable[];
  68573. /**
  68574. * Disposes the material
  68575. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68576. */
  68577. dispose(forceDisposeEffect?: boolean): void;
  68578. /**
  68579. * Makes a duplicate of the material, and gives it a new name
  68580. * @param name defines the new name for the duplicated material
  68581. * @returns the cloned material
  68582. */
  68583. clone(name: string): SkyMaterial;
  68584. /**
  68585. * Serializes this material in a JSON representation
  68586. * @returns the serialized material object
  68587. */
  68588. serialize(): any;
  68589. /**
  68590. * Gets the current class name of the material e.g. "SkyMaterial"
  68591. * Mainly use in serialization.
  68592. * @returns the class name
  68593. */
  68594. getClassName(): string;
  68595. /**
  68596. * Creates a sky material from parsed material data
  68597. * @param source defines the JSON representation of the material
  68598. * @param scene defines the hosting scene
  68599. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68600. * @returns a new sky material
  68601. */
  68602. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  68603. }
  68604. }
  68605. declare module BABYLON {
  68606. /** @hidden */
  68607. export var terrainPixelShader: {
  68608. name: string;
  68609. shader: string;
  68610. };
  68611. }
  68612. declare module BABYLON {
  68613. /** @hidden */
  68614. export var terrainVertexShader: {
  68615. name: string;
  68616. shader: string;
  68617. };
  68618. }
  68619. declare module BABYLON {
  68620. export class TerrainMaterial extends BABYLON.PushMaterial {
  68621. private _mixTexture;
  68622. mixTexture: BABYLON.BaseTexture;
  68623. private _diffuseTexture1;
  68624. diffuseTexture1: BABYLON.Texture;
  68625. private _diffuseTexture2;
  68626. diffuseTexture2: BABYLON.Texture;
  68627. private _diffuseTexture3;
  68628. diffuseTexture3: BABYLON.Texture;
  68629. private _bumpTexture1;
  68630. bumpTexture1: BABYLON.Texture;
  68631. private _bumpTexture2;
  68632. bumpTexture2: BABYLON.Texture;
  68633. private _bumpTexture3;
  68634. bumpTexture3: BABYLON.Texture;
  68635. diffuseColor: BABYLON.Color3;
  68636. specularColor: BABYLON.Color3;
  68637. specularPower: number;
  68638. private _disableLighting;
  68639. disableLighting: boolean;
  68640. private _maxSimultaneousLights;
  68641. maxSimultaneousLights: number;
  68642. private _renderId;
  68643. constructor(name: string, scene: BABYLON.Scene);
  68644. needAlphaBlending(): boolean;
  68645. needAlphaTesting(): boolean;
  68646. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68647. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68648. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68649. getAnimatables(): BABYLON.IAnimatable[];
  68650. getActiveTextures(): BABYLON.BaseTexture[];
  68651. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68652. dispose(forceDisposeEffect?: boolean): void;
  68653. clone(name: string): TerrainMaterial;
  68654. serialize(): any;
  68655. getClassName(): string;
  68656. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  68657. }
  68658. }
  68659. declare module BABYLON {
  68660. /** @hidden */
  68661. export var triplanarPixelShader: {
  68662. name: string;
  68663. shader: string;
  68664. };
  68665. }
  68666. declare module BABYLON {
  68667. /** @hidden */
  68668. export var triplanarVertexShader: {
  68669. name: string;
  68670. shader: string;
  68671. };
  68672. }
  68673. declare module BABYLON {
  68674. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  68675. mixTexture: BABYLON.BaseTexture;
  68676. private _diffuseTextureX;
  68677. diffuseTextureX: BABYLON.BaseTexture;
  68678. private _diffuseTextureY;
  68679. diffuseTextureY: BABYLON.BaseTexture;
  68680. private _diffuseTextureZ;
  68681. diffuseTextureZ: BABYLON.BaseTexture;
  68682. private _normalTextureX;
  68683. normalTextureX: BABYLON.BaseTexture;
  68684. private _normalTextureY;
  68685. normalTextureY: BABYLON.BaseTexture;
  68686. private _normalTextureZ;
  68687. normalTextureZ: BABYLON.BaseTexture;
  68688. tileSize: number;
  68689. diffuseColor: BABYLON.Color3;
  68690. specularColor: BABYLON.Color3;
  68691. specularPower: number;
  68692. private _disableLighting;
  68693. disableLighting: boolean;
  68694. private _maxSimultaneousLights;
  68695. maxSimultaneousLights: number;
  68696. private _renderId;
  68697. constructor(name: string, scene: BABYLON.Scene);
  68698. needAlphaBlending(): boolean;
  68699. needAlphaTesting(): boolean;
  68700. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68701. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68702. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68703. getAnimatables(): BABYLON.IAnimatable[];
  68704. getActiveTextures(): BABYLON.BaseTexture[];
  68705. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68706. dispose(forceDisposeEffect?: boolean): void;
  68707. clone(name: string): TriPlanarMaterial;
  68708. serialize(): any;
  68709. getClassName(): string;
  68710. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  68711. }
  68712. }
  68713. declare module BABYLON {
  68714. /** @hidden */
  68715. export var waterPixelShader: {
  68716. name: string;
  68717. shader: string;
  68718. };
  68719. }
  68720. declare module BABYLON {
  68721. /** @hidden */
  68722. export var waterVertexShader: {
  68723. name: string;
  68724. shader: string;
  68725. };
  68726. }
  68727. declare module BABYLON {
  68728. export class WaterMaterial extends BABYLON.PushMaterial {
  68729. renderTargetSize: BABYLON.Vector2;
  68730. private _bumpTexture;
  68731. bumpTexture: BABYLON.BaseTexture;
  68732. diffuseColor: BABYLON.Color3;
  68733. specularColor: BABYLON.Color3;
  68734. specularPower: number;
  68735. private _disableLighting;
  68736. disableLighting: boolean;
  68737. private _maxSimultaneousLights;
  68738. maxSimultaneousLights: number;
  68739. /**
  68740. * @param {number}: Represents the wind force
  68741. */
  68742. windForce: number;
  68743. /**
  68744. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  68745. */
  68746. windDirection: BABYLON.Vector2;
  68747. /**
  68748. * @param {number}: Wave height, represents the height of the waves
  68749. */
  68750. waveHeight: number;
  68751. /**
  68752. * @param {number}: Bump height, represents the bump height related to the bump map
  68753. */
  68754. bumpHeight: number;
  68755. /**
  68756. * @param {boolean}: Add a smaller moving bump to less steady waves.
  68757. */
  68758. private _bumpSuperimpose;
  68759. bumpSuperimpose: boolean;
  68760. /**
  68761. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  68762. */
  68763. private _fresnelSeparate;
  68764. fresnelSeparate: boolean;
  68765. /**
  68766. * @param {boolean}: bump Waves modify the reflection.
  68767. */
  68768. private _bumpAffectsReflection;
  68769. bumpAffectsReflection: boolean;
  68770. /**
  68771. * @param {number}: The water color blended with the refraction (near)
  68772. */
  68773. waterColor: BABYLON.Color3;
  68774. /**
  68775. * @param {number}: The blend factor related to the water color
  68776. */
  68777. colorBlendFactor: number;
  68778. /**
  68779. * @param {number}: The water color blended with the reflection (far)
  68780. */
  68781. waterColor2: BABYLON.Color3;
  68782. /**
  68783. * @param {number}: The blend factor related to the water color (reflection, far)
  68784. */
  68785. colorBlendFactor2: number;
  68786. /**
  68787. * @param {number}: Represents the maximum length of a wave
  68788. */
  68789. waveLength: number;
  68790. /**
  68791. * @param {number}: Defines the waves speed
  68792. */
  68793. waveSpeed: number;
  68794. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  68795. private _mesh;
  68796. private _refractionRTT;
  68797. private _reflectionRTT;
  68798. private _reflectionTransform;
  68799. private _lastTime;
  68800. private _lastDeltaTime;
  68801. private _renderId;
  68802. private _useLogarithmicDepth;
  68803. private _waitingRenderList;
  68804. /**
  68805. * Gets a boolean indicating that current material needs to register RTT
  68806. */
  68807. readonly hasRenderTargetTextures: boolean;
  68808. /**
  68809. * Constructor
  68810. */
  68811. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  68812. useLogarithmicDepth: boolean;
  68813. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68814. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68815. addToRenderList(node: any): void;
  68816. enableRenderTargets(enable: boolean): void;
  68817. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  68818. readonly renderTargetsEnabled: boolean;
  68819. needAlphaBlending(): boolean;
  68820. needAlphaTesting(): boolean;
  68821. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68822. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68823. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68824. private _createRenderTargets;
  68825. getAnimatables(): BABYLON.IAnimatable[];
  68826. getActiveTextures(): BABYLON.BaseTexture[];
  68827. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68828. dispose(forceDisposeEffect?: boolean): void;
  68829. clone(name: string): WaterMaterial;
  68830. serialize(): any;
  68831. getClassName(): string;
  68832. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  68833. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  68834. }
  68835. }
  68836. declare module BABYLON {
  68837. /** @hidden */
  68838. export var asciiartPixelShader: {
  68839. name: string;
  68840. shader: string;
  68841. };
  68842. }
  68843. declare module BABYLON {
  68844. /**
  68845. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  68846. *
  68847. * It basically takes care rendering the font front the given font size to a texture.
  68848. * This is used later on in the postprocess.
  68849. */
  68850. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  68851. private _font;
  68852. private _text;
  68853. private _charSize;
  68854. /**
  68855. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68856. */
  68857. readonly charSize: number;
  68858. /**
  68859. * Create a new instance of the Ascii Art FontTexture class
  68860. * @param name the name of the texture
  68861. * @param font the font to use, use the W3C CSS notation
  68862. * @param text the caracter set to use in the rendering.
  68863. * @param scene the scene that owns the texture
  68864. */
  68865. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68866. /**
  68867. * Gets the max char width of a font.
  68868. * @param font the font to use, use the W3C CSS notation
  68869. * @return the max char width
  68870. */
  68871. private getFontWidth;
  68872. /**
  68873. * Gets the max char height of a font.
  68874. * @param font the font to use, use the W3C CSS notation
  68875. * @return the max char height
  68876. */
  68877. private getFontHeight;
  68878. /**
  68879. * Clones the current AsciiArtTexture.
  68880. * @return the clone of the texture.
  68881. */
  68882. clone(): AsciiArtFontTexture;
  68883. /**
  68884. * Parses a json object representing the texture and returns an instance of it.
  68885. * @param source the source JSON representation
  68886. * @param scene the scene to create the texture for
  68887. * @return the parsed texture
  68888. */
  68889. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  68890. }
  68891. /**
  68892. * Option available in the Ascii Art Post Process.
  68893. */
  68894. export interface IAsciiArtPostProcessOptions {
  68895. /**
  68896. * The font to use following the w3c font definition.
  68897. */
  68898. font?: string;
  68899. /**
  68900. * The character set to use in the postprocess.
  68901. */
  68902. characterSet?: string;
  68903. /**
  68904. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68905. * This number is defined between 0 and 1;
  68906. */
  68907. mixToTile?: number;
  68908. /**
  68909. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68910. * This number is defined between 0 and 1;
  68911. */
  68912. mixToNormal?: number;
  68913. }
  68914. /**
  68915. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  68916. *
  68917. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68918. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  68919. */
  68920. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  68921. /**
  68922. * The font texture used to render the char in the post process.
  68923. */
  68924. private _asciiArtFontTexture;
  68925. /**
  68926. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68927. * This number is defined between 0 and 1;
  68928. */
  68929. mixToTile: number;
  68930. /**
  68931. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68932. * This number is defined between 0 and 1;
  68933. */
  68934. mixToNormal: number;
  68935. /**
  68936. * Instantiates a new Ascii Art Post Process.
  68937. * @param name the name to give to the postprocess
  68938. * @camera the camera to apply the post process to.
  68939. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  68940. */
  68941. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  68942. }
  68943. }
  68944. declare module BABYLON {
  68945. /** @hidden */
  68946. export var digitalrainPixelShader: {
  68947. name: string;
  68948. shader: string;
  68949. };
  68950. }
  68951. declare module BABYLON {
  68952. /**
  68953. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  68954. *
  68955. * It basically takes care rendering the font front the given font size to a texture.
  68956. * This is used later on in the postprocess.
  68957. */
  68958. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  68959. private _font;
  68960. private _text;
  68961. private _charSize;
  68962. /**
  68963. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68964. */
  68965. readonly charSize: number;
  68966. /**
  68967. * Create a new instance of the Digital Rain FontTexture class
  68968. * @param name the name of the texture
  68969. * @param font the font to use, use the W3C CSS notation
  68970. * @param text the caracter set to use in the rendering.
  68971. * @param scene the scene that owns the texture
  68972. */
  68973. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68974. /**
  68975. * Gets the max char width of a font.
  68976. * @param font the font to use, use the W3C CSS notation
  68977. * @return the max char width
  68978. */
  68979. private getFontWidth;
  68980. /**
  68981. * Gets the max char height of a font.
  68982. * @param font the font to use, use the W3C CSS notation
  68983. * @return the max char height
  68984. */
  68985. private getFontHeight;
  68986. /**
  68987. * Clones the current DigitalRainFontTexture.
  68988. * @return the clone of the texture.
  68989. */
  68990. clone(): DigitalRainFontTexture;
  68991. /**
  68992. * Parses a json object representing the texture and returns an instance of it.
  68993. * @param source the source JSON representation
  68994. * @param scene the scene to create the texture for
  68995. * @return the parsed texture
  68996. */
  68997. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  68998. }
  68999. /**
  69000. * Option available in the Digital Rain Post Process.
  69001. */
  69002. export interface IDigitalRainPostProcessOptions {
  69003. /**
  69004. * The font to use following the w3c font definition.
  69005. */
  69006. font?: string;
  69007. /**
  69008. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69009. * This number is defined between 0 and 1;
  69010. */
  69011. mixToTile?: number;
  69012. /**
  69013. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69014. * This number is defined between 0 and 1;
  69015. */
  69016. mixToNormal?: number;
  69017. }
  69018. /**
  69019. * DigitalRainPostProcess helps rendering everithing in digital rain.
  69020. *
  69021. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69022. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  69023. */
  69024. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  69025. /**
  69026. * The font texture used to render the char in the post process.
  69027. */
  69028. private _digitalRainFontTexture;
  69029. /**
  69030. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69031. * This number is defined between 0 and 1;
  69032. */
  69033. mixToTile: number;
  69034. /**
  69035. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69036. * This number is defined between 0 and 1;
  69037. */
  69038. mixToNormal: number;
  69039. /**
  69040. * Instantiates a new Digital Rain Post Process.
  69041. * @param name the name to give to the postprocess
  69042. * @camera the camera to apply the post process to.
  69043. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  69044. */
  69045. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  69046. }
  69047. }
  69048. declare module BABYLON {
  69049. /** @hidden */
  69050. export var oceanPostProcessPixelShader: {
  69051. name: string;
  69052. shader: string;
  69053. };
  69054. }
  69055. declare module BABYLON {
  69056. /**
  69057. * Option available in the Ocean Post Process.
  69058. */
  69059. export interface IOceanPostProcessOptions {
  69060. /**
  69061. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  69062. */
  69063. reflectionSize?: number | {
  69064. width: number;
  69065. height: number;
  69066. } | {
  69067. ratio: number;
  69068. };
  69069. /**
  69070. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  69071. */
  69072. refractionSize?: number | {
  69073. width: number;
  69074. height: number;
  69075. } | {
  69076. ratio: number;
  69077. };
  69078. }
  69079. /**
  69080. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  69081. *
  69082. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69083. * Example usage:
  69084. * var pp = new OceanPostProcess("myOcean", camera);
  69085. * pp.reflectionEnabled = true;
  69086. * pp.refractionEnabled = true;
  69087. */
  69088. export class OceanPostProcess extends BABYLON.PostProcess {
  69089. /**
  69090. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  69091. */
  69092. /**
  69093. * Sets weither or not the real-time reflection is enabled on the ocean.
  69094. * Is set to true, the reflection mirror texture will be used as reflection texture.
  69095. */
  69096. reflectionEnabled: boolean;
  69097. /**
  69098. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  69099. */
  69100. /**
  69101. * Sets weither or not the real-time refraction is enabled on the ocean.
  69102. * Is set to true, the refraction render target texture will be used as refraction texture.
  69103. */
  69104. refractionEnabled: boolean;
  69105. /**
  69106. * Gets wether or not the post-processes is supported by the running hardware.
  69107. * This requires draw buffer supports.
  69108. */
  69109. readonly isSupported: boolean;
  69110. /**
  69111. * This is the reflection mirror texture used to display reflections on the ocean.
  69112. * By default, render list is empty.
  69113. */
  69114. reflectionTexture: BABYLON.MirrorTexture;
  69115. /**
  69116. * This is the refraction render target texture used to display refraction on the ocean.
  69117. * By default, render list is empty.
  69118. */
  69119. refractionTexture: BABYLON.RenderTargetTexture;
  69120. private _time;
  69121. private _cameraRotation;
  69122. private _cameraViewMatrix;
  69123. private _reflectionEnabled;
  69124. private _refractionEnabled;
  69125. private _geometryRenderer;
  69126. /**
  69127. * Instantiates a new Ocean Post Process.
  69128. * @param name the name to give to the postprocess.
  69129. * @camera the camera to apply the post process to.
  69130. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  69131. */
  69132. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  69133. /**
  69134. * Returns the appropriate defines according to the current configuration.
  69135. */
  69136. private _getDefines;
  69137. /**
  69138. * Computes the current camera rotation as the shader requires a camera rotation.
  69139. */
  69140. private _computeCameraRotation;
  69141. }
  69142. }
  69143. declare module BABYLON {
  69144. /** @hidden */
  69145. export var brickProceduralTexturePixelShader: {
  69146. name: string;
  69147. shader: string;
  69148. };
  69149. }
  69150. declare module BABYLON {
  69151. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  69152. private _numberOfBricksHeight;
  69153. private _numberOfBricksWidth;
  69154. private _jointColor;
  69155. private _brickColor;
  69156. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69157. updateShaderUniforms(): void;
  69158. numberOfBricksHeight: number;
  69159. numberOfBricksWidth: number;
  69160. jointColor: BABYLON.Color3;
  69161. brickColor: BABYLON.Color3;
  69162. /**
  69163. * Serializes this brick procedural texture
  69164. * @returns a serialized brick procedural texture object
  69165. */
  69166. serialize(): any;
  69167. /**
  69168. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  69169. * @param parsedTexture defines parsed texture data
  69170. * @param scene defines the current scene
  69171. * @param rootUrl defines the root URL containing brick procedural texture information
  69172. * @returns a parsed Brick Procedural BABYLON.Texture
  69173. */
  69174. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  69175. }
  69176. }
  69177. declare module BABYLON {
  69178. /** @hidden */
  69179. export var cloudProceduralTexturePixelShader: {
  69180. name: string;
  69181. shader: string;
  69182. };
  69183. }
  69184. declare module BABYLON {
  69185. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  69186. private _skyColor;
  69187. private _cloudColor;
  69188. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69189. updateShaderUniforms(): void;
  69190. skyColor: BABYLON.Color4;
  69191. cloudColor: BABYLON.Color4;
  69192. /**
  69193. * Serializes this cloud procedural texture
  69194. * @returns a serialized cloud procedural texture object
  69195. */
  69196. serialize(): any;
  69197. /**
  69198. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  69199. * @param parsedTexture defines parsed texture data
  69200. * @param scene defines the current scene
  69201. * @param rootUrl defines the root URL containing cloud procedural texture information
  69202. * @returns a parsed Cloud Procedural BABYLON.Texture
  69203. */
  69204. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  69205. }
  69206. }
  69207. declare module BABYLON {
  69208. /** @hidden */
  69209. export var fireProceduralTexturePixelShader: {
  69210. name: string;
  69211. shader: string;
  69212. };
  69213. }
  69214. declare module BABYLON {
  69215. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  69216. private _time;
  69217. private _speed;
  69218. private _autoGenerateTime;
  69219. private _fireColors;
  69220. private _alphaThreshold;
  69221. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69222. updateShaderUniforms(): void;
  69223. render(useCameraPostProcess?: boolean): void;
  69224. static readonly PurpleFireColors: BABYLON.Color3[];
  69225. static readonly GreenFireColors: BABYLON.Color3[];
  69226. static readonly RedFireColors: BABYLON.Color3[];
  69227. static readonly BlueFireColors: BABYLON.Color3[];
  69228. autoGenerateTime: boolean;
  69229. fireColors: BABYLON.Color3[];
  69230. time: number;
  69231. speed: BABYLON.Vector2;
  69232. alphaThreshold: number;
  69233. /**
  69234. * Serializes this fire procedural texture
  69235. * @returns a serialized fire procedural texture object
  69236. */
  69237. serialize(): any;
  69238. /**
  69239. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  69240. * @param parsedTexture defines parsed texture data
  69241. * @param scene defines the current scene
  69242. * @param rootUrl defines the root URL containing fire procedural texture information
  69243. * @returns a parsed Fire Procedural BABYLON.Texture
  69244. */
  69245. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  69246. }
  69247. }
  69248. declare module BABYLON {
  69249. /** @hidden */
  69250. export var grassProceduralTexturePixelShader: {
  69251. name: string;
  69252. shader: string;
  69253. };
  69254. }
  69255. declare module BABYLON {
  69256. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  69257. private _grassColors;
  69258. private _groundColor;
  69259. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69260. updateShaderUniforms(): void;
  69261. grassColors: BABYLON.Color3[];
  69262. groundColor: BABYLON.Color3;
  69263. /**
  69264. * Serializes this grass procedural texture
  69265. * @returns a serialized grass procedural texture object
  69266. */
  69267. serialize(): any;
  69268. /**
  69269. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  69270. * @param parsedTexture defines parsed texture data
  69271. * @param scene defines the current scene
  69272. * @param rootUrl defines the root URL containing grass procedural texture information
  69273. * @returns a parsed Grass Procedural BABYLON.Texture
  69274. */
  69275. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  69276. }
  69277. }
  69278. declare module BABYLON {
  69279. /** @hidden */
  69280. export var marbleProceduralTexturePixelShader: {
  69281. name: string;
  69282. shader: string;
  69283. };
  69284. }
  69285. declare module BABYLON {
  69286. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  69287. private _numberOfTilesHeight;
  69288. private _numberOfTilesWidth;
  69289. private _amplitude;
  69290. private _jointColor;
  69291. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69292. updateShaderUniforms(): void;
  69293. numberOfTilesHeight: number;
  69294. amplitude: number;
  69295. numberOfTilesWidth: number;
  69296. jointColor: BABYLON.Color3;
  69297. /**
  69298. * Serializes this marble procedural texture
  69299. * @returns a serialized marble procedural texture object
  69300. */
  69301. serialize(): any;
  69302. /**
  69303. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  69304. * @param parsedTexture defines parsed texture data
  69305. * @param scene defines the current scene
  69306. * @param rootUrl defines the root URL containing marble procedural texture information
  69307. * @returns a parsed Marble Procedural BABYLON.Texture
  69308. */
  69309. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  69310. }
  69311. }
  69312. declare module BABYLON {
  69313. /** @hidden */
  69314. export var normalMapProceduralTexturePixelShader: {
  69315. name: string;
  69316. shader: string;
  69317. };
  69318. }
  69319. declare module BABYLON {
  69320. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  69321. private _baseTexture;
  69322. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69323. updateShaderUniforms(): void;
  69324. render(useCameraPostProcess?: boolean): void;
  69325. resize(size: any, generateMipMaps: any): void;
  69326. baseTexture: BABYLON.Texture;
  69327. /**
  69328. * Serializes this normal map procedural texture
  69329. * @returns a serialized normal map procedural texture object
  69330. */
  69331. serialize(): any;
  69332. /**
  69333. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  69334. * @param parsedTexture defines parsed texture data
  69335. * @param scene defines the current scene
  69336. * @param rootUrl defines the root URL containing normal map procedural texture information
  69337. * @returns a parsed Normal Map Procedural BABYLON.Texture
  69338. */
  69339. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  69340. }
  69341. }
  69342. declare module BABYLON {
  69343. /** @hidden */
  69344. export var perlinNoiseProceduralTexturePixelShader: {
  69345. name: string;
  69346. shader: string;
  69347. };
  69348. }
  69349. declare module BABYLON {
  69350. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  69351. time: number;
  69352. timeScale: number;
  69353. translationSpeed: number;
  69354. private _currentTranslation;
  69355. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69356. updateShaderUniforms(): void;
  69357. render(useCameraPostProcess?: boolean): void;
  69358. resize(size: any, generateMipMaps: any): void;
  69359. /**
  69360. * Serializes this perlin noise procedural texture
  69361. * @returns a serialized perlin noise procedural texture object
  69362. */
  69363. serialize(): any;
  69364. /**
  69365. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  69366. * @param parsedTexture defines parsed texture data
  69367. * @param scene defines the current scene
  69368. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  69369. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  69370. */
  69371. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  69372. }
  69373. }
  69374. declare module BABYLON {
  69375. /** @hidden */
  69376. export var roadProceduralTexturePixelShader: {
  69377. name: string;
  69378. shader: string;
  69379. };
  69380. }
  69381. declare module BABYLON {
  69382. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  69383. private _roadColor;
  69384. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69385. updateShaderUniforms(): void;
  69386. roadColor: BABYLON.Color3;
  69387. /**
  69388. * Serializes this road procedural texture
  69389. * @returns a serialized road procedural texture object
  69390. */
  69391. serialize(): any;
  69392. /**
  69393. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  69394. * @param parsedTexture defines parsed texture data
  69395. * @param scene defines the current scene
  69396. * @param rootUrl defines the root URL containing road procedural texture information
  69397. * @returns a parsed Road Procedural BABYLON.Texture
  69398. */
  69399. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  69400. }
  69401. }
  69402. declare module BABYLON {
  69403. /** @hidden */
  69404. export var starfieldProceduralTexturePixelShader: {
  69405. name: string;
  69406. shader: string;
  69407. };
  69408. }
  69409. declare module BABYLON {
  69410. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  69411. private _time;
  69412. private _alpha;
  69413. private _beta;
  69414. private _zoom;
  69415. private _formuparam;
  69416. private _stepsize;
  69417. private _tile;
  69418. private _brightness;
  69419. private _darkmatter;
  69420. private _distfading;
  69421. private _saturation;
  69422. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69423. updateShaderUniforms(): void;
  69424. time: number;
  69425. alpha: number;
  69426. beta: number;
  69427. formuparam: number;
  69428. stepsize: number;
  69429. zoom: number;
  69430. tile: number;
  69431. brightness: number;
  69432. darkmatter: number;
  69433. distfading: number;
  69434. saturation: number;
  69435. /**
  69436. * Serializes this starfield procedural texture
  69437. * @returns a serialized starfield procedural texture object
  69438. */
  69439. serialize(): any;
  69440. /**
  69441. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  69442. * @param parsedTexture defines parsed texture data
  69443. * @param scene defines the current scene
  69444. * @param rootUrl defines the root URL containing startfield procedural texture information
  69445. * @returns a parsed Starfield Procedural BABYLON.Texture
  69446. */
  69447. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  69448. }
  69449. }
  69450. declare module BABYLON {
  69451. /** @hidden */
  69452. export var woodProceduralTexturePixelShader: {
  69453. name: string;
  69454. shader: string;
  69455. };
  69456. }
  69457. declare module BABYLON {
  69458. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  69459. private _ampScale;
  69460. private _woodColor;
  69461. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69462. updateShaderUniforms(): void;
  69463. ampScale: number;
  69464. woodColor: BABYLON.Color3;
  69465. /**
  69466. * Serializes this wood procedural texture
  69467. * @returns a serialized wood procedural texture object
  69468. */
  69469. serialize(): any;
  69470. /**
  69471. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  69472. * @param parsedTexture defines parsed texture data
  69473. * @param scene defines the current scene
  69474. * @param rootUrl defines the root URL containing wood procedural texture information
  69475. * @returns a parsed Wood Procedural BABYLON.Texture
  69476. */
  69477. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  69478. }
  69479. }