documentation.d.ts 3.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. /**
  408. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  409. * @param num the number to convert and pad
  410. * @param length the expected length of the string
  411. * @returns the padded string
  412. */
  413. static PadNumber(num: number, length: number): string;
  414. }
  415. }
  416. declare module BABYLON {
  417. /**
  418. * Class containing a set of static utilities functions for deep copy.
  419. */
  420. export class DeepCopier {
  421. /**
  422. * Tries to copy an object by duplicating every property
  423. * @param source defines the source object
  424. * @param destination defines the target object
  425. * @param doNotCopyList defines a list of properties to avoid
  426. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  427. */
  428. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  429. }
  430. }
  431. declare module BABYLON {
  432. /**
  433. * Class containing a set of static utilities functions for precision date
  434. */
  435. export class PrecisionDate {
  436. /**
  437. * Gets either window.performance.now() if supported or Date.now() else
  438. */
  439. static get Now(): number;
  440. }
  441. }
  442. declare module BABYLON {
  443. /** @hidden */
  444. export class _DevTools {
  445. static WarnImport(name: string): string;
  446. }
  447. }
  448. declare module BABYLON {
  449. /**
  450. * Interface used to define the mechanism to get data from the network
  451. */
  452. export interface IWebRequest {
  453. /**
  454. * Returns client's response url
  455. */
  456. responseURL: string;
  457. /**
  458. * Returns client's status
  459. */
  460. status: number;
  461. /**
  462. * Returns client's status as a text
  463. */
  464. statusText: string;
  465. }
  466. }
  467. declare module BABYLON {
  468. /**
  469. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  470. */
  471. export class WebRequest implements IWebRequest {
  472. private _xhr;
  473. /**
  474. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  475. * i.e. when loading files, where the server/service expects an Authorization header
  476. */
  477. static CustomRequestHeaders: {
  478. [key: string]: string;
  479. };
  480. /**
  481. * Add callback functions in this array to update all the requests before they get sent to the network
  482. */
  483. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  484. private _injectCustomRequestHeaders;
  485. /**
  486. * Gets or sets a function to be called when loading progress changes
  487. */
  488. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  489. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  490. /**
  491. * Returns client's state
  492. */
  493. get readyState(): number;
  494. /**
  495. * Returns client's status
  496. */
  497. get status(): number;
  498. /**
  499. * Returns client's status as a text
  500. */
  501. get statusText(): string;
  502. /**
  503. * Returns client's response
  504. */
  505. get response(): any;
  506. /**
  507. * Returns client's response url
  508. */
  509. get responseURL(): string;
  510. /**
  511. * Returns client's response as text
  512. */
  513. get responseText(): string;
  514. /**
  515. * Gets or sets the expected response type
  516. */
  517. get responseType(): XMLHttpRequestResponseType;
  518. set responseType(value: XMLHttpRequestResponseType);
  519. /** @hidden */
  520. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  521. /** @hidden */
  522. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  523. /**
  524. * Cancels any network activity
  525. */
  526. abort(): void;
  527. /**
  528. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  529. * @param body defines an optional request body
  530. */
  531. send(body?: Document | BodyInit | null): void;
  532. /**
  533. * Sets the request method, request URL
  534. * @param method defines the method to use (GET, POST, etc..)
  535. * @param url defines the url to connect with
  536. */
  537. open(method: string, url: string): void;
  538. /**
  539. * Sets the value of a request header.
  540. * @param name The name of the header whose value is to be set
  541. * @param value The value to set as the body of the header
  542. */
  543. setRequestHeader(name: string, value: string): void;
  544. /**
  545. * Get the string containing the text of a particular header's value.
  546. * @param name The name of the header
  547. * @returns The string containing the text of the given header name
  548. */
  549. getResponseHeader(name: string): Nullable<string>;
  550. }
  551. }
  552. declare module BABYLON {
  553. /**
  554. * File request interface
  555. */
  556. export interface IFileRequest {
  557. /**
  558. * Raised when the request is complete (success or error).
  559. */
  560. onCompleteObservable: Observable<IFileRequest>;
  561. /**
  562. * Aborts the request for a file.
  563. */
  564. abort: () => void;
  565. }
  566. }
  567. declare module BABYLON {
  568. /**
  569. * Define options used to create a render target texture
  570. */
  571. export class RenderTargetCreationOptions {
  572. /**
  573. * Specifies is mipmaps must be generated
  574. */
  575. generateMipMaps?: boolean;
  576. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  577. generateDepthBuffer?: boolean;
  578. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  579. generateStencilBuffer?: boolean;
  580. /** Defines texture type (int by default) */
  581. type?: number;
  582. /** Defines sampling mode (trilinear by default) */
  583. samplingMode?: number;
  584. /** Defines format (RGBA by default) */
  585. format?: number;
  586. }
  587. }
  588. declare module BABYLON {
  589. /** Defines the cross module used constants to avoid circular dependncies */
  590. export class Constants {
  591. /** Defines that alpha blending is disabled */
  592. static readonly ALPHA_DISABLE: number;
  593. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  594. static readonly ALPHA_ADD: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  596. static readonly ALPHA_COMBINE: number;
  597. /** Defines that alpha blending is DEST - SRC * DEST */
  598. static readonly ALPHA_SUBTRACT: number;
  599. /** Defines that alpha blending is SRC * DEST */
  600. static readonly ALPHA_MULTIPLY: number;
  601. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  602. static readonly ALPHA_MAXIMIZED: number;
  603. /** Defines that alpha blending is SRC + DEST */
  604. static readonly ALPHA_ONEONE: number;
  605. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  606. static readonly ALPHA_PREMULTIPLIED: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  609. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  612. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  613. static readonly ALPHA_INTERPOLATE: number;
  614. /**
  615. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  616. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_SCREENMODE: number;
  619. /**
  620. * Defines that alpha blending is SRC + DST
  621. * Alpha will be set to SRC ALPHA + DST ALPHA
  622. */
  623. static readonly ALPHA_ONEONE_ONEONE: number;
  624. /**
  625. * Defines that alpha blending is SRC * DST ALPHA + DST
  626. * Alpha will be set to 0
  627. */
  628. static readonly ALPHA_ALPHATOCOLOR: number;
  629. /**
  630. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  631. */
  632. static readonly ALPHA_REVERSEONEMINUS: number;
  633. /**
  634. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  635. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  636. */
  637. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST
  640. * Alpha will be set to SRC ALPHA
  641. */
  642. static readonly ALPHA_ONEONE_ONEZERO: number;
  643. /**
  644. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  645. * Alpha will be set to DST ALPHA
  646. */
  647. static readonly ALPHA_EXCLUSION: number;
  648. /** Defines that alpha blending equation a SUM */
  649. static readonly ALPHA_EQUATION_ADD: number;
  650. /** Defines that alpha blending equation a SUBSTRACTION */
  651. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  652. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  654. /** Defines that alpha blending equation a MAX operation */
  655. static readonly ALPHA_EQUATION_MAX: number;
  656. /** Defines that alpha blending equation a MIN operation */
  657. static readonly ALPHA_EQUATION_MIN: number;
  658. /**
  659. * Defines that alpha blending equation a DARKEN operation:
  660. * It takes the min of the src and sums the alpha channels.
  661. */
  662. static readonly ALPHA_EQUATION_DARKEN: number;
  663. /** Defines that the ressource is not delayed*/
  664. static readonly DELAYLOADSTATE_NONE: number;
  665. /** Defines that the ressource was successfully delay loaded */
  666. static readonly DELAYLOADSTATE_LOADED: number;
  667. /** Defines that the ressource is currently delay loading */
  668. static readonly DELAYLOADSTATE_LOADING: number;
  669. /** Defines that the ressource is delayed and has not started loading */
  670. static readonly DELAYLOADSTATE_NOTLOADED: number;
  671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  672. static readonly NEVER: number;
  673. /** 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 */
  674. static readonly ALWAYS: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  676. static readonly LESS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  678. static readonly EQUAL: number;
  679. /** 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 */
  680. static readonly LEQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  682. static readonly GREATER: number;
  683. /** 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 */
  684. static readonly GEQUAL: number;
  685. /** 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 */
  686. static readonly NOTEQUAL: number;
  687. /** Passed to stencilOperation to specify that stencil value must be kept */
  688. static readonly KEEP: number;
  689. /** Passed to stencilOperation to specify that stencil value must be replaced */
  690. static readonly REPLACE: number;
  691. /** Passed to stencilOperation to specify that stencil value must be incremented */
  692. static readonly INCR: number;
  693. /** Passed to stencilOperation to specify that stencil value must be decremented */
  694. static readonly DECR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be inverted */
  696. static readonly INVERT: number;
  697. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  698. static readonly INCR_WRAP: number;
  699. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  700. static readonly DECR_WRAP: number;
  701. /** Texture is not repeating outside of 0..1 UVs */
  702. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  703. /** Texture is repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  705. /** Texture is repeating and mirrored */
  706. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  707. /** ALPHA */
  708. static readonly TEXTUREFORMAT_ALPHA: number;
  709. /** LUMINANCE */
  710. static readonly TEXTUREFORMAT_LUMINANCE: number;
  711. /** LUMINANCE_ALPHA */
  712. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  713. /** RGB */
  714. static readonly TEXTUREFORMAT_RGB: number;
  715. /** RGBA */
  716. static readonly TEXTUREFORMAT_RGBA: number;
  717. /** RED */
  718. static readonly TEXTUREFORMAT_RED: number;
  719. /** RED (2nd reference) */
  720. static readonly TEXTUREFORMAT_R: number;
  721. /** RG */
  722. static readonly TEXTUREFORMAT_RG: number;
  723. /** RED_INTEGER */
  724. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  725. /** RED_INTEGER (2nd reference) */
  726. static readonly TEXTUREFORMAT_R_INTEGER: number;
  727. /** RG_INTEGER */
  728. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  729. /** RGB_INTEGER */
  730. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  731. /** RGBA_INTEGER */
  732. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  733. /** UNSIGNED_BYTE */
  734. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  735. /** UNSIGNED_BYTE (2nd reference) */
  736. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  737. /** FLOAT */
  738. static readonly TEXTURETYPE_FLOAT: number;
  739. /** HALF_FLOAT */
  740. static readonly TEXTURETYPE_HALF_FLOAT: number;
  741. /** BYTE */
  742. static readonly TEXTURETYPE_BYTE: number;
  743. /** SHORT */
  744. static readonly TEXTURETYPE_SHORT: number;
  745. /** UNSIGNED_SHORT */
  746. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  747. /** INT */
  748. static readonly TEXTURETYPE_INT: number;
  749. /** UNSIGNED_INT */
  750. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  751. /** UNSIGNED_SHORT_4_4_4_4 */
  752. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  753. /** UNSIGNED_SHORT_5_5_5_1 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  755. /** UNSIGNED_SHORT_5_6_5 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  757. /** UNSIGNED_INT_2_10_10_10_REV */
  758. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  759. /** UNSIGNED_INT_24_8 */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  761. /** UNSIGNED_INT_10F_11F_11F_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  763. /** UNSIGNED_INT_5_9_9_9_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  765. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  766. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  767. /** nearest is mag = nearest and min = nearest and no mip */
  768. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  769. /** mag = nearest and min = nearest and mip = none */
  770. static readonly TEXTURE_NEAREST_NEAREST: number;
  771. /** Bilinear is mag = linear and min = linear and no mip */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** mag = linear and min = linear and mip = none */
  774. static readonly TEXTURE_LINEAR_LINEAR: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** Trilinear is mag = linear and min = linear and mip = linear */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  779. /** mag = nearest and min = nearest and mip = nearest */
  780. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  781. /** mag = nearest and min = linear and mip = nearest */
  782. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = linear */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  785. /** mag = nearest and min = linear and mip = none */
  786. static readonly TEXTURE_NEAREST_LINEAR: number;
  787. /** nearest is mag = nearest and min = nearest and mip = linear */
  788. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  789. /** mag = linear and min = nearest and mip = nearest */
  790. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  791. /** mag = linear and min = nearest and mip = linear */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  793. /** Bilinear is mag = linear and min = linear and mip = nearest */
  794. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = none */
  796. static readonly TEXTURE_LINEAR_NEAREST: number;
  797. /** Explicit coordinates mode */
  798. static readonly TEXTURE_EXPLICIT_MODE: number;
  799. /** Spherical coordinates mode */
  800. static readonly TEXTURE_SPHERICAL_MODE: number;
  801. /** Planar coordinates mode */
  802. static readonly TEXTURE_PLANAR_MODE: number;
  803. /** Cubic coordinates mode */
  804. static readonly TEXTURE_CUBIC_MODE: number;
  805. /** Projection coordinates mode */
  806. static readonly TEXTURE_PROJECTION_MODE: number;
  807. /** Skybox coordinates mode */
  808. static readonly TEXTURE_SKYBOX_MODE: number;
  809. /** Inverse Cubic coordinates mode */
  810. static readonly TEXTURE_INVCUBIC_MODE: number;
  811. /** Equirectangular coordinates mode */
  812. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  813. /** Equirectangular Fixed coordinates mode */
  814. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed Mirrored coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  817. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  818. static readonly SCALEMODE_FLOOR: number;
  819. /** Defines that texture rescaling will look for the nearest power of 2 size */
  820. static readonly SCALEMODE_NEAREST: number;
  821. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  822. static readonly SCALEMODE_CEILING: number;
  823. /**
  824. * The dirty texture flag value
  825. */
  826. static readonly MATERIAL_TextureDirtyFlag: number;
  827. /**
  828. * The dirty light flag value
  829. */
  830. static readonly MATERIAL_LightDirtyFlag: number;
  831. /**
  832. * The dirty fresnel flag value
  833. */
  834. static readonly MATERIAL_FresnelDirtyFlag: number;
  835. /**
  836. * The dirty attribute flag value
  837. */
  838. static readonly MATERIAL_AttributesDirtyFlag: number;
  839. /**
  840. * The dirty misc flag value
  841. */
  842. static readonly MATERIAL_MiscDirtyFlag: number;
  843. /**
  844. * The all dirty flag value
  845. */
  846. static readonly MATERIAL_AllDirtyFlag: number;
  847. /**
  848. * Returns the triangle fill mode
  849. */
  850. static readonly MATERIAL_TriangleFillMode: number;
  851. /**
  852. * Returns the wireframe mode
  853. */
  854. static readonly MATERIAL_WireFrameFillMode: number;
  855. /**
  856. * Returns the point fill mode
  857. */
  858. static readonly MATERIAL_PointFillMode: number;
  859. /**
  860. * Returns the point list draw mode
  861. */
  862. static readonly MATERIAL_PointListDrawMode: number;
  863. /**
  864. * Returns the line list draw mode
  865. */
  866. static readonly MATERIAL_LineListDrawMode: number;
  867. /**
  868. * Returns the line loop draw mode
  869. */
  870. static readonly MATERIAL_LineLoopDrawMode: number;
  871. /**
  872. * Returns the line strip draw mode
  873. */
  874. static readonly MATERIAL_LineStripDrawMode: number;
  875. /**
  876. * Returns the triangle strip draw mode
  877. */
  878. static readonly MATERIAL_TriangleStripDrawMode: number;
  879. /**
  880. * Returns the triangle fan draw mode
  881. */
  882. static readonly MATERIAL_TriangleFanDrawMode: number;
  883. /**
  884. * Stores the clock-wise side orientation
  885. */
  886. static readonly MATERIAL_ClockWiseSideOrientation: number;
  887. /**
  888. * Stores the counter clock-wise side orientation
  889. */
  890. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  891. /**
  892. * Nothing
  893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  894. */
  895. static readonly ACTION_NothingTrigger: number;
  896. /**
  897. * On pick
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnPickTrigger: number;
  901. /**
  902. * On left pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnLeftPickTrigger: number;
  906. /**
  907. * On right pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnRightPickTrigger: number;
  911. /**
  912. * On center pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnCenterPickTrigger: number;
  916. /**
  917. * On pick down
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPickDownTrigger: number;
  921. /**
  922. * On double pick
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnDoublePickTrigger: number;
  926. /**
  927. * On pick up
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnPickUpTrigger: number;
  931. /**
  932. * On pick out.
  933. * This trigger will only be raised if you also declared a OnPickDown
  934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnPickOutTrigger: number;
  937. /**
  938. * On long press
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnLongPressTrigger: number;
  942. /**
  943. * On pointer over
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnPointerOverTrigger: number;
  947. /**
  948. * On pointer out
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOutTrigger: number;
  952. /**
  953. * On every frame
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnEveryFrameTrigger: number;
  957. /**
  958. * On intersection enter
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnIntersectionEnterTrigger: number;
  962. /**
  963. * On intersection exit
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionExitTrigger: number;
  967. /**
  968. * On key down
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnKeyDownTrigger: number;
  972. /**
  973. * On key up
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyUpTrigger: number;
  977. /**
  978. * Billboard mode will only apply to Y axis
  979. */
  980. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  981. /**
  982. * Billboard mode will apply to all axes
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  985. /**
  986. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  989. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  990. * Test order :
  991. * Is the bounding sphere outside the frustum ?
  992. * If not, are the bounding box vertices outside the frustum ?
  993. * It not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  996. /** Culling strategy : Bounding Sphere Only.
  997. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  998. * It's also less accurate than the standard because some not visible objects can still be selected.
  999. * Test : is the bounding sphere outside the frustum ?
  1000. * If not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1003. /** Culling strategy : Optimistic Inclusion.
  1004. * This in an inclusion test first, then the standard exclusion test.
  1005. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1006. * 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.
  1007. * Anyway, it's as accurate as the standard strategy.
  1008. * Test :
  1009. * Is the cullable object bounding sphere center in the frustum ?
  1010. * If not, apply the default culling strategy.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1013. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1014. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1015. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1016. * 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.
  1017. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1018. * Test :
  1019. * Is the cullable object bounding sphere center in the frustum ?
  1020. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1023. /**
  1024. * No logging while loading
  1025. */
  1026. static readonly SCENELOADER_NO_LOGGING: number;
  1027. /**
  1028. * Minimal logging while loading
  1029. */
  1030. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1031. /**
  1032. * Summary logging while loading
  1033. */
  1034. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1035. /**
  1036. * Detailled logging while loading
  1037. */
  1038. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1039. }
  1040. }
  1041. declare module BABYLON {
  1042. /**
  1043. * This represents the required contract to create a new type of texture loader.
  1044. */
  1045. export interface IInternalTextureLoader {
  1046. /**
  1047. * Defines wether the loader supports cascade loading the different faces.
  1048. */
  1049. supportCascades: boolean;
  1050. /**
  1051. * This returns if the loader support the current file information.
  1052. * @param extension defines the file extension of the file being loaded
  1053. * @returns true if the loader can load the specified file
  1054. */
  1055. canLoad(extension: string): boolean;
  1056. /**
  1057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1058. * @param data contains the texture data
  1059. * @param texture defines the BabylonJS internal texture
  1060. * @param createPolynomials will be true if polynomials have been requested
  1061. * @param onLoad defines the callback to trigger once the texture is ready
  1062. * @param onError defines the callback to trigger in case of error
  1063. */
  1064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1065. /**
  1066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1067. * @param data contains the texture data
  1068. * @param texture defines the BabylonJS internal texture
  1069. * @param callback defines the method to call once ready to upload
  1070. */
  1071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1072. }
  1073. }
  1074. declare module BABYLON {
  1075. /**
  1076. * Class used to store and describe the pipeline context associated with an effect
  1077. */
  1078. export interface IPipelineContext {
  1079. /**
  1080. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1081. */
  1082. isAsync: boolean;
  1083. /**
  1084. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1085. */
  1086. isReady: boolean;
  1087. /** @hidden */
  1088. _getVertexShaderCode(): string | null;
  1089. /** @hidden */
  1090. _getFragmentShaderCode(): string | null;
  1091. /** @hidden */
  1092. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1093. }
  1094. }
  1095. declare module BABYLON {
  1096. /**
  1097. * Class used to store gfx data (like WebGLBuffer)
  1098. */
  1099. export class DataBuffer {
  1100. /**
  1101. * Gets or sets the number of objects referencing this buffer
  1102. */
  1103. references: number;
  1104. /** Gets or sets the size of the underlying buffer */
  1105. capacity: number;
  1106. /**
  1107. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1108. */
  1109. is32Bits: boolean;
  1110. /**
  1111. * Gets the underlying buffer
  1112. */
  1113. get underlyingResource(): any;
  1114. }
  1115. }
  1116. declare module BABYLON {
  1117. /** @hidden */
  1118. export interface IShaderProcessor {
  1119. attributeProcessor?: (attribute: string) => string;
  1120. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1121. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1122. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1123. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1124. lineProcessor?: (line: string, isFragment: boolean) => string;
  1125. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1126. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface ProcessingOptions {
  1132. defines: string[];
  1133. indexParameters: any;
  1134. isFragment: boolean;
  1135. shouldUseHighPrecisionShader: boolean;
  1136. supportsUniformBuffers: boolean;
  1137. shadersRepository: string;
  1138. includesShadersStore: {
  1139. [key: string]: string;
  1140. };
  1141. processor?: IShaderProcessor;
  1142. version: string;
  1143. platformName: string;
  1144. lookForClosingBracketForUniformBuffer?: boolean;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export class ShaderCodeNode {
  1150. line: string;
  1151. children: ShaderCodeNode[];
  1152. additionalDefineKey?: string;
  1153. additionalDefineValue?: string;
  1154. isValid(preprocessors: {
  1155. [key: string]: string;
  1156. }): boolean;
  1157. process(preprocessors: {
  1158. [key: string]: string;
  1159. }, options: ProcessingOptions): string;
  1160. }
  1161. }
  1162. declare module BABYLON {
  1163. /** @hidden */
  1164. export class ShaderCodeCursor {
  1165. private _lines;
  1166. lineIndex: number;
  1167. get currentLine(): string;
  1168. get canRead(): boolean;
  1169. set lines(value: string[]);
  1170. }
  1171. }
  1172. declare module BABYLON {
  1173. /** @hidden */
  1174. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderDefineExpression {
  1183. isTrue(preprocessors: {
  1184. [key: string]: string;
  1185. }): boolean;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export class ShaderCodeTestNode extends ShaderCodeNode {
  1191. testExpression: ShaderDefineExpression;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1200. define: string;
  1201. not: boolean;
  1202. constructor(define: string, not?: boolean);
  1203. isTrue(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1211. leftOperand: ShaderDefineExpression;
  1212. rightOperand: ShaderDefineExpression;
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module BABYLON {
  1219. /** @hidden */
  1220. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1221. leftOperand: ShaderDefineExpression;
  1222. rightOperand: ShaderDefineExpression;
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module BABYLON {
  1229. /** @hidden */
  1230. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1231. define: string;
  1232. operand: string;
  1233. testValue: string;
  1234. constructor(define: string, operand: string, testValue: string);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module BABYLON {
  1241. /**
  1242. * Class used to enable access to offline support
  1243. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1244. */
  1245. export interface IOfflineProvider {
  1246. /**
  1247. * Gets a boolean indicating if scene must be saved in the database
  1248. */
  1249. enableSceneOffline: boolean;
  1250. /**
  1251. * Gets a boolean indicating if textures must be saved in the database
  1252. */
  1253. enableTexturesOffline: boolean;
  1254. /**
  1255. * Open the offline support and make it available
  1256. * @param successCallback defines the callback to call on success
  1257. * @param errorCallback defines the callback to call on error
  1258. */
  1259. open(successCallback: () => void, errorCallback: () => void): void;
  1260. /**
  1261. * Loads an image from the offline support
  1262. * @param url defines the url to load from
  1263. * @param image defines the target DOM image
  1264. */
  1265. loadImage(url: string, image: HTMLImageElement): void;
  1266. /**
  1267. * Loads a file from offline support
  1268. * @param url defines the URL to load from
  1269. * @param sceneLoaded defines a callback to call on success
  1270. * @param progressCallBack defines a callback to call when progress changed
  1271. * @param errorCallback defines a callback to call on error
  1272. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1273. */
  1274. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1275. }
  1276. }
  1277. declare module BABYLON {
  1278. /**
  1279. * Class used to help managing file picking and drag'n'drop
  1280. * File Storage
  1281. */
  1282. export class FilesInputStore {
  1283. /**
  1284. * List of files ready to be loaded
  1285. */
  1286. static FilesToLoad: {
  1287. [key: string]: File;
  1288. };
  1289. }
  1290. }
  1291. declare module BABYLON {
  1292. /**
  1293. * Class used to define a retry strategy when error happens while loading assets
  1294. */
  1295. export class RetryStrategy {
  1296. /**
  1297. * Function used to defines an exponential back off strategy
  1298. * @param maxRetries defines the maximum number of retries (3 by default)
  1299. * @param baseInterval defines the interval between retries
  1300. * @returns the strategy function to use
  1301. */
  1302. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * @ignore
  1308. * Application error to support additional information when loading a file
  1309. */
  1310. export abstract class BaseError extends Error {
  1311. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /** @ignore */
  1316. export class LoadFileError extends BaseError {
  1317. request?: WebRequest;
  1318. file?: File;
  1319. /**
  1320. * Creates a new LoadFileError
  1321. * @param message defines the message of the error
  1322. * @param request defines the optional web request
  1323. * @param file defines the optional file
  1324. */
  1325. constructor(message: string, object?: WebRequest | File);
  1326. }
  1327. /** @ignore */
  1328. export class RequestFileError extends BaseError {
  1329. request: WebRequest;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. */
  1335. constructor(message: string, request: WebRequest);
  1336. }
  1337. /** @ignore */
  1338. export class ReadFileError extends BaseError {
  1339. file: File;
  1340. /**
  1341. * Creates a new ReadFileError
  1342. * @param message defines the message of the error
  1343. * @param file defines the optional file
  1344. */
  1345. constructor(message: string, file: File);
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export class FileTools {
  1351. /**
  1352. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1353. */
  1354. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1355. /**
  1356. * Gets or sets the base URL to use to load assets
  1357. */
  1358. static BaseUrl: string;
  1359. /**
  1360. * Default behaviour for cors in the application.
  1361. * It can be a string if the expected behavior is identical in the entire app.
  1362. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1363. */
  1364. static CorsBehavior: string | ((url: string | string[]) => string);
  1365. /**
  1366. * Gets or sets a function used to pre-process url before using them to load assets
  1367. */
  1368. static PreprocessUrl: (url: string) => string;
  1369. /**
  1370. * Removes unwanted characters from an url
  1371. * @param url defines the url to clean
  1372. * @returns the cleaned url
  1373. */
  1374. private static _CleanUrl;
  1375. /**
  1376. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1377. * @param url define the url we are trying
  1378. * @param element define the dom element where to configure the cors policy
  1379. */
  1380. static SetCorsBehavior(url: string | string[], element: {
  1381. crossOrigin: string | null;
  1382. }): void;
  1383. /**
  1384. * Loads an image as an HTMLImageElement.
  1385. * @param input url string, ArrayBuffer, or Blob to load
  1386. * @param onLoad callback called when the image successfully loads
  1387. * @param onError callback called when the image fails to load
  1388. * @param offlineProvider offline provider for caching
  1389. * @param mimeType optional mime type
  1390. * @returns the HTMLImageElement of the loaded image
  1391. */
  1392. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1393. /**
  1394. * Reads a file from a File object
  1395. * @param file defines the file to load
  1396. * @param onSuccess defines the callback to call when data is loaded
  1397. * @param onProgress defines the callback to call during loading process
  1398. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1399. * @param onError defines the callback to call when an error occurs
  1400. * @returns a file request object
  1401. */
  1402. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1403. /**
  1404. * Loads a file from a url
  1405. * @param url url to load
  1406. * @param onSuccess callback called when the file successfully loads
  1407. * @param onProgress callback called while file is loading (if the server supports this mode)
  1408. * @param offlineProvider defines the offline provider for caching
  1409. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1410. * @param onError callback called when the file fails to load
  1411. * @returns a file request object
  1412. */
  1413. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1420. * @param onError callback called when the file fails to load
  1421. * @param onOpened callback called when the web request is opened
  1422. * @returns a file request object
  1423. */
  1424. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1425. /**
  1426. * Checks if the loaded document was accessed via `file:`-Protocol.
  1427. * @returns boolean
  1428. */
  1429. static IsFileURL(): boolean;
  1430. }
  1431. }
  1432. declare module BABYLON {
  1433. /** @hidden */
  1434. export class ShaderProcessor {
  1435. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1436. private static _ProcessPrecision;
  1437. private static _ExtractOperation;
  1438. private static _BuildSubExpression;
  1439. private static _BuildExpression;
  1440. private static _MoveCursorWithinIf;
  1441. private static _MoveCursor;
  1442. private static _EvaluatePreProcessors;
  1443. private static _PreparePreProcessors;
  1444. private static _ProcessShaderConversion;
  1445. private static _ProcessIncludes;
  1446. /**
  1447. * Loads a file from a url
  1448. * @param url url to load
  1449. * @param onSuccess callback called when the file successfully loads
  1450. * @param onProgress callback called while file is loading (if the server supports this mode)
  1451. * @param offlineProvider defines the offline provider for caching
  1452. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1453. * @param onError callback called when the file fails to load
  1454. * @returns a file request object
  1455. * @hidden
  1456. */
  1457. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1458. }
  1459. }
  1460. declare module BABYLON {
  1461. /**
  1462. * @hidden
  1463. */
  1464. export interface IColor4Like {
  1465. r: float;
  1466. g: float;
  1467. b: float;
  1468. a: float;
  1469. }
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor3Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. }
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IVector4Like {
  1482. x: float;
  1483. y: float;
  1484. z: float;
  1485. w: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector3Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector2Like {
  1499. x: float;
  1500. y: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IMatrixLike {
  1506. toArray(): DeepImmutable<Float32Array>;
  1507. updateFlag: int;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IViewportLike {
  1513. x: float;
  1514. y: float;
  1515. width: float;
  1516. height: float;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IPlaneLike {
  1522. normal: IVector3Like;
  1523. d: float;
  1524. normalize(): void;
  1525. }
  1526. }
  1527. declare module BABYLON {
  1528. /**
  1529. * Interface used to define common properties for effect fallbacks
  1530. */
  1531. export interface IEffectFallbacks {
  1532. /**
  1533. * Removes the defines that should be removed when falling back.
  1534. * @param currentDefines defines the current define statements for the shader.
  1535. * @param effect defines the current effect we try to compile
  1536. * @returns The resulting defines with defines of the current rank removed.
  1537. */
  1538. reduce(currentDefines: string, effect: Effect): string;
  1539. /**
  1540. * Removes the fallback from the bound mesh.
  1541. */
  1542. unBindMesh(): void;
  1543. /**
  1544. * Checks to see if more fallbacks are still availible.
  1545. */
  1546. hasMoreFallbacks: boolean;
  1547. }
  1548. }
  1549. declare module BABYLON {
  1550. /**
  1551. * Class used to evalaute queries containing `and` and `or` operators
  1552. */
  1553. export class AndOrNotEvaluator {
  1554. /**
  1555. * Evaluate a query
  1556. * @param query defines the query to evaluate
  1557. * @param evaluateCallback defines the callback used to filter result
  1558. * @returns true if the query matches
  1559. */
  1560. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1561. private static _HandleParenthesisContent;
  1562. private static _SimplifyNegation;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /**
  1567. * Class used to store custom tags
  1568. */
  1569. export class Tags {
  1570. /**
  1571. * Adds support for tags on the given object
  1572. * @param obj defines the object to use
  1573. */
  1574. static EnableFor(obj: any): void;
  1575. /**
  1576. * Removes tags support
  1577. * @param obj defines the object to use
  1578. */
  1579. static DisableFor(obj: any): void;
  1580. /**
  1581. * Gets a boolean indicating if the given object has tags
  1582. * @param obj defines the object to use
  1583. * @returns a boolean
  1584. */
  1585. static HasTags(obj: any): boolean;
  1586. /**
  1587. * Gets the tags available on a given object
  1588. * @param obj defines the object to use
  1589. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1590. * @returns the tags
  1591. */
  1592. static GetTags(obj: any, asString?: boolean): any;
  1593. /**
  1594. * Adds tags to an object
  1595. * @param obj defines the object to use
  1596. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1597. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1598. */
  1599. static AddTagsTo(obj: any, tagsString: string): void;
  1600. /**
  1601. * @hidden
  1602. */
  1603. static _AddTagTo(obj: any, tag: string): void;
  1604. /**
  1605. * Removes specific tags from a specific object
  1606. * @param obj defines the object to use
  1607. * @param tagsString defines the tags to remove
  1608. */
  1609. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1610. /**
  1611. * @hidden
  1612. */
  1613. static _RemoveTagFrom(obj: any, tag: string): void;
  1614. /**
  1615. * Defines if tags hosted on an object match a given query
  1616. * @param obj defines the object to use
  1617. * @param tagsQuery defines the tag query
  1618. * @returns a boolean
  1619. */
  1620. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1621. }
  1622. }
  1623. declare module BABYLON {
  1624. /**
  1625. * Scalar computation library
  1626. */
  1627. export class Scalar {
  1628. /**
  1629. * Two pi constants convenient for computation.
  1630. */
  1631. static TwoPi: number;
  1632. /**
  1633. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1634. * @param a number
  1635. * @param b number
  1636. * @param epsilon (default = 1.401298E-45)
  1637. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. */
  1639. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1640. /**
  1641. * Returns a string : the upper case translation of the number i to hexadecimal.
  1642. * @param i number
  1643. * @returns the upper case translation of the number i to hexadecimal.
  1644. */
  1645. static ToHex(i: number): string;
  1646. /**
  1647. * Returns -1 if value is negative and +1 is value is positive.
  1648. * @param value the value
  1649. * @returns the value itself if it's equal to zero.
  1650. */
  1651. static Sign(value: number): number;
  1652. /**
  1653. * Returns the value itself if it's between min and max.
  1654. * Returns min if the value is lower than min.
  1655. * Returns max if the value is greater than max.
  1656. * @param value the value to clmap
  1657. * @param min the min value to clamp to (default: 0)
  1658. * @param max the max value to clamp to (default: 1)
  1659. * @returns the clamped value
  1660. */
  1661. static Clamp(value: number, min?: number, max?: number): number;
  1662. /**
  1663. * the log2 of value.
  1664. * @param value the value to compute log2 of
  1665. * @returns the log2 of value.
  1666. */
  1667. static Log2(value: number): number;
  1668. /**
  1669. * Loops the value, so that it is never larger than length and never smaller than 0.
  1670. *
  1671. * This is similar to the modulo operator but it works with floating point numbers.
  1672. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1673. * With t = 5 and length = 2.5, the result would be 0.0.
  1674. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1675. * @param value the value
  1676. * @param length the length
  1677. * @returns the looped value
  1678. */
  1679. static Repeat(value: number, length: number): number;
  1680. /**
  1681. * Normalize the value between 0.0 and 1.0 using min and max values
  1682. * @param value value to normalize
  1683. * @param min max to normalize between
  1684. * @param max min to normalize between
  1685. * @returns the normalized value
  1686. */
  1687. static Normalize(value: number, min: number, max: number): number;
  1688. /**
  1689. * Denormalize the value from 0.0 and 1.0 using min and max values
  1690. * @param normalized value to denormalize
  1691. * @param min max to denormalize between
  1692. * @param max min to denormalize between
  1693. * @returns the denormalized value
  1694. */
  1695. static Denormalize(normalized: number, min: number, max: number): number;
  1696. /**
  1697. * Calculates the shortest difference between two given angles given in degrees.
  1698. * @param current current angle in degrees
  1699. * @param target target angle in degrees
  1700. * @returns the delta
  1701. */
  1702. static DeltaAngle(current: number, target: number): number;
  1703. /**
  1704. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1705. * @param tx value
  1706. * @param length length
  1707. * @returns The returned value will move back and forth between 0 and length
  1708. */
  1709. static PingPong(tx: number, length: number): number;
  1710. /**
  1711. * Interpolates between min and max with smoothing at the limits.
  1712. *
  1713. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1714. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1715. * @param from from
  1716. * @param to to
  1717. * @param tx value
  1718. * @returns the smooth stepped value
  1719. */
  1720. static SmoothStep(from: number, to: number, tx: number): number;
  1721. /**
  1722. * Moves a value current towards target.
  1723. *
  1724. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1725. * Negative values of maxDelta pushes the value away from target.
  1726. * @param current current value
  1727. * @param target target value
  1728. * @param maxDelta max distance to move
  1729. * @returns resulting value
  1730. */
  1731. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1732. /**
  1733. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1734. *
  1735. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1736. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1737. * @param current current value
  1738. * @param target target value
  1739. * @param maxDelta max distance to move
  1740. * @returns resulting angle
  1741. */
  1742. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1743. /**
  1744. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1745. * @param start start value
  1746. * @param end target value
  1747. * @param amount amount to lerp between
  1748. * @returns the lerped value
  1749. */
  1750. static Lerp(start: number, end: number, amount: number): number;
  1751. /**
  1752. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1753. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1754. * @param start start value
  1755. * @param end target value
  1756. * @param amount amount to lerp between
  1757. * @returns the lerped value
  1758. */
  1759. static LerpAngle(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1762. * @param a start value
  1763. * @param b target value
  1764. * @param value value between a and b
  1765. * @returns the inverseLerp value
  1766. */
  1767. static InverseLerp(a: number, b: number, value: number): number;
  1768. /**
  1769. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1770. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1771. * @param value1 spline value
  1772. * @param tangent1 spline value
  1773. * @param value2 spline value
  1774. * @param tangent2 spline value
  1775. * @param amount input value
  1776. * @returns hermite result
  1777. */
  1778. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1779. /**
  1780. * Returns a random float number between and min and max values
  1781. * @param min min value of random
  1782. * @param max max value of random
  1783. * @returns random value
  1784. */
  1785. static RandomRange(min: number, max: number): number;
  1786. /**
  1787. * This function returns percentage of a number in a given range.
  1788. *
  1789. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1790. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1791. * @param number to convert to percentage
  1792. * @param min min range
  1793. * @param max max range
  1794. * @returns the percentage
  1795. */
  1796. static RangeToPercent(number: number, min: number, max: number): number;
  1797. /**
  1798. * This function returns number that corresponds to the percentage in a given range.
  1799. *
  1800. * PercentToRange(0.34,0,100) will return 34.
  1801. * @param percent to convert to number
  1802. * @param min min range
  1803. * @param max max range
  1804. * @returns the number
  1805. */
  1806. static PercentToRange(percent: number, min: number, max: number): number;
  1807. /**
  1808. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1809. * @param angle The angle to normalize in radian.
  1810. * @return The converted angle.
  1811. */
  1812. static NormalizeRadians(angle: number): number;
  1813. }
  1814. }
  1815. declare module BABYLON {
  1816. /**
  1817. * Constant used to convert a value to gamma space
  1818. * @ignorenaming
  1819. */
  1820. export const ToGammaSpace: number;
  1821. /**
  1822. * Constant used to convert a value to linear space
  1823. * @ignorenaming
  1824. */
  1825. export const ToLinearSpace = 2.2;
  1826. /**
  1827. * Constant used to define the minimal number value in Babylon.js
  1828. * @ignorenaming
  1829. */
  1830. let Epsilon: number;
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Class used to represent a viewport on screen
  1835. */
  1836. export class Viewport {
  1837. /** viewport left coordinate */
  1838. x: number;
  1839. /** viewport top coordinate */
  1840. y: number;
  1841. /**viewport width */
  1842. width: number;
  1843. /** viewport height */
  1844. height: number;
  1845. /**
  1846. * Creates a Viewport object located at (x, y) and sized (width, height)
  1847. * @param x defines viewport left coordinate
  1848. * @param y defines viewport top coordinate
  1849. * @param width defines the viewport width
  1850. * @param height defines the viewport height
  1851. */
  1852. constructor(
  1853. /** viewport left coordinate */
  1854. x: number,
  1855. /** viewport top coordinate */
  1856. y: number,
  1857. /**viewport width */
  1858. width: number,
  1859. /** viewport height */
  1860. height: number);
  1861. /**
  1862. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1863. * @param renderWidth defines the rendering width
  1864. * @param renderHeight defines the rendering height
  1865. * @returns a new Viewport
  1866. */
  1867. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1868. /**
  1869. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1870. * @param renderWidth defines the rendering width
  1871. * @param renderHeight defines the rendering height
  1872. * @param ref defines the target viewport
  1873. * @returns the current viewport
  1874. */
  1875. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1876. /**
  1877. * Returns a new Viewport copied from the current one
  1878. * @returns a new Viewport
  1879. */
  1880. clone(): Viewport;
  1881. }
  1882. }
  1883. declare module BABYLON {
  1884. /**
  1885. * Class containing a set of static utilities functions for arrays.
  1886. */
  1887. export class ArrayTools {
  1888. /**
  1889. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1890. * @param size the number of element to construct and put in the array
  1891. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1892. * @returns a new array filled with new objects
  1893. */
  1894. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1895. }
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class representing a vector containing 2 coordinates
  1900. */
  1901. export class Vector2 {
  1902. /** defines the first coordinate */
  1903. x: number;
  1904. /** defines the second coordinate */
  1905. y: number;
  1906. /**
  1907. * Creates a new Vector2 from the given x and y coordinates
  1908. * @param x defines the first coordinate
  1909. * @param y defines the second coordinate
  1910. */
  1911. constructor(
  1912. /** defines the first coordinate */
  1913. x?: number,
  1914. /** defines the second coordinate */
  1915. y?: number);
  1916. /**
  1917. * Gets a string with the Vector2 coordinates
  1918. * @returns a string with the Vector2 coordinates
  1919. */
  1920. toString(): string;
  1921. /**
  1922. * Gets class name
  1923. * @returns the string "Vector2"
  1924. */
  1925. getClassName(): string;
  1926. /**
  1927. * Gets current vector hash code
  1928. * @returns the Vector2 hash code as a number
  1929. */
  1930. getHashCode(): number;
  1931. /**
  1932. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1933. * @param array defines the source array
  1934. * @param index defines the offset in source array
  1935. * @returns the current Vector2
  1936. */
  1937. toArray(array: FloatArray, index?: number): Vector2;
  1938. /**
  1939. * Copy the current vector to an array
  1940. * @returns a new array with 2 elements: the Vector2 coordinates.
  1941. */
  1942. asArray(): number[];
  1943. /**
  1944. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1945. * @param source defines the source Vector2
  1946. * @returns the current updated Vector2
  1947. */
  1948. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1949. /**
  1950. * Sets the Vector2 coordinates with the given floats
  1951. * @param x defines the first coordinate
  1952. * @param y defines the second coordinate
  1953. * @returns the current updated Vector2
  1954. */
  1955. copyFromFloats(x: number, y: number): Vector2;
  1956. /**
  1957. * Sets the Vector2 coordinates with the given floats
  1958. * @param x defines the first coordinate
  1959. * @param y defines the second coordinate
  1960. * @returns the current updated Vector2
  1961. */
  1962. set(x: number, y: number): Vector2;
  1963. /**
  1964. * Add another vector with the current one
  1965. * @param otherVector defines the other vector
  1966. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1967. */
  1968. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1969. /**
  1970. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1971. * @param otherVector defines the other vector
  1972. * @param result defines the target vector
  1973. * @returns the unmodified current Vector2
  1974. */
  1975. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1976. /**
  1977. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1978. * @param otherVector defines the other vector
  1979. * @returns the current updated Vector2
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1984. * @param otherVector defines the other vector
  1985. * @returns a new Vector2
  1986. */
  1987. addVector3(otherVector: Vector3): Vector2;
  1988. /**
  1989. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. subtract(otherVector: Vector2): Vector2;
  1994. /**
  1995. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1996. * @param otherVector defines the other vector
  1997. * @param result defines the target vector
  1998. * @returns the unmodified current Vector2
  1999. */
  2000. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2001. /**
  2002. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2003. * @param otherVector defines the other vector
  2004. * @returns the current updated Vector2
  2005. */
  2006. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2007. /**
  2008. * Multiplies in place the current Vector2 coordinates by the given ones
  2009. * @param otherVector defines the other vector
  2010. * @returns the current updated Vector2
  2011. */
  2012. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2013. /**
  2014. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2015. * @param otherVector defines the other vector
  2016. * @returns a new Vector2
  2017. */
  2018. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2019. /**
  2020. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @param result defines the target vector
  2023. * @returns the unmodified current Vector2
  2024. */
  2025. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2026. /**
  2027. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2028. * @param x defines the first coordinate
  2029. * @param y defines the second coordinate
  2030. * @returns a new Vector2
  2031. */
  2032. multiplyByFloats(x: number, y: number): Vector2;
  2033. /**
  2034. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2035. * @param otherVector defines the other vector
  2036. * @returns a new Vector2
  2037. */
  2038. divide(otherVector: Vector2): Vector2;
  2039. /**
  2040. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2041. * @param otherVector defines the other vector
  2042. * @param result defines the target vector
  2043. * @returns the unmodified current Vector2
  2044. */
  2045. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2046. /**
  2047. * Divides the current Vector2 coordinates by the given ones
  2048. * @param otherVector defines the other vector
  2049. * @returns the current updated Vector2
  2050. */
  2051. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Gets a new Vector2 with current Vector2 negated coordinates
  2054. * @returns a new Vector2
  2055. */
  2056. negate(): Vector2;
  2057. /**
  2058. * Negate this vector in place
  2059. * @returns this
  2060. */
  2061. negateInPlace(): Vector2;
  2062. /**
  2063. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2064. * @param result defines the Vector3 object where to store the result
  2065. * @returns the current Vector2
  2066. */
  2067. negateToRef(result: Vector2): Vector2;
  2068. /**
  2069. * Multiply the Vector2 coordinates by scale
  2070. * @param scale defines the scaling factor
  2071. * @returns the current updated Vector2
  2072. */
  2073. scaleInPlace(scale: number): Vector2;
  2074. /**
  2075. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2076. * @param scale defines the scaling factor
  2077. * @returns a new Vector2
  2078. */
  2079. scale(scale: number): Vector2;
  2080. /**
  2081. * Scale the current Vector2 values by a factor to a given Vector2
  2082. * @param scale defines the scale factor
  2083. * @param result defines the Vector2 object where to store the result
  2084. * @returns the unmodified current Vector2
  2085. */
  2086. scaleToRef(scale: number, result: Vector2): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Gets a boolean if two vectors are equals
  2096. * @param otherVector defines the other vector
  2097. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2098. */
  2099. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2100. /**
  2101. * Gets a boolean if two vectors are equals (using an epsilon value)
  2102. * @param otherVector defines the other vector
  2103. * @param epsilon defines the minimal distance to consider equality
  2104. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2105. */
  2106. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2107. /**
  2108. * Gets a new Vector2 from current Vector2 floored values
  2109. * @returns a new Vector2
  2110. */
  2111. floor(): Vector2;
  2112. /**
  2113. * Gets a new Vector2 from current Vector2 floored values
  2114. * @returns a new Vector2
  2115. */
  2116. fract(): Vector2;
  2117. /**
  2118. * Gets the length of the vector
  2119. * @returns the vector length (float)
  2120. */
  2121. length(): number;
  2122. /**
  2123. * Gets the vector squared length
  2124. * @returns the vector squared length (float)
  2125. */
  2126. lengthSquared(): number;
  2127. /**
  2128. * Normalize the vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. normalize(): Vector2;
  2132. /**
  2133. * Gets a new Vector2 copied from the Vector2
  2134. * @returns a new Vector2
  2135. */
  2136. clone(): Vector2;
  2137. /**
  2138. * Gets a new Vector2(0, 0)
  2139. * @returns a new Vector2
  2140. */
  2141. static Zero(): Vector2;
  2142. /**
  2143. * Gets a new Vector2(1, 1)
  2144. * @returns a new Vector2
  2145. */
  2146. static One(): Vector2;
  2147. /**
  2148. * Gets a new Vector2 set from the given index element of the given array
  2149. * @param array defines the data source
  2150. * @param offset defines the offset in the data source
  2151. * @returns a new Vector2
  2152. */
  2153. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2154. /**
  2155. * Sets "result" from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @param result defines the target vector
  2159. */
  2160. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2161. /**
  2162. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2163. * @param value1 defines 1st point of control
  2164. * @param value2 defines 2nd point of control
  2165. * @param value3 defines 3rd point of control
  2166. * @param value4 defines 4th point of control
  2167. * @param amount defines the interpolation factor
  2168. * @returns a new Vector2
  2169. */
  2170. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2171. /**
  2172. * 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".
  2173. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2174. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2175. * @param value defines the value to clamp
  2176. * @param min defines the lower limit
  2177. * @param max defines the upper limit
  2178. * @returns a new Vector2
  2179. */
  2180. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2183. * @param value1 defines the 1st control point
  2184. * @param tangent1 defines the outgoing tangent
  2185. * @param value2 defines the 2nd control point
  2186. * @param tangent2 defines the incoming tangent
  2187. * @param amount defines the interpolation factor
  2188. * @returns a new Vector2
  2189. */
  2190. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2191. /**
  2192. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2193. * @param start defines the start vector
  2194. * @param end defines the end vector
  2195. * @param amount defines the interpolation factor
  2196. * @returns a new Vector2
  2197. */
  2198. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2199. /**
  2200. * Gets the dot product of the vector "left" and the vector "right"
  2201. * @param left defines first vector
  2202. * @param right defines second vector
  2203. * @returns the dot product (float)
  2204. */
  2205. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2206. /**
  2207. * Returns a new Vector2 equal to the normalized given vector
  2208. * @param vector defines the vector to normalize
  2209. * @returns a new Vector2
  2210. */
  2211. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2214. * @param left defines 1st vector
  2215. * @param right defines 2nd vector
  2216. * @returns a new Vector2
  2217. */
  2218. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2228. * @param vector defines the vector to transform
  2229. * @param transformation defines the matrix to apply
  2230. * @returns a new Vector2
  2231. */
  2232. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2233. /**
  2234. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @param result defines the target vector
  2238. */
  2239. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2240. /**
  2241. * Determines if a given vector is included in a triangle
  2242. * @param p defines the vector to test
  2243. * @param p0 defines 1st triangle point
  2244. * @param p1 defines 2nd triangle point
  2245. * @param p2 defines 3rd triangle point
  2246. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2247. */
  2248. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2249. /**
  2250. * Gets the distance between the vectors "value1" and "value2"
  2251. * @param value1 defines first vector
  2252. * @param value2 defines second vector
  2253. * @returns the distance between vectors
  2254. */
  2255. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2256. /**
  2257. * Returns the squared distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the squared distance between vectors
  2261. */
  2262. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns a new Vector2
  2268. */
  2269. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2270. /**
  2271. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2272. * @param p defines the middle point
  2273. * @param segA defines one point of the segment
  2274. * @param segB defines the other point of the segment
  2275. * @returns the shortest distance
  2276. */
  2277. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2278. }
  2279. /**
  2280. * Class used to store (x,y,z) vector representation
  2281. * A Vector3 is the main object used in 3D geometry
  2282. * It can represent etiher the coordinates of a point the space, either a direction
  2283. * Reminder: js uses a left handed forward facing system
  2284. */
  2285. export class Vector3 {
  2286. /**
  2287. * Defines the first coordinates (on X axis)
  2288. */
  2289. x: number;
  2290. /**
  2291. * Defines the second coordinates (on Y axis)
  2292. */
  2293. y: number;
  2294. /**
  2295. * Defines the third coordinates (on Z axis)
  2296. */
  2297. z: number;
  2298. private static _UpReadOnly;
  2299. private static _ZeroReadOnly;
  2300. /**
  2301. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2302. * @param x defines the first coordinates (on X axis)
  2303. * @param y defines the second coordinates (on Y axis)
  2304. * @param z defines the third coordinates (on Z axis)
  2305. */
  2306. constructor(
  2307. /**
  2308. * Defines the first coordinates (on X axis)
  2309. */
  2310. x?: number,
  2311. /**
  2312. * Defines the second coordinates (on Y axis)
  2313. */
  2314. y?: number,
  2315. /**
  2316. * Defines the third coordinates (on Z axis)
  2317. */
  2318. z?: number);
  2319. /**
  2320. * Creates a string representation of the Vector3
  2321. * @returns a string with the Vector3 coordinates.
  2322. */
  2323. toString(): string;
  2324. /**
  2325. * Gets the class name
  2326. * @returns the string "Vector3"
  2327. */
  2328. getClassName(): string;
  2329. /**
  2330. * Creates the Vector3 hash code
  2331. * @returns a number which tends to be unique between Vector3 instances
  2332. */
  2333. getHashCode(): number;
  2334. /**
  2335. * Creates an array containing three elements : the coordinates of the Vector3
  2336. * @returns a new array of numbers
  2337. */
  2338. asArray(): number[];
  2339. /**
  2340. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2341. * @param array defines the destination array
  2342. * @param index defines the offset in the destination array
  2343. * @returns the current Vector3
  2344. */
  2345. toArray(array: FloatArray, index?: number): Vector3;
  2346. /**
  2347. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2348. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2349. */
  2350. toQuaternion(): Quaternion;
  2351. /**
  2352. * Adds the given vector to the current Vector3
  2353. * @param otherVector defines the second operand
  2354. * @returns the current updated Vector3
  2355. */
  2356. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2357. /**
  2358. * Adds the given coordinates to the current Vector3
  2359. * @param x defines the x coordinate of the operand
  2360. * @param y defines the y coordinate of the operand
  2361. * @param z defines the z coordinate of the operand
  2362. * @returns the current updated Vector3
  2363. */
  2364. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2365. /**
  2366. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2367. * @param otherVector defines the second operand
  2368. * @returns the resulting Vector3
  2369. */
  2370. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2373. * @param otherVector defines the second operand
  2374. * @param result defines the Vector3 object where to store the result
  2375. * @returns the current Vector3
  2376. */
  2377. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2378. /**
  2379. * Subtract the given vector from the current Vector3
  2380. * @param otherVector defines the second operand
  2381. * @returns the current updated Vector3
  2382. */
  2383. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2384. /**
  2385. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the resulting Vector3
  2388. */
  2389. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2392. * @param otherVector defines the second operand
  2393. * @param result defines the Vector3 object where to store the result
  2394. * @returns the current Vector3
  2395. */
  2396. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2397. /**
  2398. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2399. * @param x defines the x coordinate of the operand
  2400. * @param y defines the y coordinate of the operand
  2401. * @param z defines the z coordinate of the operand
  2402. * @returns the resulting Vector3
  2403. */
  2404. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2405. /**
  2406. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2407. * @param x defines the x coordinate of the operand
  2408. * @param y defines the y coordinate of the operand
  2409. * @param z defines the z coordinate of the operand
  2410. * @param result defines the Vector3 object where to store the result
  2411. * @returns the current Vector3
  2412. */
  2413. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2414. /**
  2415. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2416. * @returns a new Vector3
  2417. */
  2418. negate(): Vector3;
  2419. /**
  2420. * Negate this vector in place
  2421. * @returns this
  2422. */
  2423. negateInPlace(): Vector3;
  2424. /**
  2425. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. negateToRef(result: Vector3): Vector3;
  2430. /**
  2431. * Multiplies the Vector3 coordinates by the float "scale"
  2432. * @param scale defines the multiplier factor
  2433. * @returns the current updated Vector3
  2434. */
  2435. scaleInPlace(scale: number): Vector3;
  2436. /**
  2437. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2438. * @param scale defines the multiplier factor
  2439. * @returns a new Vector3
  2440. */
  2441. scale(scale: number): Vector3;
  2442. /**
  2443. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2444. * @param scale defines the multiplier factor
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the current Vector3
  2447. */
  2448. scaleToRef(scale: number, result: Vector3): Vector3;
  2449. /**
  2450. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2451. * @param scale defines the scale factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the unmodified current Vector3
  2454. */
  2455. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2458. * @param otherVector defines the second operand
  2459. * @returns true if both vectors are equals
  2460. */
  2461. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2462. /**
  2463. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2464. * @param otherVector defines the second operand
  2465. * @param epsilon defines the minimal distance to define values as equals
  2466. * @returns true if both vectors are distant less than epsilon
  2467. */
  2468. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 coordinates equals the given floats
  2471. * @param x defines the x coordinate of the operand
  2472. * @param y defines the y coordinate of the operand
  2473. * @param z defines the z coordinate of the operand
  2474. * @returns true if both vectors are equals
  2475. */
  2476. equalsToFloats(x: number, y: number, z: number): boolean;
  2477. /**
  2478. * Multiplies the current Vector3 coordinates by the given ones
  2479. * @param otherVector defines the second operand
  2480. * @returns the current updated Vector3
  2481. */
  2482. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2483. /**
  2484. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2485. * @param otherVector defines the second operand
  2486. * @returns the new Vector3
  2487. */
  2488. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2489. /**
  2490. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2491. * @param otherVector defines the second operand
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the current Vector3
  2494. */
  2495. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2496. /**
  2497. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2498. * @param x defines the x coordinate of the operand
  2499. * @param y defines the y coordinate of the operand
  2500. * @param z defines the z coordinate of the operand
  2501. * @returns the new Vector3
  2502. */
  2503. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2504. /**
  2505. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2506. * @param otherVector defines the second operand
  2507. * @returns the new Vector3
  2508. */
  2509. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2510. /**
  2511. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2512. * @param otherVector defines the second operand
  2513. * @param result defines the Vector3 object where to store the result
  2514. * @returns the current Vector3
  2515. */
  2516. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones.
  2519. * @param otherVector defines the second operand
  2520. * @returns the current updated Vector3
  2521. */
  2522. divideInPlace(otherVector: Vector3): Vector3;
  2523. /**
  2524. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2525. * @param other defines the second operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2529. /**
  2530. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2531. * @param other defines the second operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2537. * @param x defines the x coordinate of the operand
  2538. * @param y defines the y coordinate of the operand
  2539. * @param z defines the z coordinate of the operand
  2540. * @returns the current updated Vector3
  2541. */
  2542. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2543. /**
  2544. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2545. * @param x defines the x coordinate of the operand
  2546. * @param y defines the y coordinate of the operand
  2547. * @param z defines the z coordinate of the operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2551. /**
  2552. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2553. * Check if is non uniform within a certain amount of decimal places to account for this
  2554. * @param epsilon the amount the values can differ
  2555. * @returns if the the vector is non uniform to a certain number of decimal places
  2556. */
  2557. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2558. /**
  2559. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2560. */
  2561. get isNonUniform(): boolean;
  2562. /**
  2563. * Gets a new Vector3 from current Vector3 floored values
  2564. * @returns a new Vector3
  2565. */
  2566. floor(): Vector3;
  2567. /**
  2568. * Gets a new Vector3 from current Vector3 floored values
  2569. * @returns a new Vector3
  2570. */
  2571. fract(): Vector3;
  2572. /**
  2573. * Gets the length of the Vector3
  2574. * @returns the length of the Vector3
  2575. */
  2576. length(): number;
  2577. /**
  2578. * Gets the squared length of the Vector3
  2579. * @returns squared length of the Vector3
  2580. */
  2581. lengthSquared(): number;
  2582. /**
  2583. * Normalize the current Vector3.
  2584. * Please note that this is an in place operation.
  2585. * @returns the current updated Vector3
  2586. */
  2587. normalize(): Vector3;
  2588. /**
  2589. * Reorders the x y z properties of the vector in place
  2590. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2591. * @returns the current updated vector
  2592. */
  2593. reorderInPlace(order: string): this;
  2594. /**
  2595. * Rotates the vector around 0,0,0 by a quaternion
  2596. * @param quaternion the rotation quaternion
  2597. * @param result vector to store the result
  2598. * @returns the resulting vector
  2599. */
  2600. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2601. /**
  2602. * Rotates a vector around a given point
  2603. * @param quaternion the rotation quaternion
  2604. * @param point the point to rotate around
  2605. * @param result vector to store the result
  2606. * @returns the resulting vector
  2607. */
  2608. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2609. /**
  2610. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2611. * The cross product is then orthogonal to both current and "other"
  2612. * @param other defines the right operand
  2613. * @returns the cross product
  2614. */
  2615. cross(other: Vector3): Vector3;
  2616. /**
  2617. * Normalize the current Vector3 with the given input length.
  2618. * Please note that this is an in place operation.
  2619. * @param len the length of the vector
  2620. * @returns the current updated Vector3
  2621. */
  2622. normalizeFromLength(len: number): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 to a new vector
  2625. * @returns the new Vector3
  2626. */
  2627. normalizeToNew(): Vector3;
  2628. /**
  2629. * Normalize the current Vector3 to the reference
  2630. * @param reference define the Vector3 to update
  2631. * @returns the updated Vector3
  2632. */
  2633. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2634. /**
  2635. * Creates a new Vector3 copied from the current Vector3
  2636. * @returns the new Vector3
  2637. */
  2638. clone(): Vector3;
  2639. /**
  2640. * Copies the given vector coordinates to the current Vector3 ones
  2641. * @param source defines the source Vector3
  2642. * @returns the current updated Vector3
  2643. */
  2644. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2645. /**
  2646. * Copies the given floats to the current Vector3 coordinates
  2647. * @param x defines the x coordinate of the operand
  2648. * @param y defines the y coordinate of the operand
  2649. * @param z defines the z coordinate of the operand
  2650. * @returns the current updated Vector3
  2651. */
  2652. copyFromFloats(x: number, y: number, z: number): Vector3;
  2653. /**
  2654. * Copies the given floats to the current Vector3 coordinates
  2655. * @param x defines the x coordinate of the operand
  2656. * @param y defines the y coordinate of the operand
  2657. * @param z defines the z coordinate of the operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. set(x: number, y: number, z: number): Vector3;
  2661. /**
  2662. * Copies the given float to the current Vector3 coordinates
  2663. * @param v defines the x, y and z coordinates of the operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. setAll(v: number): Vector3;
  2667. /**
  2668. * Get the clip factor between two vectors
  2669. * @param vector0 defines the first operand
  2670. * @param vector1 defines the second operand
  2671. * @param axis defines the axis to use
  2672. * @param size defines the size along the axis
  2673. * @returns the clip factor
  2674. */
  2675. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2676. /**
  2677. * Get angle between two vectors
  2678. * @param vector0 angle between vector0 and vector1
  2679. * @param vector1 angle between vector0 and vector1
  2680. * @param normal direction of the normal
  2681. * @return the angle between vector0 and vector1
  2682. */
  2683. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2684. /**
  2685. * Returns a new Vector3 set from the index "offset" of the given array
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @returns the new Vector3
  2689. */
  2690. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. * @deprecated Please use FromArray instead.
  2697. */
  2698. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2699. /**
  2700. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @param result defines the Vector3 where to store the result
  2704. */
  2705. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. * @deprecated Please use FromArrayToRef instead.
  2712. */
  2713. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2714. /**
  2715. * Sets the given vector "result" with the given floats.
  2716. * @param x defines the x coordinate of the source
  2717. * @param y defines the y coordinate of the source
  2718. * @param z defines the z coordinate of the source
  2719. * @param result defines the Vector3 where to store the result
  2720. */
  2721. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2724. * @returns a new empty Vector3
  2725. */
  2726. static Zero(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2729. * @returns a new unit Vector3
  2730. */
  2731. static One(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2734. * @returns a new up Vector3
  2735. */
  2736. static Up(): Vector3;
  2737. /**
  2738. * Gets a up Vector3 that must not be updated
  2739. */
  2740. static get UpReadOnly(): DeepImmutable<Vector3>;
  2741. /**
  2742. * Gets a zero Vector3 that must not be updated
  2743. */
  2744. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2745. /**
  2746. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2747. * @returns a new down Vector3
  2748. */
  2749. static Down(): Vector3;
  2750. /**
  2751. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2752. * @returns a new forward Vector3
  2753. */
  2754. static Forward(): Vector3;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2757. * @returns a new forward Vector3
  2758. */
  2759. static Backward(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2762. * @returns a new right Vector3
  2763. */
  2764. static Right(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2767. * @returns a new left Vector3
  2768. */
  2769. static Left(): Vector3;
  2770. /**
  2771. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2772. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2773. * @param vector defines the Vector3 to transform
  2774. * @param transformation defines the transformation matrix
  2775. * @returns the transformed Vector3
  2776. */
  2777. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2778. /**
  2779. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2780. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2781. * @param vector defines the Vector3 to transform
  2782. * @param transformation defines the transformation matrix
  2783. * @param result defines the Vector3 where to store the result
  2784. */
  2785. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2786. /**
  2787. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2788. * This method computes tranformed coordinates only, not transformed direction vectors
  2789. * @param x define the x coordinate of the source vector
  2790. * @param y define the y coordinate of the source vector
  2791. * @param z define the z coordinate of the source vector
  2792. * @param transformation defines the transformation matrix
  2793. * @param result defines the Vector3 where to store the result
  2794. */
  2795. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2796. /**
  2797. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2798. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2799. * @param vector defines the Vector3 to transform
  2800. * @param transformation defines the transformation matrix
  2801. * @returns the new Vector3
  2802. */
  2803. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2804. /**
  2805. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2806. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2807. * @param vector defines the Vector3 to transform
  2808. * @param transformation defines the transformation matrix
  2809. * @param result defines the Vector3 where to store the result
  2810. */
  2811. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2812. /**
  2813. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2814. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2815. * @param x define the x coordinate of the source vector
  2816. * @param y define the y coordinate of the source vector
  2817. * @param z define the z coordinate of the source vector
  2818. * @param transformation defines the transformation matrix
  2819. * @param result defines the Vector3 where to store the result
  2820. */
  2821. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2822. /**
  2823. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2824. * @param value1 defines the first control point
  2825. * @param value2 defines the second control point
  2826. * @param value3 defines the third control point
  2827. * @param value4 defines the fourth control point
  2828. * @param amount defines the amount on the spline to use
  2829. * @returns the new Vector3
  2830. */
  2831. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2832. /**
  2833. * 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"
  2834. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2835. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2836. * @param value defines the current value
  2837. * @param min defines the lower range value
  2838. * @param max defines the upper range value
  2839. * @returns the new Vector3
  2840. */
  2841. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2842. /**
  2843. * 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"
  2844. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2845. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2846. * @param value defines the current value
  2847. * @param min defines the lower range value
  2848. * @param max defines the upper range value
  2849. * @param result defines the Vector3 where to store the result
  2850. */
  2851. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2852. /**
  2853. * Checks if a given vector is inside a specific range
  2854. * @param v defines the vector to test
  2855. * @param min defines the minimum range
  2856. * @param max defines the maximum range
  2857. */
  2858. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2861. * @param value1 defines the first control point
  2862. * @param tangent1 defines the first tangent vector
  2863. * @param value2 defines the second control point
  2864. * @param tangent2 defines the second tangent vector
  2865. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2866. * @returns the new Vector3
  2867. */
  2868. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2871. * @param start defines the start value
  2872. * @param end defines the end value
  2873. * @param amount max defines amount between both (between 0 and 1)
  2874. * @returns the new Vector3
  2875. */
  2876. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2879. * @param start defines the start value
  2880. * @param end defines the end value
  2881. * @param amount max defines amount between both (between 0 and 1)
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2885. /**
  2886. * Returns the dot product (float) between the vectors "left" and "right"
  2887. * @param left defines the left operand
  2888. * @param right defines the right operand
  2889. * @returns the dot product
  2890. */
  2891. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2892. /**
  2893. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2894. * The cross product is then orthogonal to both "left" and "right"
  2895. * @param left defines the left operand
  2896. * @param right defines the right operand
  2897. * @returns the cross product
  2898. */
  2899. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2900. /**
  2901. * Sets the given vector "result" with the cross product of "left" and "right"
  2902. * The cross product is then orthogonal to both "left" and "right"
  2903. * @param left defines the left operand
  2904. * @param right defines the right operand
  2905. * @param result defines the Vector3 where to store the result
  2906. */
  2907. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2908. /**
  2909. * Returns a new Vector3 as the normalization of the given vector
  2910. * @param vector defines the Vector3 to normalize
  2911. * @returns the new Vector3
  2912. */
  2913. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Sets the given vector "result" with the normalization of the given first vector
  2916. * @param vector defines the Vector3 to normalize
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2920. /**
  2921. * Project a Vector3 onto screen space
  2922. * @param vector defines the Vector3 to project
  2923. * @param world defines the world matrix to use
  2924. * @param transform defines the transform (view x projection) matrix to use
  2925. * @param viewport defines the screen viewport to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2929. /** @hidden */
  2930. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2931. /**
  2932. * Unproject from screen space to object space
  2933. * @param source defines the screen space Vector3 to use
  2934. * @param viewportWidth defines the current width of the viewport
  2935. * @param viewportHeight defines the current height of the viewport
  2936. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2937. * @param transform defines the transform (view x projection) matrix to use
  2938. * @returns the new Vector3
  2939. */
  2940. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2941. /**
  2942. * Unproject from screen space to object space
  2943. * @param source defines the screen space Vector3 to use
  2944. * @param viewportWidth defines the current width of the viewport
  2945. * @param viewportHeight defines the current height of the viewport
  2946. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2947. * @param view defines the view matrix to use
  2948. * @param projection defines the projection matrix to use
  2949. * @returns the new Vector3
  2950. */
  2951. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2952. /**
  2953. * Unproject from screen space to object space
  2954. * @param source defines the screen space Vector3 to use
  2955. * @param viewportWidth defines the current width of the viewport
  2956. * @param viewportHeight defines the current height of the viewport
  2957. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2958. * @param view defines the view matrix to use
  2959. * @param projection defines the projection matrix to use
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param sourceX defines the screen space x coordinate to use
  2966. * @param sourceY defines the screen space y coordinate to use
  2967. * @param sourceZ defines the screen space z coordinate to use
  2968. * @param viewportWidth defines the current width of the viewport
  2969. * @param viewportHeight defines the current height of the viewport
  2970. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2971. * @param view defines the view matrix to use
  2972. * @param projection defines the projection matrix to use
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Gets the minimal coordinate values between two Vector3
  2978. * @param left defines the first operand
  2979. * @param right defines the second operand
  2980. * @returns the new Vector3
  2981. */
  2982. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Gets the maximal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Returns the distance between the vectors "value1" and "value2"
  2992. * @param value1 defines the first operand
  2993. * @param value2 defines the second operand
  2994. * @returns the distance
  2995. */
  2996. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2997. /**
  2998. * Returns the squared distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the squared distance
  3002. */
  3003. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns a new Vector3 located at the center between "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the new Vector3
  3009. */
  3010. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3013. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3014. * to something in order to rotate it from its local system to the given target system
  3015. * Note: axis1, axis2 and axis3 are normalized during this operation
  3016. * @param axis1 defines the first axis
  3017. * @param axis2 defines the second axis
  3018. * @param axis3 defines the third axis
  3019. * @returns a new Vector3
  3020. */
  3021. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3024. * @param axis1 defines the first axis
  3025. * @param axis2 defines the second axis
  3026. * @param axis3 defines the third axis
  3027. * @param ref defines the Vector3 where to store the result
  3028. */
  3029. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3030. }
  3031. /**
  3032. * Vector4 class created for EulerAngle class conversion to Quaternion
  3033. */
  3034. export class Vector4 {
  3035. /** x value of the vector */
  3036. x: number;
  3037. /** y value of the vector */
  3038. y: number;
  3039. /** z value of the vector */
  3040. z: number;
  3041. /** w value of the vector */
  3042. w: number;
  3043. /**
  3044. * Creates a Vector4 object from the given floats.
  3045. * @param x x value of the vector
  3046. * @param y y value of the vector
  3047. * @param z z value of the vector
  3048. * @param w w value of the vector
  3049. */
  3050. constructor(
  3051. /** x value of the vector */
  3052. x: number,
  3053. /** y value of the vector */
  3054. y: number,
  3055. /** z value of the vector */
  3056. z: number,
  3057. /** w value of the vector */
  3058. w: number);
  3059. /**
  3060. * Returns the string with the Vector4 coordinates.
  3061. * @returns a string containing all the vector values
  3062. */
  3063. toString(): string;
  3064. /**
  3065. * Returns the string "Vector4".
  3066. * @returns "Vector4"
  3067. */
  3068. getClassName(): string;
  3069. /**
  3070. * Returns the Vector4 hash code.
  3071. * @returns a unique hash code
  3072. */
  3073. getHashCode(): number;
  3074. /**
  3075. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3076. * @returns the resulting array
  3077. */
  3078. asArray(): number[];
  3079. /**
  3080. * Populates the given array from the given index with the Vector4 coordinates.
  3081. * @param array array to populate
  3082. * @param index index of the array to start at (default: 0)
  3083. * @returns the Vector4.
  3084. */
  3085. toArray(array: FloatArray, index?: number): Vector4;
  3086. /**
  3087. * Adds the given vector to the current Vector4.
  3088. * @param otherVector the vector to add
  3089. * @returns the updated Vector4.
  3090. */
  3091. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3092. /**
  3093. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3094. * @param otherVector the vector to add
  3095. * @returns the resulting vector
  3096. */
  3097. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3098. /**
  3099. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3100. * @param otherVector the vector to add
  3101. * @param result the vector to store the result
  3102. * @returns the current Vector4.
  3103. */
  3104. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3105. /**
  3106. * Subtract in place the given vector from the current Vector4.
  3107. * @param otherVector the vector to subtract
  3108. * @returns the updated Vector4.
  3109. */
  3110. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3111. /**
  3112. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3113. * @param otherVector the vector to add
  3114. * @returns the new vector with the result
  3115. */
  3116. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3117. /**
  3118. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3119. * @param otherVector the vector to subtract
  3120. * @param result the vector to store the result
  3121. * @returns the current Vector4.
  3122. */
  3123. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3124. /**
  3125. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3126. */
  3127. /**
  3128. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3129. * @param x value to subtract
  3130. * @param y value to subtract
  3131. * @param z value to subtract
  3132. * @param w value to subtract
  3133. * @returns new vector containing the result
  3134. */
  3135. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3136. /**
  3137. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. * @param x value to subtract
  3139. * @param y value to subtract
  3140. * @param z value to subtract
  3141. * @param w value to subtract
  3142. * @param result the vector to store the result in
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3148. * @returns a new vector with the negated values
  3149. */
  3150. negate(): Vector4;
  3151. /**
  3152. * Negate this vector in place
  3153. * @returns this
  3154. */
  3155. negateInPlace(): Vector4;
  3156. /**
  3157. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3158. * @param result defines the Vector3 object where to store the result
  3159. * @returns the current Vector4
  3160. */
  3161. negateToRef(result: Vector4): Vector4;
  3162. /**
  3163. * Multiplies the current Vector4 coordinates by scale (float).
  3164. * @param scale the number to scale with
  3165. * @returns the updated Vector4.
  3166. */
  3167. scaleInPlace(scale: number): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3170. * @param scale the number to scale with
  3171. * @returns a new vector with the result
  3172. */
  3173. scale(scale: number): Vector4;
  3174. /**
  3175. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3176. * @param scale the number to scale with
  3177. * @param result a vector to store the result in
  3178. * @returns the current Vector4.
  3179. */
  3180. scaleToRef(scale: number, result: Vector4): Vector4;
  3181. /**
  3182. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3183. * @param scale defines the scale factor
  3184. * @param result defines the Vector4 object where to store the result
  3185. * @returns the unmodified current Vector4
  3186. */
  3187. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3188. /**
  3189. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3190. * @param otherVector the vector to compare against
  3191. * @returns true if they are equal
  3192. */
  3193. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3194. /**
  3195. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3196. * @param otherVector vector to compare against
  3197. * @param epsilon (Default: very small number)
  3198. * @returns true if they are equal
  3199. */
  3200. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3201. /**
  3202. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3203. * @param x x value to compare against
  3204. * @param y y value to compare against
  3205. * @param z z value to compare against
  3206. * @param w w value to compare against
  3207. * @returns true if equal
  3208. */
  3209. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3210. /**
  3211. * Multiplies in place the current Vector4 by the given one.
  3212. * @param otherVector vector to multiple with
  3213. * @returns the updated Vector4.
  3214. */
  3215. multiplyInPlace(otherVector: Vector4): Vector4;
  3216. /**
  3217. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3218. * @param otherVector vector to multiple with
  3219. * @returns resulting new vector
  3220. */
  3221. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3222. /**
  3223. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3224. * @param otherVector vector to multiple with
  3225. * @param result vector to store the result
  3226. * @returns the current Vector4.
  3227. */
  3228. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3229. /**
  3230. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3231. * @param x x value multiply with
  3232. * @param y y value multiply with
  3233. * @param z z value multiply with
  3234. * @param w w value multiply with
  3235. * @returns resulting new vector
  3236. */
  3237. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3240. * @param otherVector vector to devide with
  3241. * @returns resulting new vector
  3242. */
  3243. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3246. * @param otherVector vector to devide with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Divides the current Vector3 coordinates by the given ones.
  3253. * @param otherVector vector to devide with
  3254. * @returns the updated Vector3.
  3255. */
  3256. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3257. /**
  3258. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3259. * @param other defines the second operand
  3260. * @returns the current updated Vector4
  3261. */
  3262. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3263. /**
  3264. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3265. * @param other defines the second operand
  3266. * @returns the current updated Vector4
  3267. */
  3268. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Gets a new Vector4 from current Vector4 floored values
  3271. * @returns a new Vector4
  3272. */
  3273. floor(): Vector4;
  3274. /**
  3275. * Gets a new Vector4 from current Vector3 floored values
  3276. * @returns a new Vector4
  3277. */
  3278. fract(): Vector4;
  3279. /**
  3280. * Returns the Vector4 length (float).
  3281. * @returns the length
  3282. */
  3283. length(): number;
  3284. /**
  3285. * Returns the Vector4 squared length (float).
  3286. * @returns the length squared
  3287. */
  3288. lengthSquared(): number;
  3289. /**
  3290. * Normalizes in place the Vector4.
  3291. * @returns the updated Vector4.
  3292. */
  3293. normalize(): Vector4;
  3294. /**
  3295. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3296. * @returns this converted to a new vector3
  3297. */
  3298. toVector3(): Vector3;
  3299. /**
  3300. * Returns a new Vector4 copied from the current one.
  3301. * @returns the new cloned vector
  3302. */
  3303. clone(): Vector4;
  3304. /**
  3305. * Updates the current Vector4 with the given one coordinates.
  3306. * @param source the source vector to copy from
  3307. * @returns the updated Vector4.
  3308. */
  3309. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3310. /**
  3311. * Updates the current Vector4 coordinates with the given floats.
  3312. * @param x float to copy from
  3313. * @param y float to copy from
  3314. * @param z float to copy from
  3315. * @param w float to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to set from
  3322. * @param y float to set from
  3323. * @param z float to set from
  3324. * @param w float to set from
  3325. * @returns the updated Vector4.
  3326. */
  3327. set(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Copies the given float to the current Vector3 coordinates
  3330. * @param v defines the x, y, z and w coordinates of the operand
  3331. * @returns the current updated Vector3
  3332. */
  3333. setAll(v: number): Vector4;
  3334. /**
  3335. * Returns a new Vector4 set from the starting index of the given array.
  3336. * @param array the array to pull values from
  3337. * @param offset the offset into the array to start at
  3338. * @returns the new vector
  3339. */
  3340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3341. /**
  3342. * Updates the given vector "result" from the starting index of the given array.
  3343. * @param array the array to pull values from
  3344. * @param offset the offset into the array to start at
  3345. * @param result the vector to store the result in
  3346. */
  3347. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3348. /**
  3349. * Updates the given vector "result" from the starting index of the given Float32Array.
  3350. * @param array the array to pull values from
  3351. * @param offset the offset into the array to start at
  3352. * @param result the vector to store the result in
  3353. */
  3354. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3355. /**
  3356. * Updates the given vector "result" coordinates from the given floats.
  3357. * @param x float to set from
  3358. * @param y float to set from
  3359. * @param z float to set from
  3360. * @param w float to set from
  3361. * @param result the vector to the floats in
  3362. */
  3363. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3364. /**
  3365. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3366. * @returns the new vector
  3367. */
  3368. static Zero(): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3371. * @returns the new vector
  3372. */
  3373. static One(): Vector4;
  3374. /**
  3375. * Returns a new normalized Vector4 from the given one.
  3376. * @param vector the vector to normalize
  3377. * @returns the vector
  3378. */
  3379. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3380. /**
  3381. * Updates the given vector "result" from the normalization of the given one.
  3382. * @param vector the vector to normalize
  3383. * @param result the vector to store the result in
  3384. */
  3385. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3386. /**
  3387. * Returns a vector with the minimum values from the left and right vectors
  3388. * @param left left vector to minimize
  3389. * @param right right vector to minimize
  3390. * @returns a new vector with the minimum of the left and right vector values
  3391. */
  3392. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Returns a vector with the maximum values from the left and right vectors
  3395. * @param left left vector to maximize
  3396. * @param right right vector to maximize
  3397. * @returns a new vector with the maximum of the left and right vector values
  3398. */
  3399. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3400. /**
  3401. * Returns the distance (float) between the vectors "value1" and "value2".
  3402. * @param value1 value to calulate the distance between
  3403. * @param value2 value to calulate the distance between
  3404. * @return the distance between the two vectors
  3405. */
  3406. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3407. /**
  3408. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3409. * @param value1 value to calulate the distance between
  3410. * @param value2 value to calulate the distance between
  3411. * @return the distance between the two vectors squared
  3412. */
  3413. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3414. /**
  3415. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3416. * @param value1 value to calulate the center between
  3417. * @param value2 value to calulate the center between
  3418. * @return the center between the two vectors
  3419. */
  3420. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3421. /**
  3422. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3423. * This methods computes transformed normalized direction vectors only.
  3424. * @param vector the vector to transform
  3425. * @param transformation the transformation matrix to apply
  3426. * @returns the new vector
  3427. */
  3428. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3429. /**
  3430. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3431. * This methods computes transformed normalized direction vectors only.
  3432. * @param vector the vector to transform
  3433. * @param transformation the transformation matrix to apply
  3434. * @param result the vector to store the result in
  3435. */
  3436. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3437. /**
  3438. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3439. * This methods computes transformed normalized direction vectors only.
  3440. * @param x value to transform
  3441. * @param y value to transform
  3442. * @param z value to transform
  3443. * @param w value to transform
  3444. * @param transformation the transformation matrix to apply
  3445. * @param result the vector to store the results in
  3446. */
  3447. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3448. /**
  3449. * Creates a new Vector4 from a Vector3
  3450. * @param source defines the source data
  3451. * @param w defines the 4th component (default is 0)
  3452. * @returns a new Vector4
  3453. */
  3454. static FromVector3(source: Vector3, w?: number): Vector4;
  3455. }
  3456. /**
  3457. * Class used to store quaternion data
  3458. * @see https://en.wikipedia.org/wiki/Quaternion
  3459. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3460. */
  3461. export class Quaternion {
  3462. /** defines the first component (0 by default) */
  3463. x: number;
  3464. /** defines the second component (0 by default) */
  3465. y: number;
  3466. /** defines the third component (0 by default) */
  3467. z: number;
  3468. /** defines the fourth component (1.0 by default) */
  3469. w: number;
  3470. /**
  3471. * Creates a new Quaternion from the given floats
  3472. * @param x defines the first component (0 by default)
  3473. * @param y defines the second component (0 by default)
  3474. * @param z defines the third component (0 by default)
  3475. * @param w defines the fourth component (1.0 by default)
  3476. */
  3477. constructor(
  3478. /** defines the first component (0 by default) */
  3479. x?: number,
  3480. /** defines the second component (0 by default) */
  3481. y?: number,
  3482. /** defines the third component (0 by default) */
  3483. z?: number,
  3484. /** defines the fourth component (1.0 by default) */
  3485. w?: number);
  3486. /**
  3487. * Gets a string representation for the current quaternion
  3488. * @returns a string with the Quaternion coordinates
  3489. */
  3490. toString(): string;
  3491. /**
  3492. * Gets the class name of the quaternion
  3493. * @returns the string "Quaternion"
  3494. */
  3495. getClassName(): string;
  3496. /**
  3497. * Gets a hash code for this quaternion
  3498. * @returns the quaternion hash code
  3499. */
  3500. getHashCode(): number;
  3501. /**
  3502. * Copy the quaternion to an array
  3503. * @returns a new array populated with 4 elements from the quaternion coordinates
  3504. */
  3505. asArray(): number[];
  3506. /**
  3507. * Check if two quaternions are equals
  3508. * @param otherQuaternion defines the second operand
  3509. * @return true if the current quaternion and the given one coordinates are strictly equals
  3510. */
  3511. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3512. /**
  3513. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3514. * @param otherQuaternion defines the other quaternion
  3515. * @param epsilon defines the minimal distance to consider equality
  3516. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3517. */
  3518. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3519. /**
  3520. * Clone the current quaternion
  3521. * @returns a new quaternion copied from the current one
  3522. */
  3523. clone(): Quaternion;
  3524. /**
  3525. * Copy a quaternion to the current one
  3526. * @param other defines the other quaternion
  3527. * @returns the updated current quaternion
  3528. */
  3529. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3530. /**
  3531. * Updates the current quaternion with the given float coordinates
  3532. * @param x defines the x coordinate
  3533. * @param y defines the y coordinate
  3534. * @param z defines the z coordinate
  3535. * @param w defines the w coordinate
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3539. /**
  3540. * Updates the current quaternion from the given float coordinates
  3541. * @param x defines the x coordinate
  3542. * @param y defines the y coordinate
  3543. * @param z defines the z coordinate
  3544. * @param w defines the w coordinate
  3545. * @returns the updated current quaternion
  3546. */
  3547. set(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Adds two quaternions
  3550. * @param other defines the second operand
  3551. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3552. */
  3553. add(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Add a quaternion to the current one
  3556. * @param other defines the quaternion to add
  3557. * @returns the current quaternion
  3558. */
  3559. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3560. /**
  3561. * Subtract two quaternions
  3562. * @param other defines the second operand
  3563. * @returns a new quaternion as the subtraction result of the given one from the current one
  3564. */
  3565. subtract(other: Quaternion): Quaternion;
  3566. /**
  3567. * Multiplies the current quaternion by a scale factor
  3568. * @param value defines the scale factor
  3569. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3570. */
  3571. scale(value: number): Quaternion;
  3572. /**
  3573. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3574. * @param scale defines the scale factor
  3575. * @param result defines the Quaternion object where to store the result
  3576. * @returns the unmodified current quaternion
  3577. */
  3578. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3579. /**
  3580. * Multiplies in place the current quaternion by a scale factor
  3581. * @param value defines the scale factor
  3582. * @returns the current modified quaternion
  3583. */
  3584. scaleInPlace(value: number): Quaternion;
  3585. /**
  3586. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3587. * @param scale defines the scale factor
  3588. * @param result defines the Quaternion object where to store the result
  3589. * @returns the unmodified current quaternion
  3590. */
  3591. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3592. /**
  3593. * Multiplies two quaternions
  3594. * @param q1 defines the second operand
  3595. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3596. */
  3597. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3598. /**
  3599. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3600. * @param q1 defines the second operand
  3601. * @param result defines the target quaternion
  3602. * @returns the current quaternion
  3603. */
  3604. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3605. /**
  3606. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3607. * @param q1 defines the second operand
  3608. * @returns the currentupdated quaternion
  3609. */
  3610. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3611. /**
  3612. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3613. * @param ref defines the target quaternion
  3614. * @returns the current quaternion
  3615. */
  3616. conjugateToRef(ref: Quaternion): Quaternion;
  3617. /**
  3618. * Conjugates in place (1-q) the current quaternion
  3619. * @returns the current updated quaternion
  3620. */
  3621. conjugateInPlace(): Quaternion;
  3622. /**
  3623. * Conjugates in place (1-q) the current quaternion
  3624. * @returns a new quaternion
  3625. */
  3626. conjugate(): Quaternion;
  3627. /**
  3628. * Gets length of current quaternion
  3629. * @returns the quaternion length (float)
  3630. */
  3631. length(): number;
  3632. /**
  3633. * Normalize in place the current quaternion
  3634. * @returns the current updated quaternion
  3635. */
  3636. normalize(): Quaternion;
  3637. /**
  3638. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3639. * @param order is a reserved parameter and is ignore for now
  3640. * @returns a new Vector3 containing the Euler angles
  3641. */
  3642. toEulerAngles(order?: string): Vector3;
  3643. /**
  3644. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3645. * @param result defines the vector which will be filled with the Euler angles
  3646. * @param order is a reserved parameter and is ignore for now
  3647. * @returns the current unchanged quaternion
  3648. */
  3649. toEulerAnglesToRef(result: Vector3): Quaternion;
  3650. /**
  3651. * Updates the given rotation matrix with the current quaternion values
  3652. * @param result defines the target matrix
  3653. * @returns the current unchanged quaternion
  3654. */
  3655. toRotationMatrix(result: Matrix): Quaternion;
  3656. /**
  3657. * Updates the current quaternion from the given rotation matrix values
  3658. * @param matrix defines the source matrix
  3659. * @returns the current updated quaternion
  3660. */
  3661. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3662. /**
  3663. * Creates a new quaternion from a rotation matrix
  3664. * @param matrix defines the source matrix
  3665. * @returns a new quaternion created from the given rotation matrix values
  3666. */
  3667. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3668. /**
  3669. * Updates the given quaternion with the given rotation matrix values
  3670. * @param matrix defines the source matrix
  3671. * @param result defines the target quaternion
  3672. */
  3673. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3674. /**
  3675. * Returns the dot product (float) between the quaternions "left" and "right"
  3676. * @param left defines the left operand
  3677. * @param right defines the right operand
  3678. * @returns the dot product
  3679. */
  3680. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3681. /**
  3682. * Checks if the two quaternions are close to each other
  3683. * @param quat0 defines the first quaternion to check
  3684. * @param quat1 defines the second quaternion to check
  3685. * @returns true if the two quaternions are close to each other
  3686. */
  3687. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3688. /**
  3689. * Creates an empty quaternion
  3690. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3691. */
  3692. static Zero(): Quaternion;
  3693. /**
  3694. * Inverse a given quaternion
  3695. * @param q defines the source quaternion
  3696. * @returns a new quaternion as the inverted current quaternion
  3697. */
  3698. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3699. /**
  3700. * Inverse a given quaternion
  3701. * @param q defines the source quaternion
  3702. * @param result the quaternion the result will be stored in
  3703. * @returns the result quaternion
  3704. */
  3705. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3706. /**
  3707. * Creates an identity quaternion
  3708. * @returns the identity quaternion
  3709. */
  3710. static Identity(): Quaternion;
  3711. /**
  3712. * Gets a boolean indicating if the given quaternion is identity
  3713. * @param quaternion defines the quaternion to check
  3714. * @returns true if the quaternion is identity
  3715. */
  3716. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3717. /**
  3718. * Creates a quaternion from a rotation around an axis
  3719. * @param axis defines the axis to use
  3720. * @param angle defines the angle to use
  3721. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3722. */
  3723. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3724. /**
  3725. * Creates a rotation around an axis and stores it into the given quaternion
  3726. * @param axis defines the axis to use
  3727. * @param angle defines the angle to use
  3728. * @param result defines the target quaternion
  3729. * @returns the target quaternion
  3730. */
  3731. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3732. /**
  3733. * Creates a new quaternion from data stored into an array
  3734. * @param array defines the data source
  3735. * @param offset defines the offset in the source array where the data starts
  3736. * @returns a new quaternion
  3737. */
  3738. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3739. /**
  3740. * Updates the given quaternion "result" from the starting index of the given array.
  3741. * @param array the array to pull values from
  3742. * @param offset the offset into the array to start at
  3743. * @param result the quaternion to store the result in
  3744. */
  3745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3746. /**
  3747. * Create a quaternion from Euler rotation angles
  3748. * @param x Pitch
  3749. * @param y Yaw
  3750. * @param z Roll
  3751. * @returns the new Quaternion
  3752. */
  3753. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3754. /**
  3755. * Updates a quaternion from Euler rotation angles
  3756. * @param x Pitch
  3757. * @param y Yaw
  3758. * @param z Roll
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation vector
  3765. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation vector
  3771. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3772. * @param result the quaternion to store the result
  3773. * @returns the updated quaternion
  3774. */
  3775. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3776. /**
  3777. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3778. * @param yaw defines the rotation around Y axis
  3779. * @param pitch defines the rotation around X axis
  3780. * @param roll defines the rotation around Z axis
  3781. * @returns the new quaternion
  3782. */
  3783. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3784. /**
  3785. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3786. * @param yaw defines the rotation around Y axis
  3787. * @param pitch defines the rotation around X axis
  3788. * @param roll defines the rotation around Z axis
  3789. * @param result defines the target quaternion
  3790. */
  3791. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3792. /**
  3793. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3794. * @param alpha defines the rotation around first axis
  3795. * @param beta defines the rotation around second axis
  3796. * @param gamma defines the rotation around third axis
  3797. * @returns the new quaternion
  3798. */
  3799. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3800. /**
  3801. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3802. * @param alpha defines the rotation around first axis
  3803. * @param beta defines the rotation around second axis
  3804. * @param gamma defines the rotation around third axis
  3805. * @param result defines the target quaternion
  3806. */
  3807. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3808. /**
  3809. * 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)
  3810. * @param axis1 defines the first axis
  3811. * @param axis2 defines the second axis
  3812. * @param axis3 defines the third axis
  3813. * @returns the new quaternion
  3814. */
  3815. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3816. /**
  3817. * 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
  3818. * @param axis1 defines the first axis
  3819. * @param axis2 defines the second axis
  3820. * @param axis3 defines the third axis
  3821. * @param ref defines the target quaternion
  3822. */
  3823. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3824. /**
  3825. * Interpolates between two quaternions
  3826. * @param left defines first quaternion
  3827. * @param right defines second quaternion
  3828. * @param amount defines the gradient to use
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. /**
  3833. * Interpolates between two quaternions and stores it into a target quaternion
  3834. * @param left defines first quaternion
  3835. * @param right defines second quaternion
  3836. * @param amount defines the gradient to use
  3837. * @param result defines the target quaternion
  3838. */
  3839. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3840. /**
  3841. * Interpolate between two quaternions using Hermite interpolation
  3842. * @param value1 defines first quaternion
  3843. * @param tangent1 defines the incoming tangent
  3844. * @param value2 defines second quaternion
  3845. * @param tangent2 defines the outgoing tangent
  3846. * @param amount defines the target quaternion
  3847. * @returns the new interpolated quaternion
  3848. */
  3849. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3850. }
  3851. /**
  3852. * Class used to store matrix data (4x4)
  3853. */
  3854. export class Matrix {
  3855. private static _updateFlagSeed;
  3856. private static _identityReadOnly;
  3857. private _isIdentity;
  3858. private _isIdentityDirty;
  3859. private _isIdentity3x2;
  3860. private _isIdentity3x2Dirty;
  3861. /**
  3862. * Gets the update flag of the matrix which is an unique number for the matrix.
  3863. * It will be incremented every time the matrix data change.
  3864. * You can use it to speed the comparison between two versions of the same matrix.
  3865. */
  3866. updateFlag: number;
  3867. private readonly _m;
  3868. /**
  3869. * Gets the internal data of the matrix
  3870. */
  3871. get m(): DeepImmutable<Float32Array>;
  3872. /** @hidden */
  3873. _markAsUpdated(): void;
  3874. /** @hidden */
  3875. private _updateIdentityStatus;
  3876. /**
  3877. * Creates an empty matrix (filled with zeros)
  3878. */
  3879. constructor();
  3880. /**
  3881. * Check if the current matrix is identity
  3882. * @returns true is the matrix is the identity matrix
  3883. */
  3884. isIdentity(): boolean;
  3885. /**
  3886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3887. * @returns true is the matrix is the identity matrix
  3888. */
  3889. isIdentityAs3x2(): boolean;
  3890. /**
  3891. * Gets the determinant of the matrix
  3892. * @returns the matrix determinant
  3893. */
  3894. determinant(): number;
  3895. /**
  3896. * Returns the matrix as a Float32Array
  3897. * @returns the matrix underlying array
  3898. */
  3899. toArray(): DeepImmutable<Float32Array>;
  3900. /**
  3901. * Returns the matrix as a Float32Array
  3902. * @returns the matrix underlying array.
  3903. */
  3904. asArray(): DeepImmutable<Float32Array>;
  3905. /**
  3906. * Inverts the current matrix in place
  3907. * @returns the current inverted matrix
  3908. */
  3909. invert(): Matrix;
  3910. /**
  3911. * Sets all the matrix elements to zero
  3912. * @returns the current matrix
  3913. */
  3914. reset(): Matrix;
  3915. /**
  3916. * Adds the current matrix with a second one
  3917. * @param other defines the matrix to add
  3918. * @returns a new matrix as the addition of the current matrix and the given one
  3919. */
  3920. add(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3923. * @param other defines the matrix to add
  3924. * @param result defines the target matrix
  3925. * @returns the current matrix
  3926. */
  3927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3928. /**
  3929. * Adds in place the given matrix to the current matrix
  3930. * @param other defines the second operand
  3931. * @returns the current updated matrix
  3932. */
  3933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3934. /**
  3935. * Sets the given matrix to the current inverted Matrix
  3936. * @param other defines the target matrix
  3937. * @returns the unmodified current matrix
  3938. */
  3939. invertToRef(other: Matrix): Matrix;
  3940. /**
  3941. * add a value at the specified position in the current Matrix
  3942. * @param index the index of the value within the matrix. between 0 and 15.
  3943. * @param value the value to be added
  3944. * @returns the current updated matrix
  3945. */
  3946. addAtIndex(index: number, value: number): Matrix;
  3947. /**
  3948. * mutiply the specified position in the current Matrix by a value
  3949. * @param index the index of the value within the matrix. between 0 and 15.
  3950. * @param value the value to be added
  3951. * @returns the current updated matrix
  3952. */
  3953. multiplyAtIndex(index: number, value: number): Matrix;
  3954. /**
  3955. * Inserts the translation vector (using 3 floats) in the current matrix
  3956. * @param x defines the 1st component of the translation
  3957. * @param y defines the 2nd component of the translation
  3958. * @param z defines the 3rd component of the translation
  3959. * @returns the current updated matrix
  3960. */
  3961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3962. /**
  3963. * Adds the translation vector (using 3 floats) in the current matrix
  3964. * @param x defines the 1st component of the translation
  3965. * @param y defines the 2nd component of the translation
  3966. * @param z defines the 3rd component of the translation
  3967. * @returns the current updated matrix
  3968. */
  3969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3970. /**
  3971. * Inserts the translation vector in the current matrix
  3972. * @param vector3 defines the translation to insert
  3973. * @returns the current updated matrix
  3974. */
  3975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3976. /**
  3977. * Gets the translation value of the current matrix
  3978. * @returns a new Vector3 as the extracted translation from the matrix
  3979. */
  3980. getTranslation(): Vector3;
  3981. /**
  3982. * Fill a Vector3 with the extracted translation from the matrix
  3983. * @param result defines the Vector3 where to store the translation
  3984. * @returns the current matrix
  3985. */
  3986. getTranslationToRef(result: Vector3): Matrix;
  3987. /**
  3988. * Remove rotation and scaling part from the matrix
  3989. * @returns the updated matrix
  3990. */
  3991. removeRotationAndScaling(): Matrix;
  3992. /**
  3993. * Multiply two matrices
  3994. * @param other defines the second operand
  3995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3996. */
  3997. multiply(other: DeepImmutable<Matrix>): Matrix;
  3998. /**
  3999. * Copy the current matrix from the given one
  4000. * @param other defines the source matrix
  4001. * @returns the current updated matrix
  4002. */
  4003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Populates the given array from the starting index with the current matrix values
  4006. * @param array defines the target array
  4007. * @param offset defines the offset in the target array where to start storing values
  4008. * @returns the current matrix
  4009. */
  4010. copyToArray(array: Float32Array, offset?: number): Matrix;
  4011. /**
  4012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4013. * @param other defines the second operand
  4014. * @param result defines the matrix where to store the multiplication
  4015. * @returns the current matrix
  4016. */
  4017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4018. /**
  4019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4020. * @param other defines the second operand
  4021. * @param result defines the array where to store the multiplication
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4026. /**
  4027. * Check equality between this matrix and a second one
  4028. * @param value defines the second matrix to compare
  4029. * @returns true is the current matrix and the given one values are strictly equal
  4030. */
  4031. equals(value: DeepImmutable<Matrix>): boolean;
  4032. /**
  4033. * Clone the current matrix
  4034. * @returns a new matrix from the current matrix
  4035. */
  4036. clone(): Matrix;
  4037. /**
  4038. * Returns the name of the current matrix class
  4039. * @returns the string "Matrix"
  4040. */
  4041. getClassName(): string;
  4042. /**
  4043. * Gets the hash code of the current matrix
  4044. * @returns the hash code
  4045. */
  4046. getHashCode(): number;
  4047. /**
  4048. * Decomposes the current Matrix into a translation, rotation and scaling components
  4049. * @param scale defines the scale vector3 given as a reference to update
  4050. * @param rotation defines the rotation quaternion given as a reference to update
  4051. * @param translation defines the translation vector3 given as a reference to update
  4052. * @returns true if operation was successful
  4053. */
  4054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4055. /**
  4056. * Gets specific row of the matrix
  4057. * @param index defines the number of the row to get
  4058. * @returns the index-th row of the current matrix as a new Vector4
  4059. */
  4060. getRow(index: number): Nullable<Vector4>;
  4061. /**
  4062. * Sets the index-th row of the current matrix to the vector4 values
  4063. * @param index defines the number of the row to set
  4064. * @param row defines the target vector4
  4065. * @returns the updated current matrix
  4066. */
  4067. setRow(index: number, row: Vector4): Matrix;
  4068. /**
  4069. * Compute the transpose of the matrix
  4070. * @returns the new transposed matrix
  4071. */
  4072. transpose(): Matrix;
  4073. /**
  4074. * Compute the transpose of the matrix and store it in a given matrix
  4075. * @param result defines the target matrix
  4076. * @returns the current matrix
  4077. */
  4078. transposeToRef(result: Matrix): Matrix;
  4079. /**
  4080. * Sets the index-th row of the current matrix with the given 4 x float values
  4081. * @param index defines the row index
  4082. * @param x defines the x component to set
  4083. * @param y defines the y component to set
  4084. * @param z defines the z component to set
  4085. * @param w defines the w component to set
  4086. * @returns the updated current matrix
  4087. */
  4088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4089. /**
  4090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4091. * @param scale defines the scale factor
  4092. * @returns a new matrix
  4093. */
  4094. scale(scale: number): Matrix;
  4095. /**
  4096. * Scale the current matrix values by a factor to a given result matrix
  4097. * @param scale defines the scale factor
  4098. * @param result defines the matrix to store the result
  4099. * @returns the current matrix
  4100. */
  4101. scaleToRef(scale: number, result: Matrix): Matrix;
  4102. /**
  4103. * Scale the current matrix values by a factor and add the result to a given matrix
  4104. * @param scale defines the scale factor
  4105. * @param result defines the Matrix to store the result
  4106. * @returns the current matrix
  4107. */
  4108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4109. /**
  4110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4111. * @param ref matrix to store the result
  4112. */
  4113. toNormalMatrix(ref: Matrix): void;
  4114. /**
  4115. * Gets only rotation part of the current matrix
  4116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4117. */
  4118. getRotationMatrix(): Matrix;
  4119. /**
  4120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4121. * @param result defines the target matrix to store data to
  4122. * @returns the current matrix
  4123. */
  4124. getRotationMatrixToRef(result: Matrix): Matrix;
  4125. /**
  4126. * Toggles model matrix from being right handed to left handed in place and vice versa
  4127. */
  4128. toggleModelMatrixHandInPlace(): void;
  4129. /**
  4130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleProjectionMatrixHandInPlace(): void;
  4133. /**
  4134. * Creates a matrix from an array
  4135. * @param array defines the source array
  4136. * @param offset defines an offset in the source array
  4137. * @returns a new Matrix set from the starting index of the given array
  4138. */
  4139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4140. /**
  4141. * Copy the content of an array into a given matrix
  4142. * @param array defines the source array
  4143. * @param offset defines an offset in the source array
  4144. * @param result defines the target matrix
  4145. */
  4146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4147. /**
  4148. * Stores an array into a matrix after having multiplied each component by a given factor
  4149. * @param array defines the source array
  4150. * @param offset defines the offset in the source array
  4151. * @param scale defines the scaling factor
  4152. * @param result defines the target matrix
  4153. */
  4154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4155. /**
  4156. * Gets an identity matrix that must not be updated
  4157. */
  4158. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4159. /**
  4160. * Stores a list of values (16) inside a given matrix
  4161. * @param initialM11 defines 1st value of 1st row
  4162. * @param initialM12 defines 2nd value of 1st row
  4163. * @param initialM13 defines 3rd value of 1st row
  4164. * @param initialM14 defines 4th value of 1st row
  4165. * @param initialM21 defines 1st value of 2nd row
  4166. * @param initialM22 defines 2nd value of 2nd row
  4167. * @param initialM23 defines 3rd value of 2nd row
  4168. * @param initialM24 defines 4th value of 2nd row
  4169. * @param initialM31 defines 1st value of 3rd row
  4170. * @param initialM32 defines 2nd value of 3rd row
  4171. * @param initialM33 defines 3rd value of 3rd row
  4172. * @param initialM34 defines 4th value of 3rd row
  4173. * @param initialM41 defines 1st value of 4th row
  4174. * @param initialM42 defines 2nd value of 4th row
  4175. * @param initialM43 defines 3rd value of 4th row
  4176. * @param initialM44 defines 4th value of 4th row
  4177. * @param result defines the target matrix
  4178. */
  4179. 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;
  4180. /**
  4181. * Creates new matrix from a list of values (16)
  4182. * @param initialM11 defines 1st value of 1st row
  4183. * @param initialM12 defines 2nd value of 1st row
  4184. * @param initialM13 defines 3rd value of 1st row
  4185. * @param initialM14 defines 4th value of 1st row
  4186. * @param initialM21 defines 1st value of 2nd row
  4187. * @param initialM22 defines 2nd value of 2nd row
  4188. * @param initialM23 defines 3rd value of 2nd row
  4189. * @param initialM24 defines 4th value of 2nd row
  4190. * @param initialM31 defines 1st value of 3rd row
  4191. * @param initialM32 defines 2nd value of 3rd row
  4192. * @param initialM33 defines 3rd value of 3rd row
  4193. * @param initialM34 defines 4th value of 3rd row
  4194. * @param initialM41 defines 1st value of 4th row
  4195. * @param initialM42 defines 2nd value of 4th row
  4196. * @param initialM43 defines 3rd value of 4th row
  4197. * @param initialM44 defines 4th value of 4th row
  4198. * @returns the new matrix
  4199. */
  4200. 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;
  4201. /**
  4202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4203. * @param scale defines the scale vector3
  4204. * @param rotation defines the rotation quaternion
  4205. * @param translation defines the translation vector3
  4206. * @returns a new matrix
  4207. */
  4208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4211. * @param scale defines the scale vector3
  4212. * @param rotation defines the rotation quaternion
  4213. * @param translation defines the translation vector3
  4214. * @param result defines the target matrix
  4215. */
  4216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4217. /**
  4218. * Creates a new identity matrix
  4219. * @returns a new identity matrix
  4220. */
  4221. static Identity(): Matrix;
  4222. /**
  4223. * Creates a new identity matrix and stores the result in a given matrix
  4224. * @param result defines the target matrix
  4225. */
  4226. static IdentityToRef(result: Matrix): void;
  4227. /**
  4228. * Creates a new zero matrix
  4229. * @returns a new zero matrix
  4230. */
  4231. static Zero(): Matrix;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the X axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationX(angle: number): Matrix;
  4238. /**
  4239. * Creates a new matrix as the invert of a given matrix
  4240. * @param source defines the source matrix
  4241. * @returns the new matrix
  4242. */
  4243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4246. * @param angle defines the angle (in radians) to use
  4247. * @param result defines the target matrix
  4248. */
  4249. static RotationXToRef(angle: number, result: Matrix): void;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Y axis
  4252. * @param angle defines the angle (in radians) to use
  4253. * @return the new matrix
  4254. */
  4255. static RotationY(angle: number): Matrix;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4258. * @param angle defines the angle (in radians) to use
  4259. * @param result defines the target matrix
  4260. */
  4261. static RotationYToRef(angle: number, result: Matrix): void;
  4262. /**
  4263. * Creates a new rotation matrix for "angle" radians around the Z axis
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationZ(angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4270. * @param angle defines the angle (in radians) to use
  4271. * @param result defines the target matrix
  4272. */
  4273. static RotationZToRef(angle: number, result: Matrix): void;
  4274. /**
  4275. * Creates a new rotation matrix for "angle" radians around the given axis
  4276. * @param axis defines the axis to use
  4277. * @param angle defines the angle (in radians) to use
  4278. * @return the new matrix
  4279. */
  4280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4283. * @param axis defines the axis to use
  4284. * @param angle defines the angle (in radians) to use
  4285. * @param result defines the target matrix
  4286. */
  4287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4288. /**
  4289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4291. * @param from defines the vector to align
  4292. * @param to defines the vector to align to
  4293. * @param result defines the target matrix
  4294. */
  4295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4296. /**
  4297. * Creates a rotation matrix
  4298. * @param yaw defines the yaw angle in radians (Y axis)
  4299. * @param pitch defines the pitch angle in radians (X axis)
  4300. * @param roll defines the roll angle in radians (X axis)
  4301. * @returns the new rotation matrix
  4302. */
  4303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4304. /**
  4305. * Creates a rotation matrix and stores it in a given matrix
  4306. * @param yaw defines the yaw angle in radians (Y axis)
  4307. * @param pitch defines the pitch angle in radians (X axis)
  4308. * @param roll defines the roll angle in radians (X axis)
  4309. * @param result defines the target matrix
  4310. */
  4311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4312. /**
  4313. * Creates a scaling matrix
  4314. * @param x defines the scale factor on X axis
  4315. * @param y defines the scale factor on Y axis
  4316. * @param z defines the scale factor on Z axis
  4317. * @returns the new matrix
  4318. */
  4319. static Scaling(x: number, y: number, z: number): Matrix;
  4320. /**
  4321. * Creates a scaling matrix and stores it in a given matrix
  4322. * @param x defines the scale factor on X axis
  4323. * @param y defines the scale factor on Y axis
  4324. * @param z defines the scale factor on Z axis
  4325. * @param result defines the target matrix
  4326. */
  4327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4328. /**
  4329. * Creates a translation matrix
  4330. * @param x defines the translation on X axis
  4331. * @param y defines the translation on Y axis
  4332. * @param z defines the translationon Z axis
  4333. * @returns the new matrix
  4334. */
  4335. static Translation(x: number, y: number, z: number): Matrix;
  4336. /**
  4337. * Creates a translation matrix and stores it in a given matrix
  4338. * @param x defines the translation on X axis
  4339. * @param y defines the translation on Y axis
  4340. * @param z defines the translationon Z axis
  4341. * @param result defines the target matrix
  4342. */
  4343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4344. /**
  4345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4346. * @param startValue defines the start value
  4347. * @param endValue defines the end value
  4348. * @param gradient defines the gradient factor
  4349. * @returns the new matrix
  4350. */
  4351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4352. /**
  4353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4354. * @param startValue defines the start value
  4355. * @param endValue defines the end value
  4356. * @param gradient defines the gradient factor
  4357. * @param result defines the Matrix object where to store data
  4358. */
  4359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4360. /**
  4361. * Builds a new matrix whose values are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @returns the new matrix
  4369. */
  4370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4371. /**
  4372. * Update a matrix to values which are computed by:
  4373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4376. * @param startValue defines the first matrix
  4377. * @param endValue defines the second matrix
  4378. * @param gradient defines the gradient between the two matrices
  4379. * @param result defines the target matrix
  4380. */
  4381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in left handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * 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"
  4402. * This function works in right handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @returns the new matrix
  4407. */
  4408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4409. /**
  4410. * 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".
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @param result defines the target matrix
  4416. */
  4417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param width defines the viewport width
  4421. * @param height defines the viewport height
  4422. * @param znear defines the near clip plane
  4423. * @param zfar defines the far clip plane
  4424. * @returns a new matrix as a left-handed orthographic projection matrix
  4425. */
  4426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4427. /**
  4428. * Store a left-handed orthographic projection to a given matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @param result defines the target matrix
  4434. */
  4435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4436. /**
  4437. * Create a left-handed orthographic projection matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @returns a new matrix as a left-handed orthographic projection matrix
  4445. */
  4446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4447. /**
  4448. * Stores a left-handed orthographic projection into a given matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @param result defines the target matrix
  4456. */
  4457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4458. /**
  4459. * Creates a right-handed orthographic projection matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a right-handed orthographic projection matrix
  4467. */
  4468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed orthographic projection into a given matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @param result defines the target matrix
  4478. */
  4479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4480. /**
  4481. * Creates a left-handed perspective projection matrix
  4482. * @param width defines the viewport width
  4483. * @param height defines the viewport height
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @returns a new matrix as a left-handed perspective projection matrix
  4487. */
  4488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Stores a left-handed perspective projection into a given matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @param result defines the target matrix
  4505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4506. */
  4507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4508. /**
  4509. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar not used as infinity is used as far clip
  4514. * @param result defines the target matrix
  4515. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4516. */
  4517. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4518. /**
  4519. * Creates a right-handed perspective projection matrix
  4520. * @param fov defines the horizontal field of view
  4521. * @param aspect defines the aspect ratio
  4522. * @param znear defines the near clip plane
  4523. * @param zfar defines the far clip plane
  4524. * @returns a new matrix as a right-handed perspective projection matrix
  4525. */
  4526. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4527. /**
  4528. * Stores a right-handed perspective projection into a given matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @param result defines the target matrix
  4534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4535. */
  4536. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4537. /**
  4538. * Stores a right-handed perspective projection into a given matrix
  4539. * @param fov defines the horizontal field of view
  4540. * @param aspect defines the aspect ratio
  4541. * @param znear defines the near clip plane
  4542. * @param zfar not used as infinity is used as far clip
  4543. * @param result defines the target matrix
  4544. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4545. */
  4546. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4547. /**
  4548. * Stores a perspective projection for WebVR info a given matrix
  4549. * @param fov defines the field of view
  4550. * @param znear defines the near clip plane
  4551. * @param zfar defines the far clip plane
  4552. * @param result defines the target matrix
  4553. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4554. */
  4555. static PerspectiveFovWebVRToRef(fov: {
  4556. upDegrees: number;
  4557. downDegrees: number;
  4558. leftDegrees: number;
  4559. rightDegrees: number;
  4560. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4561. /**
  4562. * Computes a complete transformation matrix
  4563. * @param viewport defines the viewport to use
  4564. * @param world defines the world matrix
  4565. * @param view defines the view matrix
  4566. * @param projection defines the projection matrix
  4567. * @param zmin defines the near clip plane
  4568. * @param zmax defines the far clip plane
  4569. * @returns the transformation matrix
  4570. */
  4571. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4572. /**
  4573. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4574. * @param matrix defines the matrix to use
  4575. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4576. */
  4577. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4578. /**
  4579. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4580. * @param matrix defines the matrix to use
  4581. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4582. */
  4583. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4584. /**
  4585. * Compute the transpose of a given matrix
  4586. * @param matrix defines the matrix to transpose
  4587. * @returns the new matrix
  4588. */
  4589. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4590. /**
  4591. * Compute the transpose of a matrix and store it in a target matrix
  4592. * @param matrix defines the matrix to transpose
  4593. * @param result defines the target matrix
  4594. */
  4595. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4596. /**
  4597. * Computes a reflection matrix from a plane
  4598. * @param plane defines the reflection plane
  4599. * @returns a new matrix
  4600. */
  4601. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4602. /**
  4603. * Computes a reflection matrix from a plane
  4604. * @param plane defines the reflection plane
  4605. * @param result defines the target matrix
  4606. */
  4607. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4608. /**
  4609. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4610. * @param xaxis defines the value of the 1st axis
  4611. * @param yaxis defines the value of the 2nd axis
  4612. * @param zaxis defines the value of the 3rd axis
  4613. * @param result defines the target matrix
  4614. */
  4615. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4616. /**
  4617. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4618. * @param quat defines the quaternion to use
  4619. * @param result defines the target matrix
  4620. */
  4621. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4622. }
  4623. /**
  4624. * @hidden
  4625. */
  4626. export class TmpVectors {
  4627. static Vector2: Vector2[];
  4628. static Vector3: Vector3[];
  4629. static Vector4: Vector4[];
  4630. static Quaternion: Quaternion[];
  4631. static Matrix: Matrix[];
  4632. }
  4633. }
  4634. declare module BABYLON {
  4635. /**
  4636. * Defines potential orientation for back face culling
  4637. */
  4638. export enum Orientation {
  4639. /**
  4640. * Clockwise
  4641. */
  4642. CW = 0,
  4643. /** Counter clockwise */
  4644. CCW = 1
  4645. }
  4646. /** Class used to represent a Bezier curve */
  4647. export class BezierCurve {
  4648. /**
  4649. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4650. * @param t defines the time
  4651. * @param x1 defines the left coordinate on X axis
  4652. * @param y1 defines the left coordinate on Y axis
  4653. * @param x2 defines the right coordinate on X axis
  4654. * @param y2 defines the right coordinate on Y axis
  4655. * @returns the interpolated value
  4656. */
  4657. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4658. }
  4659. /**
  4660. * Defines angle representation
  4661. */
  4662. export class Angle {
  4663. private _radians;
  4664. /**
  4665. * Creates an Angle object of "radians" radians (float).
  4666. * @param radians the angle in radians
  4667. */
  4668. constructor(radians: number);
  4669. /**
  4670. * Get value in degrees
  4671. * @returns the Angle value in degrees (float)
  4672. */
  4673. degrees(): number;
  4674. /**
  4675. * Get value in radians
  4676. * @returns the Angle value in radians (float)
  4677. */
  4678. radians(): number;
  4679. /**
  4680. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4681. * @param a defines first vector
  4682. * @param b defines second vector
  4683. * @returns a new Angle
  4684. */
  4685. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4686. /**
  4687. * Gets a new Angle object from the given float in radians
  4688. * @param radians defines the angle value in radians
  4689. * @returns a new Angle
  4690. */
  4691. static FromRadians(radians: number): Angle;
  4692. /**
  4693. * Gets a new Angle object from the given float in degrees
  4694. * @param degrees defines the angle value in degrees
  4695. * @returns a new Angle
  4696. */
  4697. static FromDegrees(degrees: number): Angle;
  4698. }
  4699. /**
  4700. * This represents an arc in a 2d space.
  4701. */
  4702. export class Arc2 {
  4703. /** Defines the start point of the arc */
  4704. startPoint: Vector2;
  4705. /** Defines the mid point of the arc */
  4706. midPoint: Vector2;
  4707. /** Defines the end point of the arc */
  4708. endPoint: Vector2;
  4709. /**
  4710. * Defines the center point of the arc.
  4711. */
  4712. centerPoint: Vector2;
  4713. /**
  4714. * Defines the radius of the arc.
  4715. */
  4716. radius: number;
  4717. /**
  4718. * Defines the angle of the arc (from mid point to end point).
  4719. */
  4720. angle: Angle;
  4721. /**
  4722. * Defines the start angle of the arc (from start point to middle point).
  4723. */
  4724. startAngle: Angle;
  4725. /**
  4726. * Defines the orientation of the arc (clock wise/counter clock wise).
  4727. */
  4728. orientation: Orientation;
  4729. /**
  4730. * Creates an Arc object from the three given points : start, middle and end.
  4731. * @param startPoint Defines the start point of the arc
  4732. * @param midPoint Defines the midlle point of the arc
  4733. * @param endPoint Defines the end point of the arc
  4734. */
  4735. constructor(
  4736. /** Defines the start point of the arc */
  4737. startPoint: Vector2,
  4738. /** Defines the mid point of the arc */
  4739. midPoint: Vector2,
  4740. /** Defines the end point of the arc */
  4741. endPoint: Vector2);
  4742. }
  4743. /**
  4744. * Represents a 2D path made up of multiple 2D points
  4745. */
  4746. export class Path2 {
  4747. private _points;
  4748. private _length;
  4749. /**
  4750. * If the path start and end point are the same
  4751. */
  4752. closed: boolean;
  4753. /**
  4754. * Creates a Path2 object from the starting 2D coordinates x and y.
  4755. * @param x the starting points x value
  4756. * @param y the starting points y value
  4757. */
  4758. constructor(x: number, y: number);
  4759. /**
  4760. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4761. * @param x the added points x value
  4762. * @param y the added points y value
  4763. * @returns the updated Path2.
  4764. */
  4765. addLineTo(x: number, y: number): Path2;
  4766. /**
  4767. * 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.
  4768. * @param midX middle point x value
  4769. * @param midY middle point y value
  4770. * @param endX end point x value
  4771. * @param endY end point y value
  4772. * @param numberOfSegments (default: 36)
  4773. * @returns the updated Path2.
  4774. */
  4775. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4776. /**
  4777. * Closes the Path2.
  4778. * @returns the Path2.
  4779. */
  4780. close(): Path2;
  4781. /**
  4782. * Gets the sum of the distance between each sequential point in the path
  4783. * @returns the Path2 total length (float).
  4784. */
  4785. length(): number;
  4786. /**
  4787. * Gets the points which construct the path
  4788. * @returns the Path2 internal array of points.
  4789. */
  4790. getPoints(): Vector2[];
  4791. /**
  4792. * Retreives the point at the distance aways from the starting point
  4793. * @param normalizedLengthPosition the length along the path to retreive the point from
  4794. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4795. */
  4796. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4797. /**
  4798. * Creates a new path starting from an x and y position
  4799. * @param x starting x value
  4800. * @param y starting y value
  4801. * @returns a new Path2 starting at the coordinates (x, y).
  4802. */
  4803. static StartingAt(x: number, y: number): Path2;
  4804. }
  4805. /**
  4806. * Represents a 3D path made up of multiple 3D points
  4807. */
  4808. export class Path3D {
  4809. /**
  4810. * an array of Vector3, the curve axis of the Path3D
  4811. */
  4812. path: Vector3[];
  4813. private _curve;
  4814. private _distances;
  4815. private _tangents;
  4816. private _normals;
  4817. private _binormals;
  4818. private _raw;
  4819. private _alignTangentsWithPath;
  4820. private readonly _pointAtData;
  4821. /**
  4822. * new Path3D(path, normal, raw)
  4823. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4824. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4825. * @param path an array of Vector3, the curve axis of the Path3D
  4826. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4827. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4829. */
  4830. constructor(
  4831. /**
  4832. * an array of Vector3, the curve axis of the Path3D
  4833. */
  4834. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4835. /**
  4836. * Returns the Path3D array of successive Vector3 designing its curve.
  4837. * @returns the Path3D array of successive Vector3 designing its curve.
  4838. */
  4839. getCurve(): Vector3[];
  4840. /**
  4841. * Returns the Path3D array of successive Vector3 designing its curve.
  4842. * @returns the Path3D array of successive Vector3 designing its curve.
  4843. */
  4844. getPoints(): Vector3[];
  4845. /**
  4846. * @returns the computed length (float) of the path.
  4847. */
  4848. length(): number;
  4849. /**
  4850. * Returns an array populated with tangent vectors on each Path3D curve point.
  4851. * @returns an array populated with tangent vectors on each Path3D curve point.
  4852. */
  4853. getTangents(): Vector3[];
  4854. /**
  4855. * Returns an array populated with normal vectors on each Path3D curve point.
  4856. * @returns an array populated with normal vectors on each Path3D curve point.
  4857. */
  4858. getNormals(): Vector3[];
  4859. /**
  4860. * Returns an array populated with binormal vectors on each Path3D curve point.
  4861. * @returns an array populated with binormal vectors on each Path3D curve point.
  4862. */
  4863. getBinormals(): Vector3[];
  4864. /**
  4865. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4866. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4867. */
  4868. getDistances(): number[];
  4869. /**
  4870. * Returns an interpolated point along this path
  4871. * @param position the position of the point along this path, from 0.0 to 1.0
  4872. * @returns a new Vector3 as the point
  4873. */
  4874. getPointAt(position: number): Vector3;
  4875. /**
  4876. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4877. * @param position the position of the point along this path, from 0.0 to 1.0
  4878. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4879. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4880. */
  4881. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4882. /**
  4883. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4886. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4887. */
  4888. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4889. /**
  4890. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4891. * @param position the position of the point along this path, from 0.0 to 1.0
  4892. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4893. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4894. */
  4895. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4896. /**
  4897. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4900. */
  4901. getDistanceAt(position: number): number;
  4902. /**
  4903. * Returns the array index of the previous point of an interpolated point along this path
  4904. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4905. * @returns the array index
  4906. */
  4907. getPreviousPointIndexAt(position: number): number;
  4908. /**
  4909. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4910. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4911. * @returns the sub position
  4912. */
  4913. getSubPositionAt(position: number): number;
  4914. /**
  4915. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4916. * @param target the vector of which to get the closest position to
  4917. * @returns the position of the closest virtual point on this path to the target vector
  4918. */
  4919. getClosestPositionTo(target: Vector3): number;
  4920. /**
  4921. * Returns a sub path (slice) of this path
  4922. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4923. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4924. * @returns a sub path (slice) of this path
  4925. */
  4926. slice(start?: number, end?: number): Path3D;
  4927. /**
  4928. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4929. * @param path path which all values are copied into the curves points
  4930. * @param firstNormal which should be projected onto the curve
  4931. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4932. * @returns the same object updated.
  4933. */
  4934. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4935. private _compute;
  4936. private _getFirstNonNullVector;
  4937. private _getLastNonNullVector;
  4938. private _normalVector;
  4939. /**
  4940. * Updates the point at data for an interpolated point along this curve
  4941. * @param position the position of the point along this curve, from 0.0 to 1.0
  4942. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4943. * @returns the (updated) point at data
  4944. */
  4945. private _updatePointAtData;
  4946. /**
  4947. * Updates the point at data from the specified parameters
  4948. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4949. * @param point the interpolated point
  4950. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4951. */
  4952. private _setPointAtData;
  4953. /**
  4954. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4955. */
  4956. private _updateInterpolationMatrix;
  4957. }
  4958. /**
  4959. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4960. * A Curve3 is designed from a series of successive Vector3.
  4961. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4962. */
  4963. export class Curve3 {
  4964. private _points;
  4965. private _length;
  4966. /**
  4967. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4969. * @param v1 (Vector3) the control point
  4970. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4971. * @param nbPoints (integer) the wanted number of points in the curve
  4972. * @returns the created Curve3
  4973. */
  4974. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4975. /**
  4976. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4978. * @param v1 (Vector3) the first control point
  4979. * @param v2 (Vector3) the second control point
  4980. * @param v3 (Vector3) the end point of the Cubic Bezier
  4981. * @param nbPoints (integer) the wanted number of points in the curve
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4985. /**
  4986. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4987. * @param p1 (Vector3) the origin point of the Hermite Spline
  4988. * @param t1 (Vector3) the tangent vector at the origin point
  4989. * @param p2 (Vector3) the end point of the Hermite Spline
  4990. * @param t2 (Vector3) the tangent vector at the end point
  4991. * @param nbPoints (integer) the wanted number of points in the curve
  4992. * @returns the created Curve3
  4993. */
  4994. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4995. /**
  4996. * Returns a Curve3 object along a CatmullRom Spline curve :
  4997. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4998. * @param nbPoints (integer) the wanted number of points between each curve control points
  4999. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5000. * @returns the created Curve3
  5001. */
  5002. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5003. /**
  5004. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5005. * A Curve3 is designed from a series of successive Vector3.
  5006. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5007. * @param points points which make up the curve
  5008. */
  5009. constructor(points: Vector3[]);
  5010. /**
  5011. * @returns the Curve3 stored array of successive Vector3
  5012. */
  5013. getPoints(): Vector3[];
  5014. /**
  5015. * @returns the computed length (float) of the curve.
  5016. */
  5017. length(): number;
  5018. /**
  5019. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5020. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5021. * curveA and curveB keep unchanged.
  5022. * @param curve the curve to continue from this curve
  5023. * @returns the newly constructed curve
  5024. */
  5025. continue(curve: DeepImmutable<Curve3>): Curve3;
  5026. private _computeLength;
  5027. }
  5028. }
  5029. declare module BABYLON {
  5030. /**
  5031. * This represents the main contract an easing function should follow.
  5032. * Easing functions are used throughout the animation system.
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export interface IEasingFunction {
  5036. /**
  5037. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5038. * of the easing function.
  5039. * The link below provides some of the most common examples of easing functions.
  5040. * @see https://easings.net/
  5041. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5042. * @returns the corresponding value on the curve defined by the easing function
  5043. */
  5044. ease(gradient: number): number;
  5045. }
  5046. /**
  5047. * Base class used for every default easing function.
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class EasingFunction implements IEasingFunction {
  5051. /**
  5052. * Interpolation follows the mathematical formula associated with the easing function.
  5053. */
  5054. static readonly EASINGMODE_EASEIN: number;
  5055. /**
  5056. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEOUT: number;
  5059. /**
  5060. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5061. */
  5062. static readonly EASINGMODE_EASEINOUT: number;
  5063. private _easingMode;
  5064. /**
  5065. * Sets the easing mode of the current function.
  5066. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5067. */
  5068. setEasingMode(easingMode: number): void;
  5069. /**
  5070. * Gets the current easing mode.
  5071. * @returns the easing mode
  5072. */
  5073. getEasingMode(): number;
  5074. /**
  5075. * @hidden
  5076. */
  5077. easeInCore(gradient: number): number;
  5078. /**
  5079. * Given an input gradient between 0 and 1, this returns the corresponding value
  5080. * of the easing function.
  5081. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5082. * @returns the corresponding value on the curve defined by the easing function
  5083. */
  5084. ease(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a circle shape (see link below).
  5088. * @see https://easings.net/#easeInCirc
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class CircleEase extends EasingFunction implements IEasingFunction {
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a ease back shape (see link below).
  5097. * @see https://easings.net/#easeInBack
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class BackEase extends EasingFunction implements IEasingFunction {
  5101. /** Defines the amplitude of the function */
  5102. amplitude: number;
  5103. /**
  5104. * Instantiates a back ease easing
  5105. * @see https://easings.net/#easeInBack
  5106. * @param amplitude Defines the amplitude of the function
  5107. */
  5108. constructor(
  5109. /** Defines the amplitude of the function */
  5110. amplitude?: number);
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a bouncing shape (see link below).
  5116. * @see https://easings.net/#easeInBounce
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BounceEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the number of bounces */
  5121. bounces: number;
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness: number;
  5124. /**
  5125. * Instantiates a bounce easing
  5126. * @see https://easings.net/#easeInBounce
  5127. * @param bounces Defines the number of bounces
  5128. * @param bounciness Defines the amplitude of the bounce
  5129. */
  5130. constructor(
  5131. /** Defines the number of bounces */
  5132. bounces?: number,
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness?: number);
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with a power of 3 shape (see link below).
  5140. * @see https://easings.net/#easeInCubic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class CubicEase extends EasingFunction implements IEasingFunction {
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with an elastic shape (see link below).
  5149. * @see https://easings.net/#easeInElastic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the number of oscillations*/
  5154. oscillations: number;
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness: number;
  5157. /**
  5158. * Instantiates an elastic easing function
  5159. * @see https://easings.net/#easeInElastic
  5160. * @param oscillations Defines the number of oscillations
  5161. * @param springiness Defines the amplitude of the oscillations
  5162. */
  5163. constructor(
  5164. /** Defines the number of oscillations*/
  5165. oscillations?: number,
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness?: number);
  5168. /** @hidden */
  5169. easeInCore(gradient: number): number;
  5170. }
  5171. /**
  5172. * Easing function with an exponential shape (see link below).
  5173. * @see https://easings.net/#easeInExpo
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5177. /** Defines the exponent of the function */
  5178. exponent: number;
  5179. /**
  5180. * Instantiates an exponential easing function
  5181. * @see https://easings.net/#easeInExpo
  5182. * @param exponent Defines the exponent of the function
  5183. */
  5184. constructor(
  5185. /** Defines the exponent of the function */
  5186. exponent?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with a power shape (see link below).
  5192. * @see https://easings.net/#easeInQuad
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class PowerEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the power of the function */
  5197. power: number;
  5198. /**
  5199. * Instantiates an power base easing function
  5200. * @see https://easings.net/#easeInQuad
  5201. * @param power Defines the power of the function
  5202. */
  5203. constructor(
  5204. /** Defines the power of the function */
  5205. power?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 2 shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 4 shape (see link below).
  5220. * @see https://easings.net/#easeInQuart
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 5 shape (see link below).
  5229. * @see https://easings.net/#easeInQuint
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a sin shape (see link below).
  5238. * @see https://easings.net/#easeInSine
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class SineEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a bezier shape (see link below).
  5247. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1: number;
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1: number;
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2: number;
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2: number;
  5259. /**
  5260. * Instantiates a bezier function
  5261. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5262. * @param x1 Defines the x component of the start tangent in the bezier curve
  5263. * @param y1 Defines the y component of the start tangent in the bezier curve
  5264. * @param x2 Defines the x component of the end tangent in the bezier curve
  5265. * @param y2 Defines the y component of the end tangent in the bezier curve
  5266. */
  5267. constructor(
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1?: number,
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1?: number,
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2?: number,
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. }
  5280. declare module BABYLON {
  5281. /**
  5282. * Class used to hold a RBG color
  5283. */
  5284. export class Color3 {
  5285. /**
  5286. * Defines the red component (between 0 and 1, default is 0)
  5287. */
  5288. r: number;
  5289. /**
  5290. * Defines the green component (between 0 and 1, default is 0)
  5291. */
  5292. g: number;
  5293. /**
  5294. * Defines the blue component (between 0 and 1, default is 0)
  5295. */
  5296. b: number;
  5297. /**
  5298. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5299. * @param r defines the red component (between 0 and 1, default is 0)
  5300. * @param g defines the green component (between 0 and 1, default is 0)
  5301. * @param b defines the blue component (between 0 and 1, default is 0)
  5302. */
  5303. constructor(
  5304. /**
  5305. * Defines the red component (between 0 and 1, default is 0)
  5306. */
  5307. r?: number,
  5308. /**
  5309. * Defines the green component (between 0 and 1, default is 0)
  5310. */
  5311. g?: number,
  5312. /**
  5313. * Defines the blue component (between 0 and 1, default is 0)
  5314. */
  5315. b?: number);
  5316. /**
  5317. * Creates a string with the Color3 current values
  5318. * @returns the string representation of the Color3 object
  5319. */
  5320. toString(): string;
  5321. /**
  5322. * Returns the string "Color3"
  5323. * @returns "Color3"
  5324. */
  5325. getClassName(): string;
  5326. /**
  5327. * Compute the Color3 hash code
  5328. * @returns an unique number that can be used to hash Color3 objects
  5329. */
  5330. getHashCode(): number;
  5331. /**
  5332. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5333. * @param array defines the array where to store the r,g,b components
  5334. * @param index defines an optional index in the target array to define where to start storing values
  5335. * @returns the current Color3 object
  5336. */
  5337. toArray(array: FloatArray, index?: number): Color3;
  5338. /**
  5339. * Returns a new Color4 object from the current Color3 and the given alpha
  5340. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5341. * @returns a new Color4 object
  5342. */
  5343. toColor4(alpha?: number): Color4;
  5344. /**
  5345. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5346. * @returns the new array
  5347. */
  5348. asArray(): number[];
  5349. /**
  5350. * Returns the luminance value
  5351. * @returns a float value
  5352. */
  5353. toLuminance(): number;
  5354. /**
  5355. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5356. * @param otherColor defines the second operand
  5357. * @returns the new Color3 object
  5358. */
  5359. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5360. /**
  5361. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5362. * @param otherColor defines the second operand
  5363. * @param result defines the Color3 object where to store the result
  5364. * @returns the current Color3
  5365. */
  5366. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5367. /**
  5368. * Determines equality between Color3 objects
  5369. * @param otherColor defines the second operand
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equals(otherColor: DeepImmutable<Color3>): boolean;
  5373. /**
  5374. * Determines equality between the current Color3 object and a set of r,b,g values
  5375. * @param r defines the red component to check
  5376. * @param g defines the green component to check
  5377. * @param b defines the blue component to check
  5378. * @returns true if the rgb values are equal to the given ones
  5379. */
  5380. equalsFloats(r: number, g: number, b: number): boolean;
  5381. /**
  5382. * Multiplies in place each rgb value by scale
  5383. * @param scale defines the scaling factor
  5384. * @returns the updated Color3
  5385. */
  5386. scale(scale: number): Color3;
  5387. /**
  5388. * Multiplies the rgb values by scale and stores the result into "result"
  5389. * @param scale defines the scaling factor
  5390. * @param result defines the Color3 object where to store the result
  5391. * @returns the unmodified current Color3
  5392. */
  5393. scaleToRef(scale: number, result: Color3): Color3;
  5394. /**
  5395. * Scale the current Color3 values by a factor and add the result to a given Color3
  5396. * @param scale defines the scale factor
  5397. * @param result defines color to store the result into
  5398. * @returns the unmodified current Color3
  5399. */
  5400. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5401. /**
  5402. * Clamps the rgb values by the min and max values and stores the result into "result"
  5403. * @param min defines minimum clamping value (default is 0)
  5404. * @param max defines maximum clamping value (default is 1)
  5405. * @param result defines color to store the result into
  5406. * @returns the original Color3
  5407. */
  5408. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5409. /**
  5410. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5411. * @param otherColor defines the second operand
  5412. * @returns the new Color3
  5413. */
  5414. add(otherColor: DeepImmutable<Color3>): Color3;
  5415. /**
  5416. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5417. * @param otherColor defines the second operand
  5418. * @param result defines Color3 object to store the result into
  5419. * @returns the unmodified current Color3
  5420. */
  5421. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5422. /**
  5423. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5424. * @param otherColor defines the second operand
  5425. * @returns the new Color3
  5426. */
  5427. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5430. * @param otherColor defines the second operand
  5431. * @param result defines Color3 object to store the result into
  5432. * @returns the unmodified current Color3
  5433. */
  5434. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5435. /**
  5436. * Copy the current object
  5437. * @returns a new Color3 copied the current one
  5438. */
  5439. clone(): Color3;
  5440. /**
  5441. * Copies the rgb values from the source in the current Color3
  5442. * @param source defines the source Color3 object
  5443. * @returns the updated Color3 object
  5444. */
  5445. copyFrom(source: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. copyFromFloats(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Updates the Color3 rgb values from the given floats
  5456. * @param r defines the red component to read from
  5457. * @param g defines the green component to read from
  5458. * @param b defines the blue component to read from
  5459. * @returns the current Color3 object
  5460. */
  5461. set(r: number, g: number, b: number): Color3;
  5462. /**
  5463. * Compute the Color3 hexadecimal code as a string
  5464. * @returns a string containing the hexadecimal representation of the Color3 object
  5465. */
  5466. toHexString(): string;
  5467. /**
  5468. * Computes a new Color3 converted from the current one to linear space
  5469. * @returns a new Color3 object
  5470. */
  5471. toLinearSpace(): Color3;
  5472. /**
  5473. * Converts current color in rgb space to HSV values
  5474. * @returns a new color3 representing the HSV values
  5475. */
  5476. toHSV(): Color3;
  5477. /**
  5478. * Converts current color in rgb space to HSV values
  5479. * @param result defines the Color3 where to store the HSV values
  5480. */
  5481. toHSVToRef(result: Color3): void;
  5482. /**
  5483. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5484. * @param convertedColor defines the Color3 object where to store the linear space version
  5485. * @returns the unmodified Color3
  5486. */
  5487. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5488. /**
  5489. * Computes a new Color3 converted from the current one to gamma space
  5490. * @returns a new Color3 object
  5491. */
  5492. toGammaSpace(): Color3;
  5493. /**
  5494. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the gamma space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5499. private static _BlackReadOnly;
  5500. /**
  5501. * Convert Hue, saturation and value to a Color3 (RGB)
  5502. * @param hue defines the hue
  5503. * @param saturation defines the saturation
  5504. * @param value defines the value
  5505. * @param result defines the Color3 where to store the RGB values
  5506. */
  5507. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5508. /**
  5509. * Creates a new Color3 from the string containing valid hexadecimal values
  5510. * @param hex defines a string containing valid hexadecimal values
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromHexString(hex: string): Color3;
  5514. /**
  5515. * Creates a new Color3 from the starting index of the given array
  5516. * @param array defines the source array
  5517. * @param offset defines an offset in the source array
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5521. /**
  5522. * Creates a new Color3 from integer values (< 256)
  5523. * @param r defines the red component to read from (value between 0 and 255)
  5524. * @param g defines the green component to read from (value between 0 and 255)
  5525. * @param b defines the blue component to read from (value between 0 and 255)
  5526. * @returns a new Color3 object
  5527. */
  5528. static FromInts(r: number, g: number, b: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param start defines the start Color3 value
  5532. * @param end defines the end Color3 value
  5533. * @param amount defines the gradient value between start and end
  5534. * @returns a new Color3 object
  5535. */
  5536. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5537. /**
  5538. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5539. * @param left defines the start value
  5540. * @param right defines the end value
  5541. * @param amount defines the gradient factor
  5542. * @param result defines the Color3 object where to store the result
  5543. */
  5544. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5545. /**
  5546. * Returns a Color3 value containing a red color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Red(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a green color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Green(): Color3;
  5555. /**
  5556. * Returns a Color3 value containing a blue color
  5557. * @returns a new Color3 object
  5558. */
  5559. static Blue(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a black color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Black(): Color3;
  5565. /**
  5566. * Gets a Color3 value containing a black color that must not be updated
  5567. */
  5568. static get BlackReadOnly(): DeepImmutable<Color3>;
  5569. /**
  5570. * Returns a Color3 value containing a white color
  5571. * @returns a new Color3 object
  5572. */
  5573. static White(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a purple color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Purple(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a magenta color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Magenta(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a yellow color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Yellow(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a gray color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Gray(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a teal color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Teal(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a random color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Random(): Color3;
  5604. }
  5605. /**
  5606. * Class used to hold a RBGA color
  5607. */
  5608. export class Color4 {
  5609. /**
  5610. * Defines the red component (between 0 and 1, default is 0)
  5611. */
  5612. r: number;
  5613. /**
  5614. * Defines the green component (between 0 and 1, default is 0)
  5615. */
  5616. g: number;
  5617. /**
  5618. * Defines the blue component (between 0 and 1, default is 0)
  5619. */
  5620. b: number;
  5621. /**
  5622. * Defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. a: number;
  5625. /**
  5626. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5627. * @param r defines the red component (between 0 and 1, default is 0)
  5628. * @param g defines the green component (between 0 and 1, default is 0)
  5629. * @param b defines the blue component (between 0 and 1, default is 0)
  5630. * @param a defines the alpha component (between 0 and 1, default is 1)
  5631. */
  5632. constructor(
  5633. /**
  5634. * Defines the red component (between 0 and 1, default is 0)
  5635. */
  5636. r?: number,
  5637. /**
  5638. * Defines the green component (between 0 and 1, default is 0)
  5639. */
  5640. g?: number,
  5641. /**
  5642. * Defines the blue component (between 0 and 1, default is 0)
  5643. */
  5644. b?: number,
  5645. /**
  5646. * Defines the alpha component (between 0 and 1, default is 1)
  5647. */
  5648. a?: number);
  5649. /**
  5650. * Adds in place the given Color4 values to the current Color4 object
  5651. * @param right defines the second operand
  5652. * @returns the current updated Color4 object
  5653. */
  5654. addInPlace(right: DeepImmutable<Color4>): Color4;
  5655. /**
  5656. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5657. * @returns the new array
  5658. */
  5659. asArray(): number[];
  5660. /**
  5661. * Stores from the starting index in the given array the Color4 successive values
  5662. * @param array defines the array where to store the r,g,b components
  5663. * @param index defines an optional index in the target array to define where to start storing values
  5664. * @returns the current Color4 object
  5665. */
  5666. toArray(array: number[], index?: number): Color4;
  5667. /**
  5668. * Determines equality between Color4 objects
  5669. * @param otherColor defines the second operand
  5670. * @returns true if the rgba values are equal to the given ones
  5671. */
  5672. equals(otherColor: DeepImmutable<Color4>): boolean;
  5673. /**
  5674. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5675. * @param right defines the second operand
  5676. * @returns a new Color4 object
  5677. */
  5678. add(right: DeepImmutable<Color4>): Color4;
  5679. /**
  5680. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5681. * @param right defines the second operand
  5682. * @returns a new Color4 object
  5683. */
  5684. subtract(right: DeepImmutable<Color4>): Color4;
  5685. /**
  5686. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5687. * @param right defines the second operand
  5688. * @param result defines the Color4 object where to store the result
  5689. * @returns the current Color4 object
  5690. */
  5691. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5692. /**
  5693. * Creates a new Color4 with the current Color4 values multiplied by scale
  5694. * @param scale defines the scaling factor to apply
  5695. * @returns a new Color4 object
  5696. */
  5697. scale(scale: number): Color4;
  5698. /**
  5699. * Multiplies the current Color4 values by scale and stores the result in "result"
  5700. * @param scale defines the scaling factor to apply
  5701. * @param result defines the Color4 object where to store the result
  5702. * @returns the current unmodified Color4
  5703. */
  5704. scaleToRef(scale: number, result: Color4): Color4;
  5705. /**
  5706. * Scale the current Color4 values by a factor and add the result to a given Color4
  5707. * @param scale defines the scale factor
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the unmodified current Color4
  5710. */
  5711. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5712. /**
  5713. * Clamps the rgb values by the min and max values and stores the result into "result"
  5714. * @param min defines minimum clamping value (default is 0)
  5715. * @param max defines maximum clamping value (default is 1)
  5716. * @param result defines color to store the result into.
  5717. * @returns the cuurent Color4
  5718. */
  5719. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5720. /**
  5721. * Multipy an Color4 value by another and return a new Color4 object
  5722. * @param color defines the Color4 value to multiply by
  5723. * @returns a new Color4 object
  5724. */
  5725. multiply(color: Color4): Color4;
  5726. /**
  5727. * Multipy a Color4 value by another and push the result in a reference value
  5728. * @param color defines the Color4 value to multiply by
  5729. * @param result defines the Color4 to fill the result in
  5730. * @returns the result Color4
  5731. */
  5732. multiplyToRef(color: Color4, result: Color4): Color4;
  5733. /**
  5734. * Creates a string with the Color4 current values
  5735. * @returns the string representation of the Color4 object
  5736. */
  5737. toString(): string;
  5738. /**
  5739. * Returns the string "Color4"
  5740. * @returns "Color4"
  5741. */
  5742. getClassName(): string;
  5743. /**
  5744. * Compute the Color4 hash code
  5745. * @returns an unique number that can be used to hash Color4 objects
  5746. */
  5747. getHashCode(): number;
  5748. /**
  5749. * Creates a new Color4 copied from the current one
  5750. * @returns a new Color4 object
  5751. */
  5752. clone(): Color4;
  5753. /**
  5754. * Copies the given Color4 values into the current one
  5755. * @param source defines the source Color4 object
  5756. * @returns the current updated Color4 object
  5757. */
  5758. copyFrom(source: Color4): Color4;
  5759. /**
  5760. * Copies the given float values into the current one
  5761. * @param r defines the red component to read from
  5762. * @param g defines the green component to read from
  5763. * @param b defines the blue component to read from
  5764. * @param a defines the alpha component to read from
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. set(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Compute the Color4 hexadecimal code as a string
  5779. * @returns a string containing the hexadecimal representation of the Color4 object
  5780. */
  5781. toHexString(): string;
  5782. /**
  5783. * Computes a new Color4 converted from the current one to linear space
  5784. * @returns a new Color4 object
  5785. */
  5786. toLinearSpace(): Color4;
  5787. /**
  5788. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5789. * @param convertedColor defines the Color4 object where to store the linear space version
  5790. * @returns the unmodified Color4
  5791. */
  5792. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5793. /**
  5794. * Computes a new Color4 converted from the current one to gamma space
  5795. * @returns a new Color4 object
  5796. */
  5797. toGammaSpace(): Color4;
  5798. /**
  5799. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5800. * @param convertedColor defines the Color4 object where to store the gamma space version
  5801. * @returns the unmodified Color4
  5802. */
  5803. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5804. /**
  5805. * Creates a new Color4 from the string containing valid hexadecimal values
  5806. * @param hex defines a string containing valid hexadecimal values
  5807. * @returns a new Color4 object
  5808. */
  5809. static FromHexString(hex: string): Color4;
  5810. /**
  5811. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5812. * @param left defines the start value
  5813. * @param right defines the end value
  5814. * @param amount defines the gradient factor
  5815. * @returns a new Color4 object
  5816. */
  5817. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5818. /**
  5819. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5820. * @param left defines the start value
  5821. * @param right defines the end value
  5822. * @param amount defines the gradient factor
  5823. * @param result defines the Color4 object where to store data
  5824. */
  5825. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5826. /**
  5827. * Creates a new Color4 from a Color3 and an alpha value
  5828. * @param color3 defines the source Color3 to read from
  5829. * @param alpha defines the alpha component (1.0 by default)
  5830. * @returns a new Color4 object
  5831. */
  5832. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5833. /**
  5834. * Creates a new Color4 from the starting index element of the given array
  5835. * @param array defines the source array to read from
  5836. * @param offset defines the offset in the source array
  5837. * @returns a new Color4 object
  5838. */
  5839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5840. /**
  5841. * Creates a new Color3 from integer values (< 256)
  5842. * @param r defines the red component to read from (value between 0 and 255)
  5843. * @param g defines the green component to read from (value between 0 and 255)
  5844. * @param b defines the blue component to read from (value between 0 and 255)
  5845. * @param a defines the alpha component to read from (value between 0 and 255)
  5846. * @returns a new Color3 object
  5847. */
  5848. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5849. /**
  5850. * Check the content of a given array and convert it to an array containing RGBA data
  5851. * If the original array was already containing count * 4 values then it is returned directly
  5852. * @param colors defines the array to check
  5853. * @param count defines the number of RGBA data to expect
  5854. * @returns an array containing count * 4 values (RGBA)
  5855. */
  5856. static CheckColors4(colors: number[], count: number): number[];
  5857. }
  5858. /**
  5859. * @hidden
  5860. */
  5861. export class TmpColors {
  5862. static Color3: Color3[];
  5863. static Color4: Color4[];
  5864. }
  5865. }
  5866. declare module BABYLON {
  5867. /**
  5868. * Defines an interface which represents an animation key frame
  5869. */
  5870. export interface IAnimationKey {
  5871. /**
  5872. * Frame of the key frame
  5873. */
  5874. frame: number;
  5875. /**
  5876. * Value at the specifies key frame
  5877. */
  5878. value: any;
  5879. /**
  5880. * The input tangent for the cubic hermite spline
  5881. */
  5882. inTangent?: any;
  5883. /**
  5884. * The output tangent for the cubic hermite spline
  5885. */
  5886. outTangent?: any;
  5887. /**
  5888. * The animation interpolation type
  5889. */
  5890. interpolation?: AnimationKeyInterpolation;
  5891. }
  5892. /**
  5893. * Enum for the animation key frame interpolation type
  5894. */
  5895. export enum AnimationKeyInterpolation {
  5896. /**
  5897. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5898. */
  5899. STEP = 1
  5900. }
  5901. }
  5902. declare module BABYLON {
  5903. /**
  5904. * Represents the range of an animation
  5905. */
  5906. export class AnimationRange {
  5907. /**The name of the animation range**/
  5908. name: string;
  5909. /**The starting frame of the animation */
  5910. from: number;
  5911. /**The ending frame of the animation*/
  5912. to: number;
  5913. /**
  5914. * Initializes the range of an animation
  5915. * @param name The name of the animation range
  5916. * @param from The starting frame of the animation
  5917. * @param to The ending frame of the animation
  5918. */
  5919. constructor(
  5920. /**The name of the animation range**/
  5921. name: string,
  5922. /**The starting frame of the animation */
  5923. from: number,
  5924. /**The ending frame of the animation*/
  5925. to: number);
  5926. /**
  5927. * Makes a copy of the animation range
  5928. * @returns A copy of the animation range
  5929. */
  5930. clone(): AnimationRange;
  5931. }
  5932. }
  5933. declare module BABYLON {
  5934. /**
  5935. * Composed of a frame, and an action function
  5936. */
  5937. export class AnimationEvent {
  5938. /** The frame for which the event is triggered **/
  5939. frame: number;
  5940. /** The event to perform when triggered **/
  5941. action: (currentFrame: number) => void;
  5942. /** Specifies if the event should be triggered only once**/
  5943. onlyOnce?: boolean | undefined;
  5944. /**
  5945. * Specifies if the animation event is done
  5946. */
  5947. isDone: boolean;
  5948. /**
  5949. * Initializes the animation event
  5950. * @param frame The frame for which the event is triggered
  5951. * @param action The event to perform when triggered
  5952. * @param onlyOnce Specifies if the event should be triggered only once
  5953. */
  5954. constructor(
  5955. /** The frame for which the event is triggered **/
  5956. frame: number,
  5957. /** The event to perform when triggered **/
  5958. action: (currentFrame: number) => void,
  5959. /** Specifies if the event should be triggered only once**/
  5960. onlyOnce?: boolean | undefined);
  5961. /** @hidden */
  5962. _clone(): AnimationEvent;
  5963. }
  5964. }
  5965. declare module BABYLON {
  5966. /**
  5967. * Interface used to define a behavior
  5968. */
  5969. export interface Behavior<T> {
  5970. /** gets or sets behavior's name */
  5971. name: string;
  5972. /**
  5973. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5974. */
  5975. init(): void;
  5976. /**
  5977. * Called when the behavior is attached to a target
  5978. * @param target defines the target where the behavior is attached to
  5979. */
  5980. attach(target: T): void;
  5981. /**
  5982. * Called when the behavior is detached from its target
  5983. */
  5984. detach(): void;
  5985. }
  5986. /**
  5987. * Interface implemented by classes supporting behaviors
  5988. */
  5989. export interface IBehaviorAware<T> {
  5990. /**
  5991. * Attach a behavior
  5992. * @param behavior defines the behavior to attach
  5993. * @returns the current host
  5994. */
  5995. addBehavior(behavior: Behavior<T>): T;
  5996. /**
  5997. * Remove a behavior from the current object
  5998. * @param behavior defines the behavior to detach
  5999. * @returns the current host
  6000. */
  6001. removeBehavior(behavior: Behavior<T>): T;
  6002. /**
  6003. * Gets a behavior using its name to search
  6004. * @param name defines the name to search
  6005. * @returns the behavior or null if not found
  6006. */
  6007. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6008. }
  6009. }
  6010. declare module BABYLON {
  6011. /**
  6012. * Defines an array and its length.
  6013. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6014. */
  6015. export interface ISmartArrayLike<T> {
  6016. /**
  6017. * The data of the array.
  6018. */
  6019. data: Array<T>;
  6020. /**
  6021. * The active length of the array.
  6022. */
  6023. length: number;
  6024. }
  6025. /**
  6026. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6027. */
  6028. export class SmartArray<T> implements ISmartArrayLike<T> {
  6029. /**
  6030. * The full set of data from the array.
  6031. */
  6032. data: Array<T>;
  6033. /**
  6034. * The active length of the array.
  6035. */
  6036. length: number;
  6037. protected _id: number;
  6038. /**
  6039. * Instantiates a Smart Array.
  6040. * @param capacity defines the default capacity of the array.
  6041. */
  6042. constructor(capacity: number);
  6043. /**
  6044. * Pushes a value at the end of the active data.
  6045. * @param value defines the object to push in the array.
  6046. */
  6047. push(value: T): void;
  6048. /**
  6049. * Iterates over the active data and apply the lambda to them.
  6050. * @param func defines the action to apply on each value.
  6051. */
  6052. forEach(func: (content: T) => void): void;
  6053. /**
  6054. * Sorts the full sets of data.
  6055. * @param compareFn defines the comparison function to apply.
  6056. */
  6057. sort(compareFn: (a: T, b: T) => number): void;
  6058. /**
  6059. * Resets the active data to an empty array.
  6060. */
  6061. reset(): void;
  6062. /**
  6063. * Releases all the data from the array as well as the array.
  6064. */
  6065. dispose(): void;
  6066. /**
  6067. * Concats the active data with a given array.
  6068. * @param array defines the data to concatenate with.
  6069. */
  6070. concat(array: any): void;
  6071. /**
  6072. * Returns the position of a value in the active data.
  6073. * @param value defines the value to find the index for
  6074. * @returns the index if found in the active data otherwise -1
  6075. */
  6076. indexOf(value: T): number;
  6077. /**
  6078. * Returns whether an element is part of the active data.
  6079. * @param value defines the value to look for
  6080. * @returns true if found in the active data otherwise false
  6081. */
  6082. contains(value: T): boolean;
  6083. private static _GlobalId;
  6084. }
  6085. /**
  6086. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6087. * The data in this array can only be present once
  6088. */
  6089. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6090. private _duplicateId;
  6091. /**
  6092. * Pushes a value at the end of the active data.
  6093. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6094. * @param value defines the object to push in the array.
  6095. */
  6096. push(value: T): void;
  6097. /**
  6098. * Pushes a value at the end of the active data.
  6099. * If the data is already present, it won t be added again
  6100. * @param value defines the object to push in the array.
  6101. * @returns true if added false if it was already present
  6102. */
  6103. pushNoDuplicate(value: T): boolean;
  6104. /**
  6105. * Resets the active data to an empty array.
  6106. */
  6107. reset(): void;
  6108. /**
  6109. * Concats the active data with a given array.
  6110. * This ensures no dupplicate will be present in the result.
  6111. * @param array defines the data to concatenate with.
  6112. */
  6113. concatWithNoDuplicate(array: any): void;
  6114. }
  6115. }
  6116. declare module BABYLON {
  6117. /**
  6118. * @ignore
  6119. * This is a list of all the different input types that are available in the application.
  6120. * Fo instance: ArcRotateCameraGamepadInput...
  6121. */
  6122. export var CameraInputTypes: {};
  6123. /**
  6124. * This is the contract to implement in order to create a new input class.
  6125. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6126. */
  6127. export interface ICameraInput<TCamera extends Camera> {
  6128. /**
  6129. * Defines the camera the input is attached to.
  6130. */
  6131. camera: Nullable<TCamera>;
  6132. /**
  6133. * Gets the class name of the current intput.
  6134. * @returns the class name
  6135. */
  6136. getClassName(): string;
  6137. /**
  6138. * Get the friendly name associated with the input class.
  6139. * @returns the input friendly name
  6140. */
  6141. getSimpleName(): string;
  6142. /**
  6143. * Attach the input controls to a specific dom element to get the input from.
  6144. * @param element Defines the element the controls should be listened from
  6145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6146. */
  6147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6148. /**
  6149. * Detach the current controls from the specified dom element.
  6150. * @param element Defines the element to stop listening the inputs from
  6151. */
  6152. detachControl(element: Nullable<HTMLElement>): void;
  6153. /**
  6154. * Update the current camera state depending on the inputs that have been used this frame.
  6155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6156. */
  6157. checkInputs?: () => void;
  6158. }
  6159. /**
  6160. * Represents a map of input types to input instance or input index to input instance.
  6161. */
  6162. export interface CameraInputsMap<TCamera extends Camera> {
  6163. /**
  6164. * Accessor to the input by input type.
  6165. */
  6166. [name: string]: ICameraInput<TCamera>;
  6167. /**
  6168. * Accessor to the input by input index.
  6169. */
  6170. [idx: number]: ICameraInput<TCamera>;
  6171. }
  6172. /**
  6173. * This represents the input manager used within a camera.
  6174. * It helps dealing with all the different kind of input attached to a camera.
  6175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6176. */
  6177. export class CameraInputsManager<TCamera extends Camera> {
  6178. /**
  6179. * Defines the list of inputs attahed to the camera.
  6180. */
  6181. attached: CameraInputsMap<TCamera>;
  6182. /**
  6183. * Defines the dom element the camera is collecting inputs from.
  6184. * This is null if the controls have not been attached.
  6185. */
  6186. attachedElement: Nullable<HTMLElement>;
  6187. /**
  6188. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6189. */
  6190. noPreventDefault: boolean;
  6191. /**
  6192. * Defined the camera the input manager belongs to.
  6193. */
  6194. camera: TCamera;
  6195. /**
  6196. * Update the current camera state depending on the inputs that have been used this frame.
  6197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6198. */
  6199. checkInputs: () => void;
  6200. /**
  6201. * Instantiate a new Camera Input Manager.
  6202. * @param camera Defines the camera the input manager blongs to
  6203. */
  6204. constructor(camera: TCamera);
  6205. /**
  6206. * Add an input method to a camera
  6207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6208. * @param input camera input method
  6209. */
  6210. add(input: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Remove a specific input method from a camera
  6213. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6214. * @param inputToRemove camera input method
  6215. */
  6216. remove(inputToRemove: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Remove a specific input type from a camera
  6219. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6220. * @param inputType the type of the input to remove
  6221. */
  6222. removeByType(inputType: string): void;
  6223. private _addCheckInputs;
  6224. /**
  6225. * Attach the input controls to the currently attached dom element to listen the events from.
  6226. * @param input Defines the input to attach
  6227. */
  6228. attachInput(input: ICameraInput<TCamera>): void;
  6229. /**
  6230. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6231. * @param element Defines the dom element to collect the events from
  6232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6233. */
  6234. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6235. /**
  6236. * Detach the current manager inputs controls from a specific dom element.
  6237. * @param element Defines the dom element to collect the events from
  6238. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6239. */
  6240. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6241. /**
  6242. * Rebuild the dynamic inputCheck function from the current list of
  6243. * defined inputs in the manager.
  6244. */
  6245. rebuildInputCheck(): void;
  6246. /**
  6247. * Remove all attached input methods from a camera
  6248. */
  6249. clear(): void;
  6250. /**
  6251. * Serialize the current input manager attached to a camera.
  6252. * This ensures than once parsed,
  6253. * the input associated to the camera will be identical to the current ones
  6254. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6255. */
  6256. serialize(serializedCamera: any): void;
  6257. /**
  6258. * Parses an input manager serialized JSON to restore the previous list of inputs
  6259. * and states associated to a camera.
  6260. * @param parsedCamera Defines the JSON to parse
  6261. */
  6262. parse(parsedCamera: any): void;
  6263. }
  6264. }
  6265. declare module BABYLON {
  6266. /**
  6267. * Class used to store data that will be store in GPU memory
  6268. */
  6269. export class Buffer {
  6270. private _engine;
  6271. private _buffer;
  6272. /** @hidden */
  6273. _data: Nullable<DataArray>;
  6274. private _updatable;
  6275. private _instanced;
  6276. private _divisor;
  6277. /**
  6278. * Gets the byte stride.
  6279. */
  6280. readonly byteStride: number;
  6281. /**
  6282. * Constructor
  6283. * @param engine the engine
  6284. * @param data the data to use for this buffer
  6285. * @param updatable whether the data is updatable
  6286. * @param stride the stride (optional)
  6287. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6288. * @param instanced whether the buffer is instanced (optional)
  6289. * @param useBytes set to true if the stride in in bytes (optional)
  6290. * @param divisor sets an optional divisor for instances (1 by default)
  6291. */
  6292. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6293. /**
  6294. * Create a new VertexBuffer based on the current buffer
  6295. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6296. * @param offset defines offset in the buffer (0 by default)
  6297. * @param size defines the size in floats of attributes (position is 3 for instance)
  6298. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6299. * @param instanced defines if the vertex buffer contains indexed data
  6300. * @param useBytes defines if the offset and stride are in bytes *
  6301. * @param divisor sets an optional divisor for instances (1 by default)
  6302. * @returns the new vertex buffer
  6303. */
  6304. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6305. /**
  6306. * Gets a boolean indicating if the Buffer is updatable?
  6307. * @returns true if the buffer is updatable
  6308. */
  6309. isUpdatable(): boolean;
  6310. /**
  6311. * Gets current buffer's data
  6312. * @returns a DataArray or null
  6313. */
  6314. getData(): Nullable<DataArray>;
  6315. /**
  6316. * Gets underlying native buffer
  6317. * @returns underlying native buffer
  6318. */
  6319. getBuffer(): Nullable<DataBuffer>;
  6320. /**
  6321. * Gets the stride in float32 units (i.e. byte stride / 4).
  6322. * May not be an integer if the byte stride is not divisible by 4.
  6323. * @returns the stride in float32 units
  6324. * @deprecated Please use byteStride instead.
  6325. */
  6326. getStrideSize(): number;
  6327. /**
  6328. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6329. * @param data defines the data to store
  6330. */
  6331. create(data?: Nullable<DataArray>): void;
  6332. /** @hidden */
  6333. _rebuild(): void;
  6334. /**
  6335. * Update current buffer data
  6336. * @param data defines the data to store
  6337. */
  6338. update(data: DataArray): void;
  6339. /**
  6340. * Updates the data directly.
  6341. * @param data the new data
  6342. * @param offset the new offset
  6343. * @param vertexCount the vertex count (optional)
  6344. * @param useBytes set to true if the offset is in bytes
  6345. */
  6346. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6347. /**
  6348. * Release all resources
  6349. */
  6350. dispose(): void;
  6351. }
  6352. /**
  6353. * Specialized buffer used to store vertex data
  6354. */
  6355. export class VertexBuffer {
  6356. /** @hidden */
  6357. _buffer: Buffer;
  6358. private _kind;
  6359. private _size;
  6360. private _ownsBuffer;
  6361. private _instanced;
  6362. private _instanceDivisor;
  6363. /**
  6364. * The byte type.
  6365. */
  6366. static readonly BYTE: number;
  6367. /**
  6368. * The unsigned byte type.
  6369. */
  6370. static readonly UNSIGNED_BYTE: number;
  6371. /**
  6372. * The short type.
  6373. */
  6374. static readonly SHORT: number;
  6375. /**
  6376. * The unsigned short type.
  6377. */
  6378. static readonly UNSIGNED_SHORT: number;
  6379. /**
  6380. * The integer type.
  6381. */
  6382. static readonly INT: number;
  6383. /**
  6384. * The unsigned integer type.
  6385. */
  6386. static readonly UNSIGNED_INT: number;
  6387. /**
  6388. * The float type.
  6389. */
  6390. static readonly FLOAT: number;
  6391. /**
  6392. * Gets or sets the instance divisor when in instanced mode
  6393. */
  6394. get instanceDivisor(): number;
  6395. set instanceDivisor(value: number);
  6396. /**
  6397. * Gets the byte stride.
  6398. */
  6399. readonly byteStride: number;
  6400. /**
  6401. * Gets the byte offset.
  6402. */
  6403. readonly byteOffset: number;
  6404. /**
  6405. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6406. */
  6407. readonly normalized: boolean;
  6408. /**
  6409. * Gets the data type of each component in the array.
  6410. */
  6411. readonly type: number;
  6412. /**
  6413. * Constructor
  6414. * @param engine the engine
  6415. * @param data the data to use for this vertex buffer
  6416. * @param kind the vertex buffer kind
  6417. * @param updatable whether the data is updatable
  6418. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6419. * @param stride the stride (optional)
  6420. * @param instanced whether the buffer is instanced (optional)
  6421. * @param offset the offset of the data (optional)
  6422. * @param size the number of components (optional)
  6423. * @param type the type of the component (optional)
  6424. * @param normalized whether the data contains normalized data (optional)
  6425. * @param useBytes set to true if stride and offset are in bytes (optional)
  6426. * @param divisor defines the instance divisor to use (1 by default)
  6427. */
  6428. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6429. /** @hidden */
  6430. _rebuild(): void;
  6431. /**
  6432. * Returns the kind of the VertexBuffer (string)
  6433. * @returns a string
  6434. */
  6435. getKind(): string;
  6436. /**
  6437. * Gets a boolean indicating if the VertexBuffer is updatable?
  6438. * @returns true if the buffer is updatable
  6439. */
  6440. isUpdatable(): boolean;
  6441. /**
  6442. * Gets current buffer's data
  6443. * @returns a DataArray or null
  6444. */
  6445. getData(): Nullable<DataArray>;
  6446. /**
  6447. * Gets underlying native buffer
  6448. * @returns underlying native buffer
  6449. */
  6450. getBuffer(): Nullable<DataBuffer>;
  6451. /**
  6452. * Gets the stride in float32 units (i.e. byte stride / 4).
  6453. * May not be an integer if the byte stride is not divisible by 4.
  6454. * @returns the stride in float32 units
  6455. * @deprecated Please use byteStride instead.
  6456. */
  6457. getStrideSize(): number;
  6458. /**
  6459. * Returns the offset as a multiple of the type byte length.
  6460. * @returns the offset in bytes
  6461. * @deprecated Please use byteOffset instead.
  6462. */
  6463. getOffset(): number;
  6464. /**
  6465. * Returns the number of components per vertex attribute (integer)
  6466. * @returns the size in float
  6467. */
  6468. getSize(): number;
  6469. /**
  6470. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6471. * @returns true if this buffer is instanced
  6472. */
  6473. getIsInstanced(): boolean;
  6474. /**
  6475. * Returns the instancing divisor, zero for non-instanced (integer).
  6476. * @returns a number
  6477. */
  6478. getInstanceDivisor(): number;
  6479. /**
  6480. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6481. * @param data defines the data to store
  6482. */
  6483. create(data?: DataArray): void;
  6484. /**
  6485. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6486. * This function will create a new buffer if the current one is not updatable
  6487. * @param data defines the data to store
  6488. */
  6489. update(data: DataArray): void;
  6490. /**
  6491. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6492. * Returns the directly updated WebGLBuffer.
  6493. * @param data the new data
  6494. * @param offset the new offset
  6495. * @param useBytes set to true if the offset is in bytes
  6496. */
  6497. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6498. /**
  6499. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Enumerates each value of this vertex buffer as numbers.
  6504. * @param count the number of values to enumerate
  6505. * @param callback the callback function called for each value
  6506. */
  6507. forEach(count: number, callback: (value: number, index: number) => void): void;
  6508. /**
  6509. * Positions
  6510. */
  6511. static readonly PositionKind: string;
  6512. /**
  6513. * Normals
  6514. */
  6515. static readonly NormalKind: string;
  6516. /**
  6517. * Tangents
  6518. */
  6519. static readonly TangentKind: string;
  6520. /**
  6521. * Texture coordinates
  6522. */
  6523. static readonly UVKind: string;
  6524. /**
  6525. * Texture coordinates 2
  6526. */
  6527. static readonly UV2Kind: string;
  6528. /**
  6529. * Texture coordinates 3
  6530. */
  6531. static readonly UV3Kind: string;
  6532. /**
  6533. * Texture coordinates 4
  6534. */
  6535. static readonly UV4Kind: string;
  6536. /**
  6537. * Texture coordinates 5
  6538. */
  6539. static readonly UV5Kind: string;
  6540. /**
  6541. * Texture coordinates 6
  6542. */
  6543. static readonly UV6Kind: string;
  6544. /**
  6545. * Colors
  6546. */
  6547. static readonly ColorKind: string;
  6548. /**
  6549. * Matrix indices (for bones)
  6550. */
  6551. static readonly MatricesIndicesKind: string;
  6552. /**
  6553. * Matrix weights (for bones)
  6554. */
  6555. static readonly MatricesWeightsKind: string;
  6556. /**
  6557. * Additional matrix indices (for bones)
  6558. */
  6559. static readonly MatricesIndicesExtraKind: string;
  6560. /**
  6561. * Additional matrix weights (for bones)
  6562. */
  6563. static readonly MatricesWeightsExtraKind: string;
  6564. /**
  6565. * Deduces the stride given a kind.
  6566. * @param kind The kind string to deduce
  6567. * @returns The deduced stride
  6568. */
  6569. static DeduceStride(kind: string): number;
  6570. /**
  6571. * Gets the byte length of the given type.
  6572. * @param type the type
  6573. * @returns the number of bytes
  6574. */
  6575. static GetTypeByteLength(type: number): number;
  6576. /**
  6577. * Enumerates each value of the given parameters as numbers.
  6578. * @param data the data to enumerate
  6579. * @param byteOffset the byte offset of the data
  6580. * @param byteStride the byte stride of the data
  6581. * @param componentCount the number of components per element
  6582. * @param componentType the type of the component
  6583. * @param count the number of values to enumerate
  6584. * @param normalized whether the data is normalized
  6585. * @param callback the callback function called for each value
  6586. */
  6587. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6588. private static _GetFloatValue;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * @hidden
  6594. */
  6595. export class IntersectionInfo {
  6596. bu: Nullable<number>;
  6597. bv: Nullable<number>;
  6598. distance: number;
  6599. faceId: number;
  6600. subMeshId: number;
  6601. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6602. }
  6603. }
  6604. declare module BABYLON {
  6605. /**
  6606. * Represens a plane by the equation ax + by + cz + d = 0
  6607. */
  6608. export class Plane {
  6609. private static _TmpMatrix;
  6610. /**
  6611. * Normal of the plane (a,b,c)
  6612. */
  6613. normal: Vector3;
  6614. /**
  6615. * d component of the plane
  6616. */
  6617. d: number;
  6618. /**
  6619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6620. * @param a a component of the plane
  6621. * @param b b component of the plane
  6622. * @param c c component of the plane
  6623. * @param d d component of the plane
  6624. */
  6625. constructor(a: number, b: number, c: number, d: number);
  6626. /**
  6627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6628. */
  6629. asArray(): number[];
  6630. /**
  6631. * @returns a new plane copied from the current Plane.
  6632. */
  6633. clone(): Plane;
  6634. /**
  6635. * @returns the string "Plane".
  6636. */
  6637. getClassName(): string;
  6638. /**
  6639. * @returns the Plane hash code.
  6640. */
  6641. getHashCode(): number;
  6642. /**
  6643. * Normalize the current Plane in place.
  6644. * @returns the updated Plane.
  6645. */
  6646. normalize(): Plane;
  6647. /**
  6648. * Applies a transformation the plane and returns the result
  6649. * @param transformation the transformation matrix to be applied to the plane
  6650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6651. */
  6652. transform(transformation: DeepImmutable<Matrix>): Plane;
  6653. /**
  6654. * Calcualtte the dot product between the point and the plane normal
  6655. * @param point point to calculate the dot product with
  6656. * @returns the dot product (float) of the point coordinates and the plane normal.
  6657. */
  6658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6659. /**
  6660. * Updates the current Plane from the plane defined by the three given points.
  6661. * @param point1 one of the points used to contruct the plane
  6662. * @param point2 one of the points used to contruct the plane
  6663. * @param point3 one of the points used to contruct the plane
  6664. * @returns the updated Plane.
  6665. */
  6666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6667. /**
  6668. * Checks if the plane is facing a given direction
  6669. * @param direction the direction to check if the plane is facing
  6670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6671. * @returns True is the vector "direction" is the same side than the plane normal.
  6672. */
  6673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6674. /**
  6675. * Calculates the distance to a point
  6676. * @param point point to calculate distance to
  6677. * @returns the signed distance (float) from the given point to the Plane.
  6678. */
  6679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6680. /**
  6681. * Creates a plane from an array
  6682. * @param array the array to create a plane from
  6683. * @returns a new Plane from the given array.
  6684. */
  6685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6686. /**
  6687. * Creates a plane from three points
  6688. * @param point1 point used to create the plane
  6689. * @param point2 point used to create the plane
  6690. * @param point3 point used to create the plane
  6691. * @returns a new Plane defined by the three given points.
  6692. */
  6693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Creates a plane from an origin point and a normal
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @returns a new Plane the normal vector to this plane at the given origin point.
  6699. * Note : the vector "normal" is updated because normalized.
  6700. */
  6701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6702. /**
  6703. * Calculates the distance from a plane and a point
  6704. * @param origin origin of the plane to be constructed
  6705. * @param normal normal of the plane to be constructed
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6708. */
  6709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6710. }
  6711. }
  6712. declare module BABYLON {
  6713. /**
  6714. * Class used to store bounding sphere information
  6715. */
  6716. export class BoundingSphere {
  6717. /**
  6718. * Gets the center of the bounding sphere in local space
  6719. */
  6720. readonly center: Vector3;
  6721. /**
  6722. * Radius of the bounding sphere in local space
  6723. */
  6724. radius: number;
  6725. /**
  6726. * Gets the center of the bounding sphere in world space
  6727. */
  6728. readonly centerWorld: Vector3;
  6729. /**
  6730. * Radius of the bounding sphere in world space
  6731. */
  6732. radiusWorld: number;
  6733. /**
  6734. * Gets the minimum vector in local space
  6735. */
  6736. readonly minimum: Vector3;
  6737. /**
  6738. * Gets the maximum vector in local space
  6739. */
  6740. readonly maximum: Vector3;
  6741. private _worldMatrix;
  6742. private static readonly TmpVector3;
  6743. /**
  6744. * Creates a new bounding sphere
  6745. * @param min defines the minimum vector (in local space)
  6746. * @param max defines the maximum vector (in local space)
  6747. * @param worldMatrix defines the new world matrix
  6748. */
  6749. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6750. /**
  6751. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6752. * @param min defines the new minimum vector (in local space)
  6753. * @param max defines the new maximum vector (in local space)
  6754. * @param worldMatrix defines the new world matrix
  6755. */
  6756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6757. /**
  6758. * Scale the current bounding sphere by applying a scale factor
  6759. * @param factor defines the scale factor to apply
  6760. * @returns the current bounding box
  6761. */
  6762. scale(factor: number): BoundingSphere;
  6763. /**
  6764. * Gets the world matrix of the bounding box
  6765. * @returns a matrix
  6766. */
  6767. getWorldMatrix(): DeepImmutable<Matrix>;
  6768. /** @hidden */
  6769. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6770. /**
  6771. * Tests if the bounding sphere is intersecting the frustum planes
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @returns true if there is an intersection
  6774. */
  6775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if the bounding sphere center is in between the frustum planes.
  6778. * Used for optimistic fast inclusion.
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if the sphere center is in between the frustum planes
  6781. */
  6782. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding sphere
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding sphere
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Checks if two sphere intersct
  6791. * @param sphere0 sphere 0
  6792. * @param sphere1 sphere 1
  6793. * @returns true if the speres intersect
  6794. */
  6795. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6796. }
  6797. }
  6798. declare module BABYLON {
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module BABYLON {
  6944. /** @hidden */
  6945. export class Collider {
  6946. /** Define if a collision was found */
  6947. collisionFound: boolean;
  6948. /**
  6949. * Define last intersection point in local space
  6950. */
  6951. intersectionPoint: Vector3;
  6952. /**
  6953. * Define last collided mesh
  6954. */
  6955. collidedMesh: Nullable<AbstractMesh>;
  6956. private _collisionPoint;
  6957. private _planeIntersectionPoint;
  6958. private _tempVector;
  6959. private _tempVector2;
  6960. private _tempVector3;
  6961. private _tempVector4;
  6962. private _edge;
  6963. private _baseToVertex;
  6964. private _destinationPoint;
  6965. private _slidePlaneNormal;
  6966. private _displacementVector;
  6967. /** @hidden */
  6968. _radius: Vector3;
  6969. /** @hidden */
  6970. _retry: number;
  6971. private _velocity;
  6972. private _basePoint;
  6973. private _epsilon;
  6974. /** @hidden */
  6975. _velocityWorldLength: number;
  6976. /** @hidden */
  6977. _basePointWorld: Vector3;
  6978. private _velocityWorld;
  6979. private _normalizedVelocity;
  6980. /** @hidden */
  6981. _initialVelocity: Vector3;
  6982. /** @hidden */
  6983. _initialPosition: Vector3;
  6984. private _nearestDistance;
  6985. private _collisionMask;
  6986. get collisionMask(): number;
  6987. set collisionMask(mask: number);
  6988. /**
  6989. * Gets the plane normal used to compute the sliding response (in local space)
  6990. */
  6991. get slidePlaneNormal(): Vector3;
  6992. /** @hidden */
  6993. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6994. /** @hidden */
  6995. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6996. /** @hidden */
  6997. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6998. /** @hidden */
  6999. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7000. /** @hidden */
  7001. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7002. /** @hidden */
  7003. _getResponse(pos: Vector3, vel: Vector3): void;
  7004. }
  7005. }
  7006. declare module BABYLON {
  7007. /**
  7008. * Interface for cullable objects
  7009. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7010. */
  7011. export interface ICullable {
  7012. /**
  7013. * Checks if the object or part of the object is in the frustum
  7014. * @param frustumPlanes Camera near/planes
  7015. * @returns true if the object is in frustum otherwise false
  7016. */
  7017. isInFrustum(frustumPlanes: Plane[]): boolean;
  7018. /**
  7019. * Checks if a cullable object (mesh...) is in the camera frustum
  7020. * Unlike isInFrustum this cheks the full bounding box
  7021. * @param frustumPlanes Camera near/planes
  7022. * @returns true if the object is in frustum otherwise false
  7023. */
  7024. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7025. }
  7026. /**
  7027. * Info for a bounding data of a mesh
  7028. */
  7029. export class BoundingInfo implements ICullable {
  7030. /**
  7031. * Bounding box for the mesh
  7032. */
  7033. readonly boundingBox: BoundingBox;
  7034. /**
  7035. * Bounding sphere for the mesh
  7036. */
  7037. readonly boundingSphere: BoundingSphere;
  7038. private _isLocked;
  7039. private static readonly TmpVector3;
  7040. /**
  7041. * Constructs bounding info
  7042. * @param minimum min vector of the bounding box/sphere
  7043. * @param maximum max vector of the bounding box/sphere
  7044. * @param worldMatrix defines the new world matrix
  7045. */
  7046. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7047. /**
  7048. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7049. * @param min defines the new minimum vector (in local space)
  7050. * @param max defines the new maximum vector (in local space)
  7051. * @param worldMatrix defines the new world matrix
  7052. */
  7053. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * min vector of the bounding box/sphere
  7056. */
  7057. get minimum(): Vector3;
  7058. /**
  7059. * max vector of the bounding box/sphere
  7060. */
  7061. get maximum(): Vector3;
  7062. /**
  7063. * If the info is locked and won't be updated to avoid perf overhead
  7064. */
  7065. get isLocked(): boolean;
  7066. set isLocked(value: boolean);
  7067. /**
  7068. * Updates the bounding sphere and box
  7069. * @param world world matrix to be used to update
  7070. */
  7071. update(world: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7074. * @param center New center of the bounding info
  7075. * @param extend New extend of the bounding info
  7076. * @returns the current bounding info
  7077. */
  7078. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7079. /**
  7080. * Scale the current bounding info by applying a scale factor
  7081. * @param factor defines the scale factor to apply
  7082. * @returns the current bounding info
  7083. */
  7084. scale(factor: number): BoundingInfo;
  7085. /**
  7086. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7087. * @param frustumPlanes defines the frustum to test
  7088. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7089. * @returns true if the bounding info is in the frustum planes
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7092. /**
  7093. * Gets the world distance between the min and max points of the bounding box
  7094. */
  7095. get diagonalLength(): number;
  7096. /**
  7097. * Checks if a cullable object (mesh...) is in the camera frustum
  7098. * Unlike isInFrustum this cheks the full bounding box
  7099. * @param frustumPlanes Camera near/planes
  7100. * @returns true if the object is in frustum otherwise false
  7101. */
  7102. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7103. /** @hidden */
  7104. _checkCollision(collider: Collider): boolean;
  7105. /**
  7106. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7107. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7108. * @param point the point to check intersection with
  7109. * @returns if the point intersects
  7110. */
  7111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7112. /**
  7113. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7114. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7115. * @param boundingInfo the bounding info to check intersection with
  7116. * @param precise if the intersection should be done using OBB
  7117. * @returns if the bounding info intersects
  7118. */
  7119. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7120. }
  7121. }
  7122. declare module BABYLON {
  7123. /**
  7124. * Extracts minimum and maximum values from a list of indexed positions
  7125. * @param positions defines the positions to use
  7126. * @param indices defines the indices to the positions
  7127. * @param indexStart defines the start index
  7128. * @param indexCount defines the end index
  7129. * @param bias defines bias value to add to the result
  7130. * @return minimum and maximum values
  7131. */
  7132. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7133. minimum: Vector3;
  7134. maximum: Vector3;
  7135. };
  7136. /**
  7137. * Extracts minimum and maximum values from a list of positions
  7138. * @param positions defines the positions to use
  7139. * @param start defines the start index in the positions array
  7140. * @param count defines the number of positions to handle
  7141. * @param bias defines bias value to add to the result
  7142. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7143. * @return minimum and maximum values
  7144. */
  7145. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7146. minimum: Vector3;
  7147. maximum: Vector3;
  7148. };
  7149. }
  7150. declare module BABYLON {
  7151. /** @hidden */
  7152. export class WebGLDataBuffer extends DataBuffer {
  7153. private _buffer;
  7154. constructor(resource: WebGLBuffer);
  7155. get underlyingResource(): any;
  7156. }
  7157. }
  7158. declare module BABYLON {
  7159. /** @hidden */
  7160. export class WebGLPipelineContext implements IPipelineContext {
  7161. engine: ThinEngine;
  7162. program: Nullable<WebGLProgram>;
  7163. context?: WebGLRenderingContext;
  7164. vertexShader?: WebGLShader;
  7165. fragmentShader?: WebGLShader;
  7166. isParallelCompiled: boolean;
  7167. onCompiled?: () => void;
  7168. transformFeedback?: WebGLTransformFeedback | null;
  7169. vertexCompilationError: Nullable<string>;
  7170. fragmentCompilationError: Nullable<string>;
  7171. programLinkError: Nullable<string>;
  7172. programValidationError: Nullable<string>;
  7173. get isAsync(): boolean;
  7174. get isReady(): boolean;
  7175. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7176. _getVertexShaderCode(): string | null;
  7177. _getFragmentShaderCode(): string | null;
  7178. }
  7179. }
  7180. declare module BABYLON {
  7181. interface ThinEngine {
  7182. /**
  7183. * Create an uniform buffer
  7184. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7185. * @param elements defines the content of the uniform buffer
  7186. * @returns the webGL uniform buffer
  7187. */
  7188. createUniformBuffer(elements: FloatArray): DataBuffer;
  7189. /**
  7190. * Create a dynamic uniform buffer
  7191. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7192. * @param elements defines the content of the uniform buffer
  7193. * @returns the webGL uniform buffer
  7194. */
  7195. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7196. /**
  7197. * Update an existing uniform buffer
  7198. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7199. * @param uniformBuffer defines the target uniform buffer
  7200. * @param elements defines the content to update
  7201. * @param offset defines the offset in the uniform buffer where update should start
  7202. * @param count defines the size of the data to update
  7203. */
  7204. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7205. /**
  7206. * Bind an uniform buffer to the current webGL context
  7207. * @param buffer defines the buffer to bind
  7208. */
  7209. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7210. /**
  7211. * Bind a buffer to the current webGL context at a given location
  7212. * @param buffer defines the buffer to bind
  7213. * @param location defines the index where to bind the buffer
  7214. */
  7215. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7216. /**
  7217. * Bind a specific block at a given index in a specific shader program
  7218. * @param pipelineContext defines the pipeline context to use
  7219. * @param blockName defines the block name
  7220. * @param index defines the index where to bind the block
  7221. */
  7222. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7223. }
  7224. }
  7225. declare module BABYLON {
  7226. /**
  7227. * Uniform buffer objects.
  7228. *
  7229. * Handles blocks of uniform on the GPU.
  7230. *
  7231. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7232. *
  7233. * For more information, please refer to :
  7234. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7235. */
  7236. export class UniformBuffer {
  7237. private _engine;
  7238. private _buffer;
  7239. private _data;
  7240. private _bufferData;
  7241. private _dynamic?;
  7242. private _uniformLocations;
  7243. private _uniformSizes;
  7244. private _uniformLocationPointer;
  7245. private _needSync;
  7246. private _noUBO;
  7247. private _currentEffect;
  7248. /** @hidden */
  7249. _alreadyBound: boolean;
  7250. private static _MAX_UNIFORM_SIZE;
  7251. private static _tempBuffer;
  7252. /**
  7253. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7254. * This is dynamic to allow compat with webgl 1 and 2.
  7255. * You will need to pass the name of the uniform as well as the value.
  7256. */
  7257. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7258. /**
  7259. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7260. * This is dynamic to allow compat with webgl 1 and 2.
  7261. * You will need to pass the name of the uniform as well as the value.
  7262. */
  7263. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7264. /**
  7265. * Lambda to Update a single float in a uniform buffer.
  7266. * This is dynamic to allow compat with webgl 1 and 2.
  7267. * You will need to pass the name of the uniform as well as the value.
  7268. */
  7269. updateFloat: (name: string, x: number) => void;
  7270. /**
  7271. * Lambda to Update a vec2 of float in a uniform buffer.
  7272. * This is dynamic to allow compat with webgl 1 and 2.
  7273. * You will need to pass the name of the uniform as well as the value.
  7274. */
  7275. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7276. /**
  7277. * Lambda to Update a vec3 of float in a uniform buffer.
  7278. * This is dynamic to allow compat with webgl 1 and 2.
  7279. * You will need to pass the name of the uniform as well as the value.
  7280. */
  7281. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7282. /**
  7283. * Lambda to Update a vec4 of float in a uniform buffer.
  7284. * This is dynamic to allow compat with webgl 1 and 2.
  7285. * You will need to pass the name of the uniform as well as the value.
  7286. */
  7287. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7288. /**
  7289. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7290. * This is dynamic to allow compat with webgl 1 and 2.
  7291. * You will need to pass the name of the uniform as well as the value.
  7292. */
  7293. updateMatrix: (name: string, mat: Matrix) => void;
  7294. /**
  7295. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7296. * This is dynamic to allow compat with webgl 1 and 2.
  7297. * You will need to pass the name of the uniform as well as the value.
  7298. */
  7299. updateVector3: (name: string, vector: Vector3) => void;
  7300. /**
  7301. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7302. * This is dynamic to allow compat with webgl 1 and 2.
  7303. * You will need to pass the name of the uniform as well as the value.
  7304. */
  7305. updateVector4: (name: string, vector: Vector4) => void;
  7306. /**
  7307. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7308. * This is dynamic to allow compat with webgl 1 and 2.
  7309. * You will need to pass the name of the uniform as well as the value.
  7310. */
  7311. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7312. /**
  7313. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7314. * This is dynamic to allow compat with webgl 1 and 2.
  7315. * You will need to pass the name of the uniform as well as the value.
  7316. */
  7317. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7318. /**
  7319. * Instantiates a new Uniform buffer objects.
  7320. *
  7321. * Handles blocks of uniform on the GPU.
  7322. *
  7323. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7324. *
  7325. * For more information, please refer to :
  7326. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7327. * @param engine Define the engine the buffer is associated with
  7328. * @param data Define the data contained in the buffer
  7329. * @param dynamic Define if the buffer is updatable
  7330. */
  7331. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7332. /**
  7333. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7334. * or just falling back on setUniformXXX calls.
  7335. */
  7336. get useUbo(): boolean;
  7337. /**
  7338. * Indicates if the WebGL underlying uniform buffer is in sync
  7339. * with the javascript cache data.
  7340. */
  7341. get isSync(): boolean;
  7342. /**
  7343. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7344. * Also, a dynamic UniformBuffer will disable cache verification and always
  7345. * update the underlying WebGL uniform buffer to the GPU.
  7346. * @returns if Dynamic, otherwise false
  7347. */
  7348. isDynamic(): boolean;
  7349. /**
  7350. * The data cache on JS side.
  7351. * @returns the underlying data as a float array
  7352. */
  7353. getData(): Float32Array;
  7354. /**
  7355. * The underlying WebGL Uniform buffer.
  7356. * @returns the webgl buffer
  7357. */
  7358. getBuffer(): Nullable<DataBuffer>;
  7359. /**
  7360. * std140 layout specifies how to align data within an UBO structure.
  7361. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7362. * for specs.
  7363. */
  7364. private _fillAlignment;
  7365. /**
  7366. * Adds an uniform in the buffer.
  7367. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7368. * for the layout to be correct !
  7369. * @param name Name of the uniform, as used in the uniform block in the shader.
  7370. * @param size Data size, or data directly.
  7371. */
  7372. addUniform(name: string, size: number | number[]): void;
  7373. /**
  7374. * Adds a Matrix 4x4 to the uniform buffer.
  7375. * @param name Name of the uniform, as used in the uniform block in the shader.
  7376. * @param mat A 4x4 matrix.
  7377. */
  7378. addMatrix(name: string, mat: Matrix): void;
  7379. /**
  7380. * Adds a vec2 to the uniform buffer.
  7381. * @param name Name of the uniform, as used in the uniform block in the shader.
  7382. * @param x Define the x component value of the vec2
  7383. * @param y Define the y component value of the vec2
  7384. */
  7385. addFloat2(name: string, x: number, y: number): void;
  7386. /**
  7387. * Adds a vec3 to the uniform buffer.
  7388. * @param name Name of the uniform, as used in the uniform block in the shader.
  7389. * @param x Define the x component value of the vec3
  7390. * @param y Define the y component value of the vec3
  7391. * @param z Define the z component value of the vec3
  7392. */
  7393. addFloat3(name: string, x: number, y: number, z: number): void;
  7394. /**
  7395. * Adds a vec3 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param color Define the vec3 from a Color
  7398. */
  7399. addColor3(name: string, color: Color3): void;
  7400. /**
  7401. * Adds a vec4 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param color Define the rgb components from a Color
  7404. * @param alpha Define the a component of the vec4
  7405. */
  7406. addColor4(name: string, color: Color3, alpha: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param vector Define the vec3 components from a Vector
  7411. */
  7412. addVector3(name: string, vector: Vector3): void;
  7413. /**
  7414. * Adds a Matrix 3x3 to the uniform buffer.
  7415. * @param name Name of the uniform, as used in the uniform block in the shader.
  7416. */
  7417. addMatrix3x3(name: string): void;
  7418. /**
  7419. * Adds a Matrix 2x2 to the uniform buffer.
  7420. * @param name Name of the uniform, as used in the uniform block in the shader.
  7421. */
  7422. addMatrix2x2(name: string): void;
  7423. /**
  7424. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7425. */
  7426. create(): void;
  7427. /** @hidden */
  7428. _rebuild(): void;
  7429. /**
  7430. * Updates the WebGL Uniform Buffer on the GPU.
  7431. * If the `dynamic` flag is set to true, no cache comparison is done.
  7432. * Otherwise, the buffer will be updated only if the cache differs.
  7433. */
  7434. update(): void;
  7435. /**
  7436. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7437. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7438. * @param data Define the flattened data
  7439. * @param size Define the size of the data.
  7440. */
  7441. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7442. private _valueCache;
  7443. private _cacheMatrix;
  7444. private _updateMatrix3x3ForUniform;
  7445. private _updateMatrix3x3ForEffect;
  7446. private _updateMatrix2x2ForEffect;
  7447. private _updateMatrix2x2ForUniform;
  7448. private _updateFloatForEffect;
  7449. private _updateFloatForUniform;
  7450. private _updateFloat2ForEffect;
  7451. private _updateFloat2ForUniform;
  7452. private _updateFloat3ForEffect;
  7453. private _updateFloat3ForUniform;
  7454. private _updateFloat4ForEffect;
  7455. private _updateFloat4ForUniform;
  7456. private _updateMatrixForEffect;
  7457. private _updateMatrixForUniform;
  7458. private _updateVector3ForEffect;
  7459. private _updateVector3ForUniform;
  7460. private _updateVector4ForEffect;
  7461. private _updateVector4ForUniform;
  7462. private _updateColor3ForEffect;
  7463. private _updateColor3ForUniform;
  7464. private _updateColor4ForEffect;
  7465. private _updateColor4ForUniform;
  7466. /**
  7467. * Sets a sampler uniform on the effect.
  7468. * @param name Define the name of the sampler.
  7469. * @param texture Define the texture to set in the sampler
  7470. */
  7471. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7472. /**
  7473. * Directly updates the value of the uniform in the cache AND on the GPU.
  7474. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7475. * @param data Define the flattened data
  7476. */
  7477. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7478. /**
  7479. * Binds this uniform buffer to an effect.
  7480. * @param effect Define the effect to bind the buffer to
  7481. * @param name Name of the uniform block in the shader.
  7482. */
  7483. bindToEffect(effect: Effect, name: string): void;
  7484. /**
  7485. * Disposes the uniform buffer.
  7486. */
  7487. dispose(): void;
  7488. }
  7489. }
  7490. declare module BABYLON {
  7491. /**
  7492. * Enum that determines the text-wrapping mode to use.
  7493. */
  7494. export enum InspectableType {
  7495. /**
  7496. * Checkbox for booleans
  7497. */
  7498. Checkbox = 0,
  7499. /**
  7500. * Sliders for numbers
  7501. */
  7502. Slider = 1,
  7503. /**
  7504. * Vector3
  7505. */
  7506. Vector3 = 2,
  7507. /**
  7508. * Quaternions
  7509. */
  7510. Quaternion = 3,
  7511. /**
  7512. * Color3
  7513. */
  7514. Color3 = 4,
  7515. /**
  7516. * String
  7517. */
  7518. String = 5
  7519. }
  7520. /**
  7521. * Interface used to define custom inspectable properties.
  7522. * This interface is used by the inspector to display custom property grids
  7523. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7524. */
  7525. export interface IInspectable {
  7526. /**
  7527. * Gets the label to display
  7528. */
  7529. label: string;
  7530. /**
  7531. * Gets the name of the property to edit
  7532. */
  7533. propertyName: string;
  7534. /**
  7535. * Gets the type of the editor to use
  7536. */
  7537. type: InspectableType;
  7538. /**
  7539. * Gets the minimum value of the property when using in "slider" mode
  7540. */
  7541. min?: number;
  7542. /**
  7543. * Gets the maximum value of the property when using in "slider" mode
  7544. */
  7545. max?: number;
  7546. /**
  7547. * Gets the setp to use when using in "slider" mode
  7548. */
  7549. step?: number;
  7550. }
  7551. }
  7552. declare module BABYLON {
  7553. /**
  7554. * Class used to provide helper for timing
  7555. */
  7556. export class TimingTools {
  7557. /**
  7558. * Polyfill for setImmediate
  7559. * @param action defines the action to execute after the current execution block
  7560. */
  7561. static SetImmediate(action: () => void): void;
  7562. }
  7563. }
  7564. declare module BABYLON {
  7565. /**
  7566. * Class used to enable instatition of objects by class name
  7567. */
  7568. export class InstantiationTools {
  7569. /**
  7570. * Use this object to register external classes like custom textures or material
  7571. * to allow the laoders to instantiate them
  7572. */
  7573. static RegisteredExternalClasses: {
  7574. [key: string]: Object;
  7575. };
  7576. /**
  7577. * Tries to instantiate a new object from a given class name
  7578. * @param className defines the class name to instantiate
  7579. * @returns the new object or null if the system was not able to do the instantiation
  7580. */
  7581. static Instantiate(className: string): any;
  7582. }
  7583. }
  7584. declare module BABYLON {
  7585. /**
  7586. * Define options used to create a depth texture
  7587. */
  7588. export class DepthTextureCreationOptions {
  7589. /** Specifies whether or not a stencil should be allocated in the texture */
  7590. generateStencil?: boolean;
  7591. /** Specifies whether or not bilinear filtering is enable on the texture */
  7592. bilinearFiltering?: boolean;
  7593. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7594. comparisonFunction?: number;
  7595. /** Specifies if the created texture is a cube texture */
  7596. isCube?: boolean;
  7597. }
  7598. }
  7599. declare module BABYLON {
  7600. interface ThinEngine {
  7601. /**
  7602. * Creates a depth stencil cube texture.
  7603. * This is only available in WebGL 2.
  7604. * @param size The size of face edge in the cube texture.
  7605. * @param options The options defining the cube texture.
  7606. * @returns The cube texture
  7607. */
  7608. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7609. /**
  7610. * Creates a cube texture
  7611. * @param rootUrl defines the url where the files to load is located
  7612. * @param scene defines the current scene
  7613. * @param files defines the list of files to load (1 per face)
  7614. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7615. * @param onLoad defines an optional callback raised when the texture is loaded
  7616. * @param onError defines an optional callback raised if there is an issue to load the texture
  7617. * @param format defines the format of the data
  7618. * @param forcedExtension defines the extension to use to pick the right loader
  7619. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7620. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7621. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7622. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7623. * @returns the cube texture as an InternalTexture
  7624. */
  7625. 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>): InternalTexture;
  7626. /**
  7627. * Creates a cube texture
  7628. * @param rootUrl defines the url where the files to load is located
  7629. * @param scene defines the current scene
  7630. * @param files defines the list of files to load (1 per face)
  7631. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7632. * @param onLoad defines an optional callback raised when the texture is loaded
  7633. * @param onError defines an optional callback raised if there is an issue to load the texture
  7634. * @param format defines the format of the data
  7635. * @param forcedExtension defines the extension to use to pick the right loader
  7636. * @returns the cube texture as an InternalTexture
  7637. */
  7638. 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;
  7639. /**
  7640. * Creates a cube texture
  7641. * @param rootUrl defines the url where the files to load is located
  7642. * @param scene defines the current scene
  7643. * @param files defines the list of files to load (1 per face)
  7644. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7645. * @param onLoad defines an optional callback raised when the texture is loaded
  7646. * @param onError defines an optional callback raised if there is an issue to load the texture
  7647. * @param format defines the format of the data
  7648. * @param forcedExtension defines the extension to use to pick the right loader
  7649. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7650. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7651. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7652. * @returns the cube texture as an InternalTexture
  7653. */
  7654. 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;
  7655. /** @hidden */
  7656. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7657. /** @hidden */
  7658. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7659. /** @hidden */
  7660. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7661. /** @hidden */
  7662. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7663. /**
  7664. * @hidden
  7665. */
  7666. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7667. }
  7668. }
  7669. declare module BABYLON {
  7670. /**
  7671. * Class for creating a cube texture
  7672. */
  7673. export class CubeTexture extends BaseTexture {
  7674. private _delayedOnLoad;
  7675. /**
  7676. * Observable triggered once the texture has been loaded.
  7677. */
  7678. onLoadObservable: Observable<CubeTexture>;
  7679. /**
  7680. * The url of the texture
  7681. */
  7682. url: string;
  7683. /**
  7684. * Gets or sets the center of the bounding box associated with the cube texture.
  7685. * It must define where the camera used to render the texture was set
  7686. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7687. */
  7688. boundingBoxPosition: Vector3;
  7689. private _boundingBoxSize;
  7690. /**
  7691. * Gets or sets the size of the bounding box associated with the cube texture
  7692. * When defined, the cubemap will switch to local mode
  7693. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7694. * @example https://www.babylonjs-playground.com/#RNASML
  7695. */
  7696. set boundingBoxSize(value: Vector3);
  7697. /**
  7698. * Returns the bounding box size
  7699. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7700. */
  7701. get boundingBoxSize(): Vector3;
  7702. protected _rotationY: number;
  7703. /**
  7704. * Sets texture matrix rotation angle around Y axis in radians.
  7705. */
  7706. set rotationY(value: number);
  7707. /**
  7708. * Gets texture matrix rotation angle around Y axis radians.
  7709. */
  7710. get rotationY(): number;
  7711. /**
  7712. * Are mip maps generated for this texture or not.
  7713. */
  7714. get noMipmap(): boolean;
  7715. private _noMipmap;
  7716. private _files;
  7717. protected _forcedExtension: Nullable<string>;
  7718. private _extensions;
  7719. private _textureMatrix;
  7720. private _format;
  7721. private _createPolynomials;
  7722. /** @hidden */
  7723. _prefiltered: boolean;
  7724. /**
  7725. * Creates a cube texture from an array of image urls
  7726. * @param files defines an array of image urls
  7727. * @param scene defines the hosting scene
  7728. * @param noMipmap specifies if mip maps are not used
  7729. * @returns a cube texture
  7730. */
  7731. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7732. /**
  7733. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7734. * @param url defines the url of the prefiltered texture
  7735. * @param scene defines the scene the texture is attached to
  7736. * @param forcedExtension defines the extension of the file if different from the url
  7737. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7738. * @return the prefiltered texture
  7739. */
  7740. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7741. /**
  7742. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7743. * as prefiltered data.
  7744. * @param rootUrl defines the url of the texture or the root name of the six images
  7745. * @param scene defines the scene the texture is attached to
  7746. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7747. * @param noMipmap defines if mipmaps should be created or not
  7748. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7749. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7750. * @param onError defines a callback triggered in case of error during load
  7751. * @param format defines the internal format to use for the texture once loaded
  7752. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7753. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7754. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7755. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7756. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7757. * @return the cube texture
  7758. */
  7759. 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);
  7760. /**
  7761. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7762. */
  7763. get isPrefiltered(): boolean;
  7764. /**
  7765. * Get the current class name of the texture useful for serialization or dynamic coding.
  7766. * @returns "CubeTexture"
  7767. */
  7768. getClassName(): string;
  7769. /**
  7770. * Update the url (and optional buffer) of this texture if url was null during construction.
  7771. * @param url the url of the texture
  7772. * @param forcedExtension defines the extension to use
  7773. * @param onLoad callback called when the texture is loaded (defaults to null)
  7774. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7775. */
  7776. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7777. /**
  7778. * Delays loading of the cube texture
  7779. * @param forcedExtension defines the extension to use
  7780. */
  7781. delayLoad(forcedExtension?: string): void;
  7782. /**
  7783. * Returns the reflection texture matrix
  7784. * @returns the reflection texture matrix
  7785. */
  7786. getReflectionTextureMatrix(): Matrix;
  7787. /**
  7788. * Sets the reflection texture matrix
  7789. * @param value Reflection texture matrix
  7790. */
  7791. setReflectionTextureMatrix(value: Matrix): void;
  7792. /**
  7793. * Parses text to create a cube texture
  7794. * @param parsedTexture define the serialized text to read from
  7795. * @param scene defines the hosting scene
  7796. * @param rootUrl defines the root url of the cube texture
  7797. * @returns a cube texture
  7798. */
  7799. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7800. /**
  7801. * Makes a clone, or deep copy, of the cube texture
  7802. * @returns a new cube texture
  7803. */
  7804. clone(): CubeTexture;
  7805. }
  7806. }
  7807. declare module BABYLON {
  7808. /**
  7809. * Manages the defines for the Material
  7810. */
  7811. export class MaterialDefines {
  7812. /** @hidden */
  7813. protected _keys: string[];
  7814. private _isDirty;
  7815. /** @hidden */
  7816. _renderId: number;
  7817. /** @hidden */
  7818. _areLightsDirty: boolean;
  7819. /** @hidden */
  7820. _areLightsDisposed: boolean;
  7821. /** @hidden */
  7822. _areAttributesDirty: boolean;
  7823. /** @hidden */
  7824. _areTexturesDirty: boolean;
  7825. /** @hidden */
  7826. _areFresnelDirty: boolean;
  7827. /** @hidden */
  7828. _areMiscDirty: boolean;
  7829. /** @hidden */
  7830. _areImageProcessingDirty: boolean;
  7831. /** @hidden */
  7832. _normals: boolean;
  7833. /** @hidden */
  7834. _uvs: boolean;
  7835. /** @hidden */
  7836. _needNormals: boolean;
  7837. /** @hidden */
  7838. _needUVs: boolean;
  7839. [id: string]: any;
  7840. /**
  7841. * Specifies if the material needs to be re-calculated
  7842. */
  7843. get isDirty(): boolean;
  7844. /**
  7845. * Marks the material to indicate that it has been re-calculated
  7846. */
  7847. markAsProcessed(): void;
  7848. /**
  7849. * Marks the material to indicate that it needs to be re-calculated
  7850. */
  7851. markAsUnprocessed(): void;
  7852. /**
  7853. * Marks the material to indicate all of its defines need to be re-calculated
  7854. */
  7855. markAllAsDirty(): void;
  7856. /**
  7857. * Marks the material to indicate that image processing needs to be re-calculated
  7858. */
  7859. markAsImageProcessingDirty(): void;
  7860. /**
  7861. * Marks the material to indicate the lights need to be re-calculated
  7862. * @param disposed Defines whether the light is dirty due to dispose or not
  7863. */
  7864. markAsLightDirty(disposed?: boolean): void;
  7865. /**
  7866. * Marks the attribute state as changed
  7867. */
  7868. markAsAttributesDirty(): void;
  7869. /**
  7870. * Marks the texture state as changed
  7871. */
  7872. markAsTexturesDirty(): void;
  7873. /**
  7874. * Marks the fresnel state as changed
  7875. */
  7876. markAsFresnelDirty(): void;
  7877. /**
  7878. * Marks the misc state as changed
  7879. */
  7880. markAsMiscDirty(): void;
  7881. /**
  7882. * Rebuilds the material defines
  7883. */
  7884. rebuild(): void;
  7885. /**
  7886. * Specifies if two material defines are equal
  7887. * @param other - A material define instance to compare to
  7888. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7889. */
  7890. isEqual(other: MaterialDefines): boolean;
  7891. /**
  7892. * Clones this instance's defines to another instance
  7893. * @param other - material defines to clone values to
  7894. */
  7895. cloneTo(other: MaterialDefines): void;
  7896. /**
  7897. * Resets the material define values
  7898. */
  7899. reset(): void;
  7900. /**
  7901. * Converts the material define values to a string
  7902. * @returns - String of material define information
  7903. */
  7904. toString(): string;
  7905. }
  7906. }
  7907. declare module BABYLON {
  7908. /**
  7909. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7910. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7911. * 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;
  7912. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7913. */
  7914. export class ColorCurves {
  7915. private _dirty;
  7916. private _tempColor;
  7917. private _globalCurve;
  7918. private _highlightsCurve;
  7919. private _midtonesCurve;
  7920. private _shadowsCurve;
  7921. private _positiveCurve;
  7922. private _negativeCurve;
  7923. private _globalHue;
  7924. private _globalDensity;
  7925. private _globalSaturation;
  7926. private _globalExposure;
  7927. /**
  7928. * Gets the global Hue value.
  7929. * 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).
  7930. */
  7931. get globalHue(): number;
  7932. /**
  7933. * Sets the global Hue value.
  7934. * 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).
  7935. */
  7936. set globalHue(value: number);
  7937. /**
  7938. * Gets the global Density value.
  7939. * 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.
  7940. * Values less than zero provide a filter of opposite hue.
  7941. */
  7942. get globalDensity(): number;
  7943. /**
  7944. * Sets the global Density value.
  7945. * 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.
  7946. * Values less than zero provide a filter of opposite hue.
  7947. */
  7948. set globalDensity(value: number);
  7949. /**
  7950. * Gets the global Saturation value.
  7951. * 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.
  7952. */
  7953. get globalSaturation(): number;
  7954. /**
  7955. * Sets the global Saturation value.
  7956. * 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.
  7957. */
  7958. set globalSaturation(value: number);
  7959. /**
  7960. * Gets the global Exposure value.
  7961. * 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.
  7962. */
  7963. get globalExposure(): number;
  7964. /**
  7965. * Sets the global Exposure value.
  7966. * 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.
  7967. */
  7968. set globalExposure(value: number);
  7969. private _highlightsHue;
  7970. private _highlightsDensity;
  7971. private _highlightsSaturation;
  7972. private _highlightsExposure;
  7973. /**
  7974. * Gets the highlights Hue value.
  7975. * 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).
  7976. */
  7977. get highlightsHue(): number;
  7978. /**
  7979. * Sets the highlights Hue value.
  7980. * 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).
  7981. */
  7982. set highlightsHue(value: number);
  7983. /**
  7984. * Gets the highlights Density value.
  7985. * 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.
  7986. * Values less than zero provide a filter of opposite hue.
  7987. */
  7988. get highlightsDensity(): number;
  7989. /**
  7990. * Sets the highlights Density value.
  7991. * 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.
  7992. * Values less than zero provide a filter of opposite hue.
  7993. */
  7994. set highlightsDensity(value: number);
  7995. /**
  7996. * Gets the highlights Saturation value.
  7997. * 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.
  7998. */
  7999. get highlightsSaturation(): number;
  8000. /**
  8001. * Sets the highlights Saturation value.
  8002. * 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.
  8003. */
  8004. set highlightsSaturation(value: number);
  8005. /**
  8006. * Gets the highlights Exposure value.
  8007. * 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.
  8008. */
  8009. get highlightsExposure(): number;
  8010. /**
  8011. * Sets the highlights Exposure value.
  8012. * 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.
  8013. */
  8014. set highlightsExposure(value: number);
  8015. private _midtonesHue;
  8016. private _midtonesDensity;
  8017. private _midtonesSaturation;
  8018. private _midtonesExposure;
  8019. /**
  8020. * Gets the midtones Hue value.
  8021. * 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).
  8022. */
  8023. get midtonesHue(): number;
  8024. /**
  8025. * Sets the midtones Hue value.
  8026. * 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).
  8027. */
  8028. set midtonesHue(value: number);
  8029. /**
  8030. * Gets the midtones Density value.
  8031. * 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.
  8032. * Values less than zero provide a filter of opposite hue.
  8033. */
  8034. get midtonesDensity(): number;
  8035. /**
  8036. * Sets the midtones Density value.
  8037. * 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.
  8038. * Values less than zero provide a filter of opposite hue.
  8039. */
  8040. set midtonesDensity(value: number);
  8041. /**
  8042. * Gets the midtones Saturation value.
  8043. * 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.
  8044. */
  8045. get midtonesSaturation(): number;
  8046. /**
  8047. * Sets the midtones Saturation value.
  8048. * 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.
  8049. */
  8050. set midtonesSaturation(value: number);
  8051. /**
  8052. * Gets the midtones Exposure value.
  8053. * 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.
  8054. */
  8055. get midtonesExposure(): number;
  8056. /**
  8057. * Sets the midtones Exposure value.
  8058. * 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.
  8059. */
  8060. set midtonesExposure(value: number);
  8061. private _shadowsHue;
  8062. private _shadowsDensity;
  8063. private _shadowsSaturation;
  8064. private _shadowsExposure;
  8065. /**
  8066. * Gets the shadows Hue value.
  8067. * 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).
  8068. */
  8069. get shadowsHue(): number;
  8070. /**
  8071. * Sets the shadows Hue value.
  8072. * 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).
  8073. */
  8074. set shadowsHue(value: number);
  8075. /**
  8076. * Gets the shadows Density value.
  8077. * 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.
  8078. * Values less than zero provide a filter of opposite hue.
  8079. */
  8080. get shadowsDensity(): number;
  8081. /**
  8082. * Sets the shadows Density value.
  8083. * 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.
  8084. * Values less than zero provide a filter of opposite hue.
  8085. */
  8086. set shadowsDensity(value: number);
  8087. /**
  8088. * Gets the shadows Saturation value.
  8089. * 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.
  8090. */
  8091. get shadowsSaturation(): number;
  8092. /**
  8093. * Sets the shadows Saturation value.
  8094. * 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.
  8095. */
  8096. set shadowsSaturation(value: number);
  8097. /**
  8098. * Gets the shadows Exposure value.
  8099. * 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.
  8100. */
  8101. get shadowsExposure(): number;
  8102. /**
  8103. * Sets the shadows Exposure value.
  8104. * 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.
  8105. */
  8106. set shadowsExposure(value: number);
  8107. /**
  8108. * Returns the class name
  8109. * @returns The class name
  8110. */
  8111. getClassName(): string;
  8112. /**
  8113. * Binds the color curves to the shader.
  8114. * @param colorCurves The color curve to bind
  8115. * @param effect The effect to bind to
  8116. * @param positiveUniform The positive uniform shader parameter
  8117. * @param neutralUniform The neutral uniform shader parameter
  8118. * @param negativeUniform The negative uniform shader parameter
  8119. */
  8120. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8121. /**
  8122. * Prepare the list of uniforms associated with the ColorCurves effects.
  8123. * @param uniformsList The list of uniforms used in the effect
  8124. */
  8125. static PrepareUniforms(uniformsList: string[]): void;
  8126. /**
  8127. * Returns color grading data based on a hue, density, saturation and exposure value.
  8128. * @param filterHue The hue of the color filter.
  8129. * @param filterDensity The density of the color filter.
  8130. * @param saturation The saturation.
  8131. * @param exposure The exposure.
  8132. * @param result The result data container.
  8133. */
  8134. private getColorGradingDataToRef;
  8135. /**
  8136. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8137. * @param value The input slider value in range [-100,100].
  8138. * @returns Adjusted value.
  8139. */
  8140. private static applyColorGradingSliderNonlinear;
  8141. /**
  8142. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8143. * @param hue The hue (H) input.
  8144. * @param saturation The saturation (S) input.
  8145. * @param brightness The brightness (B) input.
  8146. * @result An RGBA color represented as Vector4.
  8147. */
  8148. private static fromHSBToRef;
  8149. /**
  8150. * Returns a value clamped between min and max
  8151. * @param value The value to clamp
  8152. * @param min The minimum of value
  8153. * @param max The maximum of value
  8154. * @returns The clamped value.
  8155. */
  8156. private static clamp;
  8157. /**
  8158. * Clones the current color curve instance.
  8159. * @return The cloned curves
  8160. */
  8161. clone(): ColorCurves;
  8162. /**
  8163. * Serializes the current color curve instance to a json representation.
  8164. * @return a JSON representation
  8165. */
  8166. serialize(): any;
  8167. /**
  8168. * Parses the color curve from a json representation.
  8169. * @param source the JSON source to parse
  8170. * @return The parsed curves
  8171. */
  8172. static Parse(source: any): ColorCurves;
  8173. }
  8174. }
  8175. declare module BABYLON {
  8176. /**
  8177. * Interface to follow in your material defines to integrate easily the
  8178. * Image proccessing functions.
  8179. * @hidden
  8180. */
  8181. export interface IImageProcessingConfigurationDefines {
  8182. IMAGEPROCESSING: boolean;
  8183. VIGNETTE: boolean;
  8184. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8185. VIGNETTEBLENDMODEOPAQUE: boolean;
  8186. TONEMAPPING: boolean;
  8187. TONEMAPPING_ACES: boolean;
  8188. CONTRAST: boolean;
  8189. EXPOSURE: boolean;
  8190. COLORCURVES: boolean;
  8191. COLORGRADING: boolean;
  8192. COLORGRADING3D: boolean;
  8193. SAMPLER3DGREENDEPTH: boolean;
  8194. SAMPLER3DBGRMAP: boolean;
  8195. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8196. }
  8197. /**
  8198. * @hidden
  8199. */
  8200. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8201. IMAGEPROCESSING: boolean;
  8202. VIGNETTE: boolean;
  8203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8204. VIGNETTEBLENDMODEOPAQUE: boolean;
  8205. TONEMAPPING: boolean;
  8206. TONEMAPPING_ACES: boolean;
  8207. CONTRAST: boolean;
  8208. COLORCURVES: boolean;
  8209. COLORGRADING: boolean;
  8210. COLORGRADING3D: boolean;
  8211. SAMPLER3DGREENDEPTH: boolean;
  8212. SAMPLER3DBGRMAP: boolean;
  8213. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8214. EXPOSURE: boolean;
  8215. constructor();
  8216. }
  8217. /**
  8218. * This groups together the common properties used for image processing either in direct forward pass
  8219. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8220. * or not.
  8221. */
  8222. export class ImageProcessingConfiguration {
  8223. /**
  8224. * Default tone mapping applied in BabylonJS.
  8225. */
  8226. static readonly TONEMAPPING_STANDARD: number;
  8227. /**
  8228. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8229. * to other engines rendering to increase portability.
  8230. */
  8231. static readonly TONEMAPPING_ACES: number;
  8232. /**
  8233. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8234. */
  8235. colorCurves: Nullable<ColorCurves>;
  8236. private _colorCurvesEnabled;
  8237. /**
  8238. * Gets wether the color curves effect is enabled.
  8239. */
  8240. get colorCurvesEnabled(): boolean;
  8241. /**
  8242. * Sets wether the color curves effect is enabled.
  8243. */
  8244. set colorCurvesEnabled(value: boolean);
  8245. private _colorGradingTexture;
  8246. /**
  8247. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8248. */
  8249. get colorGradingTexture(): Nullable<BaseTexture>;
  8250. /**
  8251. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8252. */
  8253. set colorGradingTexture(value: Nullable<BaseTexture>);
  8254. private _colorGradingEnabled;
  8255. /**
  8256. * Gets wether the color grading effect is enabled.
  8257. */
  8258. get colorGradingEnabled(): boolean;
  8259. /**
  8260. * Sets wether the color grading effect is enabled.
  8261. */
  8262. set colorGradingEnabled(value: boolean);
  8263. private _colorGradingWithGreenDepth;
  8264. /**
  8265. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8266. */
  8267. get colorGradingWithGreenDepth(): boolean;
  8268. /**
  8269. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8270. */
  8271. set colorGradingWithGreenDepth(value: boolean);
  8272. private _colorGradingBGR;
  8273. /**
  8274. * Gets wether the color grading texture contains BGR values.
  8275. */
  8276. get colorGradingBGR(): boolean;
  8277. /**
  8278. * Sets wether the color grading texture contains BGR values.
  8279. */
  8280. set colorGradingBGR(value: boolean);
  8281. /** @hidden */
  8282. _exposure: number;
  8283. /**
  8284. * Gets the Exposure used in the effect.
  8285. */
  8286. get exposure(): number;
  8287. /**
  8288. * Sets the Exposure used in the effect.
  8289. */
  8290. set exposure(value: number);
  8291. private _toneMappingEnabled;
  8292. /**
  8293. * Gets wether the tone mapping effect is enabled.
  8294. */
  8295. get toneMappingEnabled(): boolean;
  8296. /**
  8297. * Sets wether the tone mapping effect is enabled.
  8298. */
  8299. set toneMappingEnabled(value: boolean);
  8300. private _toneMappingType;
  8301. /**
  8302. * Gets the type of tone mapping effect.
  8303. */
  8304. get toneMappingType(): number;
  8305. /**
  8306. * Sets the type of tone mapping effect used in BabylonJS.
  8307. */
  8308. set toneMappingType(value: number);
  8309. protected _contrast: number;
  8310. /**
  8311. * Gets the contrast used in the effect.
  8312. */
  8313. get contrast(): number;
  8314. /**
  8315. * Sets the contrast used in the effect.
  8316. */
  8317. set contrast(value: number);
  8318. /**
  8319. * Vignette stretch size.
  8320. */
  8321. vignetteStretch: number;
  8322. /**
  8323. * Vignette centre X Offset.
  8324. */
  8325. vignetteCentreX: number;
  8326. /**
  8327. * Vignette centre Y Offset.
  8328. */
  8329. vignetteCentreY: number;
  8330. /**
  8331. * Vignette weight or intensity of the vignette effect.
  8332. */
  8333. vignetteWeight: number;
  8334. /**
  8335. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8336. * if vignetteEnabled is set to true.
  8337. */
  8338. vignetteColor: Color4;
  8339. /**
  8340. * Camera field of view used by the Vignette effect.
  8341. */
  8342. vignetteCameraFov: number;
  8343. private _vignetteBlendMode;
  8344. /**
  8345. * Gets the vignette blend mode allowing different kind of effect.
  8346. */
  8347. get vignetteBlendMode(): number;
  8348. /**
  8349. * Sets the vignette blend mode allowing different kind of effect.
  8350. */
  8351. set vignetteBlendMode(value: number);
  8352. private _vignetteEnabled;
  8353. /**
  8354. * Gets wether the vignette effect is enabled.
  8355. */
  8356. get vignetteEnabled(): boolean;
  8357. /**
  8358. * Sets wether the vignette effect is enabled.
  8359. */
  8360. set vignetteEnabled(value: boolean);
  8361. private _applyByPostProcess;
  8362. /**
  8363. * Gets wether the image processing is applied through a post process or not.
  8364. */
  8365. get applyByPostProcess(): boolean;
  8366. /**
  8367. * Sets wether the image processing is applied through a post process or not.
  8368. */
  8369. set applyByPostProcess(value: boolean);
  8370. private _isEnabled;
  8371. /**
  8372. * Gets wether the image processing is enabled or not.
  8373. */
  8374. get isEnabled(): boolean;
  8375. /**
  8376. * Sets wether the image processing is enabled or not.
  8377. */
  8378. set isEnabled(value: boolean);
  8379. /**
  8380. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8381. */
  8382. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8383. /**
  8384. * Method called each time the image processing information changes requires to recompile the effect.
  8385. */
  8386. protected _updateParameters(): void;
  8387. /**
  8388. * Gets the current class name.
  8389. * @return "ImageProcessingConfiguration"
  8390. */
  8391. getClassName(): string;
  8392. /**
  8393. * Prepare the list of uniforms associated with the Image Processing effects.
  8394. * @param uniforms The list of uniforms used in the effect
  8395. * @param defines the list of defines currently in use
  8396. */
  8397. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8398. /**
  8399. * Prepare the list of samplers associated with the Image Processing effects.
  8400. * @param samplersList The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of defines associated to the shader.
  8406. * @param defines the list of defines to complete
  8407. * @param forPostProcess Define if we are currently in post process mode or not
  8408. */
  8409. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8410. /**
  8411. * Returns true if all the image processing information are ready.
  8412. * @returns True if ready, otherwise, false
  8413. */
  8414. isReady(): boolean;
  8415. /**
  8416. * Binds the image processing to the shader.
  8417. * @param effect The effect to bind to
  8418. * @param overrideAspectRatio Override the aspect ratio of the effect
  8419. */
  8420. bind(effect: Effect, overrideAspectRatio?: number): void;
  8421. /**
  8422. * Clones the current image processing instance.
  8423. * @return The cloned image processing
  8424. */
  8425. clone(): ImageProcessingConfiguration;
  8426. /**
  8427. * Serializes the current image processing instance to a json representation.
  8428. * @return a JSON representation
  8429. */
  8430. serialize(): any;
  8431. /**
  8432. * Parses the image processing from a json representation.
  8433. * @param source the JSON source to parse
  8434. * @return The parsed image processing
  8435. */
  8436. static Parse(source: any): ImageProcessingConfiguration;
  8437. private static _VIGNETTEMODE_MULTIPLY;
  8438. private static _VIGNETTEMODE_OPAQUE;
  8439. /**
  8440. * Used to apply the vignette as a mix with the pixel color.
  8441. */
  8442. static get VIGNETTEMODE_MULTIPLY(): number;
  8443. /**
  8444. * Used to apply the vignette as a replacement of the pixel color.
  8445. */
  8446. static get VIGNETTEMODE_OPAQUE(): number;
  8447. }
  8448. }
  8449. declare module BABYLON {
  8450. /** @hidden */
  8451. export var postprocessVertexShader: {
  8452. name: string;
  8453. shader: string;
  8454. };
  8455. }
  8456. declare module BABYLON {
  8457. interface ThinEngine {
  8458. /**
  8459. * Creates a new render target texture
  8460. * @param size defines the size of the texture
  8461. * @param options defines the options used to create the texture
  8462. * @returns a new render target texture stored in an InternalTexture
  8463. */
  8464. createRenderTargetTexture(size: number | {
  8465. width: number;
  8466. height: number;
  8467. layers?: number;
  8468. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8469. /**
  8470. * Creates a depth stencil texture.
  8471. * This is only available in WebGL 2 or with the depth texture extension available.
  8472. * @param size The size of face edge in the texture.
  8473. * @param options The options defining the texture.
  8474. * @returns The texture
  8475. */
  8476. createDepthStencilTexture(size: number | {
  8477. width: number;
  8478. height: number;
  8479. layers?: number;
  8480. }, options: DepthTextureCreationOptions): InternalTexture;
  8481. /** @hidden */
  8482. _createDepthStencilTexture(size: number | {
  8483. width: number;
  8484. height: number;
  8485. layers?: number;
  8486. }, options: DepthTextureCreationOptions): InternalTexture;
  8487. }
  8488. }
  8489. declare module BABYLON {
  8490. /** Defines supported spaces */
  8491. export enum Space {
  8492. /** Local (object) space */
  8493. LOCAL = 0,
  8494. /** World space */
  8495. WORLD = 1,
  8496. /** Bone space */
  8497. BONE = 2
  8498. }
  8499. /** Defines the 3 main axes */
  8500. export class Axis {
  8501. /** X axis */
  8502. static X: Vector3;
  8503. /** Y axis */
  8504. static Y: Vector3;
  8505. /** Z axis */
  8506. static Z: Vector3;
  8507. }
  8508. }
  8509. declare module BABYLON {
  8510. /**
  8511. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8512. * This is the base of the follow, arc rotate cameras and Free camera
  8513. * @see http://doc.babylonjs.com/features/cameras
  8514. */
  8515. export class TargetCamera extends Camera {
  8516. private static _RigCamTransformMatrix;
  8517. private static _TargetTransformMatrix;
  8518. private static _TargetFocalPoint;
  8519. /**
  8520. * Define the current direction the camera is moving to
  8521. */
  8522. cameraDirection: Vector3;
  8523. /**
  8524. * Define the current rotation the camera is rotating to
  8525. */
  8526. cameraRotation: Vector2;
  8527. /**
  8528. * When set, the up vector of the camera will be updated by the rotation of the camera
  8529. */
  8530. updateUpVectorFromRotation: boolean;
  8531. private _tmpQuaternion;
  8532. /**
  8533. * Define the current rotation of the camera
  8534. */
  8535. rotation: Vector3;
  8536. /**
  8537. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8538. */
  8539. rotationQuaternion: Quaternion;
  8540. /**
  8541. * Define the current speed of the camera
  8542. */
  8543. speed: number;
  8544. /**
  8545. * Add constraint to the camera to prevent it to move freely in all directions and
  8546. * around all axis.
  8547. */
  8548. noRotationConstraint: boolean;
  8549. /**
  8550. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8551. * panning
  8552. */
  8553. invertRotation: boolean;
  8554. /**
  8555. * Speed multiplier for inverse camera panning
  8556. */
  8557. inverseRotationSpeed: number;
  8558. /**
  8559. * Define the current target of the camera as an object or a position.
  8560. */
  8561. lockedTarget: any;
  8562. /** @hidden */
  8563. _currentTarget: Vector3;
  8564. /** @hidden */
  8565. _initialFocalDistance: number;
  8566. /** @hidden */
  8567. _viewMatrix: Matrix;
  8568. /** @hidden */
  8569. _camMatrix: Matrix;
  8570. /** @hidden */
  8571. _cameraTransformMatrix: Matrix;
  8572. /** @hidden */
  8573. _cameraRotationMatrix: Matrix;
  8574. /** @hidden */
  8575. _referencePoint: Vector3;
  8576. /** @hidden */
  8577. _transformedReferencePoint: Vector3;
  8578. protected _globalCurrentTarget: Vector3;
  8579. protected _globalCurrentUpVector: Vector3;
  8580. /** @hidden */
  8581. _reset: () => void;
  8582. private _defaultUp;
  8583. /**
  8584. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8585. * This is the base of the follow, arc rotate cameras and Free camera
  8586. * @see http://doc.babylonjs.com/features/cameras
  8587. * @param name Defines the name of the camera in the scene
  8588. * @param position Defines the start position of the camera in the scene
  8589. * @param scene Defines the scene the camera belongs to
  8590. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8591. */
  8592. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8593. /**
  8594. * Gets the position in front of the camera at a given distance.
  8595. * @param distance The distance from the camera we want the position to be
  8596. * @returns the position
  8597. */
  8598. getFrontPosition(distance: number): Vector3;
  8599. /** @hidden */
  8600. _getLockedTargetPosition(): Nullable<Vector3>;
  8601. private _storedPosition;
  8602. private _storedRotation;
  8603. private _storedRotationQuaternion;
  8604. /**
  8605. * Store current camera state of the camera (fov, position, rotation, etc..)
  8606. * @returns the camera
  8607. */
  8608. storeState(): Camera;
  8609. /**
  8610. * Restored camera state. You must call storeState() first
  8611. * @returns whether it was successful or not
  8612. * @hidden
  8613. */
  8614. _restoreStateValues(): boolean;
  8615. /** @hidden */
  8616. _initCache(): void;
  8617. /** @hidden */
  8618. _updateCache(ignoreParentClass?: boolean): void;
  8619. /** @hidden */
  8620. _isSynchronizedViewMatrix(): boolean;
  8621. /** @hidden */
  8622. _computeLocalCameraSpeed(): number;
  8623. /**
  8624. * Defines the target the camera should look at.
  8625. * @param target Defines the new target as a Vector or a mesh
  8626. */
  8627. setTarget(target: Vector3): void;
  8628. /**
  8629. * Return the current target position of the camera. This value is expressed in local space.
  8630. * @returns the target position
  8631. */
  8632. getTarget(): Vector3;
  8633. /** @hidden */
  8634. _decideIfNeedsToMove(): boolean;
  8635. /** @hidden */
  8636. _updatePosition(): void;
  8637. /** @hidden */
  8638. _checkInputs(): void;
  8639. protected _updateCameraRotationMatrix(): void;
  8640. /**
  8641. * 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)
  8642. * @returns the current camera
  8643. */
  8644. private _rotateUpVectorWithCameraRotationMatrix;
  8645. private _cachedRotationZ;
  8646. private _cachedQuaternionRotationZ;
  8647. /** @hidden */
  8648. _getViewMatrix(): Matrix;
  8649. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8650. /**
  8651. * @hidden
  8652. */
  8653. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8654. /**
  8655. * @hidden
  8656. */
  8657. _updateRigCameras(): void;
  8658. private _getRigCamPositionAndTarget;
  8659. /**
  8660. * Gets the current object class name.
  8661. * @return the class name
  8662. */
  8663. getClassName(): string;
  8664. }
  8665. }
  8666. declare module BABYLON {
  8667. /**
  8668. * Gather the list of keyboard event types as constants.
  8669. */
  8670. export class KeyboardEventTypes {
  8671. /**
  8672. * The keydown event is fired when a key becomes active (pressed).
  8673. */
  8674. static readonly KEYDOWN: number;
  8675. /**
  8676. * The keyup event is fired when a key has been released.
  8677. */
  8678. static readonly KEYUP: number;
  8679. }
  8680. /**
  8681. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8682. */
  8683. export class KeyboardInfo {
  8684. /**
  8685. * Defines the type of event (KeyboardEventTypes)
  8686. */
  8687. type: number;
  8688. /**
  8689. * Defines the related dom event
  8690. */
  8691. event: KeyboardEvent;
  8692. /**
  8693. * Instantiates a new keyboard info.
  8694. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8695. * @param type Defines the type of event (KeyboardEventTypes)
  8696. * @param event Defines the related dom event
  8697. */
  8698. constructor(
  8699. /**
  8700. * Defines the type of event (KeyboardEventTypes)
  8701. */
  8702. type: number,
  8703. /**
  8704. * Defines the related dom event
  8705. */
  8706. event: KeyboardEvent);
  8707. }
  8708. /**
  8709. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8710. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8711. */
  8712. export class KeyboardInfoPre extends KeyboardInfo {
  8713. /**
  8714. * Defines the type of event (KeyboardEventTypes)
  8715. */
  8716. type: number;
  8717. /**
  8718. * Defines the related dom event
  8719. */
  8720. event: KeyboardEvent;
  8721. /**
  8722. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8723. */
  8724. skipOnPointerObservable: boolean;
  8725. /**
  8726. * Instantiates a new keyboard pre info.
  8727. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8728. * @param type Defines the type of event (KeyboardEventTypes)
  8729. * @param event Defines the related dom event
  8730. */
  8731. constructor(
  8732. /**
  8733. * Defines the type of event (KeyboardEventTypes)
  8734. */
  8735. type: number,
  8736. /**
  8737. * Defines the related dom event
  8738. */
  8739. event: KeyboardEvent);
  8740. }
  8741. }
  8742. declare module BABYLON {
  8743. /**
  8744. * Manage the keyboard inputs to control the movement of a free camera.
  8745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8746. */
  8747. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8748. /**
  8749. * Defines the camera the input is attached to.
  8750. */
  8751. camera: FreeCamera;
  8752. /**
  8753. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8754. */
  8755. keysUp: number[];
  8756. /**
  8757. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8758. */
  8759. keysDown: number[];
  8760. /**
  8761. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8762. */
  8763. keysLeft: number[];
  8764. /**
  8765. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8766. */
  8767. keysRight: number[];
  8768. private _keys;
  8769. private _onCanvasBlurObserver;
  8770. private _onKeyboardObserver;
  8771. private _engine;
  8772. private _scene;
  8773. /**
  8774. * Attach the input controls to a specific dom element to get the input from.
  8775. * @param element Defines the element the controls should be listened from
  8776. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8777. */
  8778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8779. /**
  8780. * Detach the current controls from the specified dom element.
  8781. * @param element Defines the element to stop listening the inputs from
  8782. */
  8783. detachControl(element: Nullable<HTMLElement>): void;
  8784. /**
  8785. * Update the current camera state depending on the inputs that have been used this frame.
  8786. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8787. */
  8788. checkInputs(): void;
  8789. /**
  8790. * Gets the class name of the current intput.
  8791. * @returns the class name
  8792. */
  8793. getClassName(): string;
  8794. /** @hidden */
  8795. _onLostFocus(): void;
  8796. /**
  8797. * Get the friendly name associated with the input class.
  8798. * @returns the input friendly name
  8799. */
  8800. getSimpleName(): string;
  8801. }
  8802. }
  8803. declare module BABYLON {
  8804. /**
  8805. * Interface describing all the common properties and methods a shadow light needs to implement.
  8806. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8807. * as well as binding the different shadow properties to the effects.
  8808. */
  8809. export interface IShadowLight extends Light {
  8810. /**
  8811. * The light id in the scene (used in scene.findLighById for instance)
  8812. */
  8813. id: string;
  8814. /**
  8815. * The position the shdow will be casted from.
  8816. */
  8817. position: Vector3;
  8818. /**
  8819. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8820. */
  8821. direction: Vector3;
  8822. /**
  8823. * The transformed position. Position of the light in world space taking parenting in account.
  8824. */
  8825. transformedPosition: Vector3;
  8826. /**
  8827. * The transformed direction. Direction of the light in world space taking parenting in account.
  8828. */
  8829. transformedDirection: Vector3;
  8830. /**
  8831. * The friendly name of the light in the scene.
  8832. */
  8833. name: string;
  8834. /**
  8835. * Defines the shadow projection clipping minimum z value.
  8836. */
  8837. shadowMinZ: number;
  8838. /**
  8839. * Defines the shadow projection clipping maximum z value.
  8840. */
  8841. shadowMaxZ: number;
  8842. /**
  8843. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8844. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8845. */
  8846. computeTransformedInformation(): boolean;
  8847. /**
  8848. * Gets the scene the light belongs to.
  8849. * @returns The scene
  8850. */
  8851. getScene(): Scene;
  8852. /**
  8853. * Callback defining a custom Projection Matrix Builder.
  8854. * This can be used to override the default projection matrix computation.
  8855. */
  8856. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8857. /**
  8858. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8859. * @param matrix The materix to updated with the projection information
  8860. * @param viewMatrix The transform matrix of the light
  8861. * @param renderList The list of mesh to render in the map
  8862. * @returns The current light
  8863. */
  8864. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8865. /**
  8866. * Gets the current depth scale used in ESM.
  8867. * @returns The scale
  8868. */
  8869. getDepthScale(): number;
  8870. /**
  8871. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8872. * @returns true if a cube texture needs to be use
  8873. */
  8874. needCube(): boolean;
  8875. /**
  8876. * Detects if the projection matrix requires to be recomputed this frame.
  8877. * @returns true if it requires to be recomputed otherwise, false.
  8878. */
  8879. needProjectionMatrixCompute(): boolean;
  8880. /**
  8881. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8882. */
  8883. forceProjectionMatrixCompute(): void;
  8884. /**
  8885. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8886. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8887. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8888. */
  8889. getShadowDirection(faceIndex?: number): Vector3;
  8890. /**
  8891. * Gets the minZ used for shadow according to both the scene and the light.
  8892. * @param activeCamera The camera we are returning the min for
  8893. * @returns the depth min z
  8894. */
  8895. getDepthMinZ(activeCamera: Camera): number;
  8896. /**
  8897. * Gets the maxZ used for shadow according to both the scene and the light.
  8898. * @param activeCamera The camera we are returning the max for
  8899. * @returns the depth max z
  8900. */
  8901. getDepthMaxZ(activeCamera: Camera): number;
  8902. }
  8903. /**
  8904. * Base implementation IShadowLight
  8905. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8906. */
  8907. export abstract class ShadowLight extends Light implements IShadowLight {
  8908. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8909. protected _position: Vector3;
  8910. protected _setPosition(value: Vector3): void;
  8911. /**
  8912. * Sets the position the shadow will be casted from. Also use as the light position for both
  8913. * point and spot lights.
  8914. */
  8915. get position(): Vector3;
  8916. /**
  8917. * Sets the position the shadow will be casted from. Also use as the light position for both
  8918. * point and spot lights.
  8919. */
  8920. set position(value: Vector3);
  8921. protected _direction: Vector3;
  8922. protected _setDirection(value: Vector3): void;
  8923. /**
  8924. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8925. * Also use as the light direction on spot and directional lights.
  8926. */
  8927. get direction(): Vector3;
  8928. /**
  8929. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8930. * Also use as the light direction on spot and directional lights.
  8931. */
  8932. set direction(value: Vector3);
  8933. protected _shadowMinZ: number;
  8934. /**
  8935. * Gets the shadow projection clipping minimum z value.
  8936. */
  8937. get shadowMinZ(): number;
  8938. /**
  8939. * Sets the shadow projection clipping minimum z value.
  8940. */
  8941. set shadowMinZ(value: number);
  8942. protected _shadowMaxZ: number;
  8943. /**
  8944. * Sets the shadow projection clipping maximum z value.
  8945. */
  8946. get shadowMaxZ(): number;
  8947. /**
  8948. * Gets the shadow projection clipping maximum z value.
  8949. */
  8950. set shadowMaxZ(value: number);
  8951. /**
  8952. * Callback defining a custom Projection Matrix Builder.
  8953. * This can be used to override the default projection matrix computation.
  8954. */
  8955. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8956. /**
  8957. * The transformed position. Position of the light in world space taking parenting in account.
  8958. */
  8959. transformedPosition: Vector3;
  8960. /**
  8961. * The transformed direction. Direction of the light in world space taking parenting in account.
  8962. */
  8963. transformedDirection: Vector3;
  8964. private _needProjectionMatrixCompute;
  8965. /**
  8966. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8967. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8968. */
  8969. computeTransformedInformation(): boolean;
  8970. /**
  8971. * Return the depth scale used for the shadow map.
  8972. * @returns the depth scale.
  8973. */
  8974. getDepthScale(): number;
  8975. /**
  8976. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8977. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8978. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8979. */
  8980. getShadowDirection(faceIndex?: number): Vector3;
  8981. /**
  8982. * Returns the ShadowLight absolute position in the World.
  8983. * @returns the position vector in world space
  8984. */
  8985. getAbsolutePosition(): Vector3;
  8986. /**
  8987. * Sets the ShadowLight direction toward the passed target.
  8988. * @param target The point to target in local space
  8989. * @returns the updated ShadowLight direction
  8990. */
  8991. setDirectionToTarget(target: Vector3): Vector3;
  8992. /**
  8993. * Returns the light rotation in euler definition.
  8994. * @returns the x y z rotation in local space.
  8995. */
  8996. getRotation(): Vector3;
  8997. /**
  8998. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8999. * @returns true if a cube texture needs to be use
  9000. */
  9001. needCube(): boolean;
  9002. /**
  9003. * Detects if the projection matrix requires to be recomputed this frame.
  9004. * @returns true if it requires to be recomputed otherwise, false.
  9005. */
  9006. needProjectionMatrixCompute(): boolean;
  9007. /**
  9008. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9009. */
  9010. forceProjectionMatrixCompute(): void;
  9011. /** @hidden */
  9012. _initCache(): void;
  9013. /** @hidden */
  9014. _isSynchronized(): boolean;
  9015. /**
  9016. * Computes the world matrix of the node
  9017. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9018. * @returns the world matrix
  9019. */
  9020. computeWorldMatrix(force?: boolean): Matrix;
  9021. /**
  9022. * Gets the minZ used for shadow according to both the scene and the light.
  9023. * @param activeCamera The camera we are returning the min for
  9024. * @returns the depth min z
  9025. */
  9026. getDepthMinZ(activeCamera: Camera): number;
  9027. /**
  9028. * Gets the maxZ used for shadow according to both the scene and the light.
  9029. * @param activeCamera The camera we are returning the max for
  9030. * @returns the depth max z
  9031. */
  9032. getDepthMaxZ(activeCamera: Camera): number;
  9033. /**
  9034. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9035. * @param matrix The materix to updated with the projection information
  9036. * @param viewMatrix The transform matrix of the light
  9037. * @param renderList The list of mesh to render in the map
  9038. * @returns The current light
  9039. */
  9040. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9041. }
  9042. }
  9043. declare module BABYLON {
  9044. /**
  9045. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9046. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9047. */
  9048. export class EffectFallbacks implements IEffectFallbacks {
  9049. private _defines;
  9050. private _currentRank;
  9051. private _maxRank;
  9052. private _mesh;
  9053. /**
  9054. * Removes the fallback from the bound mesh.
  9055. */
  9056. unBindMesh(): void;
  9057. /**
  9058. * Adds a fallback on the specified property.
  9059. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9060. * @param define The name of the define in the shader
  9061. */
  9062. addFallback(rank: number, define: string): void;
  9063. /**
  9064. * Sets the mesh to use CPU skinning when needing to fallback.
  9065. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9066. * @param mesh The mesh to use the fallbacks.
  9067. */
  9068. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9069. /**
  9070. * Checks to see if more fallbacks are still availible.
  9071. */
  9072. get hasMoreFallbacks(): boolean;
  9073. /**
  9074. * Removes the defines that should be removed when falling back.
  9075. * @param currentDefines defines the current define statements for the shader.
  9076. * @param effect defines the current effect we try to compile
  9077. * @returns The resulting defines with defines of the current rank removed.
  9078. */
  9079. reduce(currentDefines: string, effect: Effect): string;
  9080. }
  9081. }
  9082. declare module BABYLON {
  9083. /**
  9084. * "Static Class" containing the most commonly used helper while dealing with material for
  9085. * rendering purpose.
  9086. *
  9087. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9088. *
  9089. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9090. */
  9091. export class MaterialHelper {
  9092. /**
  9093. * Bind the current view position to an effect.
  9094. * @param effect The effect to be bound
  9095. * @param scene The scene the eyes position is used from
  9096. */
  9097. static BindEyePosition(effect: Effect, scene: Scene): void;
  9098. /**
  9099. * Helps preparing the defines values about the UVs in used in the effect.
  9100. * UVs are shared as much as we can accross channels in the shaders.
  9101. * @param texture The texture we are preparing the UVs for
  9102. * @param defines The defines to update
  9103. * @param key The channel key "diffuse", "specular"... used in the shader
  9104. */
  9105. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9106. /**
  9107. * Binds a texture matrix value to its corrsponding uniform
  9108. * @param texture The texture to bind the matrix for
  9109. * @param uniformBuffer The uniform buffer receivin the data
  9110. * @param key The channel key "diffuse", "specular"... used in the shader
  9111. */
  9112. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9113. /**
  9114. * Gets the current status of the fog (should it be enabled?)
  9115. * @param mesh defines the mesh to evaluate for fog support
  9116. * @param scene defines the hosting scene
  9117. * @returns true if fog must be enabled
  9118. */
  9119. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9120. /**
  9121. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9122. * @param mesh defines the current mesh
  9123. * @param scene defines the current scene
  9124. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9125. * @param pointsCloud defines if point cloud rendering has to be turned on
  9126. * @param fogEnabled defines if fog has to be turned on
  9127. * @param alphaTest defines if alpha testing has to be turned on
  9128. * @param defines defines the current list of defines
  9129. */
  9130. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9131. /**
  9132. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9133. * @param scene defines the current scene
  9134. * @param engine defines the current engine
  9135. * @param defines specifies the list of active defines
  9136. * @param useInstances defines if instances have to be turned on
  9137. * @param useClipPlane defines if clip plane have to be turned on
  9138. */
  9139. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9140. /**
  9141. * Prepares the defines for bones
  9142. * @param mesh The mesh containing the geometry data we will draw
  9143. * @param defines The defines to update
  9144. */
  9145. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9146. /**
  9147. * Prepares the defines for morph targets
  9148. * @param mesh The mesh containing the geometry data we will draw
  9149. * @param defines The defines to update
  9150. */
  9151. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9152. /**
  9153. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9154. * @param mesh The mesh containing the geometry data we will draw
  9155. * @param defines The defines to update
  9156. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9157. * @param useBones Precise whether bones should be used or not (override mesh info)
  9158. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9159. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9160. * @returns false if defines are considered not dirty and have not been checked
  9161. */
  9162. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9163. /**
  9164. * Prepares the defines related to multiview
  9165. * @param scene The scene we are intending to draw
  9166. * @param defines The defines to update
  9167. */
  9168. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9169. /**
  9170. * Prepares the defines related to the light information passed in parameter
  9171. * @param scene The scene we are intending to draw
  9172. * @param mesh The mesh the effect is compiling for
  9173. * @param light The light the effect is compiling for
  9174. * @param lightIndex The index of the light
  9175. * @param defines The defines to update
  9176. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9177. * @param state Defines the current state regarding what is needed (normals, etc...)
  9178. */
  9179. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9180. needNormals: boolean;
  9181. needRebuild: boolean;
  9182. shadowEnabled: boolean;
  9183. specularEnabled: boolean;
  9184. lightmapMode: boolean;
  9185. }): void;
  9186. /**
  9187. * Prepares the defines related to the light information passed in parameter
  9188. * @param scene The scene we are intending to draw
  9189. * @param mesh The mesh the effect is compiling for
  9190. * @param defines The defines to update
  9191. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9192. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9193. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9194. * @returns true if normals will be required for the rest of the effect
  9195. */
  9196. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9197. /**
  9198. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9199. * @param lightIndex defines the light index
  9200. * @param uniformsList The uniform list
  9201. * @param samplersList The sampler list
  9202. * @param projectedLightTexture defines if projected texture must be used
  9203. * @param uniformBuffersList defines an optional list of uniform buffers
  9204. */
  9205. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9206. /**
  9207. * Prepares the uniforms and samplers list to be used in the effect
  9208. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9209. * @param samplersList The sampler list
  9210. * @param defines The defines helping in the list generation
  9211. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9212. */
  9213. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9214. /**
  9215. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9216. * @param defines The defines to update while falling back
  9217. * @param fallbacks The authorized effect fallbacks
  9218. * @param maxSimultaneousLights The maximum number of lights allowed
  9219. * @param rank the current rank of the Effect
  9220. * @returns The newly affected rank
  9221. */
  9222. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9223. private static _TmpMorphInfluencers;
  9224. /**
  9225. * Prepares the list of attributes required for morph targets according to the effect defines.
  9226. * @param attribs The current list of supported attribs
  9227. * @param mesh The mesh to prepare the morph targets attributes for
  9228. * @param influencers The number of influencers
  9229. */
  9230. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9231. /**
  9232. * Prepares the list of attributes required for morph targets according to the effect defines.
  9233. * @param attribs The current list of supported attribs
  9234. * @param mesh The mesh to prepare the morph targets attributes for
  9235. * @param defines The current Defines of the effect
  9236. */
  9237. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9238. /**
  9239. * Prepares the list of attributes required for bones according to the effect defines.
  9240. * @param attribs The current list of supported attribs
  9241. * @param mesh The mesh to prepare the bones attributes for
  9242. * @param defines The current Defines of the effect
  9243. * @param fallbacks The current efffect fallback strategy
  9244. */
  9245. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9246. /**
  9247. * Check and prepare the list of attributes required for instances according to the effect defines.
  9248. * @param attribs The current list of supported attribs
  9249. * @param defines The current MaterialDefines of the effect
  9250. */
  9251. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9252. /**
  9253. * Add the list of attributes required for instances to the attribs array.
  9254. * @param attribs The current list of supported attribs
  9255. */
  9256. static PushAttributesForInstances(attribs: string[]): void;
  9257. /**
  9258. * Binds the light information to the effect.
  9259. * @param light The light containing the generator
  9260. * @param effect The effect we are binding the data to
  9261. * @param lightIndex The light index in the effect used to render
  9262. */
  9263. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9264. /**
  9265. * Binds the lights information from the scene to the effect for the given mesh.
  9266. * @param light Light to bind
  9267. * @param lightIndex Light index
  9268. * @param scene The scene where the light belongs to
  9269. * @param effect The effect we are binding the data to
  9270. * @param useSpecular Defines if specular is supported
  9271. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9272. */
  9273. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9274. /**
  9275. * Binds the lights information from the scene to the effect for the given mesh.
  9276. * @param scene The scene the lights belongs to
  9277. * @param mesh The mesh we are binding the information to render
  9278. * @param effect The effect we are binding the data to
  9279. * @param defines The generated defines for the effect
  9280. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9281. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9282. */
  9283. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9284. private static _tempFogColor;
  9285. /**
  9286. * Binds the fog information from the scene to the effect for the given mesh.
  9287. * @param scene The scene the lights belongs to
  9288. * @param mesh The mesh we are binding the information to render
  9289. * @param effect The effect we are binding the data to
  9290. * @param linearSpace Defines if the fog effect is applied in linear space
  9291. */
  9292. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9293. /**
  9294. * Binds the bones information from the mesh to the effect.
  9295. * @param mesh The mesh we are binding the information to render
  9296. * @param effect The effect we are binding the data to
  9297. */
  9298. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9299. /**
  9300. * Binds the morph targets information from the mesh to the effect.
  9301. * @param abstractMesh The mesh we are binding the information to render
  9302. * @param effect The effect we are binding the data to
  9303. */
  9304. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9305. /**
  9306. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9307. * @param defines The generated defines used in the effect
  9308. * @param effect The effect we are binding the data to
  9309. * @param scene The scene we are willing to render with logarithmic scale for
  9310. */
  9311. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9312. /**
  9313. * Binds the clip plane information from the scene to the effect.
  9314. * @param scene The scene the clip plane information are extracted from
  9315. * @param effect The effect we are binding the data to
  9316. */
  9317. static BindClipPlane(effect: Effect, scene: Scene): void;
  9318. }
  9319. }
  9320. declare module BABYLON {
  9321. /** @hidden */
  9322. export var packingFunctions: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module BABYLON {
  9328. /** @hidden */
  9329. export var clipPlaneFragmentDeclaration: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module BABYLON {
  9335. /** @hidden */
  9336. export var clipPlaneFragment: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module BABYLON {
  9342. /** @hidden */
  9343. export var shadowMapPixelShader: {
  9344. name: string;
  9345. shader: string;
  9346. };
  9347. }
  9348. declare module BABYLON {
  9349. /** @hidden */
  9350. export var bonesDeclaration: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module BABYLON {
  9356. /** @hidden */
  9357. export var morphTargetsVertexGlobalDeclaration: {
  9358. name: string;
  9359. shader: string;
  9360. };
  9361. }
  9362. declare module BABYLON {
  9363. /** @hidden */
  9364. export var morphTargetsVertexDeclaration: {
  9365. name: string;
  9366. shader: string;
  9367. };
  9368. }
  9369. declare module BABYLON {
  9370. /** @hidden */
  9371. export var instancesDeclaration: {
  9372. name: string;
  9373. shader: string;
  9374. };
  9375. }
  9376. declare module BABYLON {
  9377. /** @hidden */
  9378. export var helperFunctions: {
  9379. name: string;
  9380. shader: string;
  9381. };
  9382. }
  9383. declare module BABYLON {
  9384. /** @hidden */
  9385. export var clipPlaneVertexDeclaration: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module BABYLON {
  9391. /** @hidden */
  9392. export var morphTargetsVertex: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module BABYLON {
  9398. /** @hidden */
  9399. export var instancesVertex: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module BABYLON {
  9405. /** @hidden */
  9406. export var bonesVertex: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module BABYLON {
  9412. /** @hidden */
  9413. export var clipPlaneVertex: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module BABYLON {
  9419. /** @hidden */
  9420. export var shadowMapVertexShader: {
  9421. name: string;
  9422. shader: string;
  9423. };
  9424. }
  9425. declare module BABYLON {
  9426. /** @hidden */
  9427. export var depthBoxBlurPixelShader: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module BABYLON {
  9433. /**
  9434. * Class representing a ray with position and direction
  9435. */
  9436. export class Ray {
  9437. /** origin point */
  9438. origin: Vector3;
  9439. /** direction */
  9440. direction: Vector3;
  9441. /** length of the ray */
  9442. length: number;
  9443. private static readonly TmpVector3;
  9444. private _tmpRay;
  9445. /**
  9446. * Creates a new ray
  9447. * @param origin origin point
  9448. * @param direction direction
  9449. * @param length length of the ray
  9450. */
  9451. constructor(
  9452. /** origin point */
  9453. origin: Vector3,
  9454. /** direction */
  9455. direction: Vector3,
  9456. /** length of the ray */
  9457. length?: number);
  9458. /**
  9459. * Checks if the ray intersects a box
  9460. * @param minimum bound of the box
  9461. * @param maximum bound of the box
  9462. * @param intersectionTreshold extra extend to be added to the box in all direction
  9463. * @returns if the box was hit
  9464. */
  9465. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9466. /**
  9467. * Checks if the ray intersects a box
  9468. * @param box the bounding box to check
  9469. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9470. * @returns if the box was hit
  9471. */
  9472. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9473. /**
  9474. * If the ray hits a sphere
  9475. * @param sphere the bounding sphere to check
  9476. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9477. * @returns true if it hits the sphere
  9478. */
  9479. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9480. /**
  9481. * If the ray hits a triange
  9482. * @param vertex0 triangle vertex
  9483. * @param vertex1 triangle vertex
  9484. * @param vertex2 triangle vertex
  9485. * @returns intersection information if hit
  9486. */
  9487. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9488. /**
  9489. * Checks if ray intersects a plane
  9490. * @param plane the plane to check
  9491. * @returns the distance away it was hit
  9492. */
  9493. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9494. /**
  9495. * Calculate the intercept of a ray on a given axis
  9496. * @param axis to check 'x' | 'y' | 'z'
  9497. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9498. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9499. */
  9500. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9501. /**
  9502. * Checks if ray intersects a mesh
  9503. * @param mesh the mesh to check
  9504. * @param fastCheck if only the bounding box should checked
  9505. * @returns picking info of the intersecton
  9506. */
  9507. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9508. /**
  9509. * Checks if ray intersects a mesh
  9510. * @param meshes the meshes to check
  9511. * @param fastCheck if only the bounding box should checked
  9512. * @param results array to store result in
  9513. * @returns Array of picking infos
  9514. */
  9515. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9516. private _comparePickingInfo;
  9517. private static smallnum;
  9518. private static rayl;
  9519. /**
  9520. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9521. * @param sega the first point of the segment to test the intersection against
  9522. * @param segb the second point of the segment to test the intersection against
  9523. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9524. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9525. */
  9526. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9527. /**
  9528. * Update the ray from viewport position
  9529. * @param x position
  9530. * @param y y position
  9531. * @param viewportWidth viewport width
  9532. * @param viewportHeight viewport height
  9533. * @param world world matrix
  9534. * @param view view matrix
  9535. * @param projection projection matrix
  9536. * @returns this ray updated
  9537. */
  9538. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9539. /**
  9540. * Creates a ray with origin and direction of 0,0,0
  9541. * @returns the new ray
  9542. */
  9543. static Zero(): Ray;
  9544. /**
  9545. * Creates a new ray from screen space and viewport
  9546. * @param x position
  9547. * @param y y position
  9548. * @param viewportWidth viewport width
  9549. * @param viewportHeight viewport height
  9550. * @param world world matrix
  9551. * @param view view matrix
  9552. * @param projection projection matrix
  9553. * @returns new ray
  9554. */
  9555. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9556. /**
  9557. * 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
  9558. * transformed to the given world matrix.
  9559. * @param origin The origin point
  9560. * @param end The end point
  9561. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9562. * @returns the new ray
  9563. */
  9564. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9565. /**
  9566. * Transforms a ray by a matrix
  9567. * @param ray ray to transform
  9568. * @param matrix matrix to apply
  9569. * @returns the resulting new ray
  9570. */
  9571. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9572. /**
  9573. * Transforms a ray by a matrix
  9574. * @param ray ray to transform
  9575. * @param matrix matrix to apply
  9576. * @param result ray to store result in
  9577. */
  9578. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9579. /**
  9580. * Unproject a ray from screen space to object space
  9581. * @param sourceX defines the screen space x coordinate to use
  9582. * @param sourceY defines the screen space y coordinate to use
  9583. * @param viewportWidth defines the current width of the viewport
  9584. * @param viewportHeight defines the current height of the viewport
  9585. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9586. * @param view defines the view matrix to use
  9587. * @param projection defines the projection matrix to use
  9588. */
  9589. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9590. }
  9591. /**
  9592. * Type used to define predicate used to select faces when a mesh intersection is detected
  9593. */
  9594. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9595. interface Scene {
  9596. /** @hidden */
  9597. _tempPickingRay: Nullable<Ray>;
  9598. /** @hidden */
  9599. _cachedRayForTransform: Ray;
  9600. /** @hidden */
  9601. _pickWithRayInverseMatrix: Matrix;
  9602. /** @hidden */
  9603. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9604. /** @hidden */
  9605. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9606. }
  9607. }
  9608. declare module BABYLON {
  9609. /**
  9610. * Groups all the scene component constants in one place to ease maintenance.
  9611. * @hidden
  9612. */
  9613. export class SceneComponentConstants {
  9614. static readonly NAME_EFFECTLAYER: string;
  9615. static readonly NAME_LAYER: string;
  9616. static readonly NAME_LENSFLARESYSTEM: string;
  9617. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9618. static readonly NAME_PARTICLESYSTEM: string;
  9619. static readonly NAME_GAMEPAD: string;
  9620. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9621. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9622. static readonly NAME_DEPTHRENDERER: string;
  9623. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9624. static readonly NAME_SPRITE: string;
  9625. static readonly NAME_OUTLINERENDERER: string;
  9626. static readonly NAME_PROCEDURALTEXTURE: string;
  9627. static readonly NAME_SHADOWGENERATOR: string;
  9628. static readonly NAME_OCTREE: string;
  9629. static readonly NAME_PHYSICSENGINE: string;
  9630. static readonly NAME_AUDIO: string;
  9631. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9632. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9633. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9634. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9635. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9636. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9637. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9638. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9639. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9640. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9641. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9642. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9643. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9644. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9645. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9646. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9647. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9648. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9649. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9650. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9651. static readonly STEP_AFTERRENDER_AUDIO: number;
  9652. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9653. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9654. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9655. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9656. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9657. static readonly STEP_POINTERMOVE_SPRITE: number;
  9658. static readonly STEP_POINTERDOWN_SPRITE: number;
  9659. static readonly STEP_POINTERUP_SPRITE: number;
  9660. }
  9661. /**
  9662. * This represents a scene component.
  9663. *
  9664. * This is used to decouple the dependency the scene is having on the different workloads like
  9665. * layers, post processes...
  9666. */
  9667. export interface ISceneComponent {
  9668. /**
  9669. * The name of the component. Each component must have a unique name.
  9670. */
  9671. name: string;
  9672. /**
  9673. * The scene the component belongs to.
  9674. */
  9675. scene: Scene;
  9676. /**
  9677. * Register the component to one instance of a scene.
  9678. */
  9679. register(): void;
  9680. /**
  9681. * Rebuilds the elements related to this component in case of
  9682. * context lost for instance.
  9683. */
  9684. rebuild(): void;
  9685. /**
  9686. * Disposes the component and the associated ressources.
  9687. */
  9688. dispose(): void;
  9689. }
  9690. /**
  9691. * This represents a SERIALIZABLE scene component.
  9692. *
  9693. * This extends Scene Component to add Serialization methods on top.
  9694. */
  9695. export interface ISceneSerializableComponent extends ISceneComponent {
  9696. /**
  9697. * Adds all the elements from the container to the scene
  9698. * @param container the container holding the elements
  9699. */
  9700. addFromContainer(container: AbstractScene): void;
  9701. /**
  9702. * Removes all the elements in the container from the scene
  9703. * @param container contains the elements to remove
  9704. * @param dispose if the removed element should be disposed (default: false)
  9705. */
  9706. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9707. /**
  9708. * Serializes the component data to the specified json object
  9709. * @param serializationObject The object to serialize to
  9710. */
  9711. serialize(serializationObject: any): void;
  9712. }
  9713. /**
  9714. * Strong typing of a Mesh related stage step action
  9715. */
  9716. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9717. /**
  9718. * Strong typing of a Evaluate Sub Mesh related stage step action
  9719. */
  9720. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9721. /**
  9722. * Strong typing of a Active Mesh related stage step action
  9723. */
  9724. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9725. /**
  9726. * Strong typing of a Camera related stage step action
  9727. */
  9728. export type CameraStageAction = (camera: Camera) => void;
  9729. /**
  9730. * Strong typing of a Camera Frame buffer related stage step action
  9731. */
  9732. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9733. /**
  9734. * Strong typing of a Render Target related stage step action
  9735. */
  9736. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9737. /**
  9738. * Strong typing of a RenderingGroup related stage step action
  9739. */
  9740. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9741. /**
  9742. * Strong typing of a Mesh Render related stage step action
  9743. */
  9744. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9745. /**
  9746. * Strong typing of a simple stage step action
  9747. */
  9748. export type SimpleStageAction = () => void;
  9749. /**
  9750. * Strong typing of a render target action.
  9751. */
  9752. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9753. /**
  9754. * Strong typing of a pointer move action.
  9755. */
  9756. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9757. /**
  9758. * Strong typing of a pointer up/down action.
  9759. */
  9760. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9761. /**
  9762. * Representation of a stage in the scene (Basically a list of ordered steps)
  9763. * @hidden
  9764. */
  9765. export class Stage<T extends Function> extends Array<{
  9766. index: number;
  9767. component: ISceneComponent;
  9768. action: T;
  9769. }> {
  9770. /**
  9771. * Hide ctor from the rest of the world.
  9772. * @param items The items to add.
  9773. */
  9774. private constructor();
  9775. /**
  9776. * Creates a new Stage.
  9777. * @returns A new instance of a Stage
  9778. */
  9779. static Create<T extends Function>(): Stage<T>;
  9780. /**
  9781. * Registers a step in an ordered way in the targeted stage.
  9782. * @param index Defines the position to register the step in
  9783. * @param component Defines the component attached to the step
  9784. * @param action Defines the action to launch during the step
  9785. */
  9786. registerStep(index: number, component: ISceneComponent, action: T): void;
  9787. /**
  9788. * Clears all the steps from the stage.
  9789. */
  9790. clear(): void;
  9791. }
  9792. }
  9793. declare module BABYLON {
  9794. interface Scene {
  9795. /** @hidden */
  9796. _pointerOverSprite: Nullable<Sprite>;
  9797. /** @hidden */
  9798. _pickedDownSprite: Nullable<Sprite>;
  9799. /** @hidden */
  9800. _tempSpritePickingRay: Nullable<Ray>;
  9801. /**
  9802. * All of the sprite managers added to this scene
  9803. * @see http://doc.babylonjs.com/babylon101/sprites
  9804. */
  9805. spriteManagers: Array<ISpriteManager>;
  9806. /**
  9807. * An event triggered when sprites rendering is about to start
  9808. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9809. */
  9810. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9811. /**
  9812. * An event triggered when sprites rendering is done
  9813. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9814. */
  9815. onAfterSpritesRenderingObservable: Observable<Scene>;
  9816. /** @hidden */
  9817. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9818. /** Launch a ray to try to pick a sprite in the scene
  9819. * @param x position on screen
  9820. * @param y position on screen
  9821. * @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
  9822. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9823. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9824. * @returns a PickingInfo
  9825. */
  9826. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9827. /** Use the given ray to pick a sprite in the scene
  9828. * @param ray The ray (in world space) to use to pick meshes
  9829. * @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
  9830. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9831. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9832. * @returns a PickingInfo
  9833. */
  9834. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9835. /** @hidden */
  9836. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9837. /** Launch a ray to try to pick sprites in the scene
  9838. * @param x position on screen
  9839. * @param y position on screen
  9840. * @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
  9841. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9842. * @returns a PickingInfo array
  9843. */
  9844. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9845. /** Use the given ray to pick sprites in the scene
  9846. * @param ray The ray (in world space) to use to pick meshes
  9847. * @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
  9848. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9849. * @returns a PickingInfo array
  9850. */
  9851. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9852. /**
  9853. * Force the sprite under the pointer
  9854. * @param sprite defines the sprite to use
  9855. */
  9856. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9857. /**
  9858. * Gets the sprite under the pointer
  9859. * @returns a Sprite or null if no sprite is under the pointer
  9860. */
  9861. getPointerOverSprite(): Nullable<Sprite>;
  9862. }
  9863. /**
  9864. * Defines the sprite scene component responsible to manage sprites
  9865. * in a given scene.
  9866. */
  9867. export class SpriteSceneComponent implements ISceneComponent {
  9868. /**
  9869. * The component name helpfull to identify the component in the list of scene components.
  9870. */
  9871. readonly name: string;
  9872. /**
  9873. * The scene the component belongs to.
  9874. */
  9875. scene: Scene;
  9876. /** @hidden */
  9877. private _spritePredicate;
  9878. /**
  9879. * Creates a new instance of the component for the given scene
  9880. * @param scene Defines the scene to register the component in
  9881. */
  9882. constructor(scene: Scene);
  9883. /**
  9884. * Registers the component in a given scene
  9885. */
  9886. register(): void;
  9887. /**
  9888. * Rebuilds the elements related to this component in case of
  9889. * context lost for instance.
  9890. */
  9891. rebuild(): void;
  9892. /**
  9893. * Disposes the component and the associated ressources.
  9894. */
  9895. dispose(): void;
  9896. private _pickSpriteButKeepRay;
  9897. private _pointerMove;
  9898. private _pointerDown;
  9899. private _pointerUp;
  9900. }
  9901. }
  9902. declare module BABYLON {
  9903. /** @hidden */
  9904. export var fogFragmentDeclaration: {
  9905. name: string;
  9906. shader: string;
  9907. };
  9908. }
  9909. declare module BABYLON {
  9910. /** @hidden */
  9911. export var fogFragment: {
  9912. name: string;
  9913. shader: string;
  9914. };
  9915. }
  9916. declare module BABYLON {
  9917. /** @hidden */
  9918. export var spritesPixelShader: {
  9919. name: string;
  9920. shader: string;
  9921. };
  9922. }
  9923. declare module BABYLON {
  9924. /** @hidden */
  9925. export var fogVertexDeclaration: {
  9926. name: string;
  9927. shader: string;
  9928. };
  9929. }
  9930. declare module BABYLON {
  9931. /** @hidden */
  9932. export var spritesVertexShader: {
  9933. name: string;
  9934. shader: string;
  9935. };
  9936. }
  9937. declare module BABYLON {
  9938. /**
  9939. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9940. */
  9941. export interface ISpriteManager extends IDisposable {
  9942. /**
  9943. * Restricts the camera to viewing objects with the same layerMask.
  9944. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9945. */
  9946. layerMask: number;
  9947. /**
  9948. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9949. */
  9950. isPickable: boolean;
  9951. /**
  9952. * Specifies the rendering group id for this mesh (0 by default)
  9953. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9954. */
  9955. renderingGroupId: number;
  9956. /**
  9957. * Defines the list of sprites managed by the manager.
  9958. */
  9959. sprites: Array<Sprite>;
  9960. /**
  9961. * Tests the intersection of a sprite with a specific ray.
  9962. * @param ray The ray we are sending to test the collision
  9963. * @param camera The camera space we are sending rays in
  9964. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9965. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9966. * @returns picking info or null.
  9967. */
  9968. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9969. /**
  9970. * Intersects the sprites with a ray
  9971. * @param ray defines the ray to intersect with
  9972. * @param camera defines the current active camera
  9973. * @param predicate defines a predicate used to select candidate sprites
  9974. * @returns null if no hit or a PickingInfo array
  9975. */
  9976. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9977. /**
  9978. * Renders the list of sprites on screen.
  9979. */
  9980. render(): void;
  9981. }
  9982. /**
  9983. * Class used to manage multiple sprites on the same spritesheet
  9984. * @see http://doc.babylonjs.com/babylon101/sprites
  9985. */
  9986. export class SpriteManager implements ISpriteManager {
  9987. /** defines the manager's name */
  9988. name: string;
  9989. /** Gets the list of sprites */
  9990. sprites: Sprite[];
  9991. /** Gets or sets the rendering group id (0 by default) */
  9992. renderingGroupId: number;
  9993. /** Gets or sets camera layer mask */
  9994. layerMask: number;
  9995. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  9996. fogEnabled: boolean;
  9997. /** Gets or sets a boolean indicating if the sprites are pickable */
  9998. isPickable: boolean;
  9999. /** Defines the default width of a cell in the spritesheet */
  10000. cellWidth: number;
  10001. /** Defines the default height of a cell in the spritesheet */
  10002. cellHeight: number;
  10003. /** Associative array from JSON sprite data file */
  10004. private _cellData;
  10005. /** Array of sprite names from JSON sprite data file */
  10006. private _spriteMap;
  10007. /** True when packed cell data from JSON file is ready*/
  10008. private _packedAndReady;
  10009. /**
  10010. * An event triggered when the manager is disposed.
  10011. */
  10012. onDisposeObservable: Observable<SpriteManager>;
  10013. private _onDisposeObserver;
  10014. /**
  10015. * Callback called when the manager is disposed
  10016. */
  10017. set onDispose(callback: () => void);
  10018. private _capacity;
  10019. private _fromPacked;
  10020. private _spriteTexture;
  10021. private _epsilon;
  10022. private _scene;
  10023. private _vertexData;
  10024. private _buffer;
  10025. private _vertexBuffers;
  10026. private _indexBuffer;
  10027. private _effectBase;
  10028. private _effectFog;
  10029. /**
  10030. * Gets or sets the spritesheet texture
  10031. */
  10032. get texture(): Texture;
  10033. set texture(value: Texture);
  10034. private _blendMode;
  10035. /**
  10036. * Blend mode use to render the particle, it can be any of
  10037. * the static Constants.ALPHA_x properties provided in this class.
  10038. * Default value is Constants.ALPHA_COMBINE
  10039. */
  10040. get blendMode(): number;
  10041. set blendMode(blendMode: number);
  10042. /** Disables writing to the depth buffer when rendering the sprites.
  10043. * It can be handy to disable depth writing when using textures without alpha channel
  10044. * and setting some specific blend modes.
  10045. */
  10046. disableDepthWrite: boolean;
  10047. /**
  10048. * Creates a new sprite manager
  10049. * @param name defines the manager's name
  10050. * @param imgUrl defines the sprite sheet url
  10051. * @param capacity defines the maximum allowed number of sprites
  10052. * @param cellSize defines the size of a sprite cell
  10053. * @param scene defines the hosting scene
  10054. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10055. * @param samplingMode defines the smapling mode to use with spritesheet
  10056. * @param fromPacked set to false; do not alter
  10057. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10058. */
  10059. constructor(
  10060. /** defines the manager's name */
  10061. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10062. private _makePacked;
  10063. private _appendSpriteVertex;
  10064. /**
  10065. * Intersects the sprites with a ray
  10066. * @param ray defines the ray to intersect with
  10067. * @param camera defines the current active camera
  10068. * @param predicate defines a predicate used to select candidate sprites
  10069. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10070. * @returns null if no hit or a PickingInfo
  10071. */
  10072. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10073. /**
  10074. * Intersects the sprites with a ray
  10075. * @param ray defines the ray to intersect with
  10076. * @param camera defines the current active camera
  10077. * @param predicate defines a predicate used to select candidate sprites
  10078. * @returns null if no hit or a PickingInfo array
  10079. */
  10080. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10081. /**
  10082. * Render all child sprites
  10083. */
  10084. render(): void;
  10085. /**
  10086. * Release associated resources
  10087. */
  10088. dispose(): void;
  10089. }
  10090. }
  10091. declare module BABYLON {
  10092. /** Interface used by value gradients (color, factor, ...) */
  10093. export interface IValueGradient {
  10094. /**
  10095. * Gets or sets the gradient value (between 0 and 1)
  10096. */
  10097. gradient: number;
  10098. }
  10099. /** Class used to store color4 gradient */
  10100. export class ColorGradient implements IValueGradient {
  10101. /**
  10102. * Gets or sets the gradient value (between 0 and 1)
  10103. */
  10104. gradient: number;
  10105. /**
  10106. * Gets or sets first associated color
  10107. */
  10108. color1: Color4;
  10109. /**
  10110. * Gets or sets second associated color
  10111. */
  10112. color2?: Color4;
  10113. /**
  10114. * Will get a color picked randomly between color1 and color2.
  10115. * If color2 is undefined then color1 will be used
  10116. * @param result defines the target Color4 to store the result in
  10117. */
  10118. getColorToRef(result: Color4): void;
  10119. }
  10120. /** Class used to store color 3 gradient */
  10121. export class Color3Gradient implements IValueGradient {
  10122. /**
  10123. * Gets or sets the gradient value (between 0 and 1)
  10124. */
  10125. gradient: number;
  10126. /**
  10127. * Gets or sets the associated color
  10128. */
  10129. color: Color3;
  10130. }
  10131. /** Class used to store factor gradient */
  10132. export class FactorGradient implements IValueGradient {
  10133. /**
  10134. * Gets or sets the gradient value (between 0 and 1)
  10135. */
  10136. gradient: number;
  10137. /**
  10138. * Gets or sets first associated factor
  10139. */
  10140. factor1: number;
  10141. /**
  10142. * Gets or sets second associated factor
  10143. */
  10144. factor2?: number;
  10145. /**
  10146. * Will get a number picked randomly between factor1 and factor2.
  10147. * If factor2 is undefined then factor1 will be used
  10148. * @returns the picked number
  10149. */
  10150. getFactor(): number;
  10151. }
  10152. /**
  10153. * Helper used to simplify some generic gradient tasks
  10154. */
  10155. export class GradientHelper {
  10156. /**
  10157. * Gets the current gradient from an array of IValueGradient
  10158. * @param ratio defines the current ratio to get
  10159. * @param gradients defines the array of IValueGradient
  10160. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10161. */
  10162. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10163. }
  10164. }
  10165. declare module BABYLON {
  10166. /**
  10167. * Interface for the size containing width and height
  10168. */
  10169. export interface ISize {
  10170. /**
  10171. * Width
  10172. */
  10173. width: number;
  10174. /**
  10175. * Heighht
  10176. */
  10177. height: number;
  10178. }
  10179. /**
  10180. * Size containing widht and height
  10181. */
  10182. export class Size implements ISize {
  10183. /**
  10184. * Width
  10185. */
  10186. width: number;
  10187. /**
  10188. * Height
  10189. */
  10190. height: number;
  10191. /**
  10192. * Creates a Size object from the given width and height (floats).
  10193. * @param width width of the new size
  10194. * @param height height of the new size
  10195. */
  10196. constructor(width: number, height: number);
  10197. /**
  10198. * Returns a string with the Size width and height
  10199. * @returns a string with the Size width and height
  10200. */
  10201. toString(): string;
  10202. /**
  10203. * "Size"
  10204. * @returns the string "Size"
  10205. */
  10206. getClassName(): string;
  10207. /**
  10208. * Returns the Size hash code.
  10209. * @returns a hash code for a unique width and height
  10210. */
  10211. getHashCode(): number;
  10212. /**
  10213. * Updates the current size from the given one.
  10214. * @param src the given size
  10215. */
  10216. copyFrom(src: Size): void;
  10217. /**
  10218. * Updates in place the current Size from the given floats.
  10219. * @param width width of the new size
  10220. * @param height height of the new size
  10221. * @returns the updated Size.
  10222. */
  10223. copyFromFloats(width: number, height: number): Size;
  10224. /**
  10225. * Updates in place the current Size from the given floats.
  10226. * @param width width to set
  10227. * @param height height to set
  10228. * @returns the updated Size.
  10229. */
  10230. set(width: number, height: number): Size;
  10231. /**
  10232. * Multiplies the width and height by numbers
  10233. * @param w factor to multiple the width by
  10234. * @param h factor to multiple the height by
  10235. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10236. */
  10237. multiplyByFloats(w: number, h: number): Size;
  10238. /**
  10239. * Clones the size
  10240. * @returns a new Size copied from the given one.
  10241. */
  10242. clone(): Size;
  10243. /**
  10244. * True if the current Size and the given one width and height are strictly equal.
  10245. * @param other the other size to compare against
  10246. * @returns True if the current Size and the given one width and height are strictly equal.
  10247. */
  10248. equals(other: Size): boolean;
  10249. /**
  10250. * The surface of the Size : width * height (float).
  10251. */
  10252. get surface(): number;
  10253. /**
  10254. * Create a new size of zero
  10255. * @returns a new Size set to (0.0, 0.0)
  10256. */
  10257. static Zero(): Size;
  10258. /**
  10259. * Sums the width and height of two sizes
  10260. * @param otherSize size to add to this size
  10261. * @returns a new Size set as the addition result of the current Size and the given one.
  10262. */
  10263. add(otherSize: Size): Size;
  10264. /**
  10265. * Subtracts the width and height of two
  10266. * @param otherSize size to subtract to this size
  10267. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10268. */
  10269. subtract(otherSize: Size): Size;
  10270. /**
  10271. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10272. * @param start starting size to lerp between
  10273. * @param end end size to lerp between
  10274. * @param amount amount to lerp between the start and end values
  10275. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10276. */
  10277. static Lerp(start: Size, end: Size, amount: number): Size;
  10278. }
  10279. }
  10280. declare module BABYLON {
  10281. interface ThinEngine {
  10282. /**
  10283. * Creates a dynamic texture
  10284. * @param width defines the width of the texture
  10285. * @param height defines the height of the texture
  10286. * @param generateMipMaps defines if the engine should generate the mip levels
  10287. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10288. * @returns the dynamic texture inside an InternalTexture
  10289. */
  10290. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10291. /**
  10292. * Update the content of a dynamic texture
  10293. * @param texture defines the texture to update
  10294. * @param canvas defines the canvas containing the source
  10295. * @param invertY defines if data must be stored with Y axis inverted
  10296. * @param premulAlpha defines if alpha is stored as premultiplied
  10297. * @param format defines the format of the data
  10298. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10299. */
  10300. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10301. }
  10302. }
  10303. declare module BABYLON {
  10304. /**
  10305. * Helper class used to generate a canvas to manipulate images
  10306. */
  10307. export class CanvasGenerator {
  10308. /**
  10309. * Create a new canvas (or offscreen canvas depending on the context)
  10310. * @param width defines the expected width
  10311. * @param height defines the expected height
  10312. * @return a new canvas or offscreen canvas
  10313. */
  10314. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10315. }
  10316. }
  10317. declare module BABYLON {
  10318. /**
  10319. * A class extending Texture allowing drawing on a texture
  10320. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10321. */
  10322. export class DynamicTexture extends Texture {
  10323. private _generateMipMaps;
  10324. private _canvas;
  10325. private _context;
  10326. private _engine;
  10327. /**
  10328. * Creates a DynamicTexture
  10329. * @param name defines the name of the texture
  10330. * @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
  10331. * @param scene defines the scene where you want the texture
  10332. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10333. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10334. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10335. */
  10336. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10337. /**
  10338. * Get the current class name of the texture useful for serialization or dynamic coding.
  10339. * @returns "DynamicTexture"
  10340. */
  10341. getClassName(): string;
  10342. /**
  10343. * Gets the current state of canRescale
  10344. */
  10345. get canRescale(): boolean;
  10346. private _recreate;
  10347. /**
  10348. * Scales the texture
  10349. * @param ratio the scale factor to apply to both width and height
  10350. */
  10351. scale(ratio: number): void;
  10352. /**
  10353. * Resizes the texture
  10354. * @param width the new width
  10355. * @param height the new height
  10356. */
  10357. scaleTo(width: number, height: number): void;
  10358. /**
  10359. * Gets the context of the canvas used by the texture
  10360. * @returns the canvas context of the dynamic texture
  10361. */
  10362. getContext(): CanvasRenderingContext2D;
  10363. /**
  10364. * Clears the texture
  10365. */
  10366. clear(): void;
  10367. /**
  10368. * Updates the texture
  10369. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10370. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10371. */
  10372. update(invertY?: boolean, premulAlpha?: boolean): void;
  10373. /**
  10374. * Draws text onto the texture
  10375. * @param text defines the text to be drawn
  10376. * @param x defines the placement of the text from the left
  10377. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10378. * @param font defines the font to be used with font-style, font-size, font-name
  10379. * @param color defines the color used for the text
  10380. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10381. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10382. * @param update defines whether texture is immediately update (default is true)
  10383. */
  10384. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10385. /**
  10386. * Clones the texture
  10387. * @returns the clone of the texture.
  10388. */
  10389. clone(): DynamicTexture;
  10390. /**
  10391. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10392. * @returns a serialized dynamic texture object
  10393. */
  10394. serialize(): any;
  10395. /** @hidden */
  10396. _rebuild(): void;
  10397. }
  10398. }
  10399. declare module BABYLON {
  10400. interface Engine {
  10401. /**
  10402. * Creates a raw texture
  10403. * @param data defines the data to store in the texture
  10404. * @param width defines the width of the texture
  10405. * @param height defines the height of the texture
  10406. * @param format defines the format of the data
  10407. * @param generateMipMaps defines if the engine should generate the mip levels
  10408. * @param invertY defines if data must be stored with Y axis inverted
  10409. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10410. * @param compression defines the compression used (null by default)
  10411. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10412. * @returns the raw texture inside an InternalTexture
  10413. */
  10414. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10415. /**
  10416. * Update a raw texture
  10417. * @param texture defines the texture to update
  10418. * @param data defines the data to store in the texture
  10419. * @param format defines the format of the data
  10420. * @param invertY defines if data must be stored with Y axis inverted
  10421. */
  10422. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10423. /**
  10424. * Update a raw texture
  10425. * @param texture defines the texture to update
  10426. * @param data defines the data to store in the texture
  10427. * @param format defines the format of the data
  10428. * @param invertY defines if data must be stored with Y axis inverted
  10429. * @param compression defines the compression used (null by default)
  10430. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10431. */
  10432. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10433. /**
  10434. * Creates a new raw cube texture
  10435. * @param data defines the array of data to use to create each face
  10436. * @param size defines the size of the textures
  10437. * @param format defines the format of the data
  10438. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10439. * @param generateMipMaps defines if the engine should generate the mip levels
  10440. * @param invertY defines if data must be stored with Y axis inverted
  10441. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10442. * @param compression defines the compression used (null by default)
  10443. * @returns the cube texture as an InternalTexture
  10444. */
  10445. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10446. /**
  10447. * Update a raw cube texture
  10448. * @param texture defines the texture to udpdate
  10449. * @param data defines the data to store
  10450. * @param format defines the data format
  10451. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10452. * @param invertY defines if data must be stored with Y axis inverted
  10453. */
  10454. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10455. /**
  10456. * Update a raw cube texture
  10457. * @param texture defines the texture to udpdate
  10458. * @param data defines the data to store
  10459. * @param format defines the data format
  10460. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10461. * @param invertY defines if data must be stored with Y axis inverted
  10462. * @param compression defines the compression used (null by default)
  10463. */
  10464. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10465. /**
  10466. * Update a raw cube texture
  10467. * @param texture defines the texture to udpdate
  10468. * @param data defines the data to store
  10469. * @param format defines the data format
  10470. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10471. * @param invertY defines if data must be stored with Y axis inverted
  10472. * @param compression defines the compression used (null by default)
  10473. * @param level defines which level of the texture to update
  10474. */
  10475. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10476. /**
  10477. * Creates a new raw cube texture from a specified url
  10478. * @param url defines the url where the data is located
  10479. * @param scene defines the current scene
  10480. * @param size defines the size of the textures
  10481. * @param format defines the format of the data
  10482. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10483. * @param noMipmap defines if the engine should avoid generating the mip levels
  10484. * @param callback defines a callback used to extract texture data from loaded data
  10485. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10486. * @param onLoad defines a callback called when texture is loaded
  10487. * @param onError defines a callback called if there is an error
  10488. * @returns the cube texture as an InternalTexture
  10489. */
  10490. 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;
  10491. /**
  10492. * Creates a new raw cube texture from a specified url
  10493. * @param url defines the url where the data is located
  10494. * @param scene defines the current scene
  10495. * @param size defines the size of the textures
  10496. * @param format defines the format of the data
  10497. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10498. * @param noMipmap defines if the engine should avoid generating the mip levels
  10499. * @param callback defines a callback used to extract texture data from loaded data
  10500. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10501. * @param onLoad defines a callback called when texture is loaded
  10502. * @param onError defines a callback called if there is an error
  10503. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10504. * @param invertY defines if data must be stored with Y axis inverted
  10505. * @returns the cube texture as an InternalTexture
  10506. */
  10507. 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;
  10508. /**
  10509. * Creates a new raw 3D texture
  10510. * @param data defines the data used to create the texture
  10511. * @param width defines the width of the texture
  10512. * @param height defines the height of the texture
  10513. * @param depth defines the depth of the texture
  10514. * @param format defines the format of the texture
  10515. * @param generateMipMaps defines if the engine must generate mip levels
  10516. * @param invertY defines if data must be stored with Y axis inverted
  10517. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10518. * @param compression defines the compressed used (can be null)
  10519. * @param textureType defines the compressed used (can be null)
  10520. * @returns a new raw 3D texture (stored in an InternalTexture)
  10521. */
  10522. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10523. /**
  10524. * Update a raw 3D texture
  10525. * @param texture defines the texture to update
  10526. * @param data defines the data to store
  10527. * @param format defines the data format
  10528. * @param invertY defines if data must be stored with Y axis inverted
  10529. */
  10530. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10531. /**
  10532. * Update a raw 3D texture
  10533. * @param texture defines the texture to update
  10534. * @param data defines the data to store
  10535. * @param format defines the data format
  10536. * @param invertY defines if data must be stored with Y axis inverted
  10537. * @param compression defines the used compression (can be null)
  10538. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10539. */
  10540. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10541. /**
  10542. * Creates a new raw 2D array texture
  10543. * @param data defines the data used to create the texture
  10544. * @param width defines the width of the texture
  10545. * @param height defines the height of the texture
  10546. * @param depth defines the number of layers of the texture
  10547. * @param format defines the format of the texture
  10548. * @param generateMipMaps defines if the engine must generate mip levels
  10549. * @param invertY defines if data must be stored with Y axis inverted
  10550. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10551. * @param compression defines the compressed used (can be null)
  10552. * @param textureType defines the compressed used (can be null)
  10553. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10554. */
  10555. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10556. /**
  10557. * Update a raw 2D array texture
  10558. * @param texture defines the texture to update
  10559. * @param data defines the data to store
  10560. * @param format defines the data format
  10561. * @param invertY defines if data must be stored with Y axis inverted
  10562. */
  10563. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10564. /**
  10565. * Update a raw 2D array texture
  10566. * @param texture defines the texture to update
  10567. * @param data defines the data to store
  10568. * @param format defines the data format
  10569. * @param invertY defines if data must be stored with Y axis inverted
  10570. * @param compression defines the used compression (can be null)
  10571. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10572. */
  10573. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10574. }
  10575. }
  10576. declare module BABYLON {
  10577. /**
  10578. * Raw texture can help creating a texture directly from an array of data.
  10579. * This can be super useful if you either get the data from an uncompressed source or
  10580. * if you wish to create your texture pixel by pixel.
  10581. */
  10582. export class RawTexture extends Texture {
  10583. /**
  10584. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10585. */
  10586. format: number;
  10587. private _engine;
  10588. /**
  10589. * Instantiates a new RawTexture.
  10590. * Raw texture can help creating a texture directly from an array of data.
  10591. * This can be super useful if you either get the data from an uncompressed source or
  10592. * if you wish to create your texture pixel by pixel.
  10593. * @param data define the array of data to use to create the texture
  10594. * @param width define the width of the texture
  10595. * @param height define the height of the texture
  10596. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10597. * @param scene define the scene the texture belongs to
  10598. * @param generateMipMaps define whether mip maps should be generated or not
  10599. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10600. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10601. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10602. */
  10603. constructor(data: ArrayBufferView, width: number, height: number,
  10604. /**
  10605. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10606. */
  10607. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10608. /**
  10609. * Updates the texture underlying data.
  10610. * @param data Define the new data of the texture
  10611. */
  10612. update(data: ArrayBufferView): void;
  10613. /**
  10614. * Creates a luminance texture from some data.
  10615. * @param data Define the texture data
  10616. * @param width Define the width of the texture
  10617. * @param height Define the height of the texture
  10618. * @param scene Define the scene the texture belongs to
  10619. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10620. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10621. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10622. * @returns the luminance texture
  10623. */
  10624. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10625. /**
  10626. * Creates a luminance alpha texture from some data.
  10627. * @param data Define the texture data
  10628. * @param width Define the width of the texture
  10629. * @param height Define the height of the texture
  10630. * @param scene Define the scene the texture belongs to
  10631. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10632. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10633. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10634. * @returns the luminance alpha texture
  10635. */
  10636. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10637. /**
  10638. * Creates an alpha texture from some data.
  10639. * @param data Define the texture data
  10640. * @param width Define the width of the texture
  10641. * @param height Define the height of the texture
  10642. * @param scene Define the scene the texture belongs to
  10643. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10644. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10645. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10646. * @returns the alpha texture
  10647. */
  10648. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10649. /**
  10650. * Creates a RGB texture from some data.
  10651. * @param data Define the texture data
  10652. * @param width Define the width of the texture
  10653. * @param height Define the height of the texture
  10654. * @param scene Define the scene the texture belongs to
  10655. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10656. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10657. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10658. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10659. * @returns the RGB alpha texture
  10660. */
  10661. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10662. /**
  10663. * Creates a RGBA texture from some data.
  10664. * @param data Define the texture data
  10665. * @param width Define the width of the texture
  10666. * @param height Define the height of the texture
  10667. * @param scene Define the scene the texture belongs to
  10668. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10669. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10670. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10671. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10672. * @returns the RGBA texture
  10673. */
  10674. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10675. /**
  10676. * Creates a R texture from some data.
  10677. * @param data Define the texture data
  10678. * @param width Define the width of the texture
  10679. * @param height Define the height of the texture
  10680. * @param scene Define the scene the texture belongs to
  10681. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10682. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10683. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10684. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10685. * @returns the R texture
  10686. */
  10687. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10688. }
  10689. }
  10690. declare module BABYLON {
  10691. interface AbstractScene {
  10692. /**
  10693. * The list of procedural textures added to the scene
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10695. */
  10696. proceduralTextures: Array<ProceduralTexture>;
  10697. }
  10698. /**
  10699. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10700. * in a given scene.
  10701. */
  10702. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10703. /**
  10704. * The component name helpfull to identify the component in the list of scene components.
  10705. */
  10706. readonly name: string;
  10707. /**
  10708. * The scene the component belongs to.
  10709. */
  10710. scene: Scene;
  10711. /**
  10712. * Creates a new instance of the component for the given scene
  10713. * @param scene Defines the scene to register the component in
  10714. */
  10715. constructor(scene: Scene);
  10716. /**
  10717. * Registers the component in a given scene
  10718. */
  10719. register(): void;
  10720. /**
  10721. * Rebuilds the elements related to this component in case of
  10722. * context lost for instance.
  10723. */
  10724. rebuild(): void;
  10725. /**
  10726. * Disposes the component and the associated ressources.
  10727. */
  10728. dispose(): void;
  10729. private _beforeClear;
  10730. }
  10731. }
  10732. declare module BABYLON {
  10733. interface ThinEngine {
  10734. /**
  10735. * Creates a new render target cube texture
  10736. * @param size defines the size of the texture
  10737. * @param options defines the options used to create the texture
  10738. * @returns a new render target cube texture stored in an InternalTexture
  10739. */
  10740. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10741. }
  10742. }
  10743. declare module BABYLON {
  10744. /** @hidden */
  10745. export var proceduralVertexShader: {
  10746. name: string;
  10747. shader: string;
  10748. };
  10749. }
  10750. declare module BABYLON {
  10751. /**
  10752. * 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.
  10753. * This is the base class of any Procedural texture and contains most of the shareable code.
  10754. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10755. */
  10756. export class ProceduralTexture extends Texture {
  10757. isCube: boolean;
  10758. /**
  10759. * Define if the texture is enabled or not (disabled texture will not render)
  10760. */
  10761. isEnabled: boolean;
  10762. /**
  10763. * Define if the texture must be cleared before rendering (default is true)
  10764. */
  10765. autoClear: boolean;
  10766. /**
  10767. * Callback called when the texture is generated
  10768. */
  10769. onGenerated: () => void;
  10770. /**
  10771. * Event raised when the texture is generated
  10772. */
  10773. onGeneratedObservable: Observable<ProceduralTexture>;
  10774. /** @hidden */
  10775. _generateMipMaps: boolean;
  10776. /** @hidden **/
  10777. _effect: Effect;
  10778. /** @hidden */
  10779. _textures: {
  10780. [key: string]: Texture;
  10781. };
  10782. private _size;
  10783. private _currentRefreshId;
  10784. private _frameId;
  10785. private _refreshRate;
  10786. private _vertexBuffers;
  10787. private _indexBuffer;
  10788. private _uniforms;
  10789. private _samplers;
  10790. private _fragment;
  10791. private _floats;
  10792. private _ints;
  10793. private _floatsArrays;
  10794. private _colors3;
  10795. private _colors4;
  10796. private _vectors2;
  10797. private _vectors3;
  10798. private _matrices;
  10799. private _fallbackTexture;
  10800. private _fallbackTextureUsed;
  10801. private _engine;
  10802. private _cachedDefines;
  10803. private _contentUpdateId;
  10804. private _contentData;
  10805. /**
  10806. * Instantiates a new procedural texture.
  10807. * 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.
  10808. * This is the base class of any Procedural texture and contains most of the shareable code.
  10809. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10810. * @param name Define the name of the texture
  10811. * @param size Define the size of the texture to create
  10812. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10813. * @param scene Define the scene the texture belongs to
  10814. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10815. * @param generateMipMaps Define if the texture should creates mip maps or not
  10816. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10817. */
  10818. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10819. /**
  10820. * The effect that is created when initializing the post process.
  10821. * @returns The created effect corresponding the the postprocess.
  10822. */
  10823. getEffect(): Effect;
  10824. /**
  10825. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10826. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10827. */
  10828. getContent(): Nullable<ArrayBufferView>;
  10829. private _createIndexBuffer;
  10830. /** @hidden */
  10831. _rebuild(): void;
  10832. /**
  10833. * Resets the texture in order to recreate its associated resources.
  10834. * This can be called in case of context loss
  10835. */
  10836. reset(): void;
  10837. protected _getDefines(): string;
  10838. /**
  10839. * Is the texture ready to be used ? (rendered at least once)
  10840. * @returns true if ready, otherwise, false.
  10841. */
  10842. isReady(): boolean;
  10843. /**
  10844. * Resets the refresh counter of the texture and start bak from scratch.
  10845. * Could be useful to regenerate the texture if it is setup to render only once.
  10846. */
  10847. resetRefreshCounter(): void;
  10848. /**
  10849. * Set the fragment shader to use in order to render the texture.
  10850. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10851. */
  10852. setFragment(fragment: any): void;
  10853. /**
  10854. * Define the refresh rate of the texture or the rendering frequency.
  10855. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10856. */
  10857. get refreshRate(): number;
  10858. set refreshRate(value: number);
  10859. /** @hidden */
  10860. _shouldRender(): boolean;
  10861. /**
  10862. * Get the size the texture is rendering at.
  10863. * @returns the size (texture is always squared)
  10864. */
  10865. getRenderSize(): number;
  10866. /**
  10867. * Resize the texture to new value.
  10868. * @param size Define the new size the texture should have
  10869. * @param generateMipMaps Define whether the new texture should create mip maps
  10870. */
  10871. resize(size: number, generateMipMaps: boolean): void;
  10872. private _checkUniform;
  10873. /**
  10874. * Set a texture in the shader program used to render.
  10875. * @param name Define the name of the uniform samplers as defined in the shader
  10876. * @param texture Define the texture to bind to this sampler
  10877. * @return the texture itself allowing "fluent" like uniform updates
  10878. */
  10879. setTexture(name: string, texture: Texture): ProceduralTexture;
  10880. /**
  10881. * Set a float in the shader.
  10882. * @param name Define the name of the uniform as defined in the shader
  10883. * @param value Define the value to give to the uniform
  10884. * @return the texture itself allowing "fluent" like uniform updates
  10885. */
  10886. setFloat(name: string, value: number): ProceduralTexture;
  10887. /**
  10888. * Set a int in the shader.
  10889. * @param name Define the name of the uniform as defined in the shader
  10890. * @param value Define the value to give to the uniform
  10891. * @return the texture itself allowing "fluent" like uniform updates
  10892. */
  10893. setInt(name: string, value: number): ProceduralTexture;
  10894. /**
  10895. * Set an array of floats in the shader.
  10896. * @param name Define the name of the uniform as defined in the shader
  10897. * @param value Define the value to give to the uniform
  10898. * @return the texture itself allowing "fluent" like uniform updates
  10899. */
  10900. setFloats(name: string, value: number[]): ProceduralTexture;
  10901. /**
  10902. * Set a vec3 in the shader from a Color3.
  10903. * @param name Define the name of the uniform as defined in the shader
  10904. * @param value Define the value to give to the uniform
  10905. * @return the texture itself allowing "fluent" like uniform updates
  10906. */
  10907. setColor3(name: string, value: Color3): ProceduralTexture;
  10908. /**
  10909. * Set a vec4 in the shader from a Color4.
  10910. * @param name Define the name of the uniform as defined in the shader
  10911. * @param value Define the value to give to the uniform
  10912. * @return the texture itself allowing "fluent" like uniform updates
  10913. */
  10914. setColor4(name: string, value: Color4): ProceduralTexture;
  10915. /**
  10916. * Set a vec2 in the shader from a Vector2.
  10917. * @param name Define the name of the uniform as defined in the shader
  10918. * @param value Define the value to give to the uniform
  10919. * @return the texture itself allowing "fluent" like uniform updates
  10920. */
  10921. setVector2(name: string, value: Vector2): ProceduralTexture;
  10922. /**
  10923. * Set a vec3 in the shader from a Vector3.
  10924. * @param name Define the name of the uniform as defined in the shader
  10925. * @param value Define the value to give to the uniform
  10926. * @return the texture itself allowing "fluent" like uniform updates
  10927. */
  10928. setVector3(name: string, value: Vector3): ProceduralTexture;
  10929. /**
  10930. * Set a mat4 in the shader from a MAtrix.
  10931. * @param name Define the name of the uniform as defined in the shader
  10932. * @param value Define the value to give to the uniform
  10933. * @return the texture itself allowing "fluent" like uniform updates
  10934. */
  10935. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10936. /**
  10937. * Render the texture to its associated render target.
  10938. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10939. */
  10940. render(useCameraPostProcess?: boolean): void;
  10941. /**
  10942. * Clone the texture.
  10943. * @returns the cloned texture
  10944. */
  10945. clone(): ProceduralTexture;
  10946. /**
  10947. * Dispose the texture and release its asoociated resources.
  10948. */
  10949. dispose(): void;
  10950. }
  10951. }
  10952. declare module BABYLON {
  10953. /**
  10954. * This represents the base class for particle system in Babylon.
  10955. * 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.
  10956. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10957. * @example https://doc.babylonjs.com/babylon101/particles
  10958. */
  10959. export class BaseParticleSystem {
  10960. /**
  10961. * Source color is added to the destination color without alpha affecting the result
  10962. */
  10963. static BLENDMODE_ONEONE: number;
  10964. /**
  10965. * Blend current color and particle color using particle’s alpha
  10966. */
  10967. static BLENDMODE_STANDARD: number;
  10968. /**
  10969. * Add current color and particle color multiplied by particle’s alpha
  10970. */
  10971. static BLENDMODE_ADD: number;
  10972. /**
  10973. * Multiply current color with particle color
  10974. */
  10975. static BLENDMODE_MULTIPLY: number;
  10976. /**
  10977. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10978. */
  10979. static BLENDMODE_MULTIPLYADD: number;
  10980. /**
  10981. * List of animations used by the particle system.
  10982. */
  10983. animations: Animation[];
  10984. /**
  10985. * The id of the Particle system.
  10986. */
  10987. id: string;
  10988. /**
  10989. * The friendly name of the Particle system.
  10990. */
  10991. name: string;
  10992. /**
  10993. * The rendering group used by the Particle system to chose when to render.
  10994. */
  10995. renderingGroupId: number;
  10996. /**
  10997. * The emitter represents the Mesh or position we are attaching the particle system to.
  10998. */
  10999. emitter: Nullable<AbstractMesh | Vector3>;
  11000. /**
  11001. * The maximum number of particles to emit per frame
  11002. */
  11003. emitRate: number;
  11004. /**
  11005. * If you want to launch only a few particles at once, that can be done, as well.
  11006. */
  11007. manualEmitCount: number;
  11008. /**
  11009. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11010. */
  11011. updateSpeed: number;
  11012. /**
  11013. * The amount of time the particle system is running (depends of the overall update speed).
  11014. */
  11015. targetStopDuration: number;
  11016. /**
  11017. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11018. */
  11019. disposeOnStop: boolean;
  11020. /**
  11021. * Minimum power of emitting particles.
  11022. */
  11023. minEmitPower: number;
  11024. /**
  11025. * Maximum power of emitting particles.
  11026. */
  11027. maxEmitPower: number;
  11028. /**
  11029. * Minimum life time of emitting particles.
  11030. */
  11031. minLifeTime: number;
  11032. /**
  11033. * Maximum life time of emitting particles.
  11034. */
  11035. maxLifeTime: number;
  11036. /**
  11037. * Minimum Size of emitting particles.
  11038. */
  11039. minSize: number;
  11040. /**
  11041. * Maximum Size of emitting particles.
  11042. */
  11043. maxSize: number;
  11044. /**
  11045. * Minimum scale of emitting particles on X axis.
  11046. */
  11047. minScaleX: number;
  11048. /**
  11049. * Maximum scale of emitting particles on X axis.
  11050. */
  11051. maxScaleX: number;
  11052. /**
  11053. * Minimum scale of emitting particles on Y axis.
  11054. */
  11055. minScaleY: number;
  11056. /**
  11057. * Maximum scale of emitting particles on Y axis.
  11058. */
  11059. maxScaleY: number;
  11060. /**
  11061. * Gets or sets the minimal initial rotation in radians.
  11062. */
  11063. minInitialRotation: number;
  11064. /**
  11065. * Gets or sets the maximal initial rotation in radians.
  11066. */
  11067. maxInitialRotation: number;
  11068. /**
  11069. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11070. */
  11071. minAngularSpeed: number;
  11072. /**
  11073. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11074. */
  11075. maxAngularSpeed: number;
  11076. /**
  11077. * The texture used to render each particle. (this can be a spritesheet)
  11078. */
  11079. particleTexture: Nullable<Texture>;
  11080. /**
  11081. * The layer mask we are rendering the particles through.
  11082. */
  11083. layerMask: number;
  11084. /**
  11085. * This can help using your own shader to render the particle system.
  11086. * The according effect will be created
  11087. */
  11088. customShader: any;
  11089. /**
  11090. * By default particle system starts as soon as they are created. This prevents the
  11091. * automatic start to happen and let you decide when to start emitting particles.
  11092. */
  11093. preventAutoStart: boolean;
  11094. private _noiseTexture;
  11095. /**
  11096. * Gets or sets a texture used to add random noise to particle positions
  11097. */
  11098. get noiseTexture(): Nullable<ProceduralTexture>;
  11099. set noiseTexture(value: Nullable<ProceduralTexture>);
  11100. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11101. noiseStrength: Vector3;
  11102. /**
  11103. * Callback triggered when the particle animation is ending.
  11104. */
  11105. onAnimationEnd: Nullable<() => void>;
  11106. /**
  11107. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11108. */
  11109. blendMode: number;
  11110. /**
  11111. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11112. * to override the particles.
  11113. */
  11114. forceDepthWrite: boolean;
  11115. /** 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 */
  11116. preWarmCycles: number;
  11117. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11118. preWarmStepOffset: number;
  11119. /**
  11120. * 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)
  11121. */
  11122. spriteCellChangeSpeed: number;
  11123. /**
  11124. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11125. */
  11126. startSpriteCellID: number;
  11127. /**
  11128. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11129. */
  11130. endSpriteCellID: number;
  11131. /**
  11132. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11133. */
  11134. spriteCellWidth: number;
  11135. /**
  11136. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11137. */
  11138. spriteCellHeight: number;
  11139. /**
  11140. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11141. */
  11142. spriteRandomStartCell: boolean;
  11143. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11144. translationPivot: Vector2;
  11145. /** @hidden */
  11146. protected _isAnimationSheetEnabled: boolean;
  11147. /**
  11148. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11149. */
  11150. beginAnimationOnStart: boolean;
  11151. /**
  11152. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11153. */
  11154. beginAnimationFrom: number;
  11155. /**
  11156. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11157. */
  11158. beginAnimationTo: number;
  11159. /**
  11160. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11161. */
  11162. beginAnimationLoop: boolean;
  11163. /**
  11164. * Gets or sets a world offset applied to all particles
  11165. */
  11166. worldOffset: Vector3;
  11167. /**
  11168. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11169. */
  11170. get isAnimationSheetEnabled(): boolean;
  11171. set isAnimationSheetEnabled(value: boolean);
  11172. /**
  11173. * Get hosting scene
  11174. * @returns the scene
  11175. */
  11176. getScene(): Scene;
  11177. /**
  11178. * You can use gravity if you want to give an orientation to your particles.
  11179. */
  11180. gravity: Vector3;
  11181. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11182. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11183. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11184. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11185. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11186. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11187. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11188. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11189. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11190. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11191. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11192. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11193. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11194. /**
  11195. * Defines the delay in milliseconds before starting the system (0 by default)
  11196. */
  11197. startDelay: number;
  11198. /**
  11199. * Gets the current list of drag gradients.
  11200. * You must use addDragGradient and removeDragGradient to udpate this list
  11201. * @returns the list of drag gradients
  11202. */
  11203. getDragGradients(): Nullable<Array<FactorGradient>>;
  11204. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11205. limitVelocityDamping: number;
  11206. /**
  11207. * Gets the current list of limit velocity gradients.
  11208. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11209. * @returns the list of limit velocity gradients
  11210. */
  11211. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11212. /**
  11213. * Gets the current list of color gradients.
  11214. * You must use addColorGradient and removeColorGradient to udpate this list
  11215. * @returns the list of color gradients
  11216. */
  11217. getColorGradients(): Nullable<Array<ColorGradient>>;
  11218. /**
  11219. * Gets the current list of size gradients.
  11220. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11221. * @returns the list of size gradients
  11222. */
  11223. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11224. /**
  11225. * Gets the current list of color remap gradients.
  11226. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11227. * @returns the list of color remap gradients
  11228. */
  11229. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11230. /**
  11231. * Gets the current list of alpha remap gradients.
  11232. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11233. * @returns the list of alpha remap gradients
  11234. */
  11235. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11236. /**
  11237. * Gets the current list of life time gradients.
  11238. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11239. * @returns the list of life time gradients
  11240. */
  11241. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11242. /**
  11243. * Gets the current list of angular speed gradients.
  11244. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11245. * @returns the list of angular speed gradients
  11246. */
  11247. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11248. /**
  11249. * Gets the current list of velocity gradients.
  11250. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11251. * @returns the list of velocity gradients
  11252. */
  11253. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11254. /**
  11255. * Gets the current list of start size gradients.
  11256. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11257. * @returns the list of start size gradients
  11258. */
  11259. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11260. /**
  11261. * Gets the current list of emit rate gradients.
  11262. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11263. * @returns the list of emit rate gradients
  11264. */
  11265. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11266. /**
  11267. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11268. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11269. */
  11270. get direction1(): Vector3;
  11271. set direction1(value: Vector3);
  11272. /**
  11273. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11274. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11275. */
  11276. get direction2(): Vector3;
  11277. set direction2(value: Vector3);
  11278. /**
  11279. * 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.
  11280. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11281. */
  11282. get minEmitBox(): Vector3;
  11283. set minEmitBox(value: Vector3);
  11284. /**
  11285. * 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.
  11286. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11287. */
  11288. get maxEmitBox(): Vector3;
  11289. set maxEmitBox(value: Vector3);
  11290. /**
  11291. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11292. */
  11293. color1: Color4;
  11294. /**
  11295. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11296. */
  11297. color2: Color4;
  11298. /**
  11299. * Color the particle will have at the end of its lifetime
  11300. */
  11301. colorDead: Color4;
  11302. /**
  11303. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11304. */
  11305. textureMask: Color4;
  11306. /**
  11307. * The particle emitter type defines the emitter used by the particle system.
  11308. * It can be for example box, sphere, or cone...
  11309. */
  11310. particleEmitterType: IParticleEmitterType;
  11311. /** @hidden */
  11312. _isSubEmitter: boolean;
  11313. /**
  11314. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11315. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11316. */
  11317. billboardMode: number;
  11318. protected _isBillboardBased: boolean;
  11319. /**
  11320. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11321. */
  11322. get isBillboardBased(): boolean;
  11323. set isBillboardBased(value: boolean);
  11324. /**
  11325. * The scene the particle system belongs to.
  11326. */
  11327. protected _scene: Scene;
  11328. /**
  11329. * Local cache of defines for image processing.
  11330. */
  11331. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11332. /**
  11333. * Default configuration related to image processing available in the standard Material.
  11334. */
  11335. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11336. /**
  11337. * Gets the image processing configuration used either in this material.
  11338. */
  11339. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11340. /**
  11341. * Sets the Default image processing configuration used either in the this material.
  11342. *
  11343. * If sets to null, the scene one is in use.
  11344. */
  11345. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11346. /**
  11347. * Attaches a new image processing configuration to the Standard Material.
  11348. * @param configuration
  11349. */
  11350. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11351. /** @hidden */
  11352. protected _reset(): void;
  11353. /** @hidden */
  11354. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11355. /**
  11356. * Instantiates a particle system.
  11357. * 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.
  11358. * @param name The name of the particle system
  11359. */
  11360. constructor(name: string);
  11361. /**
  11362. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11363. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11364. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11365. * @returns the emitter
  11366. */
  11367. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11368. /**
  11369. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11370. * @param radius The radius of the hemisphere to emit from
  11371. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11372. * @returns the emitter
  11373. */
  11374. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11375. /**
  11376. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11377. * @param radius The radius of the sphere to emit from
  11378. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11379. * @returns the emitter
  11380. */
  11381. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11382. /**
  11383. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11384. * @param radius The radius of the sphere to emit from
  11385. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11386. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11387. * @returns the emitter
  11388. */
  11389. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11390. /**
  11391. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11392. * @param radius The radius of the emission cylinder
  11393. * @param height The height of the emission cylinder
  11394. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11395. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11396. * @returns the emitter
  11397. */
  11398. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11399. /**
  11400. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11401. * @param radius The radius of the cylinder to emit from
  11402. * @param height The height of the emission cylinder
  11403. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11404. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11405. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11406. * @returns the emitter
  11407. */
  11408. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11409. /**
  11410. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11411. * @param radius The radius of the cone to emit from
  11412. * @param angle The base angle of the cone
  11413. * @returns the emitter
  11414. */
  11415. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11416. /**
  11417. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11418. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11419. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11420. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11421. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11422. * @returns the emitter
  11423. */
  11424. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11425. }
  11426. }
  11427. declare module BABYLON {
  11428. /**
  11429. * Type of sub emitter
  11430. */
  11431. export enum SubEmitterType {
  11432. /**
  11433. * Attached to the particle over it's lifetime
  11434. */
  11435. ATTACHED = 0,
  11436. /**
  11437. * Created when the particle dies
  11438. */
  11439. END = 1
  11440. }
  11441. /**
  11442. * Sub emitter class used to emit particles from an existing particle
  11443. */
  11444. export class SubEmitter {
  11445. /**
  11446. * the particle system to be used by the sub emitter
  11447. */
  11448. particleSystem: ParticleSystem;
  11449. /**
  11450. * Type of the submitter (Default: END)
  11451. */
  11452. type: SubEmitterType;
  11453. /**
  11454. * 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)
  11455. * Note: This only is supported when using an emitter of type Mesh
  11456. */
  11457. inheritDirection: boolean;
  11458. /**
  11459. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11460. */
  11461. inheritedVelocityAmount: number;
  11462. /**
  11463. * Creates a sub emitter
  11464. * @param particleSystem the particle system to be used by the sub emitter
  11465. */
  11466. constructor(
  11467. /**
  11468. * the particle system to be used by the sub emitter
  11469. */
  11470. particleSystem: ParticleSystem);
  11471. /**
  11472. * Clones the sub emitter
  11473. * @returns the cloned sub emitter
  11474. */
  11475. clone(): SubEmitter;
  11476. /**
  11477. * Serialize current object to a JSON object
  11478. * @returns the serialized object
  11479. */
  11480. serialize(): any;
  11481. /** @hidden */
  11482. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11483. /**
  11484. * Creates a new SubEmitter from a serialized JSON version
  11485. * @param serializationObject defines the JSON object to read from
  11486. * @param scene defines the hosting scene
  11487. * @param rootUrl defines the rootUrl for data loading
  11488. * @returns a new SubEmitter
  11489. */
  11490. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11491. /** Release associated resources */
  11492. dispose(): void;
  11493. }
  11494. }
  11495. declare module BABYLON {
  11496. /** @hidden */
  11497. export var imageProcessingDeclaration: {
  11498. name: string;
  11499. shader: string;
  11500. };
  11501. }
  11502. declare module BABYLON {
  11503. /** @hidden */
  11504. export var imageProcessingFunctions: {
  11505. name: string;
  11506. shader: string;
  11507. };
  11508. }
  11509. declare module BABYLON {
  11510. /** @hidden */
  11511. export var particlesPixelShader: {
  11512. name: string;
  11513. shader: string;
  11514. };
  11515. }
  11516. declare module BABYLON {
  11517. /** @hidden */
  11518. export var particlesVertexShader: {
  11519. name: string;
  11520. shader: string;
  11521. };
  11522. }
  11523. declare module BABYLON {
  11524. /**
  11525. * This represents a particle system in Babylon.
  11526. * 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.
  11527. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11528. * @example https://doc.babylonjs.com/babylon101/particles
  11529. */
  11530. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11531. /**
  11532. * Billboard mode will only apply to Y axis
  11533. */
  11534. static readonly BILLBOARDMODE_Y: number;
  11535. /**
  11536. * Billboard mode will apply to all axes
  11537. */
  11538. static readonly BILLBOARDMODE_ALL: number;
  11539. /**
  11540. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11541. */
  11542. static readonly BILLBOARDMODE_STRETCHED: number;
  11543. /**
  11544. * This function can be defined to provide custom update for active particles.
  11545. * This function will be called instead of regular update (age, position, color, etc.).
  11546. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11547. */
  11548. updateFunction: (particles: Particle[]) => void;
  11549. private _emitterWorldMatrix;
  11550. /**
  11551. * This function can be defined to specify initial direction for every new particle.
  11552. * It by default use the emitterType defined function
  11553. */
  11554. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11555. /**
  11556. * This function can be defined to specify initial position for every new particle.
  11557. * It by default use the emitterType defined function
  11558. */
  11559. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11560. /**
  11561. * @hidden
  11562. */
  11563. _inheritedVelocityOffset: Vector3;
  11564. /**
  11565. * An event triggered when the system is disposed
  11566. */
  11567. onDisposeObservable: Observable<ParticleSystem>;
  11568. private _onDisposeObserver;
  11569. /**
  11570. * Sets a callback that will be triggered when the system is disposed
  11571. */
  11572. set onDispose(callback: () => void);
  11573. private _particles;
  11574. private _epsilon;
  11575. private _capacity;
  11576. private _stockParticles;
  11577. private _newPartsExcess;
  11578. private _vertexData;
  11579. private _vertexBuffer;
  11580. private _vertexBuffers;
  11581. private _spriteBuffer;
  11582. private _indexBuffer;
  11583. private _effect;
  11584. private _customEffect;
  11585. private _cachedDefines;
  11586. private _scaledColorStep;
  11587. private _colorDiff;
  11588. private _scaledDirection;
  11589. private _scaledGravity;
  11590. private _currentRenderId;
  11591. private _alive;
  11592. private _useInstancing;
  11593. private _started;
  11594. private _stopped;
  11595. private _actualFrame;
  11596. private _scaledUpdateSpeed;
  11597. private _vertexBufferSize;
  11598. /** @hidden */
  11599. _currentEmitRateGradient: Nullable<FactorGradient>;
  11600. /** @hidden */
  11601. _currentEmitRate1: number;
  11602. /** @hidden */
  11603. _currentEmitRate2: number;
  11604. /** @hidden */
  11605. _currentStartSizeGradient: Nullable<FactorGradient>;
  11606. /** @hidden */
  11607. _currentStartSize1: number;
  11608. /** @hidden */
  11609. _currentStartSize2: number;
  11610. private readonly _rawTextureWidth;
  11611. private _rampGradientsTexture;
  11612. private _useRampGradients;
  11613. /** Gets or sets a boolean indicating that ramp gradients must be used
  11614. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11615. */
  11616. get useRampGradients(): boolean;
  11617. set useRampGradients(value: boolean);
  11618. /**
  11619. * 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.
  11620. * 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: [])
  11621. */
  11622. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11623. private _subEmitters;
  11624. /**
  11625. * @hidden
  11626. * If the particle systems emitter should be disposed when the particle system is disposed
  11627. */
  11628. _disposeEmitterOnDispose: boolean;
  11629. /**
  11630. * The current active Sub-systems, this property is used by the root particle system only.
  11631. */
  11632. activeSubSystems: Array<ParticleSystem>;
  11633. /**
  11634. * Specifies if the particles are updated in emitter local space or world space
  11635. */
  11636. isLocal: boolean;
  11637. private _rootParticleSystem;
  11638. /**
  11639. * Gets the current list of active particles
  11640. */
  11641. get particles(): Particle[];
  11642. /**
  11643. * Returns the string "ParticleSystem"
  11644. * @returns a string containing the class name
  11645. */
  11646. getClassName(): string;
  11647. /**
  11648. * Instantiates a particle system.
  11649. * 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.
  11650. * @param name The name of the particle system
  11651. * @param capacity The max number of particles alive at the same time
  11652. * @param scene The scene the particle system belongs to
  11653. * @param customEffect a custom effect used to change the way particles are rendered by default
  11654. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11655. * @param epsilon Offset used to render the particles
  11656. */
  11657. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11658. private _addFactorGradient;
  11659. private _removeFactorGradient;
  11660. /**
  11661. * Adds a new life time gradient
  11662. * @param gradient defines the gradient to use (between 0 and 1)
  11663. * @param factor defines the life time factor to affect to the specified gradient
  11664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11665. * @returns the current particle system
  11666. */
  11667. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11668. /**
  11669. * Remove a specific life time gradient
  11670. * @param gradient defines the gradient to remove
  11671. * @returns the current particle system
  11672. */
  11673. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11674. /**
  11675. * Adds a new size gradient
  11676. * @param gradient defines the gradient to use (between 0 and 1)
  11677. * @param factor defines the size factor to affect to the specified gradient
  11678. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11679. * @returns the current particle system
  11680. */
  11681. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11682. /**
  11683. * Remove a specific size gradient
  11684. * @param gradient defines the gradient to remove
  11685. * @returns the current particle system
  11686. */
  11687. removeSizeGradient(gradient: number): IParticleSystem;
  11688. /**
  11689. * Adds a new color remap gradient
  11690. * @param gradient defines the gradient to use (between 0 and 1)
  11691. * @param min defines the color remap minimal range
  11692. * @param max defines the color remap maximal range
  11693. * @returns the current particle system
  11694. */
  11695. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11696. /**
  11697. * Remove a specific color remap gradient
  11698. * @param gradient defines the gradient to remove
  11699. * @returns the current particle system
  11700. */
  11701. removeColorRemapGradient(gradient: number): IParticleSystem;
  11702. /**
  11703. * Adds a new alpha remap gradient
  11704. * @param gradient defines the gradient to use (between 0 and 1)
  11705. * @param min defines the alpha remap minimal range
  11706. * @param max defines the alpha remap maximal range
  11707. * @returns the current particle system
  11708. */
  11709. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11710. /**
  11711. * Remove a specific alpha remap gradient
  11712. * @param gradient defines the gradient to remove
  11713. * @returns the current particle system
  11714. */
  11715. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11716. /**
  11717. * Adds a new angular speed gradient
  11718. * @param gradient defines the gradient to use (between 0 and 1)
  11719. * @param factor defines the angular speed to affect to the specified gradient
  11720. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11721. * @returns the current particle system
  11722. */
  11723. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11724. /**
  11725. * Remove a specific angular speed gradient
  11726. * @param gradient defines the gradient to remove
  11727. * @returns the current particle system
  11728. */
  11729. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11730. /**
  11731. * Adds a new velocity gradient
  11732. * @param gradient defines the gradient to use (between 0 and 1)
  11733. * @param factor defines the velocity to affect to the specified gradient
  11734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11735. * @returns the current particle system
  11736. */
  11737. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11738. /**
  11739. * Remove a specific velocity gradient
  11740. * @param gradient defines the gradient to remove
  11741. * @returns the current particle system
  11742. */
  11743. removeVelocityGradient(gradient: number): IParticleSystem;
  11744. /**
  11745. * Adds a new limit velocity gradient
  11746. * @param gradient defines the gradient to use (between 0 and 1)
  11747. * @param factor defines the limit velocity value to affect to the specified gradient
  11748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11749. * @returns the current particle system
  11750. */
  11751. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11752. /**
  11753. * Remove a specific limit velocity gradient
  11754. * @param gradient defines the gradient to remove
  11755. * @returns the current particle system
  11756. */
  11757. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11758. /**
  11759. * Adds a new drag gradient
  11760. * @param gradient defines the gradient to use (between 0 and 1)
  11761. * @param factor defines the drag value to affect to the specified gradient
  11762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11763. * @returns the current particle system
  11764. */
  11765. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11766. /**
  11767. * Remove a specific drag gradient
  11768. * @param gradient defines the gradient to remove
  11769. * @returns the current particle system
  11770. */
  11771. removeDragGradient(gradient: number): IParticleSystem;
  11772. /**
  11773. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11774. * @param gradient defines the gradient to use (between 0 and 1)
  11775. * @param factor defines the emit rate value to affect to the specified gradient
  11776. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11777. * @returns the current particle system
  11778. */
  11779. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11780. /**
  11781. * Remove a specific emit rate gradient
  11782. * @param gradient defines the gradient to remove
  11783. * @returns the current particle system
  11784. */
  11785. removeEmitRateGradient(gradient: number): IParticleSystem;
  11786. /**
  11787. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11788. * @param gradient defines the gradient to use (between 0 and 1)
  11789. * @param factor defines the start size value to affect to the specified gradient
  11790. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11791. * @returns the current particle system
  11792. */
  11793. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11794. /**
  11795. * Remove a specific start size gradient
  11796. * @param gradient defines the gradient to remove
  11797. * @returns the current particle system
  11798. */
  11799. removeStartSizeGradient(gradient: number): IParticleSystem;
  11800. private _createRampGradientTexture;
  11801. /**
  11802. * Gets the current list of ramp gradients.
  11803. * You must use addRampGradient and removeRampGradient to udpate this list
  11804. * @returns the list of ramp gradients
  11805. */
  11806. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11807. /**
  11808. * Adds a new ramp gradient used to remap particle colors
  11809. * @param gradient defines the gradient to use (between 0 and 1)
  11810. * @param color defines the color to affect to the specified gradient
  11811. * @returns the current particle system
  11812. */
  11813. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11814. /**
  11815. * Remove a specific ramp gradient
  11816. * @param gradient defines the gradient to remove
  11817. * @returns the current particle system
  11818. */
  11819. removeRampGradient(gradient: number): ParticleSystem;
  11820. /**
  11821. * Adds a new color gradient
  11822. * @param gradient defines the gradient to use (between 0 and 1)
  11823. * @param color1 defines the color to affect to the specified gradient
  11824. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11825. * @returns this particle system
  11826. */
  11827. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11828. /**
  11829. * Remove a specific color gradient
  11830. * @param gradient defines the gradient to remove
  11831. * @returns this particle system
  11832. */
  11833. removeColorGradient(gradient: number): IParticleSystem;
  11834. private _fetchR;
  11835. protected _reset(): void;
  11836. private _resetEffect;
  11837. private _createVertexBuffers;
  11838. private _createIndexBuffer;
  11839. /**
  11840. * Gets the maximum number of particles active at the same time.
  11841. * @returns The max number of active particles.
  11842. */
  11843. getCapacity(): number;
  11844. /**
  11845. * Gets whether there are still active particles in the system.
  11846. * @returns True if it is alive, otherwise false.
  11847. */
  11848. isAlive(): boolean;
  11849. /**
  11850. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11851. * @returns True if it has been started, otherwise false.
  11852. */
  11853. isStarted(): boolean;
  11854. private _prepareSubEmitterInternalArray;
  11855. /**
  11856. * Starts the particle system and begins to emit
  11857. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11858. */
  11859. start(delay?: number): void;
  11860. /**
  11861. * Stops the particle system.
  11862. * @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.
  11863. */
  11864. stop(stopSubEmitters?: boolean): void;
  11865. /**
  11866. * Remove all active particles
  11867. */
  11868. reset(): void;
  11869. /**
  11870. * @hidden (for internal use only)
  11871. */
  11872. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11873. /**
  11874. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11875. * Its lifetime will start back at 0.
  11876. */
  11877. recycleParticle: (particle: Particle) => void;
  11878. private _stopSubEmitters;
  11879. private _createParticle;
  11880. private _removeFromRoot;
  11881. private _emitFromParticle;
  11882. private _update;
  11883. /** @hidden */
  11884. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11885. /** @hidden */
  11886. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11887. /** @hidden */
  11888. private _getEffect;
  11889. /**
  11890. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11891. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11892. */
  11893. animate(preWarmOnly?: boolean): void;
  11894. private _appendParticleVertices;
  11895. /**
  11896. * Rebuilds the particle system.
  11897. */
  11898. rebuild(): void;
  11899. /**
  11900. * Is this system ready to be used/rendered
  11901. * @return true if the system is ready
  11902. */
  11903. isReady(): boolean;
  11904. private _render;
  11905. /**
  11906. * Renders the particle system in its current state.
  11907. * @returns the current number of particles
  11908. */
  11909. render(): number;
  11910. /**
  11911. * Disposes the particle system and free the associated resources
  11912. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11913. */
  11914. dispose(disposeTexture?: boolean): void;
  11915. /**
  11916. * Clones the particle system.
  11917. * @param name The name of the cloned object
  11918. * @param newEmitter The new emitter to use
  11919. * @returns the cloned particle system
  11920. */
  11921. clone(name: string, newEmitter: any): ParticleSystem;
  11922. /**
  11923. * Serializes the particle system to a JSON object.
  11924. * @returns the JSON object
  11925. */
  11926. serialize(): any;
  11927. /** @hidden */
  11928. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11929. /** @hidden */
  11930. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11931. /**
  11932. * Parses a JSON object to create a particle system.
  11933. * @param parsedParticleSystem The JSON object to parse
  11934. * @param scene The scene to create the particle system in
  11935. * @param rootUrl The root url to use to load external dependencies like texture
  11936. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11937. * @returns the Parsed particle system
  11938. */
  11939. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11940. }
  11941. }
  11942. declare module BABYLON {
  11943. /**
  11944. * A particle represents one of the element emitted by a particle system.
  11945. * This is mainly define by its coordinates, direction, velocity and age.
  11946. */
  11947. export class Particle {
  11948. /**
  11949. * The particle system the particle belongs to.
  11950. */
  11951. particleSystem: ParticleSystem;
  11952. private static _Count;
  11953. /**
  11954. * Unique ID of the particle
  11955. */
  11956. id: number;
  11957. /**
  11958. * The world position of the particle in the scene.
  11959. */
  11960. position: Vector3;
  11961. /**
  11962. * The world direction of the particle in the scene.
  11963. */
  11964. direction: Vector3;
  11965. /**
  11966. * The color of the particle.
  11967. */
  11968. color: Color4;
  11969. /**
  11970. * The color change of the particle per step.
  11971. */
  11972. colorStep: Color4;
  11973. /**
  11974. * Defines how long will the life of the particle be.
  11975. */
  11976. lifeTime: number;
  11977. /**
  11978. * The current age of the particle.
  11979. */
  11980. age: number;
  11981. /**
  11982. * The current size of the particle.
  11983. */
  11984. size: number;
  11985. /**
  11986. * The current scale of the particle.
  11987. */
  11988. scale: Vector2;
  11989. /**
  11990. * The current angle of the particle.
  11991. */
  11992. angle: number;
  11993. /**
  11994. * Defines how fast is the angle changing.
  11995. */
  11996. angularSpeed: number;
  11997. /**
  11998. * Defines the cell index used by the particle to be rendered from a sprite.
  11999. */
  12000. cellIndex: number;
  12001. /**
  12002. * The information required to support color remapping
  12003. */
  12004. remapData: Vector4;
  12005. /** @hidden */
  12006. _randomCellOffset?: number;
  12007. /** @hidden */
  12008. _initialDirection: Nullable<Vector3>;
  12009. /** @hidden */
  12010. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12011. /** @hidden */
  12012. _initialStartSpriteCellID: number;
  12013. /** @hidden */
  12014. _initialEndSpriteCellID: number;
  12015. /** @hidden */
  12016. _currentColorGradient: Nullable<ColorGradient>;
  12017. /** @hidden */
  12018. _currentColor1: Color4;
  12019. /** @hidden */
  12020. _currentColor2: Color4;
  12021. /** @hidden */
  12022. _currentSizeGradient: Nullable<FactorGradient>;
  12023. /** @hidden */
  12024. _currentSize1: number;
  12025. /** @hidden */
  12026. _currentSize2: number;
  12027. /** @hidden */
  12028. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12029. /** @hidden */
  12030. _currentAngularSpeed1: number;
  12031. /** @hidden */
  12032. _currentAngularSpeed2: number;
  12033. /** @hidden */
  12034. _currentVelocityGradient: Nullable<FactorGradient>;
  12035. /** @hidden */
  12036. _currentVelocity1: number;
  12037. /** @hidden */
  12038. _currentVelocity2: number;
  12039. /** @hidden */
  12040. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12041. /** @hidden */
  12042. _currentLimitVelocity1: number;
  12043. /** @hidden */
  12044. _currentLimitVelocity2: number;
  12045. /** @hidden */
  12046. _currentDragGradient: Nullable<FactorGradient>;
  12047. /** @hidden */
  12048. _currentDrag1: number;
  12049. /** @hidden */
  12050. _currentDrag2: number;
  12051. /** @hidden */
  12052. _randomNoiseCoordinates1: Vector3;
  12053. /** @hidden */
  12054. _randomNoiseCoordinates2: Vector3;
  12055. /** @hidden */
  12056. _localPosition?: Vector3;
  12057. /**
  12058. * Creates a new instance Particle
  12059. * @param particleSystem the particle system the particle belongs to
  12060. */
  12061. constructor(
  12062. /**
  12063. * The particle system the particle belongs to.
  12064. */
  12065. particleSystem: ParticleSystem);
  12066. private updateCellInfoFromSystem;
  12067. /**
  12068. * Defines how the sprite cell index is updated for the particle
  12069. */
  12070. updateCellIndex(): void;
  12071. /** @hidden */
  12072. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12073. /** @hidden */
  12074. _inheritParticleInfoToSubEmitters(): void;
  12075. /** @hidden */
  12076. _reset(): void;
  12077. /**
  12078. * Copy the properties of particle to another one.
  12079. * @param other the particle to copy the information to.
  12080. */
  12081. copyTo(other: Particle): void;
  12082. }
  12083. }
  12084. declare module BABYLON {
  12085. /**
  12086. * Particle emitter represents a volume emitting particles.
  12087. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12088. */
  12089. export interface IParticleEmitterType {
  12090. /**
  12091. * Called by the particle System when the direction is computed for the created particle.
  12092. * @param worldMatrix is the world matrix of the particle system
  12093. * @param directionToUpdate is the direction vector to update with the result
  12094. * @param particle is the particle we are computed the direction for
  12095. * @param isLocal defines if the direction should be set in local space
  12096. */
  12097. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12098. /**
  12099. * Called by the particle System when the position is computed for the created particle.
  12100. * @param worldMatrix is the world matrix of the particle system
  12101. * @param positionToUpdate is the position vector to update with the result
  12102. * @param particle is the particle we are computed the position for
  12103. * @param isLocal defines if the position should be set in local space
  12104. */
  12105. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12106. /**
  12107. * Clones the current emitter and returns a copy of it
  12108. * @returns the new emitter
  12109. */
  12110. clone(): IParticleEmitterType;
  12111. /**
  12112. * Called by the GPUParticleSystem to setup the update shader
  12113. * @param effect defines the update shader
  12114. */
  12115. applyToShader(effect: Effect): void;
  12116. /**
  12117. * Returns a string to use to update the GPU particles update shader
  12118. * @returns the effect defines string
  12119. */
  12120. getEffectDefines(): string;
  12121. /**
  12122. * Returns a string representing the class name
  12123. * @returns a string containing the class name
  12124. */
  12125. getClassName(): string;
  12126. /**
  12127. * Serializes the particle system to a JSON object.
  12128. * @returns the JSON object
  12129. */
  12130. serialize(): any;
  12131. /**
  12132. * Parse properties from a JSON object
  12133. * @param serializationObject defines the JSON object
  12134. * @param scene defines the hosting scene
  12135. */
  12136. parse(serializationObject: any, scene: Scene): void;
  12137. }
  12138. }
  12139. declare module BABYLON {
  12140. /**
  12141. * Particle emitter emitting particles from the inside of a box.
  12142. * It emits the particles randomly between 2 given directions.
  12143. */
  12144. export class BoxParticleEmitter implements IParticleEmitterType {
  12145. /**
  12146. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12147. */
  12148. direction1: Vector3;
  12149. /**
  12150. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12151. */
  12152. direction2: Vector3;
  12153. /**
  12154. * 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.
  12155. */
  12156. minEmitBox: Vector3;
  12157. /**
  12158. * 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.
  12159. */
  12160. maxEmitBox: Vector3;
  12161. /**
  12162. * Creates a new instance BoxParticleEmitter
  12163. */
  12164. constructor();
  12165. /**
  12166. * Called by the particle System when the direction is computed for the created particle.
  12167. * @param worldMatrix is the world matrix of the particle system
  12168. * @param directionToUpdate is the direction vector to update with the result
  12169. * @param particle is the particle we are computed the direction for
  12170. * @param isLocal defines if the direction should be set in local space
  12171. */
  12172. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12173. /**
  12174. * Called by the particle System when the position is computed for the created particle.
  12175. * @param worldMatrix is the world matrix of the particle system
  12176. * @param positionToUpdate is the position vector to update with the result
  12177. * @param particle is the particle we are computed the position for
  12178. * @param isLocal defines if the position should be set in local space
  12179. */
  12180. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12181. /**
  12182. * Clones the current emitter and returns a copy of it
  12183. * @returns the new emitter
  12184. */
  12185. clone(): BoxParticleEmitter;
  12186. /**
  12187. * Called by the GPUParticleSystem to setup the update shader
  12188. * @param effect defines the update shader
  12189. */
  12190. applyToShader(effect: Effect): void;
  12191. /**
  12192. * Returns a string to use to update the GPU particles update shader
  12193. * @returns a string containng the defines string
  12194. */
  12195. getEffectDefines(): string;
  12196. /**
  12197. * Returns the string "BoxParticleEmitter"
  12198. * @returns a string containing the class name
  12199. */
  12200. getClassName(): string;
  12201. /**
  12202. * Serializes the particle system to a JSON object.
  12203. * @returns the JSON object
  12204. */
  12205. serialize(): any;
  12206. /**
  12207. * Parse properties from a JSON object
  12208. * @param serializationObject defines the JSON object
  12209. */
  12210. parse(serializationObject: any): void;
  12211. }
  12212. }
  12213. declare module BABYLON {
  12214. /**
  12215. * Particle emitter emitting particles from the inside of a cone.
  12216. * It emits the particles alongside the cone volume from the base to the particle.
  12217. * The emission direction might be randomized.
  12218. */
  12219. export class ConeParticleEmitter implements IParticleEmitterType {
  12220. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12221. directionRandomizer: number;
  12222. private _radius;
  12223. private _angle;
  12224. private _height;
  12225. /**
  12226. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12227. */
  12228. radiusRange: number;
  12229. /**
  12230. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12231. */
  12232. heightRange: number;
  12233. /**
  12234. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12235. */
  12236. emitFromSpawnPointOnly: boolean;
  12237. /**
  12238. * Gets or sets the radius of the emission cone
  12239. */
  12240. get radius(): number;
  12241. set radius(value: number);
  12242. /**
  12243. * Gets or sets the angle of the emission cone
  12244. */
  12245. get angle(): number;
  12246. set angle(value: number);
  12247. private _buildHeight;
  12248. /**
  12249. * Creates a new instance ConeParticleEmitter
  12250. * @param radius the radius of the emission cone (1 by default)
  12251. * @param angle the cone base angle (PI by default)
  12252. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12253. */
  12254. constructor(radius?: number, angle?: number,
  12255. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12256. directionRandomizer?: number);
  12257. /**
  12258. * Called by the particle System when the direction is computed for the created particle.
  12259. * @param worldMatrix is the world matrix of the particle system
  12260. * @param directionToUpdate is the direction vector to update with the result
  12261. * @param particle is the particle we are computed the direction for
  12262. * @param isLocal defines if the direction should be set in local space
  12263. */
  12264. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12265. /**
  12266. * Called by the particle System when the position is computed for the created particle.
  12267. * @param worldMatrix is the world matrix of the particle system
  12268. * @param positionToUpdate is the position vector to update with the result
  12269. * @param particle is the particle we are computed the position for
  12270. * @param isLocal defines if the position should be set in local space
  12271. */
  12272. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12273. /**
  12274. * Clones the current emitter and returns a copy of it
  12275. * @returns the new emitter
  12276. */
  12277. clone(): ConeParticleEmitter;
  12278. /**
  12279. * Called by the GPUParticleSystem to setup the update shader
  12280. * @param effect defines the update shader
  12281. */
  12282. applyToShader(effect: Effect): void;
  12283. /**
  12284. * Returns a string to use to update the GPU particles update shader
  12285. * @returns a string containng the defines string
  12286. */
  12287. getEffectDefines(): string;
  12288. /**
  12289. * Returns the string "ConeParticleEmitter"
  12290. * @returns a string containing the class name
  12291. */
  12292. getClassName(): string;
  12293. /**
  12294. * Serializes the particle system to a JSON object.
  12295. * @returns the JSON object
  12296. */
  12297. serialize(): any;
  12298. /**
  12299. * Parse properties from a JSON object
  12300. * @param serializationObject defines the JSON object
  12301. */
  12302. parse(serializationObject: any): void;
  12303. }
  12304. }
  12305. declare module BABYLON {
  12306. /**
  12307. * Particle emitter emitting particles from the inside of a cylinder.
  12308. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12309. */
  12310. export class CylinderParticleEmitter implements IParticleEmitterType {
  12311. /**
  12312. * The radius of the emission cylinder.
  12313. */
  12314. radius: number;
  12315. /**
  12316. * The height of the emission cylinder.
  12317. */
  12318. height: number;
  12319. /**
  12320. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12321. */
  12322. radiusRange: number;
  12323. /**
  12324. * How much to randomize the particle direction [0-1].
  12325. */
  12326. directionRandomizer: number;
  12327. /**
  12328. * Creates a new instance CylinderParticleEmitter
  12329. * @param radius the radius of the emission cylinder (1 by default)
  12330. * @param height the height of the emission cylinder (1 by default)
  12331. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12332. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12333. */
  12334. constructor(
  12335. /**
  12336. * The radius of the emission cylinder.
  12337. */
  12338. radius?: number,
  12339. /**
  12340. * The height of the emission cylinder.
  12341. */
  12342. height?: number,
  12343. /**
  12344. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12345. */
  12346. radiusRange?: number,
  12347. /**
  12348. * How much to randomize the particle direction [0-1].
  12349. */
  12350. directionRandomizer?: number);
  12351. /**
  12352. * Called by the particle System when the direction is computed for the created particle.
  12353. * @param worldMatrix is the world matrix of the particle system
  12354. * @param directionToUpdate is the direction vector to update with the result
  12355. * @param particle is the particle we are computed the direction for
  12356. * @param isLocal defines if the direction should be set in local space
  12357. */
  12358. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12359. /**
  12360. * Called by the particle System when the position is computed for the created particle.
  12361. * @param worldMatrix is the world matrix of the particle system
  12362. * @param positionToUpdate is the position vector to update with the result
  12363. * @param particle is the particle we are computed the position for
  12364. * @param isLocal defines if the position should be set in local space
  12365. */
  12366. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12367. /**
  12368. * Clones the current emitter and returns a copy of it
  12369. * @returns the new emitter
  12370. */
  12371. clone(): CylinderParticleEmitter;
  12372. /**
  12373. * Called by the GPUParticleSystem to setup the update shader
  12374. * @param effect defines the update shader
  12375. */
  12376. applyToShader(effect: Effect): void;
  12377. /**
  12378. * Returns a string to use to update the GPU particles update shader
  12379. * @returns a string containng the defines string
  12380. */
  12381. getEffectDefines(): string;
  12382. /**
  12383. * Returns the string "CylinderParticleEmitter"
  12384. * @returns a string containing the class name
  12385. */
  12386. getClassName(): string;
  12387. /**
  12388. * Serializes the particle system to a JSON object.
  12389. * @returns the JSON object
  12390. */
  12391. serialize(): any;
  12392. /**
  12393. * Parse properties from a JSON object
  12394. * @param serializationObject defines the JSON object
  12395. */
  12396. parse(serializationObject: any): void;
  12397. }
  12398. /**
  12399. * Particle emitter emitting particles from the inside of a cylinder.
  12400. * It emits the particles randomly between two vectors.
  12401. */
  12402. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12403. /**
  12404. * The min limit of the emission direction.
  12405. */
  12406. direction1: Vector3;
  12407. /**
  12408. * The max limit of the emission direction.
  12409. */
  12410. direction2: Vector3;
  12411. /**
  12412. * Creates a new instance CylinderDirectedParticleEmitter
  12413. * @param radius the radius of the emission cylinder (1 by default)
  12414. * @param height the height of the emission cylinder (1 by default)
  12415. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12416. * @param direction1 the min limit of the emission direction (up vector by default)
  12417. * @param direction2 the max limit of the emission direction (up vector by default)
  12418. */
  12419. constructor(radius?: number, height?: number, radiusRange?: number,
  12420. /**
  12421. * The min limit of the emission direction.
  12422. */
  12423. direction1?: Vector3,
  12424. /**
  12425. * The max limit of the emission direction.
  12426. */
  12427. direction2?: Vector3);
  12428. /**
  12429. * Called by the particle System when the direction is computed for the created particle.
  12430. * @param worldMatrix is the world matrix of the particle system
  12431. * @param directionToUpdate is the direction vector to update with the result
  12432. * @param particle is the particle we are computed the direction for
  12433. */
  12434. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12435. /**
  12436. * Clones the current emitter and returns a copy of it
  12437. * @returns the new emitter
  12438. */
  12439. clone(): CylinderDirectedParticleEmitter;
  12440. /**
  12441. * Called by the GPUParticleSystem to setup the update shader
  12442. * @param effect defines the update shader
  12443. */
  12444. applyToShader(effect: Effect): void;
  12445. /**
  12446. * Returns a string to use to update the GPU particles update shader
  12447. * @returns a string containng the defines string
  12448. */
  12449. getEffectDefines(): string;
  12450. /**
  12451. * Returns the string "CylinderDirectedParticleEmitter"
  12452. * @returns a string containing the class name
  12453. */
  12454. getClassName(): string;
  12455. /**
  12456. * Serializes the particle system to a JSON object.
  12457. * @returns the JSON object
  12458. */
  12459. serialize(): any;
  12460. /**
  12461. * Parse properties from a JSON object
  12462. * @param serializationObject defines the JSON object
  12463. */
  12464. parse(serializationObject: any): void;
  12465. }
  12466. }
  12467. declare module BABYLON {
  12468. /**
  12469. * Particle emitter emitting particles from the inside of a hemisphere.
  12470. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12471. */
  12472. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12473. /**
  12474. * The radius of the emission hemisphere.
  12475. */
  12476. radius: number;
  12477. /**
  12478. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12479. */
  12480. radiusRange: number;
  12481. /**
  12482. * How much to randomize the particle direction [0-1].
  12483. */
  12484. directionRandomizer: number;
  12485. /**
  12486. * Creates a new instance HemisphericParticleEmitter
  12487. * @param radius the radius of the emission hemisphere (1 by default)
  12488. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12489. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12490. */
  12491. constructor(
  12492. /**
  12493. * The radius of the emission hemisphere.
  12494. */
  12495. radius?: number,
  12496. /**
  12497. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12498. */
  12499. radiusRange?: number,
  12500. /**
  12501. * How much to randomize the particle direction [0-1].
  12502. */
  12503. directionRandomizer?: number);
  12504. /**
  12505. * Called by the particle System when the direction is computed for the created particle.
  12506. * @param worldMatrix is the world matrix of the particle system
  12507. * @param directionToUpdate is the direction vector to update with the result
  12508. * @param particle is the particle we are computed the direction for
  12509. * @param isLocal defines if the direction should be set in local space
  12510. */
  12511. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12512. /**
  12513. * Called by the particle System when the position is computed for the created particle.
  12514. * @param worldMatrix is the world matrix of the particle system
  12515. * @param positionToUpdate is the position vector to update with the result
  12516. * @param particle is the particle we are computed the position for
  12517. * @param isLocal defines if the position should be set in local space
  12518. */
  12519. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12520. /**
  12521. * Clones the current emitter and returns a copy of it
  12522. * @returns the new emitter
  12523. */
  12524. clone(): HemisphericParticleEmitter;
  12525. /**
  12526. * Called by the GPUParticleSystem to setup the update shader
  12527. * @param effect defines the update shader
  12528. */
  12529. applyToShader(effect: Effect): void;
  12530. /**
  12531. * Returns a string to use to update the GPU particles update shader
  12532. * @returns a string containng the defines string
  12533. */
  12534. getEffectDefines(): string;
  12535. /**
  12536. * Returns the string "HemisphericParticleEmitter"
  12537. * @returns a string containing the class name
  12538. */
  12539. getClassName(): string;
  12540. /**
  12541. * Serializes the particle system to a JSON object.
  12542. * @returns the JSON object
  12543. */
  12544. serialize(): any;
  12545. /**
  12546. * Parse properties from a JSON object
  12547. * @param serializationObject defines the JSON object
  12548. */
  12549. parse(serializationObject: any): void;
  12550. }
  12551. }
  12552. declare module BABYLON {
  12553. /**
  12554. * Particle emitter emitting particles from a point.
  12555. * It emits the particles randomly between 2 given directions.
  12556. */
  12557. export class PointParticleEmitter implements IParticleEmitterType {
  12558. /**
  12559. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12560. */
  12561. direction1: Vector3;
  12562. /**
  12563. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12564. */
  12565. direction2: Vector3;
  12566. /**
  12567. * Creates a new instance PointParticleEmitter
  12568. */
  12569. constructor();
  12570. /**
  12571. * Called by the particle System when the direction is computed for the created particle.
  12572. * @param worldMatrix is the world matrix of the particle system
  12573. * @param directionToUpdate is the direction vector to update with the result
  12574. * @param particle is the particle we are computed the direction for
  12575. * @param isLocal defines if the direction should be set in local space
  12576. */
  12577. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12578. /**
  12579. * Called by the particle System when the position is computed for the created particle.
  12580. * @param worldMatrix is the world matrix of the particle system
  12581. * @param positionToUpdate is the position vector to update with the result
  12582. * @param particle is the particle we are computed the position for
  12583. * @param isLocal defines if the position should be set in local space
  12584. */
  12585. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12586. /**
  12587. * Clones the current emitter and returns a copy of it
  12588. * @returns the new emitter
  12589. */
  12590. clone(): PointParticleEmitter;
  12591. /**
  12592. * Called by the GPUParticleSystem to setup the update shader
  12593. * @param effect defines the update shader
  12594. */
  12595. applyToShader(effect: Effect): void;
  12596. /**
  12597. * Returns a string to use to update the GPU particles update shader
  12598. * @returns a string containng the defines string
  12599. */
  12600. getEffectDefines(): string;
  12601. /**
  12602. * Returns the string "PointParticleEmitter"
  12603. * @returns a string containing the class name
  12604. */
  12605. getClassName(): string;
  12606. /**
  12607. * Serializes the particle system to a JSON object.
  12608. * @returns the JSON object
  12609. */
  12610. serialize(): any;
  12611. /**
  12612. * Parse properties from a JSON object
  12613. * @param serializationObject defines the JSON object
  12614. */
  12615. parse(serializationObject: any): void;
  12616. }
  12617. }
  12618. declare module BABYLON {
  12619. /**
  12620. * Particle emitter emitting particles from the inside of a sphere.
  12621. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12622. */
  12623. export class SphereParticleEmitter implements IParticleEmitterType {
  12624. /**
  12625. * The radius of the emission sphere.
  12626. */
  12627. radius: number;
  12628. /**
  12629. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12630. */
  12631. radiusRange: number;
  12632. /**
  12633. * How much to randomize the particle direction [0-1].
  12634. */
  12635. directionRandomizer: number;
  12636. /**
  12637. * Creates a new instance SphereParticleEmitter
  12638. * @param radius the radius of the emission sphere (1 by default)
  12639. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12640. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12641. */
  12642. constructor(
  12643. /**
  12644. * The radius of the emission sphere.
  12645. */
  12646. radius?: number,
  12647. /**
  12648. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12649. */
  12650. radiusRange?: number,
  12651. /**
  12652. * How much to randomize the particle direction [0-1].
  12653. */
  12654. directionRandomizer?: number);
  12655. /**
  12656. * Called by the particle System when the direction is computed for the created particle.
  12657. * @param worldMatrix is the world matrix of the particle system
  12658. * @param directionToUpdate is the direction vector to update with the result
  12659. * @param particle is the particle we are computed the direction for
  12660. * @param isLocal defines if the direction should be set in local space
  12661. */
  12662. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12663. /**
  12664. * Called by the particle System when the position is computed for the created particle.
  12665. * @param worldMatrix is the world matrix of the particle system
  12666. * @param positionToUpdate is the position vector to update with the result
  12667. * @param particle is the particle we are computed the position for
  12668. * @param isLocal defines if the position should be set in local space
  12669. */
  12670. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12671. /**
  12672. * Clones the current emitter and returns a copy of it
  12673. * @returns the new emitter
  12674. */
  12675. clone(): SphereParticleEmitter;
  12676. /**
  12677. * Called by the GPUParticleSystem to setup the update shader
  12678. * @param effect defines the update shader
  12679. */
  12680. applyToShader(effect: Effect): void;
  12681. /**
  12682. * Returns a string to use to update the GPU particles update shader
  12683. * @returns a string containng the defines string
  12684. */
  12685. getEffectDefines(): string;
  12686. /**
  12687. * Returns the string "SphereParticleEmitter"
  12688. * @returns a string containing the class name
  12689. */
  12690. getClassName(): string;
  12691. /**
  12692. * Serializes the particle system to a JSON object.
  12693. * @returns the JSON object
  12694. */
  12695. serialize(): any;
  12696. /**
  12697. * Parse properties from a JSON object
  12698. * @param serializationObject defines the JSON object
  12699. */
  12700. parse(serializationObject: any): void;
  12701. }
  12702. /**
  12703. * Particle emitter emitting particles from the inside of a sphere.
  12704. * It emits the particles randomly between two vectors.
  12705. */
  12706. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12707. /**
  12708. * The min limit of the emission direction.
  12709. */
  12710. direction1: Vector3;
  12711. /**
  12712. * The max limit of the emission direction.
  12713. */
  12714. direction2: Vector3;
  12715. /**
  12716. * Creates a new instance SphereDirectedParticleEmitter
  12717. * @param radius the radius of the emission sphere (1 by default)
  12718. * @param direction1 the min limit of the emission direction (up vector by default)
  12719. * @param direction2 the max limit of the emission direction (up vector by default)
  12720. */
  12721. constructor(radius?: number,
  12722. /**
  12723. * The min limit of the emission direction.
  12724. */
  12725. direction1?: Vector3,
  12726. /**
  12727. * The max limit of the emission direction.
  12728. */
  12729. direction2?: Vector3);
  12730. /**
  12731. * Called by the particle System when the direction is computed for the created particle.
  12732. * @param worldMatrix is the world matrix of the particle system
  12733. * @param directionToUpdate is the direction vector to update with the result
  12734. * @param particle is the particle we are computed the direction for
  12735. */
  12736. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12737. /**
  12738. * Clones the current emitter and returns a copy of it
  12739. * @returns the new emitter
  12740. */
  12741. clone(): SphereDirectedParticleEmitter;
  12742. /**
  12743. * Called by the GPUParticleSystem to setup the update shader
  12744. * @param effect defines the update shader
  12745. */
  12746. applyToShader(effect: Effect): void;
  12747. /**
  12748. * Returns a string to use to update the GPU particles update shader
  12749. * @returns a string containng the defines string
  12750. */
  12751. getEffectDefines(): string;
  12752. /**
  12753. * Returns the string "SphereDirectedParticleEmitter"
  12754. * @returns a string containing the class name
  12755. */
  12756. getClassName(): string;
  12757. /**
  12758. * Serializes the particle system to a JSON object.
  12759. * @returns the JSON object
  12760. */
  12761. serialize(): any;
  12762. /**
  12763. * Parse properties from a JSON object
  12764. * @param serializationObject defines the JSON object
  12765. */
  12766. parse(serializationObject: any): void;
  12767. }
  12768. }
  12769. declare module BABYLON {
  12770. /**
  12771. * Particle emitter emitting particles from a custom list of positions.
  12772. */
  12773. export class CustomParticleEmitter implements IParticleEmitterType {
  12774. /**
  12775. * Gets or sets the position generator that will create the inital position of each particle.
  12776. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12777. */
  12778. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12779. /**
  12780. * Gets or sets the destination generator that will create the final destination of each particle.
  12781. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12782. */
  12783. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12784. /**
  12785. * Creates a new instance CustomParticleEmitter
  12786. */
  12787. constructor();
  12788. /**
  12789. * Called by the particle System when the direction is computed for the created particle.
  12790. * @param worldMatrix is the world matrix of the particle system
  12791. * @param directionToUpdate is the direction vector to update with the result
  12792. * @param particle is the particle we are computed the direction for
  12793. * @param isLocal defines if the direction should be set in local space
  12794. */
  12795. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12796. /**
  12797. * Called by the particle System when the position is computed for the created particle.
  12798. * @param worldMatrix is the world matrix of the particle system
  12799. * @param positionToUpdate is the position vector to update with the result
  12800. * @param particle is the particle we are computed the position for
  12801. * @param isLocal defines if the position should be set in local space
  12802. */
  12803. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12804. /**
  12805. * Clones the current emitter and returns a copy of it
  12806. * @returns the new emitter
  12807. */
  12808. clone(): CustomParticleEmitter;
  12809. /**
  12810. * Called by the GPUParticleSystem to setup the update shader
  12811. * @param effect defines the update shader
  12812. */
  12813. applyToShader(effect: Effect): void;
  12814. /**
  12815. * Returns a string to use to update the GPU particles update shader
  12816. * @returns a string containng the defines string
  12817. */
  12818. getEffectDefines(): string;
  12819. /**
  12820. * Returns the string "PointParticleEmitter"
  12821. * @returns a string containing the class name
  12822. */
  12823. getClassName(): string;
  12824. /**
  12825. * Serializes the particle system to a JSON object.
  12826. * @returns the JSON object
  12827. */
  12828. serialize(): any;
  12829. /**
  12830. * Parse properties from a JSON object
  12831. * @param serializationObject defines the JSON object
  12832. */
  12833. parse(serializationObject: any): void;
  12834. }
  12835. }
  12836. declare module BABYLON {
  12837. /**
  12838. * Particle emitter emitting particles from the inside of a box.
  12839. * It emits the particles randomly between 2 given directions.
  12840. */
  12841. export class MeshParticleEmitter implements IParticleEmitterType {
  12842. /** Defines the mesh to use as source */
  12843. mesh?: AbstractMesh | undefined;
  12844. private _indices;
  12845. private _positions;
  12846. private _normals;
  12847. private _storedNormal;
  12848. /**
  12849. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12850. */
  12851. direction1: Vector3;
  12852. /**
  12853. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12854. */
  12855. direction2: Vector3;
  12856. /**
  12857. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12858. */
  12859. useMeshNormalsForDirection: boolean;
  12860. /**
  12861. * Creates a new instance MeshParticleEmitter
  12862. * @param mesh defines the mesh to use as source
  12863. */
  12864. constructor(
  12865. /** Defines the mesh to use as source */
  12866. mesh?: AbstractMesh | undefined);
  12867. /**
  12868. * Called by the particle System when the direction is computed for the created particle.
  12869. * @param worldMatrix is the world matrix of the particle system
  12870. * @param directionToUpdate is the direction vector to update with the result
  12871. * @param particle is the particle we are computed the direction for
  12872. * @param isLocal defines if the direction should be set in local space
  12873. */
  12874. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12875. /**
  12876. * Called by the particle System when the position is computed for the created particle.
  12877. * @param worldMatrix is the world matrix of the particle system
  12878. * @param positionToUpdate is the position vector to update with the result
  12879. * @param particle is the particle we are computed the position for
  12880. * @param isLocal defines if the position should be set in local space
  12881. */
  12882. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12883. /**
  12884. * Clones the current emitter and returns a copy of it
  12885. * @returns the new emitter
  12886. */
  12887. clone(): MeshParticleEmitter;
  12888. /**
  12889. * Called by the GPUParticleSystem to setup the update shader
  12890. * @param effect defines the update shader
  12891. */
  12892. applyToShader(effect: Effect): void;
  12893. /**
  12894. * Returns a string to use to update the GPU particles update shader
  12895. * @returns a string containng the defines string
  12896. */
  12897. getEffectDefines(): string;
  12898. /**
  12899. * Returns the string "BoxParticleEmitter"
  12900. * @returns a string containing the class name
  12901. */
  12902. getClassName(): string;
  12903. /**
  12904. * Serializes the particle system to a JSON object.
  12905. * @returns the JSON object
  12906. */
  12907. serialize(): any;
  12908. /**
  12909. * Parse properties from a JSON object
  12910. * @param serializationObject defines the JSON object
  12911. * @param scene defines the hosting scene
  12912. */
  12913. parse(serializationObject: any, scene: Scene): void;
  12914. }
  12915. }
  12916. declare module BABYLON {
  12917. /**
  12918. * Interface representing a particle system in Babylon.js.
  12919. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12920. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12921. */
  12922. export interface IParticleSystem {
  12923. /**
  12924. * List of animations used by the particle system.
  12925. */
  12926. animations: Animation[];
  12927. /**
  12928. * The id of the Particle system.
  12929. */
  12930. id: string;
  12931. /**
  12932. * The name of the Particle system.
  12933. */
  12934. name: string;
  12935. /**
  12936. * The emitter represents the Mesh or position we are attaching the particle system to.
  12937. */
  12938. emitter: Nullable<AbstractMesh | Vector3>;
  12939. /**
  12940. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12941. */
  12942. isBillboardBased: boolean;
  12943. /**
  12944. * The rendering group used by the Particle system to chose when to render.
  12945. */
  12946. renderingGroupId: number;
  12947. /**
  12948. * The layer mask we are rendering the particles through.
  12949. */
  12950. layerMask: number;
  12951. /**
  12952. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12953. */
  12954. updateSpeed: number;
  12955. /**
  12956. * The amount of time the particle system is running (depends of the overall update speed).
  12957. */
  12958. targetStopDuration: number;
  12959. /**
  12960. * The texture used to render each particle. (this can be a spritesheet)
  12961. */
  12962. particleTexture: Nullable<Texture>;
  12963. /**
  12964. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12965. */
  12966. blendMode: number;
  12967. /**
  12968. * Minimum life time of emitting particles.
  12969. */
  12970. minLifeTime: number;
  12971. /**
  12972. * Maximum life time of emitting particles.
  12973. */
  12974. maxLifeTime: number;
  12975. /**
  12976. * Minimum Size of emitting particles.
  12977. */
  12978. minSize: number;
  12979. /**
  12980. * Maximum Size of emitting particles.
  12981. */
  12982. maxSize: number;
  12983. /**
  12984. * Minimum scale of emitting particles on X axis.
  12985. */
  12986. minScaleX: number;
  12987. /**
  12988. * Maximum scale of emitting particles on X axis.
  12989. */
  12990. maxScaleX: number;
  12991. /**
  12992. * Minimum scale of emitting particles on Y axis.
  12993. */
  12994. minScaleY: number;
  12995. /**
  12996. * Maximum scale of emitting particles on Y axis.
  12997. */
  12998. maxScaleY: number;
  12999. /**
  13000. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13001. */
  13002. color1: Color4;
  13003. /**
  13004. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13005. */
  13006. color2: Color4;
  13007. /**
  13008. * Color the particle will have at the end of its lifetime.
  13009. */
  13010. colorDead: Color4;
  13011. /**
  13012. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13013. */
  13014. emitRate: number;
  13015. /**
  13016. * You can use gravity if you want to give an orientation to your particles.
  13017. */
  13018. gravity: Vector3;
  13019. /**
  13020. * Minimum power of emitting particles.
  13021. */
  13022. minEmitPower: number;
  13023. /**
  13024. * Maximum power of emitting particles.
  13025. */
  13026. maxEmitPower: number;
  13027. /**
  13028. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13029. */
  13030. minAngularSpeed: number;
  13031. /**
  13032. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13033. */
  13034. maxAngularSpeed: number;
  13035. /**
  13036. * Gets or sets the minimal initial rotation in radians.
  13037. */
  13038. minInitialRotation: number;
  13039. /**
  13040. * Gets or sets the maximal initial rotation in radians.
  13041. */
  13042. maxInitialRotation: number;
  13043. /**
  13044. * The particle emitter type defines the emitter used by the particle system.
  13045. * It can be for example box, sphere, or cone...
  13046. */
  13047. particleEmitterType: Nullable<IParticleEmitterType>;
  13048. /**
  13049. * Defines the delay in milliseconds before starting the system (0 by default)
  13050. */
  13051. startDelay: number;
  13052. /**
  13053. * 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
  13054. */
  13055. preWarmCycles: number;
  13056. /**
  13057. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13058. */
  13059. preWarmStepOffset: number;
  13060. /**
  13061. * 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)
  13062. */
  13063. spriteCellChangeSpeed: number;
  13064. /**
  13065. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13066. */
  13067. startSpriteCellID: number;
  13068. /**
  13069. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13070. */
  13071. endSpriteCellID: number;
  13072. /**
  13073. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13074. */
  13075. spriteCellWidth: number;
  13076. /**
  13077. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13078. */
  13079. spriteCellHeight: number;
  13080. /**
  13081. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13082. */
  13083. spriteRandomStartCell: boolean;
  13084. /**
  13085. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13086. */
  13087. isAnimationSheetEnabled: boolean;
  13088. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13089. translationPivot: Vector2;
  13090. /**
  13091. * Gets or sets a texture used to add random noise to particle positions
  13092. */
  13093. noiseTexture: Nullable<BaseTexture>;
  13094. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13095. noiseStrength: Vector3;
  13096. /**
  13097. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13098. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13099. */
  13100. billboardMode: number;
  13101. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13102. limitVelocityDamping: number;
  13103. /**
  13104. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13105. */
  13106. beginAnimationOnStart: boolean;
  13107. /**
  13108. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13109. */
  13110. beginAnimationFrom: number;
  13111. /**
  13112. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13113. */
  13114. beginAnimationTo: number;
  13115. /**
  13116. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13117. */
  13118. beginAnimationLoop: boolean;
  13119. /**
  13120. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13121. */
  13122. disposeOnStop: boolean;
  13123. /**
  13124. * Specifies if the particles are updated in emitter local space or world space
  13125. */
  13126. isLocal: boolean;
  13127. /**
  13128. * Gets the maximum number of particles active at the same time.
  13129. * @returns The max number of active particles.
  13130. */
  13131. getCapacity(): number;
  13132. /**
  13133. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13134. * @returns True if it has been started, otherwise false.
  13135. */
  13136. isStarted(): boolean;
  13137. /**
  13138. * Animates the particle system for this frame.
  13139. */
  13140. animate(): void;
  13141. /**
  13142. * Renders the particle system in its current state.
  13143. * @returns the current number of particles
  13144. */
  13145. render(): number;
  13146. /**
  13147. * Dispose the particle system and frees its associated resources.
  13148. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13149. */
  13150. dispose(disposeTexture?: boolean): void;
  13151. /**
  13152. * Clones the particle system.
  13153. * @param name The name of the cloned object
  13154. * @param newEmitter The new emitter to use
  13155. * @returns the cloned particle system
  13156. */
  13157. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13158. /**
  13159. * Serializes the particle system to a JSON object.
  13160. * @returns the JSON object
  13161. */
  13162. serialize(): any;
  13163. /**
  13164. * Rebuild the particle system
  13165. */
  13166. rebuild(): void;
  13167. /**
  13168. * Starts the particle system and begins to emit
  13169. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13170. */
  13171. start(delay?: number): void;
  13172. /**
  13173. * Stops the particle system.
  13174. */
  13175. stop(): void;
  13176. /**
  13177. * Remove all active particles
  13178. */
  13179. reset(): void;
  13180. /**
  13181. * Is this system ready to be used/rendered
  13182. * @return true if the system is ready
  13183. */
  13184. isReady(): boolean;
  13185. /**
  13186. * Returns the string "ParticleSystem"
  13187. * @returns a string containing the class name
  13188. */
  13189. getClassName(): string;
  13190. /**
  13191. * Adds a new color gradient
  13192. * @param gradient defines the gradient to use (between 0 and 1)
  13193. * @param color1 defines the color to affect to the specified gradient
  13194. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13195. * @returns the current particle system
  13196. */
  13197. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13198. /**
  13199. * Remove a specific color gradient
  13200. * @param gradient defines the gradient to remove
  13201. * @returns the current particle system
  13202. */
  13203. removeColorGradient(gradient: number): IParticleSystem;
  13204. /**
  13205. * Adds a new size gradient
  13206. * @param gradient defines the gradient to use (between 0 and 1)
  13207. * @param factor defines the size factor to affect to the specified gradient
  13208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13209. * @returns the current particle system
  13210. */
  13211. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13212. /**
  13213. * Remove a specific size gradient
  13214. * @param gradient defines the gradient to remove
  13215. * @returns the current particle system
  13216. */
  13217. removeSizeGradient(gradient: number): IParticleSystem;
  13218. /**
  13219. * Gets the current list of color gradients.
  13220. * You must use addColorGradient and removeColorGradient to udpate this list
  13221. * @returns the list of color gradients
  13222. */
  13223. getColorGradients(): Nullable<Array<ColorGradient>>;
  13224. /**
  13225. * Gets the current list of size gradients.
  13226. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13227. * @returns the list of size gradients
  13228. */
  13229. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13230. /**
  13231. * Gets the current list of angular speed gradients.
  13232. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13233. * @returns the list of angular speed gradients
  13234. */
  13235. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13236. /**
  13237. * Adds a new angular speed gradient
  13238. * @param gradient defines the gradient to use (between 0 and 1)
  13239. * @param factor defines the angular speed to affect to the specified gradient
  13240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13241. * @returns the current particle system
  13242. */
  13243. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13244. /**
  13245. * Remove a specific angular speed gradient
  13246. * @param gradient defines the gradient to remove
  13247. * @returns the current particle system
  13248. */
  13249. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13250. /**
  13251. * Gets the current list of velocity gradients.
  13252. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13253. * @returns the list of velocity gradients
  13254. */
  13255. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13256. /**
  13257. * Adds a new velocity gradient
  13258. * @param gradient defines the gradient to use (between 0 and 1)
  13259. * @param factor defines the velocity to affect to the specified gradient
  13260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13261. * @returns the current particle system
  13262. */
  13263. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13264. /**
  13265. * Remove a specific velocity gradient
  13266. * @param gradient defines the gradient to remove
  13267. * @returns the current particle system
  13268. */
  13269. removeVelocityGradient(gradient: number): IParticleSystem;
  13270. /**
  13271. * Gets the current list of limit velocity gradients.
  13272. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13273. * @returns the list of limit velocity gradients
  13274. */
  13275. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13276. /**
  13277. * Adds a new limit velocity gradient
  13278. * @param gradient defines the gradient to use (between 0 and 1)
  13279. * @param factor defines the limit velocity to affect to the specified gradient
  13280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13281. * @returns the current particle system
  13282. */
  13283. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13284. /**
  13285. * Remove a specific limit velocity gradient
  13286. * @param gradient defines the gradient to remove
  13287. * @returns the current particle system
  13288. */
  13289. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13290. /**
  13291. * Adds a new drag gradient
  13292. * @param gradient defines the gradient to use (between 0 and 1)
  13293. * @param factor defines the drag to affect to the specified gradient
  13294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13295. * @returns the current particle system
  13296. */
  13297. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13298. /**
  13299. * Remove a specific drag gradient
  13300. * @param gradient defines the gradient to remove
  13301. * @returns the current particle system
  13302. */
  13303. removeDragGradient(gradient: number): IParticleSystem;
  13304. /**
  13305. * Gets the current list of drag gradients.
  13306. * You must use addDragGradient and removeDragGradient to udpate this list
  13307. * @returns the list of drag gradients
  13308. */
  13309. getDragGradients(): Nullable<Array<FactorGradient>>;
  13310. /**
  13311. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13312. * @param gradient defines the gradient to use (between 0 and 1)
  13313. * @param factor defines the emit rate to affect to the specified gradient
  13314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13315. * @returns the current particle system
  13316. */
  13317. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13318. /**
  13319. * Remove a specific emit rate gradient
  13320. * @param gradient defines the gradient to remove
  13321. * @returns the current particle system
  13322. */
  13323. removeEmitRateGradient(gradient: number): IParticleSystem;
  13324. /**
  13325. * Gets the current list of emit rate gradients.
  13326. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13327. * @returns the list of emit rate gradients
  13328. */
  13329. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13330. /**
  13331. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13332. * @param gradient defines the gradient to use (between 0 and 1)
  13333. * @param factor defines the start size to affect to the specified gradient
  13334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13335. * @returns the current particle system
  13336. */
  13337. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13338. /**
  13339. * Remove a specific start size gradient
  13340. * @param gradient defines the gradient to remove
  13341. * @returns the current particle system
  13342. */
  13343. removeStartSizeGradient(gradient: number): IParticleSystem;
  13344. /**
  13345. * Gets the current list of start size gradients.
  13346. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13347. * @returns the list of start size gradients
  13348. */
  13349. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13350. /**
  13351. * Adds a new life time gradient
  13352. * @param gradient defines the gradient to use (between 0 and 1)
  13353. * @param factor defines the life time factor to affect to the specified gradient
  13354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13355. * @returns the current particle system
  13356. */
  13357. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13358. /**
  13359. * Remove a specific life time gradient
  13360. * @param gradient defines the gradient to remove
  13361. * @returns the current particle system
  13362. */
  13363. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13364. /**
  13365. * Gets the current list of life time gradients.
  13366. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13367. * @returns the list of life time gradients
  13368. */
  13369. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13370. /**
  13371. * Gets the current list of color gradients.
  13372. * You must use addColorGradient and removeColorGradient to udpate this list
  13373. * @returns the list of color gradients
  13374. */
  13375. getColorGradients(): Nullable<Array<ColorGradient>>;
  13376. /**
  13377. * Adds a new ramp gradient used to remap particle colors
  13378. * @param gradient defines the gradient to use (between 0 and 1)
  13379. * @param color defines the color to affect to the specified gradient
  13380. * @returns the current particle system
  13381. */
  13382. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13383. /**
  13384. * Gets the current list of ramp gradients.
  13385. * You must use addRampGradient and removeRampGradient to udpate this list
  13386. * @returns the list of ramp gradients
  13387. */
  13388. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13389. /** Gets or sets a boolean indicating that ramp gradients must be used
  13390. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13391. */
  13392. useRampGradients: boolean;
  13393. /**
  13394. * Adds a new color remap gradient
  13395. * @param gradient defines the gradient to use (between 0 and 1)
  13396. * @param min defines the color remap minimal range
  13397. * @param max defines the color remap maximal range
  13398. * @returns the current particle system
  13399. */
  13400. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13401. /**
  13402. * Gets the current list of color remap gradients.
  13403. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13404. * @returns the list of color remap gradients
  13405. */
  13406. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13407. /**
  13408. * Adds a new alpha remap gradient
  13409. * @param gradient defines the gradient to use (between 0 and 1)
  13410. * @param min defines the alpha remap minimal range
  13411. * @param max defines the alpha remap maximal range
  13412. * @returns the current particle system
  13413. */
  13414. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13415. /**
  13416. * Gets the current list of alpha remap gradients.
  13417. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13418. * @returns the list of alpha remap gradients
  13419. */
  13420. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13421. /**
  13422. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13423. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13424. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13425. * @returns the emitter
  13426. */
  13427. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13428. /**
  13429. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13430. * @param radius The radius of the hemisphere to emit from
  13431. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13432. * @returns the emitter
  13433. */
  13434. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13435. /**
  13436. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13437. * @param radius The radius of the sphere to emit from
  13438. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13439. * @returns the emitter
  13440. */
  13441. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13442. /**
  13443. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13444. * @param radius The radius of the sphere to emit from
  13445. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13446. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13447. * @returns the emitter
  13448. */
  13449. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13450. /**
  13451. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13452. * @param radius The radius of the emission cylinder
  13453. * @param height The height of the emission cylinder
  13454. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13455. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13456. * @returns the emitter
  13457. */
  13458. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13459. /**
  13460. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13461. * @param radius The radius of the cylinder to emit from
  13462. * @param height The height of the emission cylinder
  13463. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13464. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13465. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13466. * @returns the emitter
  13467. */
  13468. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13469. /**
  13470. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13471. * @param radius The radius of the cone to emit from
  13472. * @param angle The base angle of the cone
  13473. * @returns the emitter
  13474. */
  13475. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13476. /**
  13477. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13478. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13479. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13480. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13481. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13482. * @returns the emitter
  13483. */
  13484. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13485. /**
  13486. * Get hosting scene
  13487. * @returns the scene
  13488. */
  13489. getScene(): Scene;
  13490. }
  13491. }
  13492. declare module BABYLON {
  13493. /**
  13494. * 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.
  13495. * @see https://doc.babylonjs.com/how_to/transformnode
  13496. */
  13497. export class TransformNode extends Node {
  13498. /**
  13499. * Object will not rotate to face the camera
  13500. */
  13501. static BILLBOARDMODE_NONE: number;
  13502. /**
  13503. * Object will rotate to face the camera but only on the x axis
  13504. */
  13505. static BILLBOARDMODE_X: number;
  13506. /**
  13507. * Object will rotate to face the camera but only on the y axis
  13508. */
  13509. static BILLBOARDMODE_Y: number;
  13510. /**
  13511. * Object will rotate to face the camera but only on the z axis
  13512. */
  13513. static BILLBOARDMODE_Z: number;
  13514. /**
  13515. * Object will rotate to face the camera
  13516. */
  13517. static BILLBOARDMODE_ALL: number;
  13518. /**
  13519. * Object will rotate to face the camera's position instead of orientation
  13520. */
  13521. static BILLBOARDMODE_USE_POSITION: number;
  13522. private _forward;
  13523. private _forwardInverted;
  13524. private _up;
  13525. private _right;
  13526. private _rightInverted;
  13527. private _position;
  13528. private _rotation;
  13529. private _rotationQuaternion;
  13530. protected _scaling: Vector3;
  13531. protected _isDirty: boolean;
  13532. private _transformToBoneReferal;
  13533. private _isAbsoluteSynced;
  13534. private _billboardMode;
  13535. /**
  13536. * Gets or sets the billboard mode. Default is 0.
  13537. *
  13538. * | Value | Type | Description |
  13539. * | --- | --- | --- |
  13540. * | 0 | BILLBOARDMODE_NONE | |
  13541. * | 1 | BILLBOARDMODE_X | |
  13542. * | 2 | BILLBOARDMODE_Y | |
  13543. * | 4 | BILLBOARDMODE_Z | |
  13544. * | 7 | BILLBOARDMODE_ALL | |
  13545. *
  13546. */
  13547. get billboardMode(): number;
  13548. set billboardMode(value: number);
  13549. private _preserveParentRotationForBillboard;
  13550. /**
  13551. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13552. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13553. */
  13554. get preserveParentRotationForBillboard(): boolean;
  13555. set preserveParentRotationForBillboard(value: boolean);
  13556. /**
  13557. * 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
  13558. */
  13559. scalingDeterminant: number;
  13560. private _infiniteDistance;
  13561. /**
  13562. * Gets or sets the distance of the object to max, often used by skybox
  13563. */
  13564. get infiniteDistance(): boolean;
  13565. set infiniteDistance(value: boolean);
  13566. /**
  13567. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13568. * By default the system will update normals to compensate
  13569. */
  13570. ignoreNonUniformScaling: boolean;
  13571. /**
  13572. * 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
  13573. */
  13574. reIntegrateRotationIntoRotationQuaternion: boolean;
  13575. /** @hidden */
  13576. _poseMatrix: Nullable<Matrix>;
  13577. /** @hidden */
  13578. _localMatrix: Matrix;
  13579. private _usePivotMatrix;
  13580. private _absolutePosition;
  13581. private _absoluteScaling;
  13582. private _absoluteRotationQuaternion;
  13583. private _pivotMatrix;
  13584. private _pivotMatrixInverse;
  13585. protected _postMultiplyPivotMatrix: boolean;
  13586. protected _isWorldMatrixFrozen: boolean;
  13587. /** @hidden */
  13588. _indexInSceneTransformNodesArray: number;
  13589. /**
  13590. * An event triggered after the world matrix is updated
  13591. */
  13592. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13593. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13594. /**
  13595. * Gets a string identifying the name of the class
  13596. * @returns "TransformNode" string
  13597. */
  13598. getClassName(): string;
  13599. /**
  13600. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13601. */
  13602. get position(): Vector3;
  13603. set position(newPosition: Vector3);
  13604. /**
  13605. * 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)).
  13606. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13607. */
  13608. get rotation(): Vector3;
  13609. set rotation(newRotation: Vector3);
  13610. /**
  13611. * 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)).
  13612. */
  13613. get scaling(): Vector3;
  13614. set scaling(newScaling: Vector3);
  13615. /**
  13616. * 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).
  13617. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13618. */
  13619. get rotationQuaternion(): Nullable<Quaternion>;
  13620. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13621. /**
  13622. * The forward direction of that transform in world space.
  13623. */
  13624. get forward(): Vector3;
  13625. /**
  13626. * The up direction of that transform in world space.
  13627. */
  13628. get up(): Vector3;
  13629. /**
  13630. * The right direction of that transform in world space.
  13631. */
  13632. get right(): Vector3;
  13633. /**
  13634. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13635. * @param matrix the matrix to copy the pose from
  13636. * @returns this TransformNode.
  13637. */
  13638. updatePoseMatrix(matrix: Matrix): TransformNode;
  13639. /**
  13640. * Returns the mesh Pose matrix.
  13641. * @returns the pose matrix
  13642. */
  13643. getPoseMatrix(): Matrix;
  13644. /** @hidden */
  13645. _isSynchronized(): boolean;
  13646. /** @hidden */
  13647. _initCache(): void;
  13648. /**
  13649. * Flag the transform node as dirty (Forcing it to update everything)
  13650. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13651. * @returns this transform node
  13652. */
  13653. markAsDirty(property: string): TransformNode;
  13654. /**
  13655. * Returns the current mesh absolute position.
  13656. * Returns a Vector3.
  13657. */
  13658. get absolutePosition(): Vector3;
  13659. /**
  13660. * Returns the current mesh absolute scaling.
  13661. * Returns a Vector3.
  13662. */
  13663. get absoluteScaling(): Vector3;
  13664. /**
  13665. * Returns the current mesh absolute rotation.
  13666. * Returns a Quaternion.
  13667. */
  13668. get absoluteRotationQuaternion(): Quaternion;
  13669. /**
  13670. * Sets a new matrix to apply before all other transformation
  13671. * @param matrix defines the transform matrix
  13672. * @returns the current TransformNode
  13673. */
  13674. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13675. /**
  13676. * Sets a new pivot matrix to the current node
  13677. * @param matrix defines the new pivot matrix to use
  13678. * @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
  13679. * @returns the current TransformNode
  13680. */
  13681. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13682. /**
  13683. * Returns the mesh pivot matrix.
  13684. * Default : Identity.
  13685. * @returns the matrix
  13686. */
  13687. getPivotMatrix(): Matrix;
  13688. /**
  13689. * Instantiate (when possible) or clone that node with its hierarchy
  13690. * @param newParent defines the new parent to use for the instance (or clone)
  13691. * @param options defines options to configure how copy is done
  13692. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13693. * @returns an instance (or a clone) of the current node with its hiearchy
  13694. */
  13695. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13696. doNotInstantiate: boolean;
  13697. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13698. /**
  13699. * Prevents the World matrix to be computed any longer
  13700. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13701. * @returns the TransformNode.
  13702. */
  13703. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13704. /**
  13705. * Allows back the World matrix computation.
  13706. * @returns the TransformNode.
  13707. */
  13708. unfreezeWorldMatrix(): this;
  13709. /**
  13710. * True if the World matrix has been frozen.
  13711. */
  13712. get isWorldMatrixFrozen(): boolean;
  13713. /**
  13714. * Retuns the mesh absolute position in the World.
  13715. * @returns a Vector3.
  13716. */
  13717. getAbsolutePosition(): Vector3;
  13718. /**
  13719. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13720. * @param absolutePosition the absolute position to set
  13721. * @returns the TransformNode.
  13722. */
  13723. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13724. /**
  13725. * Sets the mesh position in its local space.
  13726. * @param vector3 the position to set in localspace
  13727. * @returns the TransformNode.
  13728. */
  13729. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13730. /**
  13731. * Returns the mesh position in the local space from the current World matrix values.
  13732. * @returns a new Vector3.
  13733. */
  13734. getPositionExpressedInLocalSpace(): Vector3;
  13735. /**
  13736. * Translates the mesh along the passed Vector3 in its local space.
  13737. * @param vector3 the distance to translate in localspace
  13738. * @returns the TransformNode.
  13739. */
  13740. locallyTranslate(vector3: Vector3): TransformNode;
  13741. private static _lookAtVectorCache;
  13742. /**
  13743. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13744. * @param targetPoint the position (must be in same space as current mesh) to look at
  13745. * @param yawCor optional yaw (y-axis) correction in radians
  13746. * @param pitchCor optional pitch (x-axis) correction in radians
  13747. * @param rollCor optional roll (z-axis) correction in radians
  13748. * @param space the choosen space of the target
  13749. * @returns the TransformNode.
  13750. */
  13751. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13752. /**
  13753. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13754. * This Vector3 is expressed in the World space.
  13755. * @param localAxis axis to rotate
  13756. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13757. */
  13758. getDirection(localAxis: Vector3): Vector3;
  13759. /**
  13760. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13761. * localAxis is expressed in the mesh local space.
  13762. * result is computed in the Wordl space from the mesh World matrix.
  13763. * @param localAxis axis to rotate
  13764. * @param result the resulting transformnode
  13765. * @returns this TransformNode.
  13766. */
  13767. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13768. /**
  13769. * Sets this transform node rotation to the given local axis.
  13770. * @param localAxis the axis in local space
  13771. * @param yawCor optional yaw (y-axis) correction in radians
  13772. * @param pitchCor optional pitch (x-axis) correction in radians
  13773. * @param rollCor optional roll (z-axis) correction in radians
  13774. * @returns this TransformNode
  13775. */
  13776. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13777. /**
  13778. * Sets a new pivot point to the current node
  13779. * @param point defines the new pivot point to use
  13780. * @param space defines if the point is in world or local space (local by default)
  13781. * @returns the current TransformNode
  13782. */
  13783. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13784. /**
  13785. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13786. * @returns the pivot point
  13787. */
  13788. getPivotPoint(): Vector3;
  13789. /**
  13790. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13791. * @param result the vector3 to store the result
  13792. * @returns this TransformNode.
  13793. */
  13794. getPivotPointToRef(result: Vector3): TransformNode;
  13795. /**
  13796. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13797. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13798. */
  13799. getAbsolutePivotPoint(): Vector3;
  13800. /**
  13801. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13802. * @param result vector3 to store the result
  13803. * @returns this TransformNode.
  13804. */
  13805. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13806. /**
  13807. * Defines the passed node as the parent of the current node.
  13808. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13809. * @see https://doc.babylonjs.com/how_to/parenting
  13810. * @param node the node ot set as the parent
  13811. * @returns this TransformNode.
  13812. */
  13813. setParent(node: Nullable<Node>): TransformNode;
  13814. private _nonUniformScaling;
  13815. /**
  13816. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13817. */
  13818. get nonUniformScaling(): boolean;
  13819. /** @hidden */
  13820. _updateNonUniformScalingState(value: boolean): boolean;
  13821. /**
  13822. * Attach the current TransformNode to another TransformNode associated with a bone
  13823. * @param bone Bone affecting the TransformNode
  13824. * @param affectedTransformNode TransformNode associated with the bone
  13825. * @returns this object
  13826. */
  13827. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13828. /**
  13829. * Detach the transform node if its associated with a bone
  13830. * @returns this object
  13831. */
  13832. detachFromBone(): TransformNode;
  13833. private static _rotationAxisCache;
  13834. /**
  13835. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13836. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13837. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13838. * The passed axis is also normalized.
  13839. * @param axis the axis to rotate around
  13840. * @param amount the amount to rotate in radians
  13841. * @param space Space to rotate in (Default: local)
  13842. * @returns the TransformNode.
  13843. */
  13844. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13845. /**
  13846. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13847. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13848. * The passed axis is also normalized. .
  13849. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13850. * @param point the point to rotate around
  13851. * @param axis the axis to rotate around
  13852. * @param amount the amount to rotate in radians
  13853. * @returns the TransformNode
  13854. */
  13855. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13856. /**
  13857. * Translates the mesh along the axis vector for the passed distance in the given space.
  13858. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13859. * @param axis the axis to translate in
  13860. * @param distance the distance to translate
  13861. * @param space Space to rotate in (Default: local)
  13862. * @returns the TransformNode.
  13863. */
  13864. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13865. /**
  13866. * Adds a rotation step to the mesh current rotation.
  13867. * x, y, z are Euler angles expressed in radians.
  13868. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13869. * This means this rotation is made in the mesh local space only.
  13870. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13871. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13872. * ```javascript
  13873. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13874. * ```
  13875. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13876. * 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.
  13877. * @param x Rotation to add
  13878. * @param y Rotation to add
  13879. * @param z Rotation to add
  13880. * @returns the TransformNode.
  13881. */
  13882. addRotation(x: number, y: number, z: number): TransformNode;
  13883. /**
  13884. * @hidden
  13885. */
  13886. protected _getEffectiveParent(): Nullable<Node>;
  13887. /**
  13888. * Computes the world matrix of the node
  13889. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13890. * @returns the world matrix
  13891. */
  13892. computeWorldMatrix(force?: boolean): Matrix;
  13893. /**
  13894. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13895. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13896. */
  13897. resetLocalMatrix(independentOfChildren?: boolean): void;
  13898. protected _afterComputeWorldMatrix(): void;
  13899. /**
  13900. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13901. * @param func callback function to add
  13902. *
  13903. * @returns the TransformNode.
  13904. */
  13905. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13906. /**
  13907. * Removes a registered callback function.
  13908. * @param func callback function to remove
  13909. * @returns the TransformNode.
  13910. */
  13911. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13912. /**
  13913. * Gets the position of the current mesh in camera space
  13914. * @param camera defines the camera to use
  13915. * @returns a position
  13916. */
  13917. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13918. /**
  13919. * Returns the distance from the mesh to the active camera
  13920. * @param camera defines the camera to use
  13921. * @returns the distance
  13922. */
  13923. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13924. /**
  13925. * Clone the current transform node
  13926. * @param name Name of the new clone
  13927. * @param newParent New parent for the clone
  13928. * @param doNotCloneChildren Do not clone children hierarchy
  13929. * @returns the new transform node
  13930. */
  13931. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13932. /**
  13933. * Serializes the objects information.
  13934. * @param currentSerializationObject defines the object to serialize in
  13935. * @returns the serialized object
  13936. */
  13937. serialize(currentSerializationObject?: any): any;
  13938. /**
  13939. * Returns a new TransformNode object parsed from the source provided.
  13940. * @param parsedTransformNode is the source.
  13941. * @param scene the scne the object belongs to
  13942. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13943. * @returns a new TransformNode object parsed from the source provided.
  13944. */
  13945. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13946. /**
  13947. * Get all child-transformNodes of this node
  13948. * @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
  13949. * @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
  13950. * @returns an array of TransformNode
  13951. */
  13952. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13953. /**
  13954. * Releases resources associated with this transform node.
  13955. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13956. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13957. */
  13958. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13959. /**
  13960. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13961. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13962. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13963. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13964. * @returns the current mesh
  13965. */
  13966. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13967. private _syncAbsoluteScalingAndRotation;
  13968. }
  13969. }
  13970. declare module BABYLON {
  13971. /**
  13972. * Class used to override all child animations of a given target
  13973. */
  13974. export class AnimationPropertiesOverride {
  13975. /**
  13976. * Gets or sets a value indicating if animation blending must be used
  13977. */
  13978. enableBlending: boolean;
  13979. /**
  13980. * Gets or sets the blending speed to use when enableBlending is true
  13981. */
  13982. blendingSpeed: number;
  13983. /**
  13984. * Gets or sets the default loop mode to use
  13985. */
  13986. loopMode: number;
  13987. }
  13988. }
  13989. declare module BABYLON {
  13990. /**
  13991. * Class used to store bone information
  13992. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13993. */
  13994. export class Bone extends Node {
  13995. /**
  13996. * defines the bone name
  13997. */
  13998. name: string;
  13999. private static _tmpVecs;
  14000. private static _tmpQuat;
  14001. private static _tmpMats;
  14002. /**
  14003. * Gets the list of child bones
  14004. */
  14005. children: Bone[];
  14006. /** Gets the animations associated with this bone */
  14007. animations: Animation[];
  14008. /**
  14009. * Gets or sets bone length
  14010. */
  14011. length: number;
  14012. /**
  14013. * @hidden Internal only
  14014. * Set this value to map this bone to a different index in the transform matrices
  14015. * Set this value to -1 to exclude the bone from the transform matrices
  14016. */
  14017. _index: Nullable<number>;
  14018. private _skeleton;
  14019. private _localMatrix;
  14020. private _restPose;
  14021. private _baseMatrix;
  14022. private _absoluteTransform;
  14023. private _invertedAbsoluteTransform;
  14024. private _parent;
  14025. private _scalingDeterminant;
  14026. private _worldTransform;
  14027. private _localScaling;
  14028. private _localRotation;
  14029. private _localPosition;
  14030. private _needToDecompose;
  14031. private _needToCompose;
  14032. /** @hidden */
  14033. _linkedTransformNode: Nullable<TransformNode>;
  14034. /** @hidden */
  14035. _waitingTransformNodeId: Nullable<string>;
  14036. /** @hidden */
  14037. get _matrix(): Matrix;
  14038. /** @hidden */
  14039. set _matrix(value: Matrix);
  14040. /**
  14041. * Create a new bone
  14042. * @param name defines the bone name
  14043. * @param skeleton defines the parent skeleton
  14044. * @param parentBone defines the parent (can be null if the bone is the root)
  14045. * @param localMatrix defines the local matrix
  14046. * @param restPose defines the rest pose matrix
  14047. * @param baseMatrix defines the base matrix
  14048. * @param index defines index of the bone in the hiearchy
  14049. */
  14050. constructor(
  14051. /**
  14052. * defines the bone name
  14053. */
  14054. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14055. /**
  14056. * Gets the current object class name.
  14057. * @return the class name
  14058. */
  14059. getClassName(): string;
  14060. /**
  14061. * Gets the parent skeleton
  14062. * @returns a skeleton
  14063. */
  14064. getSkeleton(): Skeleton;
  14065. /**
  14066. * Gets parent bone
  14067. * @returns a bone or null if the bone is the root of the bone hierarchy
  14068. */
  14069. getParent(): Nullable<Bone>;
  14070. /**
  14071. * Returns an array containing the root bones
  14072. * @returns an array containing the root bones
  14073. */
  14074. getChildren(): Array<Bone>;
  14075. /**
  14076. * Gets the node index in matrix array generated for rendering
  14077. * @returns the node index
  14078. */
  14079. getIndex(): number;
  14080. /**
  14081. * Sets the parent bone
  14082. * @param parent defines the parent (can be null if the bone is the root)
  14083. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14084. */
  14085. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14086. /**
  14087. * Gets the local matrix
  14088. * @returns a matrix
  14089. */
  14090. getLocalMatrix(): Matrix;
  14091. /**
  14092. * Gets the base matrix (initial matrix which remains unchanged)
  14093. * @returns a matrix
  14094. */
  14095. getBaseMatrix(): Matrix;
  14096. /**
  14097. * Gets the rest pose matrix
  14098. * @returns a matrix
  14099. */
  14100. getRestPose(): Matrix;
  14101. /**
  14102. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14103. */
  14104. getWorldMatrix(): Matrix;
  14105. /**
  14106. * Sets the local matrix to rest pose matrix
  14107. */
  14108. returnToRest(): void;
  14109. /**
  14110. * Gets the inverse of the absolute transform matrix.
  14111. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14112. * @returns a matrix
  14113. */
  14114. getInvertedAbsoluteTransform(): Matrix;
  14115. /**
  14116. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14117. * @returns a matrix
  14118. */
  14119. getAbsoluteTransform(): Matrix;
  14120. /**
  14121. * Links with the given transform node.
  14122. * The local matrix of this bone is copied from the transform node every frame.
  14123. * @param transformNode defines the transform node to link to
  14124. */
  14125. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14126. /**
  14127. * Gets the node used to drive the bone's transformation
  14128. * @returns a transform node or null
  14129. */
  14130. getTransformNode(): Nullable<TransformNode>;
  14131. /** Gets or sets current position (in local space) */
  14132. get position(): Vector3;
  14133. set position(newPosition: Vector3);
  14134. /** Gets or sets current rotation (in local space) */
  14135. get rotation(): Vector3;
  14136. set rotation(newRotation: Vector3);
  14137. /** Gets or sets current rotation quaternion (in local space) */
  14138. get rotationQuaternion(): Quaternion;
  14139. set rotationQuaternion(newRotation: Quaternion);
  14140. /** Gets or sets current scaling (in local space) */
  14141. get scaling(): Vector3;
  14142. set scaling(newScaling: Vector3);
  14143. /**
  14144. * Gets the animation properties override
  14145. */
  14146. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14147. private _decompose;
  14148. private _compose;
  14149. /**
  14150. * Update the base and local matrices
  14151. * @param matrix defines the new base or local matrix
  14152. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14153. * @param updateLocalMatrix defines if the local matrix should be updated
  14154. */
  14155. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14156. /** @hidden */
  14157. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14158. /**
  14159. * Flag the bone as dirty (Forcing it to update everything)
  14160. */
  14161. markAsDirty(): void;
  14162. /** @hidden */
  14163. _markAsDirtyAndCompose(): void;
  14164. private _markAsDirtyAndDecompose;
  14165. /**
  14166. * Translate the bone in local or world space
  14167. * @param vec The amount to translate the bone
  14168. * @param space The space that the translation is in
  14169. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14170. */
  14171. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14172. /**
  14173. * Set the postion of the bone in local or world space
  14174. * @param position The position to set the bone
  14175. * @param space The space that the position is in
  14176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14177. */
  14178. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14179. /**
  14180. * Set the absolute position of the bone (world space)
  14181. * @param position The position to set the bone
  14182. * @param mesh The mesh that this bone is attached to
  14183. */
  14184. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14185. /**
  14186. * Scale the bone on the x, y and z axes (in local space)
  14187. * @param x The amount to scale the bone on the x axis
  14188. * @param y The amount to scale the bone on the y axis
  14189. * @param z The amount to scale the bone on the z axis
  14190. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14191. */
  14192. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14193. /**
  14194. * Set the bone scaling in local space
  14195. * @param scale defines the scaling vector
  14196. */
  14197. setScale(scale: Vector3): void;
  14198. /**
  14199. * Gets the current scaling in local space
  14200. * @returns the current scaling vector
  14201. */
  14202. getScale(): Vector3;
  14203. /**
  14204. * Gets the current scaling in local space and stores it in a target vector
  14205. * @param result defines the target vector
  14206. */
  14207. getScaleToRef(result: Vector3): void;
  14208. /**
  14209. * Set the yaw, pitch, and roll of the bone in local or world space
  14210. * @param yaw The rotation of the bone on the y axis
  14211. * @param pitch The rotation of the bone on the x axis
  14212. * @param roll The rotation of the bone on the z axis
  14213. * @param space The space that the axes of rotation are in
  14214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14215. */
  14216. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14217. /**
  14218. * Add a rotation to the bone on an axis in local or world space
  14219. * @param axis The axis to rotate the bone on
  14220. * @param amount The amount to rotate the bone
  14221. * @param space The space that the axis is in
  14222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14223. */
  14224. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14225. /**
  14226. * Set the rotation of the bone to a particular axis angle in local or world space
  14227. * @param axis The axis to rotate the bone on
  14228. * @param angle The angle that the bone should be rotated to
  14229. * @param space The space that the axis is in
  14230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14231. */
  14232. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14233. /**
  14234. * Set the euler rotation of the bone in local of world space
  14235. * @param rotation The euler rotation that the bone should be set to
  14236. * @param space The space that the rotation is in
  14237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14238. */
  14239. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14240. /**
  14241. * Set the quaternion rotation of the bone in local of world space
  14242. * @param quat The quaternion rotation that the bone should be set to
  14243. * @param space The space that the rotation is in
  14244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14245. */
  14246. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14247. /**
  14248. * Set the rotation matrix of the bone in local of world space
  14249. * @param rotMat The rotation matrix that the bone should be set to
  14250. * @param space The space that the rotation is in
  14251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14252. */
  14253. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14254. private _rotateWithMatrix;
  14255. private _getNegativeRotationToRef;
  14256. /**
  14257. * Get the position of the bone in local or world space
  14258. * @param space The space that the returned position is in
  14259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14260. * @returns The position of the bone
  14261. */
  14262. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14263. /**
  14264. * Copy the position of the bone to a vector3 in local or world space
  14265. * @param space The space that the returned position is in
  14266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14267. * @param result The vector3 to copy the position to
  14268. */
  14269. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14270. /**
  14271. * Get the absolute position of the bone (world space)
  14272. * @param mesh The mesh that this bone is attached to
  14273. * @returns The absolute position of the bone
  14274. */
  14275. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14276. /**
  14277. * Copy the absolute position of the bone (world space) to the result param
  14278. * @param mesh The mesh that this bone is attached to
  14279. * @param result The vector3 to copy the absolute position to
  14280. */
  14281. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14282. /**
  14283. * Compute the absolute transforms of this bone and its children
  14284. */
  14285. computeAbsoluteTransforms(): void;
  14286. /**
  14287. * Get the world direction from an axis that is in the local space of the bone
  14288. * @param localAxis The local direction that is used to compute the world direction
  14289. * @param mesh The mesh that this bone is attached to
  14290. * @returns The world direction
  14291. */
  14292. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14293. /**
  14294. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14295. * @param localAxis The local direction that is used to compute the world direction
  14296. * @param mesh The mesh that this bone is attached to
  14297. * @param result The vector3 that the world direction will be copied to
  14298. */
  14299. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14300. /**
  14301. * Get the euler rotation of the bone in local or world space
  14302. * @param space The space that the rotation should be in
  14303. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14304. * @returns The euler rotation
  14305. */
  14306. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14307. /**
  14308. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14309. * @param space The space that the rotation should be in
  14310. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14311. * @param result The vector3 that the rotation should be copied to
  14312. */
  14313. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14314. /**
  14315. * Get the quaternion rotation of the bone in either local or world space
  14316. * @param space The space that the rotation should be in
  14317. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14318. * @returns The quaternion rotation
  14319. */
  14320. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14321. /**
  14322. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14323. * @param space The space that the rotation should be in
  14324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14325. * @param result The quaternion that the rotation should be copied to
  14326. */
  14327. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14328. /**
  14329. * Get the rotation matrix of the bone in local or world space
  14330. * @param space The space that the rotation should be in
  14331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14332. * @returns The rotation matrix
  14333. */
  14334. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14335. /**
  14336. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14337. * @param space The space that the rotation should be in
  14338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14339. * @param result The quaternion that the rotation should be copied to
  14340. */
  14341. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14342. /**
  14343. * Get the world position of a point that is in the local space of the bone
  14344. * @param position The local position
  14345. * @param mesh The mesh that this bone is attached to
  14346. * @returns The world position
  14347. */
  14348. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14349. /**
  14350. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14351. * @param position The local position
  14352. * @param mesh The mesh that this bone is attached to
  14353. * @param result The vector3 that the world position should be copied to
  14354. */
  14355. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14356. /**
  14357. * Get the local position of a point that is in world space
  14358. * @param position The world position
  14359. * @param mesh The mesh that this bone is attached to
  14360. * @returns The local position
  14361. */
  14362. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14363. /**
  14364. * Get the local position of a point that is in world space and copy it to the result param
  14365. * @param position The world position
  14366. * @param mesh The mesh that this bone is attached to
  14367. * @param result The vector3 that the local position should be copied to
  14368. */
  14369. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14370. }
  14371. }
  14372. declare module BABYLON {
  14373. /**
  14374. * Defines a runtime animation
  14375. */
  14376. export class RuntimeAnimation {
  14377. private _events;
  14378. /**
  14379. * The current frame of the runtime animation
  14380. */
  14381. private _currentFrame;
  14382. /**
  14383. * The animation used by the runtime animation
  14384. */
  14385. private _animation;
  14386. /**
  14387. * The target of the runtime animation
  14388. */
  14389. private _target;
  14390. /**
  14391. * The initiating animatable
  14392. */
  14393. private _host;
  14394. /**
  14395. * The original value of the runtime animation
  14396. */
  14397. private _originalValue;
  14398. /**
  14399. * The original blend value of the runtime animation
  14400. */
  14401. private _originalBlendValue;
  14402. /**
  14403. * The offsets cache of the runtime animation
  14404. */
  14405. private _offsetsCache;
  14406. /**
  14407. * The high limits cache of the runtime animation
  14408. */
  14409. private _highLimitsCache;
  14410. /**
  14411. * Specifies if the runtime animation has been stopped
  14412. */
  14413. private _stopped;
  14414. /**
  14415. * The blending factor of the runtime animation
  14416. */
  14417. private _blendingFactor;
  14418. /**
  14419. * The BabylonJS scene
  14420. */
  14421. private _scene;
  14422. /**
  14423. * The current value of the runtime animation
  14424. */
  14425. private _currentValue;
  14426. /** @hidden */
  14427. _animationState: _IAnimationState;
  14428. /**
  14429. * The active target of the runtime animation
  14430. */
  14431. private _activeTargets;
  14432. private _currentActiveTarget;
  14433. private _directTarget;
  14434. /**
  14435. * The target path of the runtime animation
  14436. */
  14437. private _targetPath;
  14438. /**
  14439. * The weight of the runtime animation
  14440. */
  14441. private _weight;
  14442. /**
  14443. * The ratio offset of the runtime animation
  14444. */
  14445. private _ratioOffset;
  14446. /**
  14447. * The previous delay of the runtime animation
  14448. */
  14449. private _previousDelay;
  14450. /**
  14451. * The previous ratio of the runtime animation
  14452. */
  14453. private _previousRatio;
  14454. private _enableBlending;
  14455. private _keys;
  14456. private _minFrame;
  14457. private _maxFrame;
  14458. private _minValue;
  14459. private _maxValue;
  14460. private _targetIsArray;
  14461. /**
  14462. * Gets the current frame of the runtime animation
  14463. */
  14464. get currentFrame(): number;
  14465. /**
  14466. * Gets the weight of the runtime animation
  14467. */
  14468. get weight(): number;
  14469. /**
  14470. * Gets the current value of the runtime animation
  14471. */
  14472. get currentValue(): any;
  14473. /**
  14474. * Gets the target path of the runtime animation
  14475. */
  14476. get targetPath(): string;
  14477. /**
  14478. * Gets the actual target of the runtime animation
  14479. */
  14480. get target(): any;
  14481. /** @hidden */
  14482. _onLoop: () => void;
  14483. /**
  14484. * Create a new RuntimeAnimation object
  14485. * @param target defines the target of the animation
  14486. * @param animation defines the source animation object
  14487. * @param scene defines the hosting scene
  14488. * @param host defines the initiating Animatable
  14489. */
  14490. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14491. private _preparePath;
  14492. /**
  14493. * Gets the animation from the runtime animation
  14494. */
  14495. get animation(): Animation;
  14496. /**
  14497. * Resets the runtime animation to the beginning
  14498. * @param restoreOriginal defines whether to restore the target property to the original value
  14499. */
  14500. reset(restoreOriginal?: boolean): void;
  14501. /**
  14502. * Specifies if the runtime animation is stopped
  14503. * @returns Boolean specifying if the runtime animation is stopped
  14504. */
  14505. isStopped(): boolean;
  14506. /**
  14507. * Disposes of the runtime animation
  14508. */
  14509. dispose(): void;
  14510. /**
  14511. * Apply the interpolated value to the target
  14512. * @param currentValue defines the value computed by the animation
  14513. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14514. */
  14515. setValue(currentValue: any, weight: number): void;
  14516. private _getOriginalValues;
  14517. private _setValue;
  14518. /**
  14519. * Gets the loop pmode of the runtime animation
  14520. * @returns Loop Mode
  14521. */
  14522. private _getCorrectLoopMode;
  14523. /**
  14524. * Move the current animation to a given frame
  14525. * @param frame defines the frame to move to
  14526. */
  14527. goToFrame(frame: number): void;
  14528. /**
  14529. * @hidden Internal use only
  14530. */
  14531. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14532. /**
  14533. * Execute the current animation
  14534. * @param delay defines the delay to add to the current frame
  14535. * @param from defines the lower bound of the animation range
  14536. * @param to defines the upper bound of the animation range
  14537. * @param loop defines if the current animation must loop
  14538. * @param speedRatio defines the current speed ratio
  14539. * @param weight defines the weight of the animation (default is -1 so no weight)
  14540. * @param onLoop optional callback called when animation loops
  14541. * @returns a boolean indicating if the animation is running
  14542. */
  14543. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14544. }
  14545. }
  14546. declare module BABYLON {
  14547. /**
  14548. * Class used to store an actual running animation
  14549. */
  14550. export class Animatable {
  14551. /** defines the target object */
  14552. target: any;
  14553. /** defines the starting frame number (default is 0) */
  14554. fromFrame: number;
  14555. /** defines the ending frame number (default is 100) */
  14556. toFrame: number;
  14557. /** defines if the animation must loop (default is false) */
  14558. loopAnimation: boolean;
  14559. /** defines a callback to call when animation ends if it is not looping */
  14560. onAnimationEnd?: (() => void) | null | undefined;
  14561. /** defines a callback to call when animation loops */
  14562. onAnimationLoop?: (() => void) | null | undefined;
  14563. private _localDelayOffset;
  14564. private _pausedDelay;
  14565. private _runtimeAnimations;
  14566. private _paused;
  14567. private _scene;
  14568. private _speedRatio;
  14569. private _weight;
  14570. private _syncRoot;
  14571. /**
  14572. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14573. * This will only apply for non looping animation (default is true)
  14574. */
  14575. disposeOnEnd: boolean;
  14576. /**
  14577. * Gets a boolean indicating if the animation has started
  14578. */
  14579. animationStarted: boolean;
  14580. /**
  14581. * Observer raised when the animation ends
  14582. */
  14583. onAnimationEndObservable: Observable<Animatable>;
  14584. /**
  14585. * Observer raised when the animation loops
  14586. */
  14587. onAnimationLoopObservable: Observable<Animatable>;
  14588. /**
  14589. * Gets the root Animatable used to synchronize and normalize animations
  14590. */
  14591. get syncRoot(): Nullable<Animatable>;
  14592. /**
  14593. * Gets the current frame of the first RuntimeAnimation
  14594. * Used to synchronize Animatables
  14595. */
  14596. get masterFrame(): number;
  14597. /**
  14598. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14599. */
  14600. get weight(): number;
  14601. set weight(value: number);
  14602. /**
  14603. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14604. */
  14605. get speedRatio(): number;
  14606. set speedRatio(value: number);
  14607. /**
  14608. * Creates a new Animatable
  14609. * @param scene defines the hosting scene
  14610. * @param target defines the target object
  14611. * @param fromFrame defines the starting frame number (default is 0)
  14612. * @param toFrame defines the ending frame number (default is 100)
  14613. * @param loopAnimation defines if the animation must loop (default is false)
  14614. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14615. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14616. * @param animations defines a group of animation to add to the new Animatable
  14617. * @param onAnimationLoop defines a callback to call when animation loops
  14618. */
  14619. constructor(scene: Scene,
  14620. /** defines the target object */
  14621. target: any,
  14622. /** defines the starting frame number (default is 0) */
  14623. fromFrame?: number,
  14624. /** defines the ending frame number (default is 100) */
  14625. toFrame?: number,
  14626. /** defines if the animation must loop (default is false) */
  14627. loopAnimation?: boolean, speedRatio?: number,
  14628. /** defines a callback to call when animation ends if it is not looping */
  14629. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14630. /** defines a callback to call when animation loops */
  14631. onAnimationLoop?: (() => void) | null | undefined);
  14632. /**
  14633. * Synchronize and normalize current Animatable with a source Animatable
  14634. * This is useful when using animation weights and when animations are not of the same length
  14635. * @param root defines the root Animatable to synchronize with
  14636. * @returns the current Animatable
  14637. */
  14638. syncWith(root: Animatable): Animatable;
  14639. /**
  14640. * Gets the list of runtime animations
  14641. * @returns an array of RuntimeAnimation
  14642. */
  14643. getAnimations(): RuntimeAnimation[];
  14644. /**
  14645. * Adds more animations to the current animatable
  14646. * @param target defines the target of the animations
  14647. * @param animations defines the new animations to add
  14648. */
  14649. appendAnimations(target: any, animations: Animation[]): void;
  14650. /**
  14651. * Gets the source animation for a specific property
  14652. * @param property defines the propertyu to look for
  14653. * @returns null or the source animation for the given property
  14654. */
  14655. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14656. /**
  14657. * Gets the runtime animation for a specific property
  14658. * @param property defines the propertyu to look for
  14659. * @returns null or the runtime animation for the given property
  14660. */
  14661. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14662. /**
  14663. * Resets the animatable to its original state
  14664. */
  14665. reset(): void;
  14666. /**
  14667. * Allows the animatable to blend with current running animations
  14668. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14669. * @param blendingSpeed defines the blending speed to use
  14670. */
  14671. enableBlending(blendingSpeed: number): void;
  14672. /**
  14673. * Disable animation blending
  14674. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14675. */
  14676. disableBlending(): void;
  14677. /**
  14678. * Jump directly to a given frame
  14679. * @param frame defines the frame to jump to
  14680. */
  14681. goToFrame(frame: number): void;
  14682. /**
  14683. * Pause the animation
  14684. */
  14685. pause(): void;
  14686. /**
  14687. * Restart the animation
  14688. */
  14689. restart(): void;
  14690. private _raiseOnAnimationEnd;
  14691. /**
  14692. * Stop and delete the current animation
  14693. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14694. * @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)
  14695. */
  14696. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14697. /**
  14698. * Wait asynchronously for the animation to end
  14699. * @returns a promise which will be fullfilled when the animation ends
  14700. */
  14701. waitAsync(): Promise<Animatable>;
  14702. /** @hidden */
  14703. _animate(delay: number): boolean;
  14704. }
  14705. interface Scene {
  14706. /** @hidden */
  14707. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14708. /** @hidden */
  14709. _processLateAnimationBindingsForMatrices(holder: {
  14710. totalWeight: number;
  14711. animations: RuntimeAnimation[];
  14712. originalValue: Matrix;
  14713. }): any;
  14714. /** @hidden */
  14715. _processLateAnimationBindingsForQuaternions(holder: {
  14716. totalWeight: number;
  14717. animations: RuntimeAnimation[];
  14718. originalValue: Quaternion;
  14719. }, refQuaternion: Quaternion): Quaternion;
  14720. /** @hidden */
  14721. _processLateAnimationBindings(): void;
  14722. /**
  14723. * Will start the animation sequence of a given target
  14724. * @param target defines the target
  14725. * @param from defines from which frame should animation start
  14726. * @param to defines until which frame should animation run.
  14727. * @param weight defines the weight to apply to the animation (1.0 by default)
  14728. * @param loop defines if the animation loops
  14729. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14730. * @param onAnimationEnd defines the function to be executed when the animation ends
  14731. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14732. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14733. * @param onAnimationLoop defines the callback to call when an animation loops
  14734. * @returns the animatable object created for this animation
  14735. */
  14736. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14737. /**
  14738. * Will start the animation sequence of a given target
  14739. * @param target defines the target
  14740. * @param from defines from which frame should animation start
  14741. * @param to defines until which frame should animation run.
  14742. * @param loop defines if the animation loops
  14743. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14744. * @param onAnimationEnd defines the function to be executed when the animation ends
  14745. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14746. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14747. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14748. * @param onAnimationLoop defines the callback to call when an animation loops
  14749. * @returns the animatable object created for this animation
  14750. */
  14751. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14752. /**
  14753. * Will start the animation sequence of a given target and its hierarchy
  14754. * @param target defines the target
  14755. * @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.
  14756. * @param from defines from which frame should animation start
  14757. * @param to defines until which frame should animation run.
  14758. * @param loop defines if the animation loops
  14759. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14760. * @param onAnimationEnd defines the function to be executed when the animation ends
  14761. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14762. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14763. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14764. * @param onAnimationLoop defines the callback to call when an animation loops
  14765. * @returns the list of created animatables
  14766. */
  14767. 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[];
  14768. /**
  14769. * Begin a new animation on a given node
  14770. * @param target defines the target where the animation will take place
  14771. * @param animations defines the list of animations to start
  14772. * @param from defines the initial value
  14773. * @param to defines the final value
  14774. * @param loop defines if you want animation to loop (off by default)
  14775. * @param speedRatio defines the speed ratio to apply to all animations
  14776. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14777. * @param onAnimationLoop defines the callback to call when an animation loops
  14778. * @returns the list of created animatables
  14779. */
  14780. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  14781. /**
  14782. * Begin a new animation on a given node and its hierarchy
  14783. * @param target defines the root node where the animation will take place
  14784. * @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.
  14785. * @param animations defines the list of animations to start
  14786. * @param from defines the initial value
  14787. * @param to defines the final value
  14788. * @param loop defines if you want animation to loop (off by default)
  14789. * @param speedRatio defines the speed ratio to apply to all animations
  14790. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14791. * @param onAnimationLoop defines the callback to call when an animation loops
  14792. * @returns the list of animatables created for all nodes
  14793. */
  14794. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  14795. /**
  14796. * Gets the animatable associated with a specific target
  14797. * @param target defines the target of the animatable
  14798. * @returns the required animatable if found
  14799. */
  14800. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14801. /**
  14802. * Gets all animatables associated with a given target
  14803. * @param target defines the target to look animatables for
  14804. * @returns an array of Animatables
  14805. */
  14806. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14807. /**
  14808. * Stops and removes all animations that have been applied to the scene
  14809. */
  14810. stopAllAnimations(): void;
  14811. /**
  14812. * Gets the current delta time used by animation engine
  14813. */
  14814. deltaTime: number;
  14815. }
  14816. interface Bone {
  14817. /**
  14818. * Copy an animation range from another bone
  14819. * @param source defines the source bone
  14820. * @param rangeName defines the range name to copy
  14821. * @param frameOffset defines the frame offset
  14822. * @param rescaleAsRequired defines if rescaling must be applied if required
  14823. * @param skelDimensionsRatio defines the scaling ratio
  14824. * @returns true if operation was successful
  14825. */
  14826. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14827. }
  14828. }
  14829. declare module BABYLON {
  14830. /**
  14831. * Class used to handle skinning animations
  14832. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14833. */
  14834. export class Skeleton implements IAnimatable {
  14835. /** defines the skeleton name */
  14836. name: string;
  14837. /** defines the skeleton Id */
  14838. id: string;
  14839. /**
  14840. * Defines the list of child bones
  14841. */
  14842. bones: Bone[];
  14843. /**
  14844. * Defines an estimate of the dimension of the skeleton at rest
  14845. */
  14846. dimensionsAtRest: Vector3;
  14847. /**
  14848. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14849. */
  14850. needInitialSkinMatrix: boolean;
  14851. /**
  14852. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14853. */
  14854. overrideMesh: Nullable<AbstractMesh>;
  14855. /**
  14856. * Gets the list of animations attached to this skeleton
  14857. */
  14858. animations: Array<Animation>;
  14859. private _scene;
  14860. private _isDirty;
  14861. private _transformMatrices;
  14862. private _transformMatrixTexture;
  14863. private _meshesWithPoseMatrix;
  14864. private _animatables;
  14865. private _identity;
  14866. private _synchronizedWithMesh;
  14867. private _ranges;
  14868. private _lastAbsoluteTransformsUpdateId;
  14869. private _canUseTextureForBones;
  14870. private _uniqueId;
  14871. /** @hidden */
  14872. _numBonesWithLinkedTransformNode: number;
  14873. /** @hidden */
  14874. _hasWaitingData: Nullable<boolean>;
  14875. /**
  14876. * Specifies if the skeleton should be serialized
  14877. */
  14878. doNotSerialize: boolean;
  14879. private _useTextureToStoreBoneMatrices;
  14880. /**
  14881. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14882. * Please note that this option is not available if the hardware does not support it
  14883. */
  14884. get useTextureToStoreBoneMatrices(): boolean;
  14885. set useTextureToStoreBoneMatrices(value: boolean);
  14886. private _animationPropertiesOverride;
  14887. /**
  14888. * Gets or sets the animation properties override
  14889. */
  14890. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14891. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14892. /**
  14893. * List of inspectable custom properties (used by the Inspector)
  14894. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14895. */
  14896. inspectableCustomProperties: IInspectable[];
  14897. /**
  14898. * An observable triggered before computing the skeleton's matrices
  14899. */
  14900. onBeforeComputeObservable: Observable<Skeleton>;
  14901. /**
  14902. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14903. */
  14904. get isUsingTextureForMatrices(): boolean;
  14905. /**
  14906. * Gets the unique ID of this skeleton
  14907. */
  14908. get uniqueId(): number;
  14909. /**
  14910. * Creates a new skeleton
  14911. * @param name defines the skeleton name
  14912. * @param id defines the skeleton Id
  14913. * @param scene defines the hosting scene
  14914. */
  14915. constructor(
  14916. /** defines the skeleton name */
  14917. name: string,
  14918. /** defines the skeleton Id */
  14919. id: string, scene: Scene);
  14920. /**
  14921. * Gets the current object class name.
  14922. * @return the class name
  14923. */
  14924. getClassName(): string;
  14925. /**
  14926. * Returns an array containing the root bones
  14927. * @returns an array containing the root bones
  14928. */
  14929. getChildren(): Array<Bone>;
  14930. /**
  14931. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14932. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14933. * @returns a Float32Array containing matrices data
  14934. */
  14935. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14936. /**
  14937. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14938. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14939. * @returns a raw texture containing the data
  14940. */
  14941. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14942. /**
  14943. * Gets the current hosting scene
  14944. * @returns a scene object
  14945. */
  14946. getScene(): Scene;
  14947. /**
  14948. * Gets a string representing the current skeleton data
  14949. * @param fullDetails defines a boolean indicating if we want a verbose version
  14950. * @returns a string representing the current skeleton data
  14951. */
  14952. toString(fullDetails?: boolean): string;
  14953. /**
  14954. * Get bone's index searching by name
  14955. * @param name defines bone's name to search for
  14956. * @return the indice of the bone. Returns -1 if not found
  14957. */
  14958. getBoneIndexByName(name: string): number;
  14959. /**
  14960. * Creater a new animation range
  14961. * @param name defines the name of the range
  14962. * @param from defines the start key
  14963. * @param to defines the end key
  14964. */
  14965. createAnimationRange(name: string, from: number, to: number): void;
  14966. /**
  14967. * Delete a specific animation range
  14968. * @param name defines the name of the range
  14969. * @param deleteFrames defines if frames must be removed as well
  14970. */
  14971. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14972. /**
  14973. * Gets a specific animation range
  14974. * @param name defines the name of the range to look for
  14975. * @returns the requested animation range or null if not found
  14976. */
  14977. getAnimationRange(name: string): Nullable<AnimationRange>;
  14978. /**
  14979. * Gets the list of all animation ranges defined on this skeleton
  14980. * @returns an array
  14981. */
  14982. getAnimationRanges(): Nullable<AnimationRange>[];
  14983. /**
  14984. * Copy animation range from a source skeleton.
  14985. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  14986. * @param source defines the source skeleton
  14987. * @param name defines the name of the range to copy
  14988. * @param rescaleAsRequired defines if rescaling must be applied if required
  14989. * @returns true if operation was successful
  14990. */
  14991. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  14992. /**
  14993. * Forces the skeleton to go to rest pose
  14994. */
  14995. returnToRest(): void;
  14996. private _getHighestAnimationFrame;
  14997. /**
  14998. * Begin a specific animation range
  14999. * @param name defines the name of the range to start
  15000. * @param loop defines if looping must be turned on (false by default)
  15001. * @param speedRatio defines the speed ratio to apply (1 by default)
  15002. * @param onAnimationEnd defines a callback which will be called when animation will end
  15003. * @returns a new animatable
  15004. */
  15005. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15006. /** @hidden */
  15007. _markAsDirty(): void;
  15008. /** @hidden */
  15009. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15010. /** @hidden */
  15011. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15012. private _computeTransformMatrices;
  15013. /**
  15014. * Build all resources required to render a skeleton
  15015. */
  15016. prepare(): void;
  15017. /**
  15018. * Gets the list of animatables currently running for this skeleton
  15019. * @returns an array of animatables
  15020. */
  15021. getAnimatables(): IAnimatable[];
  15022. /**
  15023. * Clone the current skeleton
  15024. * @param name defines the name of the new skeleton
  15025. * @param id defines the id of the new skeleton
  15026. * @returns the new skeleton
  15027. */
  15028. clone(name: string, id?: string): Skeleton;
  15029. /**
  15030. * Enable animation blending for this skeleton
  15031. * @param blendingSpeed defines the blending speed to apply
  15032. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15033. */
  15034. enableBlending(blendingSpeed?: number): void;
  15035. /**
  15036. * Releases all resources associated with the current skeleton
  15037. */
  15038. dispose(): void;
  15039. /**
  15040. * Serialize the skeleton in a JSON object
  15041. * @returns a JSON object
  15042. */
  15043. serialize(): any;
  15044. /**
  15045. * Creates a new skeleton from serialized data
  15046. * @param parsedSkeleton defines the serialized data
  15047. * @param scene defines the hosting scene
  15048. * @returns a new skeleton
  15049. */
  15050. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15051. /**
  15052. * Compute all node absolute transforms
  15053. * @param forceUpdate defines if computation must be done even if cache is up to date
  15054. */
  15055. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15056. /**
  15057. * Gets the root pose matrix
  15058. * @returns a matrix
  15059. */
  15060. getPoseMatrix(): Nullable<Matrix>;
  15061. /**
  15062. * Sorts bones per internal index
  15063. */
  15064. sortBones(): void;
  15065. private _sortBones;
  15066. }
  15067. }
  15068. declare module BABYLON {
  15069. /**
  15070. * Creates an instance based on a source mesh.
  15071. */
  15072. export class InstancedMesh extends AbstractMesh {
  15073. private _sourceMesh;
  15074. private _currentLOD;
  15075. /** @hidden */
  15076. _indexInSourceMeshInstanceArray: number;
  15077. constructor(name: string, source: Mesh);
  15078. /**
  15079. * Returns the string "InstancedMesh".
  15080. */
  15081. getClassName(): string;
  15082. /** Gets the list of lights affecting that mesh */
  15083. get lightSources(): Light[];
  15084. _resyncLightSources(): void;
  15085. _resyncLightSource(light: Light): void;
  15086. _removeLightSource(light: Light, dispose: boolean): void;
  15087. /**
  15088. * If the source mesh receives shadows
  15089. */
  15090. get receiveShadows(): boolean;
  15091. /**
  15092. * The material of the source mesh
  15093. */
  15094. get material(): Nullable<Material>;
  15095. /**
  15096. * Visibility of the source mesh
  15097. */
  15098. get visibility(): number;
  15099. /**
  15100. * Skeleton of the source mesh
  15101. */
  15102. get skeleton(): Nullable<Skeleton>;
  15103. /**
  15104. * Rendering ground id of the source mesh
  15105. */
  15106. get renderingGroupId(): number;
  15107. set renderingGroupId(value: number);
  15108. /**
  15109. * Returns the total number of vertices (integer).
  15110. */
  15111. getTotalVertices(): number;
  15112. /**
  15113. * Returns a positive integer : the total number of indices in this mesh geometry.
  15114. * @returns the numner of indices or zero if the mesh has no geometry.
  15115. */
  15116. getTotalIndices(): number;
  15117. /**
  15118. * The source mesh of the instance
  15119. */
  15120. get sourceMesh(): Mesh;
  15121. /**
  15122. * Is this node ready to be used/rendered
  15123. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15124. * @return {boolean} is it ready
  15125. */
  15126. isReady(completeCheck?: boolean): boolean;
  15127. /**
  15128. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15129. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15130. * @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.
  15131. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15132. */
  15133. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15134. /**
  15135. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15136. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15137. * The `data` are either a numeric array either a Float32Array.
  15138. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15139. * 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).
  15140. * Note that a new underlying VertexBuffer object is created each call.
  15141. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15142. *
  15143. * Possible `kind` values :
  15144. * - VertexBuffer.PositionKind
  15145. * - VertexBuffer.UVKind
  15146. * - VertexBuffer.UV2Kind
  15147. * - VertexBuffer.UV3Kind
  15148. * - VertexBuffer.UV4Kind
  15149. * - VertexBuffer.UV5Kind
  15150. * - VertexBuffer.UV6Kind
  15151. * - VertexBuffer.ColorKind
  15152. * - VertexBuffer.MatricesIndicesKind
  15153. * - VertexBuffer.MatricesIndicesExtraKind
  15154. * - VertexBuffer.MatricesWeightsKind
  15155. * - VertexBuffer.MatricesWeightsExtraKind
  15156. *
  15157. * Returns the Mesh.
  15158. */
  15159. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15160. /**
  15161. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15162. * If the mesh has no geometry, it is simply returned as it is.
  15163. * The `data` are either a numeric array either a Float32Array.
  15164. * No new underlying VertexBuffer object is created.
  15165. * 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.
  15166. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15167. *
  15168. * Possible `kind` values :
  15169. * - VertexBuffer.PositionKind
  15170. * - VertexBuffer.UVKind
  15171. * - VertexBuffer.UV2Kind
  15172. * - VertexBuffer.UV3Kind
  15173. * - VertexBuffer.UV4Kind
  15174. * - VertexBuffer.UV5Kind
  15175. * - VertexBuffer.UV6Kind
  15176. * - VertexBuffer.ColorKind
  15177. * - VertexBuffer.MatricesIndicesKind
  15178. * - VertexBuffer.MatricesIndicesExtraKind
  15179. * - VertexBuffer.MatricesWeightsKind
  15180. * - VertexBuffer.MatricesWeightsExtraKind
  15181. *
  15182. * Returns the Mesh.
  15183. */
  15184. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15185. /**
  15186. * Sets the mesh indices.
  15187. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15188. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15189. * This method creates a new index buffer each call.
  15190. * Returns the Mesh.
  15191. */
  15192. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15193. /**
  15194. * Boolean : True if the mesh owns the requested kind of data.
  15195. */
  15196. isVerticesDataPresent(kind: string): boolean;
  15197. /**
  15198. * Returns an array of indices (IndicesArray).
  15199. */
  15200. getIndices(): Nullable<IndicesArray>;
  15201. get _positions(): Nullable<Vector3[]>;
  15202. /**
  15203. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15204. * This means the mesh underlying bounding box and sphere are recomputed.
  15205. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15206. * @returns the current mesh
  15207. */
  15208. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15209. /** @hidden */
  15210. _preActivate(): InstancedMesh;
  15211. /** @hidden */
  15212. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15213. /** @hidden */
  15214. _postActivate(): void;
  15215. getWorldMatrix(): Matrix;
  15216. get isAnInstance(): boolean;
  15217. /**
  15218. * Returns the current associated LOD AbstractMesh.
  15219. */
  15220. getLOD(camera: Camera): AbstractMesh;
  15221. /** @hidden */
  15222. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15223. /** @hidden */
  15224. _syncSubMeshes(): InstancedMesh;
  15225. /** @hidden */
  15226. _generatePointsArray(): boolean;
  15227. /**
  15228. * Creates a new InstancedMesh from the current mesh.
  15229. * - name (string) : the cloned mesh name
  15230. * - newParent (optional Node) : the optional Node to parent the clone to.
  15231. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15232. *
  15233. * Returns the clone.
  15234. */
  15235. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15236. /**
  15237. * Disposes the InstancedMesh.
  15238. * Returns nothing.
  15239. */
  15240. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15241. }
  15242. interface Mesh {
  15243. /**
  15244. * Register a custom buffer that will be instanced
  15245. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15246. * @param kind defines the buffer kind
  15247. * @param stride defines the stride in floats
  15248. */
  15249. registerInstancedBuffer(kind: string, stride: number): void;
  15250. /** @hidden */
  15251. _userInstancedBuffersStorage: {
  15252. data: {
  15253. [key: string]: Float32Array;
  15254. };
  15255. sizes: {
  15256. [key: string]: number;
  15257. };
  15258. vertexBuffers: {
  15259. [key: string]: Nullable<VertexBuffer>;
  15260. };
  15261. strides: {
  15262. [key: string]: number;
  15263. };
  15264. };
  15265. }
  15266. interface AbstractMesh {
  15267. /**
  15268. * Object used to store instanced buffers defined by user
  15269. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15270. */
  15271. instancedBuffers: {
  15272. [key: string]: any;
  15273. };
  15274. }
  15275. }
  15276. declare module BABYLON {
  15277. /**
  15278. * Defines the options associated with the creation of a shader material.
  15279. */
  15280. export interface IShaderMaterialOptions {
  15281. /**
  15282. * Does the material work in alpha blend mode
  15283. */
  15284. needAlphaBlending: boolean;
  15285. /**
  15286. * Does the material work in alpha test mode
  15287. */
  15288. needAlphaTesting: boolean;
  15289. /**
  15290. * The list of attribute names used in the shader
  15291. */
  15292. attributes: string[];
  15293. /**
  15294. * The list of unifrom names used in the shader
  15295. */
  15296. uniforms: string[];
  15297. /**
  15298. * The list of UBO names used in the shader
  15299. */
  15300. uniformBuffers: string[];
  15301. /**
  15302. * The list of sampler names used in the shader
  15303. */
  15304. samplers: string[];
  15305. /**
  15306. * The list of defines used in the shader
  15307. */
  15308. defines: string[];
  15309. }
  15310. /**
  15311. * 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.
  15312. *
  15313. * This returned material effects how the mesh will look based on the code in the shaders.
  15314. *
  15315. * @see http://doc.babylonjs.com/how_to/shader_material
  15316. */
  15317. export class ShaderMaterial extends Material {
  15318. private _shaderPath;
  15319. private _options;
  15320. private _textures;
  15321. private _textureArrays;
  15322. private _floats;
  15323. private _ints;
  15324. private _floatsArrays;
  15325. private _colors3;
  15326. private _colors3Arrays;
  15327. private _colors4;
  15328. private _colors4Arrays;
  15329. private _vectors2;
  15330. private _vectors3;
  15331. private _vectors4;
  15332. private _matrices;
  15333. private _matrixArrays;
  15334. private _matrices3x3;
  15335. private _matrices2x2;
  15336. private _vectors2Arrays;
  15337. private _vectors3Arrays;
  15338. private _vectors4Arrays;
  15339. private _cachedWorldViewMatrix;
  15340. private _cachedWorldViewProjectionMatrix;
  15341. private _renderId;
  15342. private _multiview;
  15343. /**
  15344. * Instantiate a new shader material.
  15345. * 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.
  15346. * This returned material effects how the mesh will look based on the code in the shaders.
  15347. * @see http://doc.babylonjs.com/how_to/shader_material
  15348. * @param name Define the name of the material in the scene
  15349. * @param scene Define the scene the material belongs to
  15350. * @param shaderPath Defines the route to the shader code in one of three ways:
  15351. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15352. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15353. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15354. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15355. * @param options Define the options used to create the shader
  15356. */
  15357. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15358. /**
  15359. * Gets the shader path used to define the shader code
  15360. * It can be modified to trigger a new compilation
  15361. */
  15362. get shaderPath(): any;
  15363. /**
  15364. * Sets the shader path used to define the shader code
  15365. * It can be modified to trigger a new compilation
  15366. */
  15367. set shaderPath(shaderPath: any);
  15368. /**
  15369. * Gets the options used to compile the shader.
  15370. * They can be modified to trigger a new compilation
  15371. */
  15372. get options(): IShaderMaterialOptions;
  15373. /**
  15374. * Gets the current class name of the material e.g. "ShaderMaterial"
  15375. * Mainly use in serialization.
  15376. * @returns the class name
  15377. */
  15378. getClassName(): string;
  15379. /**
  15380. * Specifies if the material will require alpha blending
  15381. * @returns a boolean specifying if alpha blending is needed
  15382. */
  15383. needAlphaBlending(): boolean;
  15384. /**
  15385. * Specifies if this material should be rendered in alpha test mode
  15386. * @returns a boolean specifying if an alpha test is needed.
  15387. */
  15388. needAlphaTesting(): boolean;
  15389. private _checkUniform;
  15390. /**
  15391. * Set a texture in the shader.
  15392. * @param name Define the name of the uniform samplers as defined in the shader
  15393. * @param texture Define the texture to bind to this sampler
  15394. * @return the material itself allowing "fluent" like uniform updates
  15395. */
  15396. setTexture(name: string, texture: Texture): ShaderMaterial;
  15397. /**
  15398. * Set a texture array in the shader.
  15399. * @param name Define the name of the uniform sampler array as defined in the shader
  15400. * @param textures Define the list of textures to bind to this sampler
  15401. * @return the material itself allowing "fluent" like uniform updates
  15402. */
  15403. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15404. /**
  15405. * Set a float in the shader.
  15406. * @param name Define the name of the uniform as defined in the shader
  15407. * @param value Define the value to give to the uniform
  15408. * @return the material itself allowing "fluent" like uniform updates
  15409. */
  15410. setFloat(name: string, value: number): ShaderMaterial;
  15411. /**
  15412. * Set a int in the shader.
  15413. * @param name Define the name of the uniform as defined in the shader
  15414. * @param value Define the value to give to the uniform
  15415. * @return the material itself allowing "fluent" like uniform updates
  15416. */
  15417. setInt(name: string, value: number): ShaderMaterial;
  15418. /**
  15419. * Set an array of floats in the shader.
  15420. * @param name Define the name of the uniform as defined in the shader
  15421. * @param value Define the value to give to the uniform
  15422. * @return the material itself allowing "fluent" like uniform updates
  15423. */
  15424. setFloats(name: string, value: number[]): ShaderMaterial;
  15425. /**
  15426. * Set a vec3 in the shader from a Color3.
  15427. * @param name Define the name of the uniform as defined in the shader
  15428. * @param value Define the value to give to the uniform
  15429. * @return the material itself allowing "fluent" like uniform updates
  15430. */
  15431. setColor3(name: string, value: Color3): ShaderMaterial;
  15432. /**
  15433. * Set a vec3 array in the shader from a Color3 array.
  15434. * @param name Define the name of the uniform as defined in the shader
  15435. * @param value Define the value to give to the uniform
  15436. * @return the material itself allowing "fluent" like uniform updates
  15437. */
  15438. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15439. /**
  15440. * Set a vec4 in the shader from a Color4.
  15441. * @param name Define the name of the uniform as defined in the shader
  15442. * @param value Define the value to give to the uniform
  15443. * @return the material itself allowing "fluent" like uniform updates
  15444. */
  15445. setColor4(name: string, value: Color4): ShaderMaterial;
  15446. /**
  15447. * Set a vec4 array in the shader from a Color4 array.
  15448. * @param name Define the name of the uniform as defined in the shader
  15449. * @param value Define the value to give to the uniform
  15450. * @return the material itself allowing "fluent" like uniform updates
  15451. */
  15452. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15453. /**
  15454. * Set a vec2 in the shader from a Vector2.
  15455. * @param name Define the name of the uniform as defined in the shader
  15456. * @param value Define the value to give to the uniform
  15457. * @return the material itself allowing "fluent" like uniform updates
  15458. */
  15459. setVector2(name: string, value: Vector2): ShaderMaterial;
  15460. /**
  15461. * Set a vec3 in the shader from a Vector3.
  15462. * @param name Define the name of the uniform as defined in the shader
  15463. * @param value Define the value to give to the uniform
  15464. * @return the material itself allowing "fluent" like uniform updates
  15465. */
  15466. setVector3(name: string, value: Vector3): ShaderMaterial;
  15467. /**
  15468. * Set a vec4 in the shader from a Vector4.
  15469. * @param name Define the name of the uniform as defined in the shader
  15470. * @param value Define the value to give to the uniform
  15471. * @return the material itself allowing "fluent" like uniform updates
  15472. */
  15473. setVector4(name: string, value: Vector4): ShaderMaterial;
  15474. /**
  15475. * Set a mat4 in the shader from a Matrix.
  15476. * @param name Define the name of the uniform as defined in the shader
  15477. * @param value Define the value to give to the uniform
  15478. * @return the material itself allowing "fluent" like uniform updates
  15479. */
  15480. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15481. /**
  15482. * Set a float32Array in the shader from a matrix array.
  15483. * @param name Define the name of the uniform as defined in the shader
  15484. * @param value Define the value to give to the uniform
  15485. * @return the material itself allowing "fluent" like uniform updates
  15486. */
  15487. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15488. /**
  15489. * Set a mat3 in the shader from a Float32Array.
  15490. * @param name Define the name of the uniform as defined in the shader
  15491. * @param value Define the value to give to the uniform
  15492. * @return the material itself allowing "fluent" like uniform updates
  15493. */
  15494. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15495. /**
  15496. * Set a mat2 in the shader from a Float32Array.
  15497. * @param name Define the name of the uniform as defined in the shader
  15498. * @param value Define the value to give to the uniform
  15499. * @return the material itself allowing "fluent" like uniform updates
  15500. */
  15501. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15502. /**
  15503. * Set a vec2 array in the shader from a number array.
  15504. * @param name Define the name of the uniform as defined in the shader
  15505. * @param value Define the value to give to the uniform
  15506. * @return the material itself allowing "fluent" like uniform updates
  15507. */
  15508. setArray2(name: string, value: number[]): ShaderMaterial;
  15509. /**
  15510. * Set a vec3 array in the shader from a number array.
  15511. * @param name Define the name of the uniform as defined in the shader
  15512. * @param value Define the value to give to the uniform
  15513. * @return the material itself allowing "fluent" like uniform updates
  15514. */
  15515. setArray3(name: string, value: number[]): ShaderMaterial;
  15516. /**
  15517. * Set a vec4 array in the shader from a number array.
  15518. * @param name Define the name of the uniform as defined in the shader
  15519. * @param value Define the value to give to the uniform
  15520. * @return the material itself allowing "fluent" like uniform updates
  15521. */
  15522. setArray4(name: string, value: number[]): ShaderMaterial;
  15523. private _checkCache;
  15524. /**
  15525. * Specifies that the submesh is ready to be used
  15526. * @param mesh defines the mesh to check
  15527. * @param subMesh defines which submesh to check
  15528. * @param useInstances specifies that instances should be used
  15529. * @returns a boolean indicating that the submesh is ready or not
  15530. */
  15531. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15532. /**
  15533. * Checks if the material is ready to render the requested mesh
  15534. * @param mesh Define the mesh to render
  15535. * @param useInstances Define whether or not the material is used with instances
  15536. * @returns true if ready, otherwise false
  15537. */
  15538. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15539. /**
  15540. * Binds the world matrix to the material
  15541. * @param world defines the world transformation matrix
  15542. */
  15543. bindOnlyWorldMatrix(world: Matrix): void;
  15544. /**
  15545. * Binds the material to the mesh
  15546. * @param world defines the world transformation matrix
  15547. * @param mesh defines the mesh to bind the material to
  15548. */
  15549. bind(world: Matrix, mesh?: Mesh): void;
  15550. /**
  15551. * Gets the active textures from the material
  15552. * @returns an array of textures
  15553. */
  15554. getActiveTextures(): BaseTexture[];
  15555. /**
  15556. * Specifies if the material uses a texture
  15557. * @param texture defines the texture to check against the material
  15558. * @returns a boolean specifying if the material uses the texture
  15559. */
  15560. hasTexture(texture: BaseTexture): boolean;
  15561. /**
  15562. * Makes a duplicate of the material, and gives it a new name
  15563. * @param name defines the new name for the duplicated material
  15564. * @returns the cloned material
  15565. */
  15566. clone(name: string): ShaderMaterial;
  15567. /**
  15568. * Disposes the material
  15569. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15570. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15571. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15572. */
  15573. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15574. /**
  15575. * Serializes this material in a JSON representation
  15576. * @returns the serialized material object
  15577. */
  15578. serialize(): any;
  15579. /**
  15580. * Creates a shader material from parsed shader material data
  15581. * @param source defines the JSON represnetation of the material
  15582. * @param scene defines the hosting scene
  15583. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15584. * @returns a new material
  15585. */
  15586. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15587. }
  15588. }
  15589. declare module BABYLON {
  15590. /** @hidden */
  15591. export var colorPixelShader: {
  15592. name: string;
  15593. shader: string;
  15594. };
  15595. }
  15596. declare module BABYLON {
  15597. /** @hidden */
  15598. export var colorVertexShader: {
  15599. name: string;
  15600. shader: string;
  15601. };
  15602. }
  15603. declare module BABYLON {
  15604. /**
  15605. * Line mesh
  15606. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15607. */
  15608. export class LinesMesh extends Mesh {
  15609. /**
  15610. * If vertex color should be applied to the mesh
  15611. */
  15612. readonly useVertexColor?: boolean | undefined;
  15613. /**
  15614. * If vertex alpha should be applied to the mesh
  15615. */
  15616. readonly useVertexAlpha?: boolean | undefined;
  15617. /**
  15618. * Color of the line (Default: White)
  15619. */
  15620. color: Color3;
  15621. /**
  15622. * Alpha of the line (Default: 1)
  15623. */
  15624. alpha: number;
  15625. /**
  15626. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15627. * This margin is expressed in world space coordinates, so its value may vary.
  15628. * Default value is 0.1
  15629. */
  15630. intersectionThreshold: number;
  15631. private _colorShader;
  15632. private color4;
  15633. /**
  15634. * Creates a new LinesMesh
  15635. * @param name defines the name
  15636. * @param scene defines the hosting scene
  15637. * @param parent defines the parent mesh if any
  15638. * @param source defines the optional source LinesMesh used to clone data from
  15639. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15640. * When false, achieved by calling a clone(), also passing False.
  15641. * This will make creation of children, recursive.
  15642. * @param useVertexColor defines if this LinesMesh supports vertex color
  15643. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15644. */
  15645. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15646. /**
  15647. * If vertex color should be applied to the mesh
  15648. */
  15649. useVertexColor?: boolean | undefined,
  15650. /**
  15651. * If vertex alpha should be applied to the mesh
  15652. */
  15653. useVertexAlpha?: boolean | undefined);
  15654. private _addClipPlaneDefine;
  15655. private _removeClipPlaneDefine;
  15656. isReady(): boolean;
  15657. /**
  15658. * Returns the string "LineMesh"
  15659. */
  15660. getClassName(): string;
  15661. /**
  15662. * @hidden
  15663. */
  15664. get material(): Material;
  15665. /**
  15666. * @hidden
  15667. */
  15668. set material(value: Material);
  15669. /**
  15670. * @hidden
  15671. */
  15672. get checkCollisions(): boolean;
  15673. /** @hidden */
  15674. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15675. /** @hidden */
  15676. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15677. /**
  15678. * Disposes of the line mesh
  15679. * @param doNotRecurse If children should be disposed
  15680. */
  15681. dispose(doNotRecurse?: boolean): void;
  15682. /**
  15683. * Returns a new LineMesh object cloned from the current one.
  15684. */
  15685. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15686. /**
  15687. * Creates a new InstancedLinesMesh object from the mesh model.
  15688. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15689. * @param name defines the name of the new instance
  15690. * @returns a new InstancedLinesMesh
  15691. */
  15692. createInstance(name: string): InstancedLinesMesh;
  15693. }
  15694. /**
  15695. * Creates an instance based on a source LinesMesh
  15696. */
  15697. export class InstancedLinesMesh extends InstancedMesh {
  15698. /**
  15699. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15700. * This margin is expressed in world space coordinates, so its value may vary.
  15701. * Initilized with the intersectionThreshold value of the source LinesMesh
  15702. */
  15703. intersectionThreshold: number;
  15704. constructor(name: string, source: LinesMesh);
  15705. /**
  15706. * Returns the string "InstancedLinesMesh".
  15707. */
  15708. getClassName(): string;
  15709. }
  15710. }
  15711. declare module BABYLON {
  15712. /** @hidden */
  15713. export var linePixelShader: {
  15714. name: string;
  15715. shader: string;
  15716. };
  15717. }
  15718. declare module BABYLON {
  15719. /** @hidden */
  15720. export var lineVertexShader: {
  15721. name: string;
  15722. shader: string;
  15723. };
  15724. }
  15725. declare module BABYLON {
  15726. interface AbstractMesh {
  15727. /**
  15728. * Gets the edgesRenderer associated with the mesh
  15729. */
  15730. edgesRenderer: Nullable<EdgesRenderer>;
  15731. }
  15732. interface LinesMesh {
  15733. /**
  15734. * Enables the edge rendering mode on the mesh.
  15735. * This mode makes the mesh edges visible
  15736. * @param epsilon defines the maximal distance between two angles to detect a face
  15737. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15738. * @returns the currentAbstractMesh
  15739. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15740. */
  15741. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15742. }
  15743. interface InstancedLinesMesh {
  15744. /**
  15745. * Enables the edge rendering mode on the mesh.
  15746. * This mode makes the mesh edges visible
  15747. * @param epsilon defines the maximal distance between two angles to detect a face
  15748. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15749. * @returns the current InstancedLinesMesh
  15750. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15751. */
  15752. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15753. }
  15754. /**
  15755. * Defines the minimum contract an Edges renderer should follow.
  15756. */
  15757. export interface IEdgesRenderer extends IDisposable {
  15758. /**
  15759. * Gets or sets a boolean indicating if the edgesRenderer is active
  15760. */
  15761. isEnabled: boolean;
  15762. /**
  15763. * Renders the edges of the attached mesh,
  15764. */
  15765. render(): void;
  15766. /**
  15767. * Checks wether or not the edges renderer is ready to render.
  15768. * @return true if ready, otherwise false.
  15769. */
  15770. isReady(): boolean;
  15771. }
  15772. /**
  15773. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15774. */
  15775. export class EdgesRenderer implements IEdgesRenderer {
  15776. /**
  15777. * Define the size of the edges with an orthographic camera
  15778. */
  15779. edgesWidthScalerForOrthographic: number;
  15780. /**
  15781. * Define the size of the edges with a perspective camera
  15782. */
  15783. edgesWidthScalerForPerspective: number;
  15784. protected _source: AbstractMesh;
  15785. protected _linesPositions: number[];
  15786. protected _linesNormals: number[];
  15787. protected _linesIndices: number[];
  15788. protected _epsilon: number;
  15789. protected _indicesCount: number;
  15790. protected _lineShader: ShaderMaterial;
  15791. protected _ib: DataBuffer;
  15792. protected _buffers: {
  15793. [key: string]: Nullable<VertexBuffer>;
  15794. };
  15795. protected _checkVerticesInsteadOfIndices: boolean;
  15796. private _meshRebuildObserver;
  15797. private _meshDisposeObserver;
  15798. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15799. isEnabled: boolean;
  15800. /**
  15801. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15802. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15803. * @param source Mesh used to create edges
  15804. * @param epsilon sum of angles in adjacency to check for edge
  15805. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15806. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15807. */
  15808. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15809. protected _prepareRessources(): void;
  15810. /** @hidden */
  15811. _rebuild(): void;
  15812. /**
  15813. * Releases the required resources for the edges renderer
  15814. */
  15815. dispose(): void;
  15816. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15817. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15818. /**
  15819. * Checks if the pair of p0 and p1 is en edge
  15820. * @param faceIndex
  15821. * @param edge
  15822. * @param faceNormals
  15823. * @param p0
  15824. * @param p1
  15825. * @private
  15826. */
  15827. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15828. /**
  15829. * push line into the position, normal and index buffer
  15830. * @protected
  15831. */
  15832. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15833. /**
  15834. * Generates lines edges from adjacencjes
  15835. * @private
  15836. */
  15837. _generateEdgesLines(): void;
  15838. /**
  15839. * Checks wether or not the edges renderer is ready to render.
  15840. * @return true if ready, otherwise false.
  15841. */
  15842. isReady(): boolean;
  15843. /**
  15844. * Renders the edges of the attached mesh,
  15845. */
  15846. render(): void;
  15847. }
  15848. /**
  15849. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15850. */
  15851. export class LineEdgesRenderer extends EdgesRenderer {
  15852. /**
  15853. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15854. * @param source LineMesh used to generate edges
  15855. * @param epsilon not important (specified angle for edge detection)
  15856. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15857. */
  15858. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15859. /**
  15860. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15861. */
  15862. _generateEdgesLines(): void;
  15863. }
  15864. }
  15865. declare module BABYLON {
  15866. /**
  15867. * This represents the object necessary to create a rendering group.
  15868. * This is exclusively used and created by the rendering manager.
  15869. * To modify the behavior, you use the available helpers in your scene or meshes.
  15870. * @hidden
  15871. */
  15872. export class RenderingGroup {
  15873. index: number;
  15874. private static _zeroVector;
  15875. private _scene;
  15876. private _opaqueSubMeshes;
  15877. private _transparentSubMeshes;
  15878. private _alphaTestSubMeshes;
  15879. private _depthOnlySubMeshes;
  15880. private _particleSystems;
  15881. private _spriteManagers;
  15882. private _opaqueSortCompareFn;
  15883. private _alphaTestSortCompareFn;
  15884. private _transparentSortCompareFn;
  15885. private _renderOpaque;
  15886. private _renderAlphaTest;
  15887. private _renderTransparent;
  15888. /** @hidden */
  15889. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15890. onBeforeTransparentRendering: () => void;
  15891. /**
  15892. * Set the opaque sort comparison function.
  15893. * If null the sub meshes will be render in the order they were created
  15894. */
  15895. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15896. /**
  15897. * Set the alpha test sort comparison function.
  15898. * If null the sub meshes will be render in the order they were created
  15899. */
  15900. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15901. /**
  15902. * Set the transparent sort comparison function.
  15903. * If null the sub meshes will be render in the order they were created
  15904. */
  15905. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15906. /**
  15907. * Creates a new rendering group.
  15908. * @param index The rendering group index
  15909. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15910. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15911. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15912. */
  15913. 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>);
  15914. /**
  15915. * Render all the sub meshes contained in the group.
  15916. * @param customRenderFunction Used to override the default render behaviour of the group.
  15917. * @returns true if rendered some submeshes.
  15918. */
  15919. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15920. /**
  15921. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15922. * @param subMeshes The submeshes to render
  15923. */
  15924. private renderOpaqueSorted;
  15925. /**
  15926. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15927. * @param subMeshes The submeshes to render
  15928. */
  15929. private renderAlphaTestSorted;
  15930. /**
  15931. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15932. * @param subMeshes The submeshes to render
  15933. */
  15934. private renderTransparentSorted;
  15935. /**
  15936. * Renders the submeshes in a specified order.
  15937. * @param subMeshes The submeshes to sort before render
  15938. * @param sortCompareFn The comparison function use to sort
  15939. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15940. * @param transparent Specifies to activate blending if true
  15941. */
  15942. private static renderSorted;
  15943. /**
  15944. * Renders the submeshes in the order they were dispatched (no sort applied).
  15945. * @param subMeshes The submeshes to render
  15946. */
  15947. private static renderUnsorted;
  15948. /**
  15949. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15950. * are rendered back to front if in the same alpha index.
  15951. *
  15952. * @param a The first submesh
  15953. * @param b The second submesh
  15954. * @returns The result of the comparison
  15955. */
  15956. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15957. /**
  15958. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15959. * are rendered back to front.
  15960. *
  15961. * @param a The first submesh
  15962. * @param b The second submesh
  15963. * @returns The result of the comparison
  15964. */
  15965. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  15966. /**
  15967. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15968. * are rendered front to back (prevent overdraw).
  15969. *
  15970. * @param a The first submesh
  15971. * @param b The second submesh
  15972. * @returns The result of the comparison
  15973. */
  15974. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  15975. /**
  15976. * Resets the different lists of submeshes to prepare a new frame.
  15977. */
  15978. prepare(): void;
  15979. dispose(): void;
  15980. /**
  15981. * Inserts the submesh in its correct queue depending on its material.
  15982. * @param subMesh The submesh to dispatch
  15983. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  15984. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  15985. */
  15986. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  15987. dispatchSprites(spriteManager: ISpriteManager): void;
  15988. dispatchParticles(particleSystem: IParticleSystem): void;
  15989. private _renderParticles;
  15990. private _renderSprites;
  15991. }
  15992. }
  15993. declare module BABYLON {
  15994. /**
  15995. * Interface describing the different options available in the rendering manager
  15996. * regarding Auto Clear between groups.
  15997. */
  15998. export interface IRenderingManagerAutoClearSetup {
  15999. /**
  16000. * Defines whether or not autoclear is enable.
  16001. */
  16002. autoClear: boolean;
  16003. /**
  16004. * Defines whether or not to autoclear the depth buffer.
  16005. */
  16006. depth: boolean;
  16007. /**
  16008. * Defines whether or not to autoclear the stencil buffer.
  16009. */
  16010. stencil: boolean;
  16011. }
  16012. /**
  16013. * This class is used by the onRenderingGroupObservable
  16014. */
  16015. export class RenderingGroupInfo {
  16016. /**
  16017. * The Scene that being rendered
  16018. */
  16019. scene: Scene;
  16020. /**
  16021. * The camera currently used for the rendering pass
  16022. */
  16023. camera: Nullable<Camera>;
  16024. /**
  16025. * The ID of the renderingGroup being processed
  16026. */
  16027. renderingGroupId: number;
  16028. }
  16029. /**
  16030. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16031. * It is enable to manage the different groups as well as the different necessary sort functions.
  16032. * This should not be used directly aside of the few static configurations
  16033. */
  16034. export class RenderingManager {
  16035. /**
  16036. * The max id used for rendering groups (not included)
  16037. */
  16038. static MAX_RENDERINGGROUPS: number;
  16039. /**
  16040. * The min id used for rendering groups (included)
  16041. */
  16042. static MIN_RENDERINGGROUPS: number;
  16043. /**
  16044. * Used to globally prevent autoclearing scenes.
  16045. */
  16046. static AUTOCLEAR: boolean;
  16047. /**
  16048. * @hidden
  16049. */
  16050. _useSceneAutoClearSetup: boolean;
  16051. private _scene;
  16052. private _renderingGroups;
  16053. private _depthStencilBufferAlreadyCleaned;
  16054. private _autoClearDepthStencil;
  16055. private _customOpaqueSortCompareFn;
  16056. private _customAlphaTestSortCompareFn;
  16057. private _customTransparentSortCompareFn;
  16058. private _renderingGroupInfo;
  16059. /**
  16060. * Instantiates a new rendering group for a particular scene
  16061. * @param scene Defines the scene the groups belongs to
  16062. */
  16063. constructor(scene: Scene);
  16064. private _clearDepthStencilBuffer;
  16065. /**
  16066. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16067. * @hidden
  16068. */
  16069. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16070. /**
  16071. * Resets the different information of the group to prepare a new frame
  16072. * @hidden
  16073. */
  16074. reset(): void;
  16075. /**
  16076. * Dispose and release the group and its associated resources.
  16077. * @hidden
  16078. */
  16079. dispose(): void;
  16080. /**
  16081. * Clear the info related to rendering groups preventing retention points during dispose.
  16082. */
  16083. freeRenderingGroups(): void;
  16084. private _prepareRenderingGroup;
  16085. /**
  16086. * Add a sprite manager to the rendering manager in order to render it this frame.
  16087. * @param spriteManager Define the sprite manager to render
  16088. */
  16089. dispatchSprites(spriteManager: ISpriteManager): void;
  16090. /**
  16091. * Add a particle system to the rendering manager in order to render it this frame.
  16092. * @param particleSystem Define the particle system to render
  16093. */
  16094. dispatchParticles(particleSystem: IParticleSystem): void;
  16095. /**
  16096. * Add a submesh to the manager in order to render it this frame
  16097. * @param subMesh The submesh to dispatch
  16098. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16099. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16100. */
  16101. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16102. /**
  16103. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16104. * This allowed control for front to back rendering or reversly depending of the special needs.
  16105. *
  16106. * @param renderingGroupId The rendering group id corresponding to its index
  16107. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16108. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16109. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16110. */
  16111. 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;
  16112. /**
  16113. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16114. *
  16115. * @param renderingGroupId The rendering group id corresponding to its index
  16116. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16117. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16118. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16119. */
  16120. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16121. /**
  16122. * Gets the current auto clear configuration for one rendering group of the rendering
  16123. * manager.
  16124. * @param index the rendering group index to get the information for
  16125. * @returns The auto clear setup for the requested rendering group
  16126. */
  16127. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16128. }
  16129. }
  16130. declare module BABYLON {
  16131. /**
  16132. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16133. */
  16134. export interface ICustomShaderOptions {
  16135. /**
  16136. * Gets or sets the custom shader name to use
  16137. */
  16138. shaderName: string;
  16139. /**
  16140. * The list of attribute names used in the shader
  16141. */
  16142. attributes?: string[];
  16143. /**
  16144. * The list of unifrom names used in the shader
  16145. */
  16146. uniforms?: string[];
  16147. /**
  16148. * The list of sampler names used in the shader
  16149. */
  16150. samplers?: string[];
  16151. /**
  16152. * The list of defines used in the shader
  16153. */
  16154. defines?: string[];
  16155. }
  16156. /**
  16157. * Interface to implement to create a shadow generator compatible with BJS.
  16158. */
  16159. export interface IShadowGenerator {
  16160. /**
  16161. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16162. * @returns The render target texture if present otherwise, null
  16163. */
  16164. getShadowMap(): Nullable<RenderTargetTexture>;
  16165. /**
  16166. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16167. * @param subMesh The submesh we want to render in the shadow map
  16168. * @param useInstances Defines wether will draw in the map using instances
  16169. * @returns true if ready otherwise, false
  16170. */
  16171. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16172. /**
  16173. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16174. * @param defines Defines of the material we want to update
  16175. * @param lightIndex Index of the light in the enabled light list of the material
  16176. */
  16177. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16178. /**
  16179. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16180. * defined in the generator but impacting the effect).
  16181. * It implies the unifroms available on the materials are the standard BJS ones.
  16182. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16183. * @param effect The effect we are binfing the information for
  16184. */
  16185. bindShadowLight(lightIndex: string, effect: Effect): void;
  16186. /**
  16187. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16188. * (eq to shadow prjection matrix * light transform matrix)
  16189. * @returns The transform matrix used to create the shadow map
  16190. */
  16191. getTransformMatrix(): Matrix;
  16192. /**
  16193. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16194. * Cube and 2D textures for instance.
  16195. */
  16196. recreateShadowMap(): void;
  16197. /**
  16198. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16199. * @param onCompiled Callback triggered at the and of the effects compilation
  16200. * @param options Sets of optional options forcing the compilation with different modes
  16201. */
  16202. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16203. useInstances: boolean;
  16204. }>): void;
  16205. /**
  16206. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16207. * @param options Sets of optional options forcing the compilation with different modes
  16208. * @returns A promise that resolves when the compilation completes
  16209. */
  16210. forceCompilationAsync(options?: Partial<{
  16211. useInstances: boolean;
  16212. }>): Promise<void>;
  16213. /**
  16214. * Serializes the shadow generator setup to a json object.
  16215. * @returns The serialized JSON object
  16216. */
  16217. serialize(): any;
  16218. /**
  16219. * Disposes the Shadow map and related Textures and effects.
  16220. */
  16221. dispose(): void;
  16222. }
  16223. /**
  16224. * Default implementation IShadowGenerator.
  16225. * This is the main object responsible of generating shadows in the framework.
  16226. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16227. */
  16228. export class ShadowGenerator implements IShadowGenerator {
  16229. /**
  16230. * Name of the shadow generator class
  16231. */
  16232. static CLASSNAME: string;
  16233. /**
  16234. * Shadow generator mode None: no filtering applied.
  16235. */
  16236. static readonly FILTER_NONE: number;
  16237. /**
  16238. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16239. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16240. */
  16241. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16242. /**
  16243. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16244. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16245. */
  16246. static readonly FILTER_POISSONSAMPLING: number;
  16247. /**
  16248. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16249. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16250. */
  16251. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16252. /**
  16253. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16254. * edge artifacts on steep falloff.
  16255. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16256. */
  16257. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16258. /**
  16259. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16260. * edge artifacts on steep falloff.
  16261. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16262. */
  16263. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16264. /**
  16265. * Shadow generator mode PCF: Percentage Closer Filtering
  16266. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16267. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16268. */
  16269. static readonly FILTER_PCF: number;
  16270. /**
  16271. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16272. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16273. * Contact Hardening
  16274. */
  16275. static readonly FILTER_PCSS: number;
  16276. /**
  16277. * Reserved for PCF and PCSS
  16278. * Highest Quality.
  16279. *
  16280. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16281. *
  16282. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16283. */
  16284. static readonly QUALITY_HIGH: number;
  16285. /**
  16286. * Reserved for PCF and PCSS
  16287. * Good tradeoff for quality/perf cross devices
  16288. *
  16289. * Execute PCF on a 3*3 kernel.
  16290. *
  16291. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16292. */
  16293. static readonly QUALITY_MEDIUM: number;
  16294. /**
  16295. * Reserved for PCF and PCSS
  16296. * The lowest quality but the fastest.
  16297. *
  16298. * Execute PCF on a 1*1 kernel.
  16299. *
  16300. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16301. */
  16302. static readonly QUALITY_LOW: number;
  16303. /** Gets or sets the custom shader name to use */
  16304. customShaderOptions: ICustomShaderOptions;
  16305. /**
  16306. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16307. */
  16308. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16309. /**
  16310. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16311. */
  16312. onAfterShadowMapRenderObservable: Observable<Effect>;
  16313. /**
  16314. * Observable triggered before a mesh is rendered in the shadow map.
  16315. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16316. */
  16317. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16318. /**
  16319. * Observable triggered after a mesh is rendered in the shadow map.
  16320. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16321. */
  16322. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16323. protected _bias: number;
  16324. /**
  16325. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16326. */
  16327. get bias(): number;
  16328. /**
  16329. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16330. */
  16331. set bias(bias: number);
  16332. protected _normalBias: number;
  16333. /**
  16334. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16335. */
  16336. get normalBias(): number;
  16337. /**
  16338. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16339. */
  16340. set normalBias(normalBias: number);
  16341. protected _blurBoxOffset: number;
  16342. /**
  16343. * Gets the blur box offset: offset applied during the blur pass.
  16344. * Only useful if useKernelBlur = false
  16345. */
  16346. get blurBoxOffset(): number;
  16347. /**
  16348. * Sets the blur box offset: offset applied during the blur pass.
  16349. * Only useful if useKernelBlur = false
  16350. */
  16351. set blurBoxOffset(value: number);
  16352. protected _blurScale: number;
  16353. /**
  16354. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16355. * 2 means half of the size.
  16356. */
  16357. get blurScale(): number;
  16358. /**
  16359. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16360. * 2 means half of the size.
  16361. */
  16362. set blurScale(value: number);
  16363. protected _blurKernel: number;
  16364. /**
  16365. * Gets the blur kernel: kernel size of the blur pass.
  16366. * Only useful if useKernelBlur = true
  16367. */
  16368. get blurKernel(): number;
  16369. /**
  16370. * Sets the blur kernel: kernel size of the blur pass.
  16371. * Only useful if useKernelBlur = true
  16372. */
  16373. set blurKernel(value: number);
  16374. protected _useKernelBlur: boolean;
  16375. /**
  16376. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16377. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16378. */
  16379. get useKernelBlur(): boolean;
  16380. /**
  16381. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16382. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16383. */
  16384. set useKernelBlur(value: boolean);
  16385. protected _depthScale: number;
  16386. /**
  16387. * Gets the depth scale used in ESM mode.
  16388. */
  16389. get depthScale(): number;
  16390. /**
  16391. * Sets the depth scale used in ESM mode.
  16392. * This can override the scale stored on the light.
  16393. */
  16394. set depthScale(value: number);
  16395. protected _validateFilter(filter: number): number;
  16396. protected _filter: number;
  16397. /**
  16398. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16399. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16400. */
  16401. get filter(): number;
  16402. /**
  16403. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16404. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16405. */
  16406. set filter(value: number);
  16407. /**
  16408. * Gets if the current filter is set to Poisson Sampling.
  16409. */
  16410. get usePoissonSampling(): boolean;
  16411. /**
  16412. * Sets the current filter to Poisson Sampling.
  16413. */
  16414. set usePoissonSampling(value: boolean);
  16415. /**
  16416. * Gets if the current filter is set to ESM.
  16417. */
  16418. get useExponentialShadowMap(): boolean;
  16419. /**
  16420. * Sets the current filter is to ESM.
  16421. */
  16422. set useExponentialShadowMap(value: boolean);
  16423. /**
  16424. * Gets if the current filter is set to filtered ESM.
  16425. */
  16426. get useBlurExponentialShadowMap(): boolean;
  16427. /**
  16428. * Gets if the current filter is set to filtered ESM.
  16429. */
  16430. set useBlurExponentialShadowMap(value: boolean);
  16431. /**
  16432. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16433. * exponential to prevent steep falloff artifacts).
  16434. */
  16435. get useCloseExponentialShadowMap(): boolean;
  16436. /**
  16437. * Sets the current filter to "close ESM" (using the inverse of the
  16438. * exponential to prevent steep falloff artifacts).
  16439. */
  16440. set useCloseExponentialShadowMap(value: boolean);
  16441. /**
  16442. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16443. * exponential to prevent steep falloff artifacts).
  16444. */
  16445. get useBlurCloseExponentialShadowMap(): boolean;
  16446. /**
  16447. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16448. * exponential to prevent steep falloff artifacts).
  16449. */
  16450. set useBlurCloseExponentialShadowMap(value: boolean);
  16451. /**
  16452. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16453. */
  16454. get usePercentageCloserFiltering(): boolean;
  16455. /**
  16456. * Sets the current filter to "PCF" (percentage closer filtering).
  16457. */
  16458. set usePercentageCloserFiltering(value: boolean);
  16459. protected _filteringQuality: number;
  16460. /**
  16461. * Gets the PCF or PCSS Quality.
  16462. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16463. */
  16464. get filteringQuality(): number;
  16465. /**
  16466. * Sets the PCF or PCSS Quality.
  16467. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16468. */
  16469. set filteringQuality(filteringQuality: number);
  16470. /**
  16471. * Gets if the current filter is set to "PCSS" (contact hardening).
  16472. */
  16473. get useContactHardeningShadow(): boolean;
  16474. /**
  16475. * Sets the current filter to "PCSS" (contact hardening).
  16476. */
  16477. set useContactHardeningShadow(value: boolean);
  16478. protected _contactHardeningLightSizeUVRatio: number;
  16479. /**
  16480. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16481. * Using a ratio helps keeping shape stability independently of the map size.
  16482. *
  16483. * It does not account for the light projection as it was having too much
  16484. * instability during the light setup or during light position changes.
  16485. *
  16486. * Only valid if useContactHardeningShadow is true.
  16487. */
  16488. get contactHardeningLightSizeUVRatio(): number;
  16489. /**
  16490. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16491. * Using a ratio helps keeping shape stability independently of the map size.
  16492. *
  16493. * It does not account for the light projection as it was having too much
  16494. * instability during the light setup or during light position changes.
  16495. *
  16496. * Only valid if useContactHardeningShadow is true.
  16497. */
  16498. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16499. protected _darkness: number;
  16500. /** Gets or sets the actual darkness of a shadow */
  16501. get darkness(): number;
  16502. set darkness(value: number);
  16503. /**
  16504. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16505. * 0 means strongest and 1 would means no shadow.
  16506. * @returns the darkness.
  16507. */
  16508. getDarkness(): number;
  16509. /**
  16510. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16511. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16512. * @returns the shadow generator allowing fluent coding.
  16513. */
  16514. setDarkness(darkness: number): ShadowGenerator;
  16515. protected _transparencyShadow: boolean;
  16516. /** Gets or sets the ability to have transparent shadow */
  16517. get transparencyShadow(): boolean;
  16518. set transparencyShadow(value: boolean);
  16519. /**
  16520. * Sets the ability to have transparent shadow (boolean).
  16521. * @param transparent True if transparent else False
  16522. * @returns the shadow generator allowing fluent coding
  16523. */
  16524. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16525. protected _shadowMap: Nullable<RenderTargetTexture>;
  16526. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16527. /**
  16528. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16529. * @returns The render target texture if present otherwise, null
  16530. */
  16531. getShadowMap(): Nullable<RenderTargetTexture>;
  16532. /**
  16533. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16534. * @returns The render target texture if the shadow map is present otherwise, null
  16535. */
  16536. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16537. /**
  16538. * Gets the class name of that object
  16539. * @returns "ShadowGenerator"
  16540. */
  16541. getClassName(): string;
  16542. /**
  16543. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16544. * @param mesh Mesh to add
  16545. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16546. * @returns the Shadow Generator itself
  16547. */
  16548. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16549. /**
  16550. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16551. * @param mesh Mesh to remove
  16552. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16553. * @returns the Shadow Generator itself
  16554. */
  16555. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16556. /**
  16557. * Controls the extent to which the shadows fade out at the edge of the frustum
  16558. */
  16559. frustumEdgeFalloff: number;
  16560. protected _light: IShadowLight;
  16561. /**
  16562. * Returns the associated light object.
  16563. * @returns the light generating the shadow
  16564. */
  16565. getLight(): IShadowLight;
  16566. /**
  16567. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16568. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16569. * It might on the other hand introduce peter panning.
  16570. */
  16571. forceBackFacesOnly: boolean;
  16572. protected _scene: Scene;
  16573. protected _lightDirection: Vector3;
  16574. protected _effect: Effect;
  16575. protected _viewMatrix: Matrix;
  16576. protected _projectionMatrix: Matrix;
  16577. protected _transformMatrix: Matrix;
  16578. protected _cachedPosition: Vector3;
  16579. protected _cachedDirection: Vector3;
  16580. protected _cachedDefines: string;
  16581. protected _currentRenderID: number;
  16582. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16583. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16584. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16585. protected _blurPostProcesses: PostProcess[];
  16586. protected _mapSize: number;
  16587. protected _currentFaceIndex: number;
  16588. protected _currentFaceIndexCache: number;
  16589. protected _textureType: number;
  16590. protected _defaultTextureMatrix: Matrix;
  16591. protected _storedUniqueId: Nullable<number>;
  16592. /** @hidden */
  16593. static _SceneComponentInitialization: (scene: Scene) => void;
  16594. /**
  16595. * Creates a ShadowGenerator object.
  16596. * A ShadowGenerator is the required tool to use the shadows.
  16597. * Each light casting shadows needs to use its own ShadowGenerator.
  16598. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16599. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16600. * @param light The light object generating the shadows.
  16601. * @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.
  16602. */
  16603. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16604. protected _initializeGenerator(): void;
  16605. protected _createTargetRenderTexture(): void;
  16606. protected _initializeShadowMap(): void;
  16607. protected _initializeBlurRTTAndPostProcesses(): void;
  16608. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16609. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16610. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16611. protected _applyFilterValues(): void;
  16612. /**
  16613. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16614. * @param onCompiled Callback triggered at the and of the effects compilation
  16615. * @param options Sets of optional options forcing the compilation with different modes
  16616. */
  16617. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16618. useInstances: boolean;
  16619. }>): void;
  16620. /**
  16621. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16622. * @param options Sets of optional options forcing the compilation with different modes
  16623. * @returns A promise that resolves when the compilation completes
  16624. */
  16625. forceCompilationAsync(options?: Partial<{
  16626. useInstances: boolean;
  16627. }>): Promise<void>;
  16628. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16629. /**
  16630. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16631. * @param subMesh The submesh we want to render in the shadow map
  16632. * @param useInstances Defines wether will draw in the map using instances
  16633. * @returns true if ready otherwise, false
  16634. */
  16635. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16636. /**
  16637. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16638. * @param defines Defines of the material we want to update
  16639. * @param lightIndex Index of the light in the enabled light list of the material
  16640. */
  16641. prepareDefines(defines: any, lightIndex: number): void;
  16642. /**
  16643. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16644. * defined in the generator but impacting the effect).
  16645. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16646. * @param effect The effect we are binfing the information for
  16647. */
  16648. bindShadowLight(lightIndex: string, effect: Effect): void;
  16649. /**
  16650. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16651. * (eq to shadow prjection matrix * light transform matrix)
  16652. * @returns The transform matrix used to create the shadow map
  16653. */
  16654. getTransformMatrix(): Matrix;
  16655. /**
  16656. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16657. * Cube and 2D textures for instance.
  16658. */
  16659. recreateShadowMap(): void;
  16660. protected _disposeBlurPostProcesses(): void;
  16661. protected _disposeRTTandPostProcesses(): void;
  16662. /**
  16663. * Disposes the ShadowGenerator.
  16664. * Returns nothing.
  16665. */
  16666. dispose(): void;
  16667. /**
  16668. * Serializes the shadow generator setup to a json object.
  16669. * @returns The serialized JSON object
  16670. */
  16671. serialize(): any;
  16672. /**
  16673. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16674. * @param parsedShadowGenerator The JSON object to parse
  16675. * @param scene The scene to create the shadow map for
  16676. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16677. * @returns The parsed shadow generator
  16678. */
  16679. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16680. }
  16681. }
  16682. declare module BABYLON {
  16683. /**
  16684. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16685. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16686. * 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.
  16687. */
  16688. export abstract class Light extends Node {
  16689. /**
  16690. * Falloff Default: light is falling off following the material specification:
  16691. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16692. */
  16693. static readonly FALLOFF_DEFAULT: number;
  16694. /**
  16695. * Falloff Physical: light is falling off following the inverse squared distance law.
  16696. */
  16697. static readonly FALLOFF_PHYSICAL: number;
  16698. /**
  16699. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16700. * to enhance interoperability with other engines.
  16701. */
  16702. static readonly FALLOFF_GLTF: number;
  16703. /**
  16704. * Falloff Standard: light is falling off like in the standard material
  16705. * to enhance interoperability with other materials.
  16706. */
  16707. static readonly FALLOFF_STANDARD: number;
  16708. /**
  16709. * If every light affecting the material is in this lightmapMode,
  16710. * material.lightmapTexture adds or multiplies
  16711. * (depends on material.useLightmapAsShadowmap)
  16712. * after every other light calculations.
  16713. */
  16714. static readonly LIGHTMAP_DEFAULT: number;
  16715. /**
  16716. * material.lightmapTexture as only diffuse lighting from this light
  16717. * adds only specular lighting from this light
  16718. * adds dynamic shadows
  16719. */
  16720. static readonly LIGHTMAP_SPECULAR: number;
  16721. /**
  16722. * material.lightmapTexture as only lighting
  16723. * no light calculation from this light
  16724. * only adds dynamic shadows from this light
  16725. */
  16726. static readonly LIGHTMAP_SHADOWSONLY: number;
  16727. /**
  16728. * Each light type uses the default quantity according to its type:
  16729. * point/spot lights use luminous intensity
  16730. * directional lights use illuminance
  16731. */
  16732. static readonly INTENSITYMODE_AUTOMATIC: number;
  16733. /**
  16734. * lumen (lm)
  16735. */
  16736. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16737. /**
  16738. * candela (lm/sr)
  16739. */
  16740. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16741. /**
  16742. * lux (lm/m^2)
  16743. */
  16744. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16745. /**
  16746. * nit (cd/m^2)
  16747. */
  16748. static readonly INTENSITYMODE_LUMINANCE: number;
  16749. /**
  16750. * Light type const id of the point light.
  16751. */
  16752. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16753. /**
  16754. * Light type const id of the directional light.
  16755. */
  16756. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16757. /**
  16758. * Light type const id of the spot light.
  16759. */
  16760. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16761. /**
  16762. * Light type const id of the hemispheric light.
  16763. */
  16764. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16765. /**
  16766. * Diffuse gives the basic color to an object.
  16767. */
  16768. diffuse: Color3;
  16769. /**
  16770. * Specular produces a highlight color on an object.
  16771. * Note: This is note affecting PBR materials.
  16772. */
  16773. specular: Color3;
  16774. /**
  16775. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16776. * falling off base on range or angle.
  16777. * This can be set to any values in Light.FALLOFF_x.
  16778. *
  16779. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16780. * other types of materials.
  16781. */
  16782. falloffType: number;
  16783. /**
  16784. * Strength of the light.
  16785. * Note: By default it is define in the framework own unit.
  16786. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16787. */
  16788. intensity: number;
  16789. private _range;
  16790. protected _inverseSquaredRange: number;
  16791. /**
  16792. * Defines how far from the source the light is impacting in scene units.
  16793. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16794. */
  16795. get range(): number;
  16796. /**
  16797. * Defines how far from the source the light is impacting in scene units.
  16798. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16799. */
  16800. set range(value: number);
  16801. /**
  16802. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16803. * of light.
  16804. */
  16805. private _photometricScale;
  16806. private _intensityMode;
  16807. /**
  16808. * Gets the photometric scale used to interpret the intensity.
  16809. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16810. */
  16811. get intensityMode(): number;
  16812. /**
  16813. * Sets the photometric scale used to interpret the intensity.
  16814. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16815. */
  16816. set intensityMode(value: number);
  16817. private _radius;
  16818. /**
  16819. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16820. */
  16821. get radius(): number;
  16822. /**
  16823. * sets the light radius used by PBR Materials to simulate soft area lights.
  16824. */
  16825. set radius(value: number);
  16826. private _renderPriority;
  16827. /**
  16828. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16829. * exceeding the number allowed of the materials.
  16830. */
  16831. renderPriority: number;
  16832. private _shadowEnabled;
  16833. /**
  16834. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16835. * the current shadow generator.
  16836. */
  16837. get shadowEnabled(): boolean;
  16838. /**
  16839. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16840. * the current shadow generator.
  16841. */
  16842. set shadowEnabled(value: boolean);
  16843. private _includedOnlyMeshes;
  16844. /**
  16845. * Gets the only meshes impacted by this light.
  16846. */
  16847. get includedOnlyMeshes(): AbstractMesh[];
  16848. /**
  16849. * Sets the only meshes impacted by this light.
  16850. */
  16851. set includedOnlyMeshes(value: AbstractMesh[]);
  16852. private _excludedMeshes;
  16853. /**
  16854. * Gets the meshes not impacted by this light.
  16855. */
  16856. get excludedMeshes(): AbstractMesh[];
  16857. /**
  16858. * Sets the meshes not impacted by this light.
  16859. */
  16860. set excludedMeshes(value: AbstractMesh[]);
  16861. private _excludeWithLayerMask;
  16862. /**
  16863. * Gets the layer id use to find what meshes are not impacted by the light.
  16864. * Inactive if 0
  16865. */
  16866. get excludeWithLayerMask(): number;
  16867. /**
  16868. * Sets the layer id use to find what meshes are not impacted by the light.
  16869. * Inactive if 0
  16870. */
  16871. set excludeWithLayerMask(value: number);
  16872. private _includeOnlyWithLayerMask;
  16873. /**
  16874. * Gets the layer id use to find what meshes are impacted by the light.
  16875. * Inactive if 0
  16876. */
  16877. get includeOnlyWithLayerMask(): number;
  16878. /**
  16879. * Sets the layer id use to find what meshes are impacted by the light.
  16880. * Inactive if 0
  16881. */
  16882. set includeOnlyWithLayerMask(value: number);
  16883. private _lightmapMode;
  16884. /**
  16885. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16886. */
  16887. get lightmapMode(): number;
  16888. /**
  16889. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16890. */
  16891. set lightmapMode(value: number);
  16892. /**
  16893. * Shadow generator associted to the light.
  16894. * @hidden Internal use only.
  16895. */
  16896. _shadowGenerator: Nullable<IShadowGenerator>;
  16897. /**
  16898. * @hidden Internal use only.
  16899. */
  16900. _excludedMeshesIds: string[];
  16901. /**
  16902. * @hidden Internal use only.
  16903. */
  16904. _includedOnlyMeshesIds: string[];
  16905. /**
  16906. * The current light unifom buffer.
  16907. * @hidden Internal use only.
  16908. */
  16909. _uniformBuffer: UniformBuffer;
  16910. /** @hidden */
  16911. _renderId: number;
  16912. /**
  16913. * Creates a Light object in the scene.
  16914. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16915. * @param name The firendly name of the light
  16916. * @param scene The scene the light belongs too
  16917. */
  16918. constructor(name: string, scene: Scene);
  16919. protected abstract _buildUniformLayout(): void;
  16920. /**
  16921. * Sets the passed Effect "effect" with the Light information.
  16922. * @param effect The effect to update
  16923. * @param lightIndex The index of the light in the effect to update
  16924. * @returns The light
  16925. */
  16926. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16927. /**
  16928. * Sets the passed Effect "effect" with the Light textures.
  16929. * @param effect The effect to update
  16930. * @param lightIndex The index of the light in the effect to update
  16931. * @returns The light
  16932. */
  16933. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16934. /**
  16935. * Binds the lights information from the scene to the effect for the given mesh.
  16936. * @param lightIndex Light index
  16937. * @param scene The scene where the light belongs to
  16938. * @param effect The effect we are binding the data to
  16939. * @param useSpecular Defines if specular is supported
  16940. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16941. */
  16942. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16943. /**
  16944. * Sets the passed Effect "effect" with the Light information.
  16945. * @param effect The effect to update
  16946. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16947. * @returns The light
  16948. */
  16949. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16950. /**
  16951. * Returns the string "Light".
  16952. * @returns the class name
  16953. */
  16954. getClassName(): string;
  16955. /** @hidden */
  16956. readonly _isLight: boolean;
  16957. /**
  16958. * Converts the light information to a readable string for debug purpose.
  16959. * @param fullDetails Supports for multiple levels of logging within scene loading
  16960. * @returns the human readable light info
  16961. */
  16962. toString(fullDetails?: boolean): string;
  16963. /** @hidden */
  16964. protected _syncParentEnabledState(): void;
  16965. /**
  16966. * Set the enabled state of this node.
  16967. * @param value - the new enabled state
  16968. */
  16969. setEnabled(value: boolean): void;
  16970. /**
  16971. * Returns the Light associated shadow generator if any.
  16972. * @return the associated shadow generator.
  16973. */
  16974. getShadowGenerator(): Nullable<IShadowGenerator>;
  16975. /**
  16976. * Returns a Vector3, the absolute light position in the World.
  16977. * @returns the world space position of the light
  16978. */
  16979. getAbsolutePosition(): Vector3;
  16980. /**
  16981. * Specifies if the light will affect the passed mesh.
  16982. * @param mesh The mesh to test against the light
  16983. * @return true the mesh is affected otherwise, false.
  16984. */
  16985. canAffectMesh(mesh: AbstractMesh): boolean;
  16986. /**
  16987. * Sort function to order lights for rendering.
  16988. * @param a First Light object to compare to second.
  16989. * @param b Second Light object to compare first.
  16990. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16991. */
  16992. static CompareLightsPriority(a: Light, b: Light): number;
  16993. /**
  16994. * Releases resources associated with this node.
  16995. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16996. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16997. */
  16998. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16999. /**
  17000. * Returns the light type ID (integer).
  17001. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17002. */
  17003. getTypeID(): number;
  17004. /**
  17005. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17006. * @returns the scaled intensity in intensity mode unit
  17007. */
  17008. getScaledIntensity(): number;
  17009. /**
  17010. * Returns a new Light object, named "name", from the current one.
  17011. * @param name The name of the cloned light
  17012. * @returns the new created light
  17013. */
  17014. clone(name: string): Nullable<Light>;
  17015. /**
  17016. * Serializes the current light into a Serialization object.
  17017. * @returns the serialized object.
  17018. */
  17019. serialize(): any;
  17020. /**
  17021. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17022. * This new light is named "name" and added to the passed scene.
  17023. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17024. * @param name The friendly name of the light
  17025. * @param scene The scene the new light will belong to
  17026. * @returns the constructor function
  17027. */
  17028. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17029. /**
  17030. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17031. * @param parsedLight The JSON representation of the light
  17032. * @param scene The scene to create the parsed light in
  17033. * @returns the created light after parsing
  17034. */
  17035. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17036. private _hookArrayForExcluded;
  17037. private _hookArrayForIncludedOnly;
  17038. private _resyncMeshes;
  17039. /**
  17040. * Forces the meshes to update their light related information in their rendering used effects
  17041. * @hidden Internal Use Only
  17042. */
  17043. _markMeshesAsLightDirty(): void;
  17044. /**
  17045. * Recomputes the cached photometric scale if needed.
  17046. */
  17047. private _computePhotometricScale;
  17048. /**
  17049. * Returns the Photometric Scale according to the light type and intensity mode.
  17050. */
  17051. private _getPhotometricScale;
  17052. /**
  17053. * Reorder the light in the scene according to their defined priority.
  17054. * @hidden Internal Use Only
  17055. */
  17056. _reorderLightsInScene(): void;
  17057. /**
  17058. * Prepares the list of defines specific to the light type.
  17059. * @param defines the list of defines
  17060. * @param lightIndex defines the index of the light for the effect
  17061. */
  17062. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17063. }
  17064. }
  17065. declare module BABYLON {
  17066. /**
  17067. * Interface used to define Action
  17068. */
  17069. export interface IAction {
  17070. /**
  17071. * Trigger for the action
  17072. */
  17073. trigger: number;
  17074. /** Options of the trigger */
  17075. triggerOptions: any;
  17076. /**
  17077. * Gets the trigger parameters
  17078. * @returns the trigger parameters
  17079. */
  17080. getTriggerParameter(): any;
  17081. /**
  17082. * Internal only - executes current action event
  17083. * @hidden
  17084. */
  17085. _executeCurrent(evt?: ActionEvent): void;
  17086. /**
  17087. * Serialize placeholder for child classes
  17088. * @param parent of child
  17089. * @returns the serialized object
  17090. */
  17091. serialize(parent: any): any;
  17092. /**
  17093. * Internal only
  17094. * @hidden
  17095. */
  17096. _prepare(): void;
  17097. /**
  17098. * Internal only - manager for action
  17099. * @hidden
  17100. */
  17101. _actionManager: AbstractActionManager;
  17102. /**
  17103. * Adds action to chain of actions, may be a DoNothingAction
  17104. * @param action defines the next action to execute
  17105. * @returns The action passed in
  17106. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17107. */
  17108. then(action: IAction): IAction;
  17109. }
  17110. /**
  17111. * The action to be carried out following a trigger
  17112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17113. */
  17114. export class Action implements IAction {
  17115. /** the trigger, with or without parameters, for the action */
  17116. triggerOptions: any;
  17117. /**
  17118. * Trigger for the action
  17119. */
  17120. trigger: number;
  17121. /**
  17122. * Internal only - manager for action
  17123. * @hidden
  17124. */
  17125. _actionManager: ActionManager;
  17126. private _nextActiveAction;
  17127. private _child;
  17128. private _condition?;
  17129. private _triggerParameter;
  17130. /**
  17131. * An event triggered prior to action being executed.
  17132. */
  17133. onBeforeExecuteObservable: Observable<Action>;
  17134. /**
  17135. * Creates a new Action
  17136. * @param triggerOptions the trigger, with or without parameters, for the action
  17137. * @param condition an optional determinant of action
  17138. */
  17139. constructor(
  17140. /** the trigger, with or without parameters, for the action */
  17141. triggerOptions: any, condition?: Condition);
  17142. /**
  17143. * Internal only
  17144. * @hidden
  17145. */
  17146. _prepare(): void;
  17147. /**
  17148. * Gets the trigger parameters
  17149. * @returns the trigger parameters
  17150. */
  17151. getTriggerParameter(): any;
  17152. /**
  17153. * Internal only - executes current action event
  17154. * @hidden
  17155. */
  17156. _executeCurrent(evt?: ActionEvent): void;
  17157. /**
  17158. * Execute placeholder for child classes
  17159. * @param evt optional action event
  17160. */
  17161. execute(evt?: ActionEvent): void;
  17162. /**
  17163. * Skips to next active action
  17164. */
  17165. skipToNextActiveAction(): void;
  17166. /**
  17167. * Adds action to chain of actions, may be a DoNothingAction
  17168. * @param action defines the next action to execute
  17169. * @returns The action passed in
  17170. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17171. */
  17172. then(action: Action): Action;
  17173. /**
  17174. * Internal only
  17175. * @hidden
  17176. */
  17177. _getProperty(propertyPath: string): string;
  17178. /**
  17179. * Internal only
  17180. * @hidden
  17181. */
  17182. _getEffectiveTarget(target: any, propertyPath: string): any;
  17183. /**
  17184. * Serialize placeholder for child classes
  17185. * @param parent of child
  17186. * @returns the serialized object
  17187. */
  17188. serialize(parent: any): any;
  17189. /**
  17190. * Internal only called by serialize
  17191. * @hidden
  17192. */
  17193. protected _serialize(serializedAction: any, parent?: any): any;
  17194. /**
  17195. * Internal only
  17196. * @hidden
  17197. */
  17198. static _SerializeValueAsString: (value: any) => string;
  17199. /**
  17200. * Internal only
  17201. * @hidden
  17202. */
  17203. static _GetTargetProperty: (target: Node | Scene) => {
  17204. name: string;
  17205. targetType: string;
  17206. value: string;
  17207. };
  17208. }
  17209. }
  17210. declare module BABYLON {
  17211. /**
  17212. * A Condition applied to an Action
  17213. */
  17214. export class Condition {
  17215. /**
  17216. * Internal only - manager for action
  17217. * @hidden
  17218. */
  17219. _actionManager: ActionManager;
  17220. /**
  17221. * Internal only
  17222. * @hidden
  17223. */
  17224. _evaluationId: number;
  17225. /**
  17226. * Internal only
  17227. * @hidden
  17228. */
  17229. _currentResult: boolean;
  17230. /**
  17231. * Creates a new Condition
  17232. * @param actionManager the manager of the action the condition is applied to
  17233. */
  17234. constructor(actionManager: ActionManager);
  17235. /**
  17236. * Check if the current condition is valid
  17237. * @returns a boolean
  17238. */
  17239. isValid(): boolean;
  17240. /**
  17241. * Internal only
  17242. * @hidden
  17243. */
  17244. _getProperty(propertyPath: string): string;
  17245. /**
  17246. * Internal only
  17247. * @hidden
  17248. */
  17249. _getEffectiveTarget(target: any, propertyPath: string): any;
  17250. /**
  17251. * Serialize placeholder for child classes
  17252. * @returns the serialized object
  17253. */
  17254. serialize(): any;
  17255. /**
  17256. * Internal only
  17257. * @hidden
  17258. */
  17259. protected _serialize(serializedCondition: any): any;
  17260. }
  17261. /**
  17262. * Defines specific conditional operators as extensions of Condition
  17263. */
  17264. export class ValueCondition extends Condition {
  17265. /** path to specify the property of the target the conditional operator uses */
  17266. propertyPath: string;
  17267. /** the value compared by the conditional operator against the current value of the property */
  17268. value: any;
  17269. /** the conditional operator, default ValueCondition.IsEqual */
  17270. operator: number;
  17271. /**
  17272. * Internal only
  17273. * @hidden
  17274. */
  17275. private static _IsEqual;
  17276. /**
  17277. * Internal only
  17278. * @hidden
  17279. */
  17280. private static _IsDifferent;
  17281. /**
  17282. * Internal only
  17283. * @hidden
  17284. */
  17285. private static _IsGreater;
  17286. /**
  17287. * Internal only
  17288. * @hidden
  17289. */
  17290. private static _IsLesser;
  17291. /**
  17292. * returns the number for IsEqual
  17293. */
  17294. static get IsEqual(): number;
  17295. /**
  17296. * Returns the number for IsDifferent
  17297. */
  17298. static get IsDifferent(): number;
  17299. /**
  17300. * Returns the number for IsGreater
  17301. */
  17302. static get IsGreater(): number;
  17303. /**
  17304. * Returns the number for IsLesser
  17305. */
  17306. static get IsLesser(): number;
  17307. /**
  17308. * Internal only The action manager for the condition
  17309. * @hidden
  17310. */
  17311. _actionManager: ActionManager;
  17312. /**
  17313. * Internal only
  17314. * @hidden
  17315. */
  17316. private _target;
  17317. /**
  17318. * Internal only
  17319. * @hidden
  17320. */
  17321. private _effectiveTarget;
  17322. /**
  17323. * Internal only
  17324. * @hidden
  17325. */
  17326. private _property;
  17327. /**
  17328. * Creates a new ValueCondition
  17329. * @param actionManager manager for the action the condition applies to
  17330. * @param target for the action
  17331. * @param propertyPath path to specify the property of the target the conditional operator uses
  17332. * @param value the value compared by the conditional operator against the current value of the property
  17333. * @param operator the conditional operator, default ValueCondition.IsEqual
  17334. */
  17335. constructor(actionManager: ActionManager, target: any,
  17336. /** path to specify the property of the target the conditional operator uses */
  17337. propertyPath: string,
  17338. /** the value compared by the conditional operator against the current value of the property */
  17339. value: any,
  17340. /** the conditional operator, default ValueCondition.IsEqual */
  17341. operator?: number);
  17342. /**
  17343. * Compares the given value with the property value for the specified conditional operator
  17344. * @returns the result of the comparison
  17345. */
  17346. isValid(): boolean;
  17347. /**
  17348. * Serialize the ValueCondition into a JSON compatible object
  17349. * @returns serialization object
  17350. */
  17351. serialize(): any;
  17352. /**
  17353. * Gets the name of the conditional operator for the ValueCondition
  17354. * @param operator the conditional operator
  17355. * @returns the name
  17356. */
  17357. static GetOperatorName(operator: number): string;
  17358. }
  17359. /**
  17360. * Defines a predicate condition as an extension of Condition
  17361. */
  17362. export class PredicateCondition extends Condition {
  17363. /** defines the predicate function used to validate the condition */
  17364. predicate: () => boolean;
  17365. /**
  17366. * Internal only - manager for action
  17367. * @hidden
  17368. */
  17369. _actionManager: ActionManager;
  17370. /**
  17371. * Creates a new PredicateCondition
  17372. * @param actionManager manager for the action the condition applies to
  17373. * @param predicate defines the predicate function used to validate the condition
  17374. */
  17375. constructor(actionManager: ActionManager,
  17376. /** defines the predicate function used to validate the condition */
  17377. predicate: () => boolean);
  17378. /**
  17379. * @returns the validity of the predicate condition
  17380. */
  17381. isValid(): boolean;
  17382. }
  17383. /**
  17384. * Defines a state condition as an extension of Condition
  17385. */
  17386. export class StateCondition extends Condition {
  17387. /** Value to compare with target state */
  17388. value: string;
  17389. /**
  17390. * Internal only - manager for action
  17391. * @hidden
  17392. */
  17393. _actionManager: ActionManager;
  17394. /**
  17395. * Internal only
  17396. * @hidden
  17397. */
  17398. private _target;
  17399. /**
  17400. * Creates a new StateCondition
  17401. * @param actionManager manager for the action the condition applies to
  17402. * @param target of the condition
  17403. * @param value to compare with target state
  17404. */
  17405. constructor(actionManager: ActionManager, target: any,
  17406. /** Value to compare with target state */
  17407. value: string);
  17408. /**
  17409. * Gets a boolean indicating if the current condition is met
  17410. * @returns the validity of the state
  17411. */
  17412. isValid(): boolean;
  17413. /**
  17414. * Serialize the StateCondition into a JSON compatible object
  17415. * @returns serialization object
  17416. */
  17417. serialize(): any;
  17418. }
  17419. }
  17420. declare module BABYLON {
  17421. /**
  17422. * This defines an action responsible to toggle a boolean once triggered.
  17423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17424. */
  17425. export class SwitchBooleanAction extends Action {
  17426. /**
  17427. * The path to the boolean property in the target object
  17428. */
  17429. propertyPath: string;
  17430. private _target;
  17431. private _effectiveTarget;
  17432. private _property;
  17433. /**
  17434. * Instantiate the action
  17435. * @param triggerOptions defines the trigger options
  17436. * @param target defines the object containing the boolean
  17437. * @param propertyPath defines the path to the boolean property in the target object
  17438. * @param condition defines the trigger related conditions
  17439. */
  17440. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17441. /** @hidden */
  17442. _prepare(): void;
  17443. /**
  17444. * Execute the action toggle the boolean value.
  17445. */
  17446. execute(): void;
  17447. /**
  17448. * Serializes the actions and its related information.
  17449. * @param parent defines the object to serialize in
  17450. * @returns the serialized object
  17451. */
  17452. serialize(parent: any): any;
  17453. }
  17454. /**
  17455. * This defines an action responsible to set a the state field of the target
  17456. * to a desired value once triggered.
  17457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17458. */
  17459. export class SetStateAction extends Action {
  17460. /**
  17461. * The value to store in the state field.
  17462. */
  17463. value: string;
  17464. private _target;
  17465. /**
  17466. * Instantiate the action
  17467. * @param triggerOptions defines the trigger options
  17468. * @param target defines the object containing the state property
  17469. * @param value defines the value to store in the state field
  17470. * @param condition defines the trigger related conditions
  17471. */
  17472. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17473. /**
  17474. * Execute the action and store the value on the target state property.
  17475. */
  17476. execute(): void;
  17477. /**
  17478. * Serializes the actions and its related information.
  17479. * @param parent defines the object to serialize in
  17480. * @returns the serialized object
  17481. */
  17482. serialize(parent: any): any;
  17483. }
  17484. /**
  17485. * This defines an action responsible to set a property of the target
  17486. * to a desired value once triggered.
  17487. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17488. */
  17489. export class SetValueAction extends Action {
  17490. /**
  17491. * The path of the property to set in the target.
  17492. */
  17493. propertyPath: string;
  17494. /**
  17495. * The value to set in the property
  17496. */
  17497. value: any;
  17498. private _target;
  17499. private _effectiveTarget;
  17500. private _property;
  17501. /**
  17502. * Instantiate the action
  17503. * @param triggerOptions defines the trigger options
  17504. * @param target defines the object containing the property
  17505. * @param propertyPath defines the path of the property to set in the target
  17506. * @param value defines the value to set in the property
  17507. * @param condition defines the trigger related conditions
  17508. */
  17509. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17510. /** @hidden */
  17511. _prepare(): void;
  17512. /**
  17513. * Execute the action and set the targetted property to the desired value.
  17514. */
  17515. execute(): void;
  17516. /**
  17517. * Serializes the actions and its related information.
  17518. * @param parent defines the object to serialize in
  17519. * @returns the serialized object
  17520. */
  17521. serialize(parent: any): any;
  17522. }
  17523. /**
  17524. * This defines an action responsible to increment the target value
  17525. * to a desired value once triggered.
  17526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17527. */
  17528. export class IncrementValueAction extends Action {
  17529. /**
  17530. * The path of the property to increment in the target.
  17531. */
  17532. propertyPath: string;
  17533. /**
  17534. * The value we should increment the property by.
  17535. */
  17536. value: any;
  17537. private _target;
  17538. private _effectiveTarget;
  17539. private _property;
  17540. /**
  17541. * Instantiate the action
  17542. * @param triggerOptions defines the trigger options
  17543. * @param target defines the object containing the property
  17544. * @param propertyPath defines the path of the property to increment in the target
  17545. * @param value defines the value value we should increment the property by
  17546. * @param condition defines the trigger related conditions
  17547. */
  17548. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17549. /** @hidden */
  17550. _prepare(): void;
  17551. /**
  17552. * Execute the action and increment the target of the value amount.
  17553. */
  17554. execute(): void;
  17555. /**
  17556. * Serializes the actions and its related information.
  17557. * @param parent defines the object to serialize in
  17558. * @returns the serialized object
  17559. */
  17560. serialize(parent: any): any;
  17561. }
  17562. /**
  17563. * This defines an action responsible to start an animation once triggered.
  17564. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17565. */
  17566. export class PlayAnimationAction extends Action {
  17567. /**
  17568. * Where the animation should start (animation frame)
  17569. */
  17570. from: number;
  17571. /**
  17572. * Where the animation should stop (animation frame)
  17573. */
  17574. to: number;
  17575. /**
  17576. * Define if the animation should loop or stop after the first play.
  17577. */
  17578. loop?: boolean;
  17579. private _target;
  17580. /**
  17581. * Instantiate the action
  17582. * @param triggerOptions defines the trigger options
  17583. * @param target defines the target animation or animation name
  17584. * @param from defines from where the animation should start (animation frame)
  17585. * @param end defines where the animation should stop (animation frame)
  17586. * @param loop defines if the animation should loop or stop after the first play
  17587. * @param condition defines the trigger related conditions
  17588. */
  17589. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17590. /** @hidden */
  17591. _prepare(): void;
  17592. /**
  17593. * Execute the action and play the animation.
  17594. */
  17595. execute(): void;
  17596. /**
  17597. * Serializes the actions and its related information.
  17598. * @param parent defines the object to serialize in
  17599. * @returns the serialized object
  17600. */
  17601. serialize(parent: any): any;
  17602. }
  17603. /**
  17604. * This defines an action responsible to stop an animation once triggered.
  17605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17606. */
  17607. export class StopAnimationAction extends Action {
  17608. private _target;
  17609. /**
  17610. * Instantiate the action
  17611. * @param triggerOptions defines the trigger options
  17612. * @param target defines the target animation or animation name
  17613. * @param condition defines the trigger related conditions
  17614. */
  17615. constructor(triggerOptions: any, target: any, condition?: Condition);
  17616. /** @hidden */
  17617. _prepare(): void;
  17618. /**
  17619. * Execute the action and stop the animation.
  17620. */
  17621. execute(): void;
  17622. /**
  17623. * Serializes the actions and its related information.
  17624. * @param parent defines the object to serialize in
  17625. * @returns the serialized object
  17626. */
  17627. serialize(parent: any): any;
  17628. }
  17629. /**
  17630. * This defines an action responsible that does nothing once triggered.
  17631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17632. */
  17633. export class DoNothingAction extends Action {
  17634. /**
  17635. * Instantiate the action
  17636. * @param triggerOptions defines the trigger options
  17637. * @param condition defines the trigger related conditions
  17638. */
  17639. constructor(triggerOptions?: any, condition?: Condition);
  17640. /**
  17641. * Execute the action and do nothing.
  17642. */
  17643. execute(): void;
  17644. /**
  17645. * Serializes the actions and its related information.
  17646. * @param parent defines the object to serialize in
  17647. * @returns the serialized object
  17648. */
  17649. serialize(parent: any): any;
  17650. }
  17651. /**
  17652. * This defines an action responsible to trigger several actions once triggered.
  17653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17654. */
  17655. export class CombineAction extends Action {
  17656. /**
  17657. * The list of aggregated animations to run.
  17658. */
  17659. children: Action[];
  17660. /**
  17661. * Instantiate the action
  17662. * @param triggerOptions defines the trigger options
  17663. * @param children defines the list of aggregated animations to run
  17664. * @param condition defines the trigger related conditions
  17665. */
  17666. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17667. /** @hidden */
  17668. _prepare(): void;
  17669. /**
  17670. * Execute the action and executes all the aggregated actions.
  17671. */
  17672. execute(evt: ActionEvent): void;
  17673. /**
  17674. * Serializes the actions and its related information.
  17675. * @param parent defines the object to serialize in
  17676. * @returns the serialized object
  17677. */
  17678. serialize(parent: any): any;
  17679. }
  17680. /**
  17681. * This defines an action responsible to run code (external event) once triggered.
  17682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17683. */
  17684. export class ExecuteCodeAction extends Action {
  17685. /**
  17686. * The callback function to run.
  17687. */
  17688. func: (evt: ActionEvent) => void;
  17689. /**
  17690. * Instantiate the action
  17691. * @param triggerOptions defines the trigger options
  17692. * @param func defines the callback function to run
  17693. * @param condition defines the trigger related conditions
  17694. */
  17695. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17696. /**
  17697. * Execute the action and run the attached code.
  17698. */
  17699. execute(evt: ActionEvent): void;
  17700. }
  17701. /**
  17702. * This defines an action responsible to set the parent property of the target once triggered.
  17703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17704. */
  17705. export class SetParentAction extends Action {
  17706. private _parent;
  17707. private _target;
  17708. /**
  17709. * Instantiate the action
  17710. * @param triggerOptions defines the trigger options
  17711. * @param target defines the target containing the parent property
  17712. * @param parent defines from where the animation should start (animation frame)
  17713. * @param condition defines the trigger related conditions
  17714. */
  17715. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17716. /** @hidden */
  17717. _prepare(): void;
  17718. /**
  17719. * Execute the action and set the parent property.
  17720. */
  17721. execute(): void;
  17722. /**
  17723. * Serializes the actions and its related information.
  17724. * @param parent defines the object to serialize in
  17725. * @returns the serialized object
  17726. */
  17727. serialize(parent: any): any;
  17728. }
  17729. }
  17730. declare module BABYLON {
  17731. /**
  17732. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17733. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17735. */
  17736. export class ActionManager extends AbstractActionManager {
  17737. /**
  17738. * Nothing
  17739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17740. */
  17741. static readonly NothingTrigger: number;
  17742. /**
  17743. * On pick
  17744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17745. */
  17746. static readonly OnPickTrigger: number;
  17747. /**
  17748. * On left pick
  17749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17750. */
  17751. static readonly OnLeftPickTrigger: number;
  17752. /**
  17753. * On right pick
  17754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17755. */
  17756. static readonly OnRightPickTrigger: number;
  17757. /**
  17758. * On center pick
  17759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17760. */
  17761. static readonly OnCenterPickTrigger: number;
  17762. /**
  17763. * On pick down
  17764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17765. */
  17766. static readonly OnPickDownTrigger: number;
  17767. /**
  17768. * On double pick
  17769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17770. */
  17771. static readonly OnDoublePickTrigger: number;
  17772. /**
  17773. * On pick up
  17774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17775. */
  17776. static readonly OnPickUpTrigger: number;
  17777. /**
  17778. * On pick out.
  17779. * This trigger will only be raised if you also declared a OnPickDown
  17780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17781. */
  17782. static readonly OnPickOutTrigger: number;
  17783. /**
  17784. * On long press
  17785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17786. */
  17787. static readonly OnLongPressTrigger: number;
  17788. /**
  17789. * On pointer over
  17790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17791. */
  17792. static readonly OnPointerOverTrigger: number;
  17793. /**
  17794. * On pointer out
  17795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17796. */
  17797. static readonly OnPointerOutTrigger: number;
  17798. /**
  17799. * On every frame
  17800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17801. */
  17802. static readonly OnEveryFrameTrigger: number;
  17803. /**
  17804. * On intersection enter
  17805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17806. */
  17807. static readonly OnIntersectionEnterTrigger: number;
  17808. /**
  17809. * On intersection exit
  17810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17811. */
  17812. static readonly OnIntersectionExitTrigger: number;
  17813. /**
  17814. * On key down
  17815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17816. */
  17817. static readonly OnKeyDownTrigger: number;
  17818. /**
  17819. * On key up
  17820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17821. */
  17822. static readonly OnKeyUpTrigger: number;
  17823. private _scene;
  17824. /**
  17825. * Creates a new action manager
  17826. * @param scene defines the hosting scene
  17827. */
  17828. constructor(scene: Scene);
  17829. /**
  17830. * Releases all associated resources
  17831. */
  17832. dispose(): void;
  17833. /**
  17834. * Gets hosting scene
  17835. * @returns the hosting scene
  17836. */
  17837. getScene(): Scene;
  17838. /**
  17839. * Does this action manager handles actions of any of the given triggers
  17840. * @param triggers defines the triggers to be tested
  17841. * @return a boolean indicating whether one (or more) of the triggers is handled
  17842. */
  17843. hasSpecificTriggers(triggers: number[]): boolean;
  17844. /**
  17845. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17846. * speed.
  17847. * @param triggerA defines the trigger to be tested
  17848. * @param triggerB defines the trigger to be tested
  17849. * @return a boolean indicating whether one (or more) of the triggers is handled
  17850. */
  17851. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17852. /**
  17853. * Does this action manager handles actions of a given trigger
  17854. * @param trigger defines the trigger to be tested
  17855. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17856. * @return whether the trigger is handled
  17857. */
  17858. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17859. /**
  17860. * Does this action manager has pointer triggers
  17861. */
  17862. get hasPointerTriggers(): boolean;
  17863. /**
  17864. * Does this action manager has pick triggers
  17865. */
  17866. get hasPickTriggers(): boolean;
  17867. /**
  17868. * Registers an action to this action manager
  17869. * @param action defines the action to be registered
  17870. * @return the action amended (prepared) after registration
  17871. */
  17872. registerAction(action: IAction): Nullable<IAction>;
  17873. /**
  17874. * Unregisters an action to this action manager
  17875. * @param action defines the action to be unregistered
  17876. * @return a boolean indicating whether the action has been unregistered
  17877. */
  17878. unregisterAction(action: IAction): Boolean;
  17879. /**
  17880. * Process a specific trigger
  17881. * @param trigger defines the trigger to process
  17882. * @param evt defines the event details to be processed
  17883. */
  17884. processTrigger(trigger: number, evt?: IActionEvent): void;
  17885. /** @hidden */
  17886. _getEffectiveTarget(target: any, propertyPath: string): any;
  17887. /** @hidden */
  17888. _getProperty(propertyPath: string): string;
  17889. /**
  17890. * Serialize this manager to a JSON object
  17891. * @param name defines the property name to store this manager
  17892. * @returns a JSON representation of this manager
  17893. */
  17894. serialize(name: string): any;
  17895. /**
  17896. * Creates a new ActionManager from a JSON data
  17897. * @param parsedActions defines the JSON data to read from
  17898. * @param object defines the hosting mesh
  17899. * @param scene defines the hosting scene
  17900. */
  17901. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17902. /**
  17903. * Get a trigger name by index
  17904. * @param trigger defines the trigger index
  17905. * @returns a trigger name
  17906. */
  17907. static GetTriggerName(trigger: number): string;
  17908. }
  17909. }
  17910. declare module BABYLON {
  17911. /**
  17912. * Class used to represent a sprite
  17913. * @see http://doc.babylonjs.com/babylon101/sprites
  17914. */
  17915. export class Sprite {
  17916. /** defines the name */
  17917. name: string;
  17918. /** Gets or sets the current world position */
  17919. position: Vector3;
  17920. /** Gets or sets the main color */
  17921. color: Color4;
  17922. /** Gets or sets the width */
  17923. width: number;
  17924. /** Gets or sets the height */
  17925. height: number;
  17926. /** Gets or sets rotation angle */
  17927. angle: number;
  17928. /** Gets or sets the cell index in the sprite sheet */
  17929. cellIndex: number;
  17930. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17931. cellRef: string;
  17932. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17933. invertU: number;
  17934. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17935. invertV: number;
  17936. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17937. disposeWhenFinishedAnimating: boolean;
  17938. /** Gets the list of attached animations */
  17939. animations: Animation[];
  17940. /** Gets or sets a boolean indicating if the sprite can be picked */
  17941. isPickable: boolean;
  17942. /**
  17943. * Gets or sets the associated action manager
  17944. */
  17945. actionManager: Nullable<ActionManager>;
  17946. private _animationStarted;
  17947. private _loopAnimation;
  17948. private _fromIndex;
  17949. private _toIndex;
  17950. private _delay;
  17951. private _direction;
  17952. private _manager;
  17953. private _time;
  17954. private _onAnimationEnd;
  17955. /**
  17956. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17957. */
  17958. isVisible: boolean;
  17959. /**
  17960. * Gets or sets the sprite size
  17961. */
  17962. get size(): number;
  17963. set size(value: number);
  17964. /**
  17965. * Creates a new Sprite
  17966. * @param name defines the name
  17967. * @param manager defines the manager
  17968. */
  17969. constructor(
  17970. /** defines the name */
  17971. name: string, manager: ISpriteManager);
  17972. /**
  17973. * Starts an animation
  17974. * @param from defines the initial key
  17975. * @param to defines the end key
  17976. * @param loop defines if the animation must loop
  17977. * @param delay defines the start delay (in ms)
  17978. * @param onAnimationEnd defines a callback to call when animation ends
  17979. */
  17980. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  17981. /** Stops current animation (if any) */
  17982. stopAnimation(): void;
  17983. /** @hidden */
  17984. _animate(deltaTime: number): void;
  17985. /** Release associated resources */
  17986. dispose(): void;
  17987. }
  17988. }
  17989. declare module BABYLON {
  17990. /**
  17991. * Information about the result of picking within a scene
  17992. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  17993. */
  17994. export class PickingInfo {
  17995. /** @hidden */
  17996. _pickingUnavailable: boolean;
  17997. /**
  17998. * If the pick collided with an object
  17999. */
  18000. hit: boolean;
  18001. /**
  18002. * Distance away where the pick collided
  18003. */
  18004. distance: number;
  18005. /**
  18006. * The location of pick collision
  18007. */
  18008. pickedPoint: Nullable<Vector3>;
  18009. /**
  18010. * The mesh corresponding the the pick collision
  18011. */
  18012. pickedMesh: Nullable<AbstractMesh>;
  18013. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18014. bu: number;
  18015. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18016. bv: number;
  18017. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18018. faceId: number;
  18019. /** Id of the the submesh that was picked */
  18020. subMeshId: number;
  18021. /** If a sprite was picked, this will be the sprite the pick collided with */
  18022. pickedSprite: Nullable<Sprite>;
  18023. /**
  18024. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18025. */
  18026. originMesh: Nullable<AbstractMesh>;
  18027. /**
  18028. * The ray that was used to perform the picking.
  18029. */
  18030. ray: Nullable<Ray>;
  18031. /**
  18032. * Gets the normal correspodning to the face the pick collided with
  18033. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18034. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18035. * @returns The normal correspodning to the face the pick collided with
  18036. */
  18037. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18038. /**
  18039. * Gets the texture coordinates of where the pick occured
  18040. * @returns the vector containing the coordnates of the texture
  18041. */
  18042. getTextureCoordinates(): Nullable<Vector2>;
  18043. }
  18044. }
  18045. declare module BABYLON {
  18046. /**
  18047. * Gather the list of pointer event types as constants.
  18048. */
  18049. export class PointerEventTypes {
  18050. /**
  18051. * 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.
  18052. */
  18053. static readonly POINTERDOWN: number;
  18054. /**
  18055. * The pointerup event is fired when a pointer is no longer active.
  18056. */
  18057. static readonly POINTERUP: number;
  18058. /**
  18059. * The pointermove event is fired when a pointer changes coordinates.
  18060. */
  18061. static readonly POINTERMOVE: number;
  18062. /**
  18063. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18064. */
  18065. static readonly POINTERWHEEL: number;
  18066. /**
  18067. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18068. */
  18069. static readonly POINTERPICK: number;
  18070. /**
  18071. * The pointertap event is fired when a the object has been touched and released without drag.
  18072. */
  18073. static readonly POINTERTAP: number;
  18074. /**
  18075. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18076. */
  18077. static readonly POINTERDOUBLETAP: number;
  18078. }
  18079. /**
  18080. * Base class of pointer info types.
  18081. */
  18082. export class PointerInfoBase {
  18083. /**
  18084. * Defines the type of event (PointerEventTypes)
  18085. */
  18086. type: number;
  18087. /**
  18088. * Defines the related dom event
  18089. */
  18090. event: PointerEvent | MouseWheelEvent;
  18091. /**
  18092. * Instantiates the base class of pointers info.
  18093. * @param type Defines the type of event (PointerEventTypes)
  18094. * @param event Defines the related dom event
  18095. */
  18096. constructor(
  18097. /**
  18098. * Defines the type of event (PointerEventTypes)
  18099. */
  18100. type: number,
  18101. /**
  18102. * Defines the related dom event
  18103. */
  18104. event: PointerEvent | MouseWheelEvent);
  18105. }
  18106. /**
  18107. * This class is used to store pointer related info for the onPrePointerObservable event.
  18108. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18109. */
  18110. export class PointerInfoPre extends PointerInfoBase {
  18111. /**
  18112. * Ray from a pointer if availible (eg. 6dof controller)
  18113. */
  18114. ray: Nullable<Ray>;
  18115. /**
  18116. * Defines the local position of the pointer on the canvas.
  18117. */
  18118. localPosition: Vector2;
  18119. /**
  18120. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18121. */
  18122. skipOnPointerObservable: boolean;
  18123. /**
  18124. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18125. * @param type Defines the type of event (PointerEventTypes)
  18126. * @param event Defines the related dom event
  18127. * @param localX Defines the local x coordinates of the pointer when the event occured
  18128. * @param localY Defines the local y coordinates of the pointer when the event occured
  18129. */
  18130. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18131. }
  18132. /**
  18133. * This type contains all the data related to a pointer event in Babylon.js.
  18134. * 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.
  18135. */
  18136. export class PointerInfo extends PointerInfoBase {
  18137. /**
  18138. * Defines the picking info associated to the info (if any)\
  18139. */
  18140. pickInfo: Nullable<PickingInfo>;
  18141. /**
  18142. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18143. * @param type Defines the type of event (PointerEventTypes)
  18144. * @param event Defines the related dom event
  18145. * @param pickInfo Defines the picking info associated to the info (if any)\
  18146. */
  18147. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18148. /**
  18149. * Defines the picking info associated to the info (if any)\
  18150. */
  18151. pickInfo: Nullable<PickingInfo>);
  18152. }
  18153. /**
  18154. * Data relating to a touch event on the screen.
  18155. */
  18156. export interface PointerTouch {
  18157. /**
  18158. * X coordinate of touch.
  18159. */
  18160. x: number;
  18161. /**
  18162. * Y coordinate of touch.
  18163. */
  18164. y: number;
  18165. /**
  18166. * Id of touch. Unique for each finger.
  18167. */
  18168. pointerId: number;
  18169. /**
  18170. * Event type passed from DOM.
  18171. */
  18172. type: any;
  18173. }
  18174. }
  18175. declare module BABYLON {
  18176. /**
  18177. * Manage the mouse inputs to control the movement of a free camera.
  18178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18179. */
  18180. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18181. /**
  18182. * Define if touch is enabled in the mouse input
  18183. */
  18184. touchEnabled: boolean;
  18185. /**
  18186. * Defines the camera the input is attached to.
  18187. */
  18188. camera: FreeCamera;
  18189. /**
  18190. * Defines the buttons associated with the input to handle camera move.
  18191. */
  18192. buttons: number[];
  18193. /**
  18194. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18195. */
  18196. angularSensibility: number;
  18197. private _pointerInput;
  18198. private _onMouseMove;
  18199. private _observer;
  18200. private previousPosition;
  18201. /**
  18202. * Observable for when a pointer move event occurs containing the move offset
  18203. */
  18204. onPointerMovedObservable: Observable<{
  18205. offsetX: number;
  18206. offsetY: number;
  18207. }>;
  18208. /**
  18209. * @hidden
  18210. * If the camera should be rotated automatically based on pointer movement
  18211. */
  18212. _allowCameraRotation: boolean;
  18213. /**
  18214. * Manage the mouse inputs to control the movement of a free camera.
  18215. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18216. * @param touchEnabled Defines if touch is enabled or not
  18217. */
  18218. constructor(
  18219. /**
  18220. * Define if touch is enabled in the mouse input
  18221. */
  18222. touchEnabled?: boolean);
  18223. /**
  18224. * Attach the input controls to a specific dom element to get the input from.
  18225. * @param element Defines the element the controls should be listened from
  18226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18227. */
  18228. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18229. /**
  18230. * Called on JS contextmenu event.
  18231. * Override this method to provide functionality.
  18232. */
  18233. protected onContextMenu(evt: PointerEvent): void;
  18234. /**
  18235. * Detach the current controls from the specified dom element.
  18236. * @param element Defines the element to stop listening the inputs from
  18237. */
  18238. detachControl(element: Nullable<HTMLElement>): void;
  18239. /**
  18240. * Gets the class name of the current intput.
  18241. * @returns the class name
  18242. */
  18243. getClassName(): string;
  18244. /**
  18245. * Get the friendly name associated with the input class.
  18246. * @returns the input friendly name
  18247. */
  18248. getSimpleName(): string;
  18249. }
  18250. }
  18251. declare module BABYLON {
  18252. /**
  18253. * Manage the touch inputs to control the movement of a free camera.
  18254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18255. */
  18256. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18257. /**
  18258. * Defines the camera the input is attached to.
  18259. */
  18260. camera: FreeCamera;
  18261. /**
  18262. * Defines the touch sensibility for rotation.
  18263. * The higher the faster.
  18264. */
  18265. touchAngularSensibility: number;
  18266. /**
  18267. * Defines the touch sensibility for move.
  18268. * The higher the faster.
  18269. */
  18270. touchMoveSensibility: number;
  18271. private _offsetX;
  18272. private _offsetY;
  18273. private _pointerPressed;
  18274. private _pointerInput;
  18275. private _observer;
  18276. private _onLostFocus;
  18277. /**
  18278. * Attach the input controls to a specific dom element to get the input from.
  18279. * @param element Defines the element the controls should be listened from
  18280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18281. */
  18282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18283. /**
  18284. * Detach the current controls from the specified dom element.
  18285. * @param element Defines the element to stop listening the inputs from
  18286. */
  18287. detachControl(element: Nullable<HTMLElement>): void;
  18288. /**
  18289. * Update the current camera state depending on the inputs that have been used this frame.
  18290. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18291. */
  18292. checkInputs(): void;
  18293. /**
  18294. * Gets the class name of the current intput.
  18295. * @returns the class name
  18296. */
  18297. getClassName(): string;
  18298. /**
  18299. * Get the friendly name associated with the input class.
  18300. * @returns the input friendly name
  18301. */
  18302. getSimpleName(): string;
  18303. }
  18304. }
  18305. declare module BABYLON {
  18306. /**
  18307. * Default Inputs manager for the FreeCamera.
  18308. * It groups all the default supported inputs for ease of use.
  18309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18310. */
  18311. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18312. /**
  18313. * @hidden
  18314. */
  18315. _mouseInput: Nullable<FreeCameraMouseInput>;
  18316. /**
  18317. * Instantiates a new FreeCameraInputsManager.
  18318. * @param camera Defines the camera the inputs belong to
  18319. */
  18320. constructor(camera: FreeCamera);
  18321. /**
  18322. * Add keyboard input support to the input manager.
  18323. * @returns the current input manager
  18324. */
  18325. addKeyboard(): FreeCameraInputsManager;
  18326. /**
  18327. * Add mouse input support to the input manager.
  18328. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18329. * @returns the current input manager
  18330. */
  18331. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18332. /**
  18333. * Removes the mouse input support from the manager
  18334. * @returns the current input manager
  18335. */
  18336. removeMouse(): FreeCameraInputsManager;
  18337. /**
  18338. * Add touch input support to the input manager.
  18339. * @returns the current input manager
  18340. */
  18341. addTouch(): FreeCameraInputsManager;
  18342. /**
  18343. * Remove all attached input methods from a camera
  18344. */
  18345. clear(): void;
  18346. }
  18347. }
  18348. declare module BABYLON {
  18349. /**
  18350. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18351. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18352. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18353. */
  18354. export class FreeCamera extends TargetCamera {
  18355. /**
  18356. * Define the collision ellipsoid of the camera.
  18357. * This is helpful to simulate a camera body like the player body around the camera
  18358. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18359. */
  18360. ellipsoid: Vector3;
  18361. /**
  18362. * Define an offset for the position of the ellipsoid around the camera.
  18363. * This can be helpful to determine the center of the body near the gravity center of the body
  18364. * instead of its head.
  18365. */
  18366. ellipsoidOffset: Vector3;
  18367. /**
  18368. * Enable or disable collisions of the camera with the rest of the scene objects.
  18369. */
  18370. checkCollisions: boolean;
  18371. /**
  18372. * Enable or disable gravity on the camera.
  18373. */
  18374. applyGravity: boolean;
  18375. /**
  18376. * Define the input manager associated to the camera.
  18377. */
  18378. inputs: FreeCameraInputsManager;
  18379. /**
  18380. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18381. * Higher values reduce sensitivity.
  18382. */
  18383. get angularSensibility(): number;
  18384. /**
  18385. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18386. * Higher values reduce sensitivity.
  18387. */
  18388. set angularSensibility(value: number);
  18389. /**
  18390. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18391. */
  18392. get keysUp(): number[];
  18393. set keysUp(value: number[]);
  18394. /**
  18395. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18396. */
  18397. get keysDown(): number[];
  18398. set keysDown(value: number[]);
  18399. /**
  18400. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18401. */
  18402. get keysLeft(): number[];
  18403. set keysLeft(value: number[]);
  18404. /**
  18405. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18406. */
  18407. get keysRight(): number[];
  18408. set keysRight(value: number[]);
  18409. /**
  18410. * Event raised when the camera collide with a mesh in the scene.
  18411. */
  18412. onCollide: (collidedMesh: AbstractMesh) => void;
  18413. private _collider;
  18414. private _needMoveForGravity;
  18415. private _oldPosition;
  18416. private _diffPosition;
  18417. private _newPosition;
  18418. /** @hidden */
  18419. _localDirection: Vector3;
  18420. /** @hidden */
  18421. _transformedDirection: Vector3;
  18422. /**
  18423. * Instantiates a Free Camera.
  18424. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18425. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18426. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18427. * @param name Define the name of the camera in the scene
  18428. * @param position Define the start position of the camera in the scene
  18429. * @param scene Define the scene the camera belongs to
  18430. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18431. */
  18432. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18433. /**
  18434. * Attached controls to the current camera.
  18435. * @param element Defines the element the controls should be listened from
  18436. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18437. */
  18438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18439. /**
  18440. * Detach the current controls from the camera.
  18441. * The camera will stop reacting to inputs.
  18442. * @param element Defines the element to stop listening the inputs from
  18443. */
  18444. detachControl(element: HTMLElement): void;
  18445. private _collisionMask;
  18446. /**
  18447. * Define a collision mask to limit the list of object the camera can collide with
  18448. */
  18449. get collisionMask(): number;
  18450. set collisionMask(mask: number);
  18451. /** @hidden */
  18452. _collideWithWorld(displacement: Vector3): void;
  18453. private _onCollisionPositionChange;
  18454. /** @hidden */
  18455. _checkInputs(): void;
  18456. /** @hidden */
  18457. _decideIfNeedsToMove(): boolean;
  18458. /** @hidden */
  18459. _updatePosition(): void;
  18460. /**
  18461. * Destroy the camera and release the current resources hold by it.
  18462. */
  18463. dispose(): void;
  18464. /**
  18465. * Gets the current object class name.
  18466. * @return the class name
  18467. */
  18468. getClassName(): string;
  18469. }
  18470. }
  18471. declare module BABYLON {
  18472. /**
  18473. * Represents a gamepad control stick position
  18474. */
  18475. export class StickValues {
  18476. /**
  18477. * The x component of the control stick
  18478. */
  18479. x: number;
  18480. /**
  18481. * The y component of the control stick
  18482. */
  18483. y: number;
  18484. /**
  18485. * Initializes the gamepad x and y control stick values
  18486. * @param x The x component of the gamepad control stick value
  18487. * @param y The y component of the gamepad control stick value
  18488. */
  18489. constructor(
  18490. /**
  18491. * The x component of the control stick
  18492. */
  18493. x: number,
  18494. /**
  18495. * The y component of the control stick
  18496. */
  18497. y: number);
  18498. }
  18499. /**
  18500. * An interface which manages callbacks for gamepad button changes
  18501. */
  18502. export interface GamepadButtonChanges {
  18503. /**
  18504. * Called when a gamepad has been changed
  18505. */
  18506. changed: boolean;
  18507. /**
  18508. * Called when a gamepad press event has been triggered
  18509. */
  18510. pressChanged: boolean;
  18511. /**
  18512. * Called when a touch event has been triggered
  18513. */
  18514. touchChanged: boolean;
  18515. /**
  18516. * Called when a value has changed
  18517. */
  18518. valueChanged: boolean;
  18519. }
  18520. /**
  18521. * Represents a gamepad
  18522. */
  18523. export class Gamepad {
  18524. /**
  18525. * The id of the gamepad
  18526. */
  18527. id: string;
  18528. /**
  18529. * The index of the gamepad
  18530. */
  18531. index: number;
  18532. /**
  18533. * The browser gamepad
  18534. */
  18535. browserGamepad: any;
  18536. /**
  18537. * Specifies what type of gamepad this represents
  18538. */
  18539. type: number;
  18540. private _leftStick;
  18541. private _rightStick;
  18542. /** @hidden */
  18543. _isConnected: boolean;
  18544. private _leftStickAxisX;
  18545. private _leftStickAxisY;
  18546. private _rightStickAxisX;
  18547. private _rightStickAxisY;
  18548. /**
  18549. * Triggered when the left control stick has been changed
  18550. */
  18551. private _onleftstickchanged;
  18552. /**
  18553. * Triggered when the right control stick has been changed
  18554. */
  18555. private _onrightstickchanged;
  18556. /**
  18557. * Represents a gamepad controller
  18558. */
  18559. static GAMEPAD: number;
  18560. /**
  18561. * Represents a generic controller
  18562. */
  18563. static GENERIC: number;
  18564. /**
  18565. * Represents an XBox controller
  18566. */
  18567. static XBOX: number;
  18568. /**
  18569. * Represents a pose-enabled controller
  18570. */
  18571. static POSE_ENABLED: number;
  18572. /**
  18573. * Represents an Dual Shock controller
  18574. */
  18575. static DUALSHOCK: number;
  18576. /**
  18577. * Specifies whether the left control stick should be Y-inverted
  18578. */
  18579. protected _invertLeftStickY: boolean;
  18580. /**
  18581. * Specifies if the gamepad has been connected
  18582. */
  18583. get isConnected(): boolean;
  18584. /**
  18585. * Initializes the gamepad
  18586. * @param id The id of the gamepad
  18587. * @param index The index of the gamepad
  18588. * @param browserGamepad The browser gamepad
  18589. * @param leftStickX The x component of the left joystick
  18590. * @param leftStickY The y component of the left joystick
  18591. * @param rightStickX The x component of the right joystick
  18592. * @param rightStickY The y component of the right joystick
  18593. */
  18594. constructor(
  18595. /**
  18596. * The id of the gamepad
  18597. */
  18598. id: string,
  18599. /**
  18600. * The index of the gamepad
  18601. */
  18602. index: number,
  18603. /**
  18604. * The browser gamepad
  18605. */
  18606. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18607. /**
  18608. * Callback triggered when the left joystick has changed
  18609. * @param callback
  18610. */
  18611. onleftstickchanged(callback: (values: StickValues) => void): void;
  18612. /**
  18613. * Callback triggered when the right joystick has changed
  18614. * @param callback
  18615. */
  18616. onrightstickchanged(callback: (values: StickValues) => void): void;
  18617. /**
  18618. * Gets the left joystick
  18619. */
  18620. get leftStick(): StickValues;
  18621. /**
  18622. * Sets the left joystick values
  18623. */
  18624. set leftStick(newValues: StickValues);
  18625. /**
  18626. * Gets the right joystick
  18627. */
  18628. get rightStick(): StickValues;
  18629. /**
  18630. * Sets the right joystick value
  18631. */
  18632. set rightStick(newValues: StickValues);
  18633. /**
  18634. * Updates the gamepad joystick positions
  18635. */
  18636. update(): void;
  18637. /**
  18638. * Disposes the gamepad
  18639. */
  18640. dispose(): void;
  18641. }
  18642. /**
  18643. * Represents a generic gamepad
  18644. */
  18645. export class GenericPad extends Gamepad {
  18646. private _buttons;
  18647. private _onbuttondown;
  18648. private _onbuttonup;
  18649. /**
  18650. * Observable triggered when a button has been pressed
  18651. */
  18652. onButtonDownObservable: Observable<number>;
  18653. /**
  18654. * Observable triggered when a button has been released
  18655. */
  18656. onButtonUpObservable: Observable<number>;
  18657. /**
  18658. * Callback triggered when a button has been pressed
  18659. * @param callback Called when a button has been pressed
  18660. */
  18661. onbuttondown(callback: (buttonPressed: number) => void): void;
  18662. /**
  18663. * Callback triggered when a button has been released
  18664. * @param callback Called when a button has been released
  18665. */
  18666. onbuttonup(callback: (buttonReleased: number) => void): void;
  18667. /**
  18668. * Initializes the generic gamepad
  18669. * @param id The id of the generic gamepad
  18670. * @param index The index of the generic gamepad
  18671. * @param browserGamepad The browser gamepad
  18672. */
  18673. constructor(id: string, index: number, browserGamepad: any);
  18674. private _setButtonValue;
  18675. /**
  18676. * Updates the generic gamepad
  18677. */
  18678. update(): void;
  18679. /**
  18680. * Disposes the generic gamepad
  18681. */
  18682. dispose(): void;
  18683. }
  18684. }
  18685. declare module BABYLON {
  18686. /**
  18687. * Defines the types of pose enabled controllers that are supported
  18688. */
  18689. export enum PoseEnabledControllerType {
  18690. /**
  18691. * HTC Vive
  18692. */
  18693. VIVE = 0,
  18694. /**
  18695. * Oculus Rift
  18696. */
  18697. OCULUS = 1,
  18698. /**
  18699. * Windows mixed reality
  18700. */
  18701. WINDOWS = 2,
  18702. /**
  18703. * Samsung gear VR
  18704. */
  18705. GEAR_VR = 3,
  18706. /**
  18707. * Google Daydream
  18708. */
  18709. DAYDREAM = 4,
  18710. /**
  18711. * Generic
  18712. */
  18713. GENERIC = 5
  18714. }
  18715. /**
  18716. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18717. */
  18718. export interface MutableGamepadButton {
  18719. /**
  18720. * Value of the button/trigger
  18721. */
  18722. value: number;
  18723. /**
  18724. * If the button/trigger is currently touched
  18725. */
  18726. touched: boolean;
  18727. /**
  18728. * If the button/trigger is currently pressed
  18729. */
  18730. pressed: boolean;
  18731. }
  18732. /**
  18733. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18734. * @hidden
  18735. */
  18736. export interface ExtendedGamepadButton extends GamepadButton {
  18737. /**
  18738. * If the button/trigger is currently pressed
  18739. */
  18740. readonly pressed: boolean;
  18741. /**
  18742. * If the button/trigger is currently touched
  18743. */
  18744. readonly touched: boolean;
  18745. /**
  18746. * Value of the button/trigger
  18747. */
  18748. readonly value: number;
  18749. }
  18750. /** @hidden */
  18751. export interface _GamePadFactory {
  18752. /**
  18753. * Returns whether or not the current gamepad can be created for this type of controller.
  18754. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18755. * @returns true if it can be created, otherwise false
  18756. */
  18757. canCreate(gamepadInfo: any): boolean;
  18758. /**
  18759. * Creates a new instance of the Gamepad.
  18760. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18761. * @returns the new gamepad instance
  18762. */
  18763. create(gamepadInfo: any): Gamepad;
  18764. }
  18765. /**
  18766. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18767. */
  18768. export class PoseEnabledControllerHelper {
  18769. /** @hidden */
  18770. static _ControllerFactories: _GamePadFactory[];
  18771. /** @hidden */
  18772. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18773. /**
  18774. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18775. * @param vrGamepad the gamepad to initialized
  18776. * @returns a vr controller of the type the gamepad identified as
  18777. */
  18778. static InitiateController(vrGamepad: any): Gamepad;
  18779. }
  18780. /**
  18781. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18782. */
  18783. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18784. /**
  18785. * If the controller is used in a webXR session
  18786. */
  18787. isXR: boolean;
  18788. private _deviceRoomPosition;
  18789. private _deviceRoomRotationQuaternion;
  18790. /**
  18791. * The device position in babylon space
  18792. */
  18793. devicePosition: Vector3;
  18794. /**
  18795. * The device rotation in babylon space
  18796. */
  18797. deviceRotationQuaternion: Quaternion;
  18798. /**
  18799. * The scale factor of the device in babylon space
  18800. */
  18801. deviceScaleFactor: number;
  18802. /**
  18803. * (Likely devicePosition should be used instead) The device position in its room space
  18804. */
  18805. position: Vector3;
  18806. /**
  18807. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18808. */
  18809. rotationQuaternion: Quaternion;
  18810. /**
  18811. * The type of controller (Eg. Windows mixed reality)
  18812. */
  18813. controllerType: PoseEnabledControllerType;
  18814. protected _calculatedPosition: Vector3;
  18815. private _calculatedRotation;
  18816. /**
  18817. * The raw pose from the device
  18818. */
  18819. rawPose: DevicePose;
  18820. private _trackPosition;
  18821. private _maxRotationDistFromHeadset;
  18822. private _draggedRoomRotation;
  18823. /**
  18824. * @hidden
  18825. */
  18826. _disableTrackPosition(fixedPosition: Vector3): void;
  18827. /**
  18828. * Internal, the mesh attached to the controller
  18829. * @hidden
  18830. */
  18831. _mesh: Nullable<AbstractMesh>;
  18832. private _poseControlledCamera;
  18833. private _leftHandSystemQuaternion;
  18834. /**
  18835. * Internal, matrix used to convert room space to babylon space
  18836. * @hidden
  18837. */
  18838. _deviceToWorld: Matrix;
  18839. /**
  18840. * Node to be used when casting a ray from the controller
  18841. * @hidden
  18842. */
  18843. _pointingPoseNode: Nullable<TransformNode>;
  18844. /**
  18845. * Name of the child mesh that can be used to cast a ray from the controller
  18846. */
  18847. static readonly POINTING_POSE: string;
  18848. /**
  18849. * Creates a new PoseEnabledController from a gamepad
  18850. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18851. */
  18852. constructor(browserGamepad: any);
  18853. private _workingMatrix;
  18854. /**
  18855. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18856. */
  18857. update(): void;
  18858. /**
  18859. * Updates only the pose device and mesh without doing any button event checking
  18860. */
  18861. protected _updatePoseAndMesh(): void;
  18862. /**
  18863. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18864. * @param poseData raw pose fromthe device
  18865. */
  18866. updateFromDevice(poseData: DevicePose): void;
  18867. /**
  18868. * @hidden
  18869. */
  18870. _meshAttachedObservable: Observable<AbstractMesh>;
  18871. /**
  18872. * Attaches a mesh to the controller
  18873. * @param mesh the mesh to be attached
  18874. */
  18875. attachToMesh(mesh: AbstractMesh): void;
  18876. /**
  18877. * Attaches the controllers mesh to a camera
  18878. * @param camera the camera the mesh should be attached to
  18879. */
  18880. attachToPoseControlledCamera(camera: TargetCamera): void;
  18881. /**
  18882. * Disposes of the controller
  18883. */
  18884. dispose(): void;
  18885. /**
  18886. * The mesh that is attached to the controller
  18887. */
  18888. get mesh(): Nullable<AbstractMesh>;
  18889. /**
  18890. * Gets the ray of the controller in the direction the controller is pointing
  18891. * @param length the length the resulting ray should be
  18892. * @returns a ray in the direction the controller is pointing
  18893. */
  18894. getForwardRay(length?: number): Ray;
  18895. }
  18896. }
  18897. declare module BABYLON {
  18898. /**
  18899. * Defines the WebVRController object that represents controllers tracked in 3D space
  18900. */
  18901. export abstract class WebVRController extends PoseEnabledController {
  18902. /**
  18903. * Internal, the default controller model for the controller
  18904. */
  18905. protected _defaultModel: Nullable<AbstractMesh>;
  18906. /**
  18907. * Fired when the trigger state has changed
  18908. */
  18909. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18910. /**
  18911. * Fired when the main button state has changed
  18912. */
  18913. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18914. /**
  18915. * Fired when the secondary button state has changed
  18916. */
  18917. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18918. /**
  18919. * Fired when the pad state has changed
  18920. */
  18921. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18922. /**
  18923. * Fired when controllers stick values have changed
  18924. */
  18925. onPadValuesChangedObservable: Observable<StickValues>;
  18926. /**
  18927. * Array of button availible on the controller
  18928. */
  18929. protected _buttons: Array<MutableGamepadButton>;
  18930. private _onButtonStateChange;
  18931. /**
  18932. * Fired when a controller button's state has changed
  18933. * @param callback the callback containing the button that was modified
  18934. */
  18935. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18936. /**
  18937. * X and Y axis corresponding to the controllers joystick
  18938. */
  18939. pad: StickValues;
  18940. /**
  18941. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18942. */
  18943. hand: string;
  18944. /**
  18945. * The default controller model for the controller
  18946. */
  18947. get defaultModel(): Nullable<AbstractMesh>;
  18948. /**
  18949. * Creates a new WebVRController from a gamepad
  18950. * @param vrGamepad the gamepad that the WebVRController should be created from
  18951. */
  18952. constructor(vrGamepad: any);
  18953. /**
  18954. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18955. */
  18956. update(): void;
  18957. /**
  18958. * Function to be called when a button is modified
  18959. */
  18960. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  18961. /**
  18962. * Loads a mesh and attaches it to the controller
  18963. * @param scene the scene the mesh should be added to
  18964. * @param meshLoaded callback for when the mesh has been loaded
  18965. */
  18966. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  18967. private _setButtonValue;
  18968. private _changes;
  18969. private _checkChanges;
  18970. /**
  18971. * Disposes of th webVRCOntroller
  18972. */
  18973. dispose(): void;
  18974. }
  18975. }
  18976. declare module BABYLON {
  18977. /**
  18978. * The HemisphericLight simulates the ambient environment light,
  18979. * so the passed direction is the light reflection direction, not the incoming direction.
  18980. */
  18981. export class HemisphericLight extends Light {
  18982. /**
  18983. * The groundColor is the light in the opposite direction to the one specified during creation.
  18984. * 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.
  18985. */
  18986. groundColor: Color3;
  18987. /**
  18988. * The light reflection direction, not the incoming direction.
  18989. */
  18990. direction: Vector3;
  18991. /**
  18992. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  18993. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  18994. * The HemisphericLight can't cast shadows.
  18995. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18996. * @param name The friendly name of the light
  18997. * @param direction The direction of the light reflection
  18998. * @param scene The scene the light belongs to
  18999. */
  19000. constructor(name: string, direction: Vector3, scene: Scene);
  19001. protected _buildUniformLayout(): void;
  19002. /**
  19003. * Returns the string "HemisphericLight".
  19004. * @return The class name
  19005. */
  19006. getClassName(): string;
  19007. /**
  19008. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19009. * Returns the updated direction.
  19010. * @param target The target the direction should point to
  19011. * @return The computed direction
  19012. */
  19013. setDirectionToTarget(target: Vector3): Vector3;
  19014. /**
  19015. * Returns the shadow generator associated to the light.
  19016. * @returns Always null for hemispheric lights because it does not support shadows.
  19017. */
  19018. getShadowGenerator(): Nullable<IShadowGenerator>;
  19019. /**
  19020. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19021. * @param effect The effect to update
  19022. * @param lightIndex The index of the light in the effect to update
  19023. * @returns The hemispheric light
  19024. */
  19025. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19026. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19027. /**
  19028. * Computes the world matrix of the node
  19029. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19030. * @param useWasUpdatedFlag defines a reserved property
  19031. * @returns the world matrix
  19032. */
  19033. computeWorldMatrix(): Matrix;
  19034. /**
  19035. * Returns the integer 3.
  19036. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19037. */
  19038. getTypeID(): number;
  19039. /**
  19040. * Prepares the list of defines specific to the light type.
  19041. * @param defines the list of defines
  19042. * @param lightIndex defines the index of the light for the effect
  19043. */
  19044. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19045. }
  19046. }
  19047. declare module BABYLON {
  19048. /** @hidden */
  19049. export var vrMultiviewToSingleviewPixelShader: {
  19050. name: string;
  19051. shader: string;
  19052. };
  19053. }
  19054. declare module BABYLON {
  19055. /**
  19056. * Renders to multiple views with a single draw call
  19057. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19058. */
  19059. export class MultiviewRenderTarget extends RenderTargetTexture {
  19060. /**
  19061. * Creates a multiview render target
  19062. * @param scene scene used with the render target
  19063. * @param size the size of the render target (used for each view)
  19064. */
  19065. constructor(scene: Scene, size?: number | {
  19066. width: number;
  19067. height: number;
  19068. } | {
  19069. ratio: number;
  19070. });
  19071. /**
  19072. * @hidden
  19073. * @param faceIndex the face index, if its a cube texture
  19074. */
  19075. _bindFrameBuffer(faceIndex?: number): void;
  19076. /**
  19077. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19078. * @returns the view count
  19079. */
  19080. getViewCount(): number;
  19081. }
  19082. }
  19083. declare module BABYLON {
  19084. /**
  19085. * Represents a camera frustum
  19086. */
  19087. export class Frustum {
  19088. /**
  19089. * Gets the planes representing the frustum
  19090. * @param transform matrix to be applied to the returned planes
  19091. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19092. */
  19093. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19094. /**
  19095. * Gets the near frustum plane transformed by the transform matrix
  19096. * @param transform transformation matrix to be applied to the resulting frustum plane
  19097. * @param frustumPlane the resuling frustum plane
  19098. */
  19099. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19100. /**
  19101. * Gets the far frustum plane transformed by the transform matrix
  19102. * @param transform transformation matrix to be applied to the resulting frustum plane
  19103. * @param frustumPlane the resuling frustum plane
  19104. */
  19105. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19106. /**
  19107. * Gets the left frustum plane transformed by the transform matrix
  19108. * @param transform transformation matrix to be applied to the resulting frustum plane
  19109. * @param frustumPlane the resuling frustum plane
  19110. */
  19111. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19112. /**
  19113. * Gets the right frustum plane transformed by the transform matrix
  19114. * @param transform transformation matrix to be applied to the resulting frustum plane
  19115. * @param frustumPlane the resuling frustum plane
  19116. */
  19117. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19118. /**
  19119. * Gets the top frustum plane transformed by the transform matrix
  19120. * @param transform transformation matrix to be applied to the resulting frustum plane
  19121. * @param frustumPlane the resuling frustum plane
  19122. */
  19123. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19124. /**
  19125. * Gets the bottom frustum plane transformed by the transform matrix
  19126. * @param transform transformation matrix to be applied to the resulting frustum plane
  19127. * @param frustumPlane the resuling frustum plane
  19128. */
  19129. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19130. /**
  19131. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19132. * @param transform transformation matrix to be applied to the resulting frustum planes
  19133. * @param frustumPlanes the resuling frustum planes
  19134. */
  19135. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19136. }
  19137. }
  19138. declare module BABYLON {
  19139. interface Engine {
  19140. /**
  19141. * Creates a new multiview render target
  19142. * @param width defines the width of the texture
  19143. * @param height defines the height of the texture
  19144. * @returns the created multiview texture
  19145. */
  19146. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19147. /**
  19148. * Binds a multiview framebuffer to be drawn to
  19149. * @param multiviewTexture texture to bind
  19150. */
  19151. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19152. }
  19153. interface Camera {
  19154. /**
  19155. * @hidden
  19156. * 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)
  19157. */
  19158. _useMultiviewToSingleView: boolean;
  19159. /**
  19160. * @hidden
  19161. * 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)
  19162. */
  19163. _multiviewTexture: Nullable<RenderTargetTexture>;
  19164. /**
  19165. * @hidden
  19166. * ensures the multiview texture of the camera exists and has the specified width/height
  19167. * @param width height to set on the multiview texture
  19168. * @param height width to set on the multiview texture
  19169. */
  19170. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19171. }
  19172. interface Scene {
  19173. /** @hidden */
  19174. _transformMatrixR: Matrix;
  19175. /** @hidden */
  19176. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19177. /** @hidden */
  19178. _createMultiviewUbo(): void;
  19179. /** @hidden */
  19180. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19181. /** @hidden */
  19182. _renderMultiviewToSingleView(camera: Camera): void;
  19183. }
  19184. }
  19185. declare module BABYLON {
  19186. /**
  19187. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19188. * This will not be used for webXR as it supports displaying texture arrays directly
  19189. */
  19190. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19191. /**
  19192. * Initializes a VRMultiviewToSingleview
  19193. * @param name name of the post process
  19194. * @param camera camera to be applied to
  19195. * @param scaleFactor scaling factor to the size of the output texture
  19196. */
  19197. constructor(name: string, camera: Camera, scaleFactor: number);
  19198. }
  19199. }
  19200. declare module BABYLON {
  19201. /**
  19202. * Interface used to define additional presentation attributes
  19203. */
  19204. export interface IVRPresentationAttributes {
  19205. /**
  19206. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19207. */
  19208. highRefreshRate: boolean;
  19209. /**
  19210. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19211. */
  19212. foveationLevel: number;
  19213. }
  19214. interface Engine {
  19215. /** @hidden */
  19216. _vrDisplay: any;
  19217. /** @hidden */
  19218. _vrSupported: boolean;
  19219. /** @hidden */
  19220. _oldSize: Size;
  19221. /** @hidden */
  19222. _oldHardwareScaleFactor: number;
  19223. /** @hidden */
  19224. _vrExclusivePointerMode: boolean;
  19225. /** @hidden */
  19226. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19227. /** @hidden */
  19228. _onVRDisplayPointerRestricted: () => void;
  19229. /** @hidden */
  19230. _onVRDisplayPointerUnrestricted: () => void;
  19231. /** @hidden */
  19232. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19233. /** @hidden */
  19234. _onVrDisplayDisconnect: Nullable<() => void>;
  19235. /** @hidden */
  19236. _onVrDisplayPresentChange: Nullable<() => void>;
  19237. /**
  19238. * Observable signaled when VR display mode changes
  19239. */
  19240. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19241. /**
  19242. * Observable signaled when VR request present is complete
  19243. */
  19244. onVRRequestPresentComplete: Observable<boolean>;
  19245. /**
  19246. * Observable signaled when VR request present starts
  19247. */
  19248. onVRRequestPresentStart: Observable<Engine>;
  19249. /**
  19250. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19251. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19252. */
  19253. isInVRExclusivePointerMode: boolean;
  19254. /**
  19255. * Gets a boolean indicating if a webVR device was detected
  19256. * @returns true if a webVR device was detected
  19257. */
  19258. isVRDevicePresent(): boolean;
  19259. /**
  19260. * Gets the current webVR device
  19261. * @returns the current webVR device (or null)
  19262. */
  19263. getVRDevice(): any;
  19264. /**
  19265. * Initializes a webVR display and starts listening to display change events
  19266. * The onVRDisplayChangedObservable will be notified upon these changes
  19267. * @returns A promise containing a VRDisplay and if vr is supported
  19268. */
  19269. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19270. /** @hidden */
  19271. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19272. /**
  19273. * Gets or sets the presentation attributes used to configure VR rendering
  19274. */
  19275. vrPresentationAttributes?: IVRPresentationAttributes;
  19276. /**
  19277. * Call this function to switch to webVR mode
  19278. * Will do nothing if webVR is not supported or if there is no webVR device
  19279. * @param options the webvr options provided to the camera. mainly used for multiview
  19280. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19281. */
  19282. enableVR(options: WebVROptions): void;
  19283. /** @hidden */
  19284. _onVRFullScreenTriggered(): void;
  19285. }
  19286. }
  19287. declare module BABYLON {
  19288. /**
  19289. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19290. * IMPORTANT!! The data is right-hand data.
  19291. * @export
  19292. * @interface DevicePose
  19293. */
  19294. export interface DevicePose {
  19295. /**
  19296. * The position of the device, values in array are [x,y,z].
  19297. */
  19298. readonly position: Nullable<Float32Array>;
  19299. /**
  19300. * The linearVelocity of the device, values in array are [x,y,z].
  19301. */
  19302. readonly linearVelocity: Nullable<Float32Array>;
  19303. /**
  19304. * The linearAcceleration of the device, values in array are [x,y,z].
  19305. */
  19306. readonly linearAcceleration: Nullable<Float32Array>;
  19307. /**
  19308. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19309. */
  19310. readonly orientation: Nullable<Float32Array>;
  19311. /**
  19312. * The angularVelocity of the device, values in array are [x,y,z].
  19313. */
  19314. readonly angularVelocity: Nullable<Float32Array>;
  19315. /**
  19316. * The angularAcceleration of the device, values in array are [x,y,z].
  19317. */
  19318. readonly angularAcceleration: Nullable<Float32Array>;
  19319. }
  19320. /**
  19321. * Interface representing a pose controlled object in Babylon.
  19322. * A pose controlled object has both regular pose values as well as pose values
  19323. * from an external device such as a VR head mounted display
  19324. */
  19325. export interface PoseControlled {
  19326. /**
  19327. * The position of the object in babylon space.
  19328. */
  19329. position: Vector3;
  19330. /**
  19331. * The rotation quaternion of the object in babylon space.
  19332. */
  19333. rotationQuaternion: Quaternion;
  19334. /**
  19335. * The position of the device in babylon space.
  19336. */
  19337. devicePosition?: Vector3;
  19338. /**
  19339. * The rotation quaternion of the device in babylon space.
  19340. */
  19341. deviceRotationQuaternion: Quaternion;
  19342. /**
  19343. * The raw pose coming from the device.
  19344. */
  19345. rawPose: Nullable<DevicePose>;
  19346. /**
  19347. * The scale of the device to be used when translating from device space to babylon space.
  19348. */
  19349. deviceScaleFactor: number;
  19350. /**
  19351. * Updates the poseControlled values based on the input device pose.
  19352. * @param poseData the pose data to update the object with
  19353. */
  19354. updateFromDevice(poseData: DevicePose): void;
  19355. }
  19356. /**
  19357. * Set of options to customize the webVRCamera
  19358. */
  19359. export interface WebVROptions {
  19360. /**
  19361. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19362. */
  19363. trackPosition?: boolean;
  19364. /**
  19365. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19366. */
  19367. positionScale?: number;
  19368. /**
  19369. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19370. */
  19371. displayName?: string;
  19372. /**
  19373. * Should the native controller meshes be initialized. (default: true)
  19374. */
  19375. controllerMeshes?: boolean;
  19376. /**
  19377. * Creating a default HemiLight only on controllers. (default: true)
  19378. */
  19379. defaultLightingOnControllers?: boolean;
  19380. /**
  19381. * If you don't want to use the default VR button of the helper. (default: false)
  19382. */
  19383. useCustomVRButton?: boolean;
  19384. /**
  19385. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19386. */
  19387. customVRButton?: HTMLButtonElement;
  19388. /**
  19389. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19390. */
  19391. rayLength?: number;
  19392. /**
  19393. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19394. */
  19395. defaultHeight?: number;
  19396. /**
  19397. * If multiview should be used if availible (default: false)
  19398. */
  19399. useMultiview?: boolean;
  19400. }
  19401. /**
  19402. * This represents a WebVR camera.
  19403. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19404. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19405. */
  19406. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19407. private webVROptions;
  19408. /**
  19409. * @hidden
  19410. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19411. */
  19412. _vrDevice: any;
  19413. /**
  19414. * The rawPose of the vrDevice.
  19415. */
  19416. rawPose: Nullable<DevicePose>;
  19417. private _onVREnabled;
  19418. private _specsVersion;
  19419. private _attached;
  19420. private _frameData;
  19421. protected _descendants: Array<Node>;
  19422. private _deviceRoomPosition;
  19423. /** @hidden */
  19424. _deviceRoomRotationQuaternion: Quaternion;
  19425. private _standingMatrix;
  19426. /**
  19427. * Represents device position in babylon space.
  19428. */
  19429. devicePosition: Vector3;
  19430. /**
  19431. * Represents device rotation in babylon space.
  19432. */
  19433. deviceRotationQuaternion: Quaternion;
  19434. /**
  19435. * The scale of the device to be used when translating from device space to babylon space.
  19436. */
  19437. deviceScaleFactor: number;
  19438. private _deviceToWorld;
  19439. private _worldToDevice;
  19440. /**
  19441. * References to the webVR controllers for the vrDevice.
  19442. */
  19443. controllers: Array<WebVRController>;
  19444. /**
  19445. * Emits an event when a controller is attached.
  19446. */
  19447. onControllersAttachedObservable: Observable<WebVRController[]>;
  19448. /**
  19449. * Emits an event when a controller's mesh has been loaded;
  19450. */
  19451. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19452. /**
  19453. * Emits an event when the HMD's pose has been updated.
  19454. */
  19455. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19456. private _poseSet;
  19457. /**
  19458. * If the rig cameras be used as parent instead of this camera.
  19459. */
  19460. rigParenting: boolean;
  19461. private _lightOnControllers;
  19462. private _defaultHeight?;
  19463. /**
  19464. * Instantiates a WebVRFreeCamera.
  19465. * @param name The name of the WebVRFreeCamera
  19466. * @param position The starting anchor position for the camera
  19467. * @param scene The scene the camera belongs to
  19468. * @param webVROptions a set of customizable options for the webVRCamera
  19469. */
  19470. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19471. /**
  19472. * Gets the device distance from the ground in meters.
  19473. * @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.
  19474. */
  19475. deviceDistanceToRoomGround(): number;
  19476. /**
  19477. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19478. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19479. */
  19480. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19481. /**
  19482. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19483. * @returns A promise with a boolean set to if the standing matrix is supported.
  19484. */
  19485. useStandingMatrixAsync(): Promise<boolean>;
  19486. /**
  19487. * Disposes the camera
  19488. */
  19489. dispose(): void;
  19490. /**
  19491. * Gets a vrController by name.
  19492. * @param name The name of the controller to retreive
  19493. * @returns the controller matching the name specified or null if not found
  19494. */
  19495. getControllerByName(name: string): Nullable<WebVRController>;
  19496. private _leftController;
  19497. /**
  19498. * The controller corresponding to the users left hand.
  19499. */
  19500. get leftController(): Nullable<WebVRController>;
  19501. private _rightController;
  19502. /**
  19503. * The controller corresponding to the users right hand.
  19504. */
  19505. get rightController(): Nullable<WebVRController>;
  19506. /**
  19507. * Casts a ray forward from the vrCamera's gaze.
  19508. * @param length Length of the ray (default: 100)
  19509. * @returns the ray corresponding to the gaze
  19510. */
  19511. getForwardRay(length?: number): Ray;
  19512. /**
  19513. * @hidden
  19514. * Updates the camera based on device's frame data
  19515. */
  19516. _checkInputs(): void;
  19517. /**
  19518. * Updates the poseControlled values based on the input device pose.
  19519. * @param poseData Pose coming from the device
  19520. */
  19521. updateFromDevice(poseData: DevicePose): void;
  19522. private _htmlElementAttached;
  19523. private _detachIfAttached;
  19524. /**
  19525. * WebVR's attach control will start broadcasting frames to the device.
  19526. * Note that in certain browsers (chrome for example) this function must be called
  19527. * within a user-interaction callback. Example:
  19528. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19529. *
  19530. * @param element html element to attach the vrDevice to
  19531. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19532. */
  19533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19534. /**
  19535. * Detaches the camera from the html element and disables VR
  19536. *
  19537. * @param element html element to detach from
  19538. */
  19539. detachControl(element: HTMLElement): void;
  19540. /**
  19541. * @returns the name of this class
  19542. */
  19543. getClassName(): string;
  19544. /**
  19545. * Calls resetPose on the vrDisplay
  19546. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19547. */
  19548. resetToCurrentRotation(): void;
  19549. /**
  19550. * @hidden
  19551. * Updates the rig cameras (left and right eye)
  19552. */
  19553. _updateRigCameras(): void;
  19554. private _workingVector;
  19555. private _oneVector;
  19556. private _workingMatrix;
  19557. private updateCacheCalled;
  19558. private _correctPositionIfNotTrackPosition;
  19559. /**
  19560. * @hidden
  19561. * Updates the cached values of the camera
  19562. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19563. */
  19564. _updateCache(ignoreParentClass?: boolean): void;
  19565. /**
  19566. * @hidden
  19567. * Get current device position in babylon world
  19568. */
  19569. _computeDevicePosition(): void;
  19570. /**
  19571. * Updates the current device position and rotation in the babylon world
  19572. */
  19573. update(): void;
  19574. /**
  19575. * @hidden
  19576. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19577. * @returns an identity matrix
  19578. */
  19579. _getViewMatrix(): Matrix;
  19580. private _tmpMatrix;
  19581. /**
  19582. * This function is called by the two RIG cameras.
  19583. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19584. * @hidden
  19585. */
  19586. _getWebVRViewMatrix(): Matrix;
  19587. /** @hidden */
  19588. _getWebVRProjectionMatrix(): Matrix;
  19589. private _onGamepadConnectedObserver;
  19590. private _onGamepadDisconnectedObserver;
  19591. private _updateCacheWhenTrackingDisabledObserver;
  19592. /**
  19593. * Initializes the controllers and their meshes
  19594. */
  19595. initControllers(): void;
  19596. }
  19597. }
  19598. declare module BABYLON {
  19599. /**
  19600. * Size options for a post process
  19601. */
  19602. export type PostProcessOptions = {
  19603. width: number;
  19604. height: number;
  19605. };
  19606. /**
  19607. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19608. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19609. */
  19610. export class PostProcess {
  19611. /** Name of the PostProcess. */
  19612. name: string;
  19613. /**
  19614. * Gets or sets the unique id of the post process
  19615. */
  19616. uniqueId: number;
  19617. /**
  19618. * Width of the texture to apply the post process on
  19619. */
  19620. width: number;
  19621. /**
  19622. * Height of the texture to apply the post process on
  19623. */
  19624. height: number;
  19625. /**
  19626. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19627. * @hidden
  19628. */
  19629. _outputTexture: Nullable<InternalTexture>;
  19630. /**
  19631. * Sampling mode used by the shader
  19632. * See https://doc.babylonjs.com/classes/3.1/texture
  19633. */
  19634. renderTargetSamplingMode: number;
  19635. /**
  19636. * Clear color to use when screen clearing
  19637. */
  19638. clearColor: Color4;
  19639. /**
  19640. * If the buffer needs to be cleared before applying the post process. (default: true)
  19641. * Should be set to false if shader will overwrite all previous pixels.
  19642. */
  19643. autoClear: boolean;
  19644. /**
  19645. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19646. */
  19647. alphaMode: number;
  19648. /**
  19649. * Sets the setAlphaBlendConstants of the babylon engine
  19650. */
  19651. alphaConstants: Color4;
  19652. /**
  19653. * Animations to be used for the post processing
  19654. */
  19655. animations: Animation[];
  19656. /**
  19657. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19658. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19659. */
  19660. enablePixelPerfectMode: boolean;
  19661. /**
  19662. * Force the postprocess to be applied without taking in account viewport
  19663. */
  19664. forceFullscreenViewport: boolean;
  19665. /**
  19666. * List of inspectable custom properties (used by the Inspector)
  19667. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19668. */
  19669. inspectableCustomProperties: IInspectable[];
  19670. /**
  19671. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19672. *
  19673. * | Value | Type | Description |
  19674. * | ----- | ----------------------------------- | ----------- |
  19675. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19676. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19677. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19678. *
  19679. */
  19680. scaleMode: number;
  19681. /**
  19682. * Force textures to be a power of two (default: false)
  19683. */
  19684. alwaysForcePOT: boolean;
  19685. private _samples;
  19686. /**
  19687. * Number of sample textures (default: 1)
  19688. */
  19689. get samples(): number;
  19690. set samples(n: number);
  19691. /**
  19692. * Modify the scale of the post process to be the same as the viewport (default: false)
  19693. */
  19694. adaptScaleToCurrentViewport: boolean;
  19695. private _camera;
  19696. private _scene;
  19697. private _engine;
  19698. private _options;
  19699. private _reusable;
  19700. private _textureType;
  19701. private _textureFormat;
  19702. /**
  19703. * Smart array of input and output textures for the post process.
  19704. * @hidden
  19705. */
  19706. _textures: SmartArray<InternalTexture>;
  19707. /**
  19708. * The index in _textures that corresponds to the output texture.
  19709. * @hidden
  19710. */
  19711. _currentRenderTextureInd: number;
  19712. private _effect;
  19713. private _samplers;
  19714. private _fragmentUrl;
  19715. private _vertexUrl;
  19716. private _parameters;
  19717. private _scaleRatio;
  19718. protected _indexParameters: any;
  19719. private _shareOutputWithPostProcess;
  19720. private _texelSize;
  19721. private _forcedOutputTexture;
  19722. /**
  19723. * Returns the fragment url or shader name used in the post process.
  19724. * @returns the fragment url or name in the shader store.
  19725. */
  19726. getEffectName(): string;
  19727. /**
  19728. * An event triggered when the postprocess is activated.
  19729. */
  19730. onActivateObservable: Observable<Camera>;
  19731. private _onActivateObserver;
  19732. /**
  19733. * A function that is added to the onActivateObservable
  19734. */
  19735. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19736. /**
  19737. * An event triggered when the postprocess changes its size.
  19738. */
  19739. onSizeChangedObservable: Observable<PostProcess>;
  19740. private _onSizeChangedObserver;
  19741. /**
  19742. * A function that is added to the onSizeChangedObservable
  19743. */
  19744. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19745. /**
  19746. * An event triggered when the postprocess applies its effect.
  19747. */
  19748. onApplyObservable: Observable<Effect>;
  19749. private _onApplyObserver;
  19750. /**
  19751. * A function that is added to the onApplyObservable
  19752. */
  19753. set onApply(callback: (effect: Effect) => void);
  19754. /**
  19755. * An event triggered before rendering the postprocess
  19756. */
  19757. onBeforeRenderObservable: Observable<Effect>;
  19758. private _onBeforeRenderObserver;
  19759. /**
  19760. * A function that is added to the onBeforeRenderObservable
  19761. */
  19762. set onBeforeRender(callback: (effect: Effect) => void);
  19763. /**
  19764. * An event triggered after rendering the postprocess
  19765. */
  19766. onAfterRenderObservable: Observable<Effect>;
  19767. private _onAfterRenderObserver;
  19768. /**
  19769. * A function that is added to the onAfterRenderObservable
  19770. */
  19771. set onAfterRender(callback: (efect: Effect) => void);
  19772. /**
  19773. * 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
  19774. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19775. */
  19776. get inputTexture(): InternalTexture;
  19777. set inputTexture(value: InternalTexture);
  19778. /**
  19779. * Gets the camera which post process is applied to.
  19780. * @returns The camera the post process is applied to.
  19781. */
  19782. getCamera(): Camera;
  19783. /**
  19784. * Gets the texel size of the postprocess.
  19785. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19786. */
  19787. get texelSize(): Vector2;
  19788. /**
  19789. * Creates a new instance PostProcess
  19790. * @param name The name of the PostProcess.
  19791. * @param fragmentUrl The url of the fragment shader to be used.
  19792. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19793. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19794. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19795. * @param camera The camera to apply the render pass to.
  19796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19797. * @param engine The engine which the post process will be applied. (default: current engine)
  19798. * @param reusable If the post process can be reused on the same frame. (default: false)
  19799. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19800. * @param textureType Type of textures used when performing the post process. (default: 0)
  19801. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19802. * @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
  19803. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19804. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19805. */
  19806. constructor(
  19807. /** Name of the PostProcess. */
  19808. 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, textureFormat?: number);
  19809. /**
  19810. * Gets a string idenfifying the name of the class
  19811. * @returns "PostProcess" string
  19812. */
  19813. getClassName(): string;
  19814. /**
  19815. * Gets the engine which this post process belongs to.
  19816. * @returns The engine the post process was enabled with.
  19817. */
  19818. getEngine(): Engine;
  19819. /**
  19820. * The effect that is created when initializing the post process.
  19821. * @returns The created effect corresponding the the postprocess.
  19822. */
  19823. getEffect(): Effect;
  19824. /**
  19825. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19826. * @param postProcess The post process to share the output with.
  19827. * @returns This post process.
  19828. */
  19829. shareOutputWith(postProcess: PostProcess): PostProcess;
  19830. /**
  19831. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19832. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19833. */
  19834. useOwnOutput(): void;
  19835. /**
  19836. * Updates the effect with the current post process compile time values and recompiles the shader.
  19837. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19838. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19839. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19840. * @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
  19841. * @param onCompiled Called when the shader has been compiled.
  19842. * @param onError Called if there is an error when compiling a shader.
  19843. */
  19844. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19845. /**
  19846. * The post process is reusable if it can be used multiple times within one frame.
  19847. * @returns If the post process is reusable
  19848. */
  19849. isReusable(): boolean;
  19850. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19851. markTextureDirty(): void;
  19852. /**
  19853. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19854. * 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.
  19855. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19856. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19857. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19858. * @returns The target texture that was bound to be written to.
  19859. */
  19860. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19861. /**
  19862. * If the post process is supported.
  19863. */
  19864. get isSupported(): boolean;
  19865. /**
  19866. * The aspect ratio of the output texture.
  19867. */
  19868. get aspectRatio(): number;
  19869. /**
  19870. * Get a value indicating if the post-process is ready to be used
  19871. * @returns true if the post-process is ready (shader is compiled)
  19872. */
  19873. isReady(): boolean;
  19874. /**
  19875. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19876. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19877. */
  19878. apply(): Nullable<Effect>;
  19879. private _disposeTextures;
  19880. /**
  19881. * Disposes the post process.
  19882. * @param camera The camera to dispose the post process on.
  19883. */
  19884. dispose(camera?: Camera): void;
  19885. }
  19886. }
  19887. declare module BABYLON {
  19888. /** @hidden */
  19889. export var kernelBlurVaryingDeclaration: {
  19890. name: string;
  19891. shader: string;
  19892. };
  19893. }
  19894. declare module BABYLON {
  19895. /** @hidden */
  19896. export var kernelBlurFragment: {
  19897. name: string;
  19898. shader: string;
  19899. };
  19900. }
  19901. declare module BABYLON {
  19902. /** @hidden */
  19903. export var kernelBlurFragment2: {
  19904. name: string;
  19905. shader: string;
  19906. };
  19907. }
  19908. declare module BABYLON {
  19909. /** @hidden */
  19910. export var kernelBlurPixelShader: {
  19911. name: string;
  19912. shader: string;
  19913. };
  19914. }
  19915. declare module BABYLON {
  19916. /** @hidden */
  19917. export var kernelBlurVertex: {
  19918. name: string;
  19919. shader: string;
  19920. };
  19921. }
  19922. declare module BABYLON {
  19923. /** @hidden */
  19924. export var kernelBlurVertexShader: {
  19925. name: string;
  19926. shader: string;
  19927. };
  19928. }
  19929. declare module BABYLON {
  19930. /**
  19931. * The Blur Post Process which blurs an image based on a kernel and direction.
  19932. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19933. */
  19934. export class BlurPostProcess extends PostProcess {
  19935. /** The direction in which to blur the image. */
  19936. direction: Vector2;
  19937. private blockCompilation;
  19938. protected _kernel: number;
  19939. protected _idealKernel: number;
  19940. protected _packedFloat: boolean;
  19941. private _staticDefines;
  19942. /**
  19943. * Sets the length in pixels of the blur sample region
  19944. */
  19945. set kernel(v: number);
  19946. /**
  19947. * Gets the length in pixels of the blur sample region
  19948. */
  19949. get kernel(): number;
  19950. /**
  19951. * Sets wether or not the blur needs to unpack/repack floats
  19952. */
  19953. set packedFloat(v: boolean);
  19954. /**
  19955. * Gets wether or not the blur is unpacking/repacking floats
  19956. */
  19957. get packedFloat(): boolean;
  19958. /**
  19959. * Creates a new instance BlurPostProcess
  19960. * @param name The name of the effect.
  19961. * @param direction The direction in which to blur the image.
  19962. * @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.
  19963. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19964. * @param camera The camera to apply the render pass to.
  19965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19966. * @param engine The engine which the post process will be applied. (default: current engine)
  19967. * @param reusable If the post process can be reused on the same frame. (default: false)
  19968. * @param textureType Type of textures used when performing the post process. (default: 0)
  19969. * @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)
  19970. */
  19971. constructor(name: string,
  19972. /** The direction in which to blur the image. */
  19973. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19974. /**
  19975. * Updates the effect with the current post process compile time values and recompiles the shader.
  19976. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19977. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19978. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19979. * @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
  19980. * @param onCompiled Called when the shader has been compiled.
  19981. * @param onError Called if there is an error when compiling a shader.
  19982. */
  19983. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19984. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19985. /**
  19986. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19987. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19988. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19989. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19990. * The gaps between physical kernels are compensated for in the weighting of the samples
  19991. * @param idealKernel Ideal blur kernel.
  19992. * @return Nearest best kernel.
  19993. */
  19994. protected _nearestBestKernel(idealKernel: number): number;
  19995. /**
  19996. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19997. * @param x The point on the Gaussian distribution to sample.
  19998. * @return the value of the Gaussian function at x.
  19999. */
  20000. protected _gaussianWeight(x: number): number;
  20001. /**
  20002. * Generates a string that can be used as a floating point number in GLSL.
  20003. * @param x Value to print.
  20004. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20005. * @return GLSL float string.
  20006. */
  20007. protected _glslFloat(x: number, decimalFigures?: number): string;
  20008. }
  20009. }
  20010. declare module BABYLON {
  20011. /**
  20012. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20013. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20014. * You can then easily use it as a reflectionTexture on a flat surface.
  20015. * In case the surface is not a plane, please consider relying on reflection probes.
  20016. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20017. */
  20018. export class MirrorTexture extends RenderTargetTexture {
  20019. private scene;
  20020. /**
  20021. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20022. * 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.
  20023. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20024. */
  20025. mirrorPlane: Plane;
  20026. /**
  20027. * Define the blur ratio used to blur the reflection if needed.
  20028. */
  20029. set blurRatio(value: number);
  20030. get blurRatio(): number;
  20031. /**
  20032. * Define the adaptive blur kernel used to blur the reflection if needed.
  20033. * This will autocompute the closest best match for the `blurKernel`
  20034. */
  20035. set adaptiveBlurKernel(value: number);
  20036. /**
  20037. * Define the blur kernel used to blur the reflection if needed.
  20038. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20039. */
  20040. set blurKernel(value: number);
  20041. /**
  20042. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20043. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20044. */
  20045. set blurKernelX(value: number);
  20046. get blurKernelX(): number;
  20047. /**
  20048. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20049. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20050. */
  20051. set blurKernelY(value: number);
  20052. get blurKernelY(): number;
  20053. private _autoComputeBlurKernel;
  20054. protected _onRatioRescale(): void;
  20055. private _updateGammaSpace;
  20056. private _imageProcessingConfigChangeObserver;
  20057. private _transformMatrix;
  20058. private _mirrorMatrix;
  20059. private _savedViewMatrix;
  20060. private _blurX;
  20061. private _blurY;
  20062. private _adaptiveBlurKernel;
  20063. private _blurKernelX;
  20064. private _blurKernelY;
  20065. private _blurRatio;
  20066. /**
  20067. * Instantiates a Mirror Texture.
  20068. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20069. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20070. * You can then easily use it as a reflectionTexture on a flat surface.
  20071. * In case the surface is not a plane, please consider relying on reflection probes.
  20072. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20073. * @param name
  20074. * @param size
  20075. * @param scene
  20076. * @param generateMipMaps
  20077. * @param type
  20078. * @param samplingMode
  20079. * @param generateDepthBuffer
  20080. */
  20081. constructor(name: string, size: number | {
  20082. width: number;
  20083. height: number;
  20084. } | {
  20085. ratio: number;
  20086. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20087. private _preparePostProcesses;
  20088. /**
  20089. * Clone the mirror texture.
  20090. * @returns the cloned texture
  20091. */
  20092. clone(): MirrorTexture;
  20093. /**
  20094. * Serialize the texture to a JSON representation you could use in Parse later on
  20095. * @returns the serialized JSON representation
  20096. */
  20097. serialize(): any;
  20098. /**
  20099. * Dispose the texture and release its associated resources.
  20100. */
  20101. dispose(): void;
  20102. }
  20103. }
  20104. declare module BABYLON {
  20105. /**
  20106. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20107. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20108. */
  20109. export class Texture extends BaseTexture {
  20110. /**
  20111. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20112. */
  20113. static SerializeBuffers: boolean;
  20114. /** @hidden */
  20115. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20116. /** @hidden */
  20117. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20118. /** @hidden */
  20119. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20120. /** nearest is mag = nearest and min = nearest and mip = linear */
  20121. static readonly NEAREST_SAMPLINGMODE: number;
  20122. /** nearest is mag = nearest and min = nearest and mip = linear */
  20123. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20124. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20125. static readonly BILINEAR_SAMPLINGMODE: number;
  20126. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20127. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20128. /** Trilinear is mag = linear and min = linear and mip = linear */
  20129. static readonly TRILINEAR_SAMPLINGMODE: number;
  20130. /** Trilinear is mag = linear and min = linear and mip = linear */
  20131. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20132. /** mag = nearest and min = nearest and mip = nearest */
  20133. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20134. /** mag = nearest and min = linear and mip = nearest */
  20135. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20136. /** mag = nearest and min = linear and mip = linear */
  20137. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20138. /** mag = nearest and min = linear and mip = none */
  20139. static readonly NEAREST_LINEAR: number;
  20140. /** mag = nearest and min = nearest and mip = none */
  20141. static readonly NEAREST_NEAREST: number;
  20142. /** mag = linear and min = nearest and mip = nearest */
  20143. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20144. /** mag = linear and min = nearest and mip = linear */
  20145. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20146. /** mag = linear and min = linear and mip = none */
  20147. static readonly LINEAR_LINEAR: number;
  20148. /** mag = linear and min = nearest and mip = none */
  20149. static readonly LINEAR_NEAREST: number;
  20150. /** Explicit coordinates mode */
  20151. static readonly EXPLICIT_MODE: number;
  20152. /** Spherical coordinates mode */
  20153. static readonly SPHERICAL_MODE: number;
  20154. /** Planar coordinates mode */
  20155. static readonly PLANAR_MODE: number;
  20156. /** Cubic coordinates mode */
  20157. static readonly CUBIC_MODE: number;
  20158. /** Projection coordinates mode */
  20159. static readonly PROJECTION_MODE: number;
  20160. /** Inverse Cubic coordinates mode */
  20161. static readonly SKYBOX_MODE: number;
  20162. /** Inverse Cubic coordinates mode */
  20163. static readonly INVCUBIC_MODE: number;
  20164. /** Equirectangular coordinates mode */
  20165. static readonly EQUIRECTANGULAR_MODE: number;
  20166. /** Equirectangular Fixed coordinates mode */
  20167. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20168. /** Equirectangular Fixed Mirrored coordinates mode */
  20169. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20170. /** Texture is not repeating outside of 0..1 UVs */
  20171. static readonly CLAMP_ADDRESSMODE: number;
  20172. /** Texture is repeating outside of 0..1 UVs */
  20173. static readonly WRAP_ADDRESSMODE: number;
  20174. /** Texture is repeating and mirrored */
  20175. static readonly MIRROR_ADDRESSMODE: number;
  20176. /**
  20177. * 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
  20178. */
  20179. static UseSerializedUrlIfAny: boolean;
  20180. /**
  20181. * Define the url of the texture.
  20182. */
  20183. url: Nullable<string>;
  20184. /**
  20185. * Define an offset on the texture to offset the u coordinates of the UVs
  20186. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20187. */
  20188. uOffset: number;
  20189. /**
  20190. * Define an offset on the texture to offset the v coordinates of the UVs
  20191. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20192. */
  20193. vOffset: number;
  20194. /**
  20195. * Define an offset on the texture to scale the u coordinates of the UVs
  20196. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20197. */
  20198. uScale: number;
  20199. /**
  20200. * Define an offset on the texture to scale the v coordinates of the UVs
  20201. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20202. */
  20203. vScale: number;
  20204. /**
  20205. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20206. * @see http://doc.babylonjs.com/how_to/more_materials
  20207. */
  20208. uAng: number;
  20209. /**
  20210. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20211. * @see http://doc.babylonjs.com/how_to/more_materials
  20212. */
  20213. vAng: number;
  20214. /**
  20215. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20216. * @see http://doc.babylonjs.com/how_to/more_materials
  20217. */
  20218. wAng: number;
  20219. /**
  20220. * Defines the center of rotation (U)
  20221. */
  20222. uRotationCenter: number;
  20223. /**
  20224. * Defines the center of rotation (V)
  20225. */
  20226. vRotationCenter: number;
  20227. /**
  20228. * Defines the center of rotation (W)
  20229. */
  20230. wRotationCenter: number;
  20231. /**
  20232. * Are mip maps generated for this texture or not.
  20233. */
  20234. get noMipmap(): boolean;
  20235. /**
  20236. * List of inspectable custom properties (used by the Inspector)
  20237. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20238. */
  20239. inspectableCustomProperties: Nullable<IInspectable[]>;
  20240. private _noMipmap;
  20241. /** @hidden */
  20242. _invertY: boolean;
  20243. private _rowGenerationMatrix;
  20244. private _cachedTextureMatrix;
  20245. private _projectionModeMatrix;
  20246. private _t0;
  20247. private _t1;
  20248. private _t2;
  20249. private _cachedUOffset;
  20250. private _cachedVOffset;
  20251. private _cachedUScale;
  20252. private _cachedVScale;
  20253. private _cachedUAng;
  20254. private _cachedVAng;
  20255. private _cachedWAng;
  20256. private _cachedProjectionMatrixId;
  20257. private _cachedCoordinatesMode;
  20258. /** @hidden */
  20259. protected _initialSamplingMode: number;
  20260. /** @hidden */
  20261. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20262. private _deleteBuffer;
  20263. protected _format: Nullable<number>;
  20264. private _delayedOnLoad;
  20265. private _delayedOnError;
  20266. private _mimeType?;
  20267. /**
  20268. * Observable triggered once the texture has been loaded.
  20269. */
  20270. onLoadObservable: Observable<Texture>;
  20271. protected _isBlocking: boolean;
  20272. /**
  20273. * Is the texture preventing material to render while loading.
  20274. * If false, a default texture will be used instead of the loading one during the preparation step.
  20275. */
  20276. set isBlocking(value: boolean);
  20277. get isBlocking(): boolean;
  20278. /**
  20279. * Get the current sampling mode associated with the texture.
  20280. */
  20281. get samplingMode(): number;
  20282. /**
  20283. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20284. */
  20285. get invertY(): boolean;
  20286. /**
  20287. * Instantiates a new texture.
  20288. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20289. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20290. * @param url defines the url of the picture to load as a texture
  20291. * @param scene defines the scene or engine the texture will belong to
  20292. * @param noMipmap defines if the texture will require mip maps or not
  20293. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20294. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20295. * @param onLoad defines a callback triggered when the texture has been loaded
  20296. * @param onError defines a callback triggered when an error occurred during the loading session
  20297. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20298. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20299. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20300. * @param mimeType defines an optional mime type information
  20301. */
  20302. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  20303. /**
  20304. * Update the url (and optional buffer) of this texture if url was null during construction.
  20305. * @param url the url of the texture
  20306. * @param buffer the buffer of the texture (defaults to null)
  20307. * @param onLoad callback called when the texture is loaded (defaults to null)
  20308. */
  20309. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20310. /**
  20311. * Finish the loading sequence of a texture flagged as delayed load.
  20312. * @hidden
  20313. */
  20314. delayLoad(): void;
  20315. private _prepareRowForTextureGeneration;
  20316. /**
  20317. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20318. * @returns the transform matrix of the texture.
  20319. */
  20320. getTextureMatrix(uBase?: number): Matrix;
  20321. /**
  20322. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20323. * @returns The reflection texture transform
  20324. */
  20325. getReflectionTextureMatrix(): Matrix;
  20326. /**
  20327. * Clones the texture.
  20328. * @returns the cloned texture
  20329. */
  20330. clone(): Texture;
  20331. /**
  20332. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20333. * @returns The JSON representation of the texture
  20334. */
  20335. serialize(): any;
  20336. /**
  20337. * Get the current class name of the texture useful for serialization or dynamic coding.
  20338. * @returns "Texture"
  20339. */
  20340. getClassName(): string;
  20341. /**
  20342. * Dispose the texture and release its associated resources.
  20343. */
  20344. dispose(): void;
  20345. /**
  20346. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20347. * @param parsedTexture Define the JSON representation of the texture
  20348. * @param scene Define the scene the parsed texture should be instantiated in
  20349. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20350. * @returns The parsed texture if successful
  20351. */
  20352. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20353. /**
  20354. * Creates a texture from its base 64 representation.
  20355. * @param data Define the base64 payload without the data: prefix
  20356. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20357. * @param scene Define the scene the texture should belong to
  20358. * @param noMipmap Forces the texture to not create mip map information if true
  20359. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20360. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20361. * @param onLoad define a callback triggered when the texture has been loaded
  20362. * @param onError define a callback triggered when an error occurred during the loading session
  20363. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20364. * @returns the created texture
  20365. */
  20366. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20367. /**
  20368. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20369. * @param data Define the base64 payload without the data: prefix
  20370. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20371. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20372. * @param scene Define the scene the texture should belong to
  20373. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20374. * @param noMipmap Forces the texture to not create mip map information if true
  20375. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20376. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20377. * @param onLoad define a callback triggered when the texture has been loaded
  20378. * @param onError define a callback triggered when an error occurred during the loading session
  20379. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20380. * @returns the created texture
  20381. */
  20382. 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;
  20383. }
  20384. }
  20385. declare module BABYLON {
  20386. /**
  20387. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20388. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20389. */
  20390. export class PostProcessManager {
  20391. private _scene;
  20392. private _indexBuffer;
  20393. private _vertexBuffers;
  20394. /**
  20395. * Creates a new instance PostProcess
  20396. * @param scene The scene that the post process is associated with.
  20397. */
  20398. constructor(scene: Scene);
  20399. private _prepareBuffers;
  20400. private _buildIndexBuffer;
  20401. /**
  20402. * Rebuilds the vertex buffers of the manager.
  20403. * @hidden
  20404. */
  20405. _rebuild(): void;
  20406. /**
  20407. * Prepares a frame to be run through a post process.
  20408. * @param sourceTexture The input texture to the post procesess. (default: null)
  20409. * @param postProcesses An array of post processes to be run. (default: null)
  20410. * @returns True if the post processes were able to be run.
  20411. * @hidden
  20412. */
  20413. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20414. /**
  20415. * Manually render a set of post processes to a texture.
  20416. * @param postProcesses An array of post processes to be run.
  20417. * @param targetTexture The target texture to render to.
  20418. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20419. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20420. * @param lodLevel defines which lod of the texture to render to
  20421. */
  20422. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20423. /**
  20424. * Finalize the result of the output of the postprocesses.
  20425. * @param doNotPresent If true the result will not be displayed to the screen.
  20426. * @param targetTexture The target texture to render to.
  20427. * @param faceIndex The index of the face to bind the target texture to.
  20428. * @param postProcesses The array of post processes to render.
  20429. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20430. * @hidden
  20431. */
  20432. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20433. /**
  20434. * Disposes of the post process manager.
  20435. */
  20436. dispose(): void;
  20437. }
  20438. }
  20439. declare module BABYLON {
  20440. /**
  20441. * This Helps creating a texture that will be created from a camera in your scene.
  20442. * It is basically a dynamic texture that could be used to create special effects for instance.
  20443. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20444. */
  20445. export class RenderTargetTexture extends Texture {
  20446. isCube: boolean;
  20447. /**
  20448. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20449. */
  20450. static readonly REFRESHRATE_RENDER_ONCE: number;
  20451. /**
  20452. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20453. */
  20454. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20455. /**
  20456. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20457. * the central point of your effect and can save a lot of performances.
  20458. */
  20459. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20460. /**
  20461. * Use this predicate to dynamically define the list of mesh you want to render.
  20462. * If set, the renderList property will be overwritten.
  20463. */
  20464. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20465. private _renderList;
  20466. /**
  20467. * Use this list to define the list of mesh you want to render.
  20468. */
  20469. get renderList(): Nullable<Array<AbstractMesh>>;
  20470. set renderList(value: Nullable<Array<AbstractMesh>>);
  20471. /**
  20472. * Use this function to overload the renderList array at rendering time.
  20473. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20474. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20475. * the cube (if the RTT is a cube, else layerOrFace=0).
  20476. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20477. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20478. * hold dummy elements!
  20479. */
  20480. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20481. private _hookArray;
  20482. /**
  20483. * Define if particles should be rendered in your texture.
  20484. */
  20485. renderParticles: boolean;
  20486. /**
  20487. * Define if sprites should be rendered in your texture.
  20488. */
  20489. renderSprites: boolean;
  20490. /**
  20491. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20492. */
  20493. coordinatesMode: number;
  20494. /**
  20495. * Define the camera used to render the texture.
  20496. */
  20497. activeCamera: Nullable<Camera>;
  20498. /**
  20499. * Override the render function of the texture with your own one.
  20500. */
  20501. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20502. /**
  20503. * Define if camera post processes should be use while rendering the texture.
  20504. */
  20505. useCameraPostProcesses: boolean;
  20506. /**
  20507. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20508. */
  20509. ignoreCameraViewport: boolean;
  20510. private _postProcessManager;
  20511. private _postProcesses;
  20512. private _resizeObserver;
  20513. /**
  20514. * An event triggered when the texture is unbind.
  20515. */
  20516. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20517. /**
  20518. * An event triggered when the texture is unbind.
  20519. */
  20520. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20521. private _onAfterUnbindObserver;
  20522. /**
  20523. * Set a after unbind callback in the texture.
  20524. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20525. */
  20526. set onAfterUnbind(callback: () => void);
  20527. /**
  20528. * An event triggered before rendering the texture
  20529. */
  20530. onBeforeRenderObservable: Observable<number>;
  20531. private _onBeforeRenderObserver;
  20532. /**
  20533. * Set a before render callback in the texture.
  20534. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20535. */
  20536. set onBeforeRender(callback: (faceIndex: number) => void);
  20537. /**
  20538. * An event triggered after rendering the texture
  20539. */
  20540. onAfterRenderObservable: Observable<number>;
  20541. private _onAfterRenderObserver;
  20542. /**
  20543. * Set a after render callback in the texture.
  20544. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20545. */
  20546. set onAfterRender(callback: (faceIndex: number) => void);
  20547. /**
  20548. * An event triggered after the texture clear
  20549. */
  20550. onClearObservable: Observable<Engine>;
  20551. private _onClearObserver;
  20552. /**
  20553. * Set a clear callback in the texture.
  20554. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20555. */
  20556. set onClear(callback: (Engine: Engine) => void);
  20557. /**
  20558. * An event triggered when the texture is resized.
  20559. */
  20560. onResizeObservable: Observable<RenderTargetTexture>;
  20561. /**
  20562. * Define the clear color of the Render Target if it should be different from the scene.
  20563. */
  20564. clearColor: Color4;
  20565. protected _size: number | {
  20566. width: number;
  20567. height: number;
  20568. layers?: number;
  20569. };
  20570. protected _initialSizeParameter: number | {
  20571. width: number;
  20572. height: number;
  20573. } | {
  20574. ratio: number;
  20575. };
  20576. protected _sizeRatio: Nullable<number>;
  20577. /** @hidden */
  20578. _generateMipMaps: boolean;
  20579. protected _renderingManager: RenderingManager;
  20580. /** @hidden */
  20581. _waitingRenderList: string[];
  20582. protected _doNotChangeAspectRatio: boolean;
  20583. protected _currentRefreshId: number;
  20584. protected _refreshRate: number;
  20585. protected _textureMatrix: Matrix;
  20586. protected _samples: number;
  20587. protected _renderTargetOptions: RenderTargetCreationOptions;
  20588. /**
  20589. * Gets render target creation options that were used.
  20590. */
  20591. get renderTargetOptions(): RenderTargetCreationOptions;
  20592. protected _engine: Engine;
  20593. protected _onRatioRescale(): void;
  20594. /**
  20595. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20596. * It must define where the camera used to render the texture is set
  20597. */
  20598. boundingBoxPosition: Vector3;
  20599. private _boundingBoxSize;
  20600. /**
  20601. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20602. * When defined, the cubemap will switch to local mode
  20603. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20604. * @example https://www.babylonjs-playground.com/#RNASML
  20605. */
  20606. set boundingBoxSize(value: Vector3);
  20607. get boundingBoxSize(): Vector3;
  20608. /**
  20609. * In case the RTT has been created with a depth texture, get the associated
  20610. * depth texture.
  20611. * Otherwise, return null.
  20612. */
  20613. get depthStencilTexture(): Nullable<InternalTexture>;
  20614. /**
  20615. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20616. * or used a shadow, depth texture...
  20617. * @param name The friendly name of the texture
  20618. * @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)
  20619. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20620. * @param generateMipMaps True if mip maps need to be generated after render.
  20621. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20622. * @param type The type of the buffer in the RTT (int, half float, float...)
  20623. * @param isCube True if a cube texture needs to be created
  20624. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20625. * @param generateDepthBuffer True to generate a depth buffer
  20626. * @param generateStencilBuffer True to generate a stencil buffer
  20627. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20628. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20629. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20630. */
  20631. constructor(name: string, size: number | {
  20632. width: number;
  20633. height: number;
  20634. layers?: number;
  20635. } | {
  20636. ratio: number;
  20637. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20638. /**
  20639. * Creates a depth stencil texture.
  20640. * This is only available in WebGL 2 or with the depth texture extension available.
  20641. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20642. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20643. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20644. */
  20645. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20646. private _processSizeParameter;
  20647. /**
  20648. * Define the number of samples to use in case of MSAA.
  20649. * It defaults to one meaning no MSAA has been enabled.
  20650. */
  20651. get samples(): number;
  20652. set samples(value: number);
  20653. /**
  20654. * Resets the refresh counter of the texture and start bak from scratch.
  20655. * Could be useful to regenerate the texture if it is setup to render only once.
  20656. */
  20657. resetRefreshCounter(): void;
  20658. /**
  20659. * Define the refresh rate of the texture or the rendering frequency.
  20660. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20661. */
  20662. get refreshRate(): number;
  20663. set refreshRate(value: number);
  20664. /**
  20665. * Adds a post process to the render target rendering passes.
  20666. * @param postProcess define the post process to add
  20667. */
  20668. addPostProcess(postProcess: PostProcess): void;
  20669. /**
  20670. * Clear all the post processes attached to the render target
  20671. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20672. */
  20673. clearPostProcesses(dispose?: boolean): void;
  20674. /**
  20675. * Remove one of the post process from the list of attached post processes to the texture
  20676. * @param postProcess define the post process to remove from the list
  20677. */
  20678. removePostProcess(postProcess: PostProcess): void;
  20679. /** @hidden */
  20680. _shouldRender(): boolean;
  20681. /**
  20682. * Gets the actual render size of the texture.
  20683. * @returns the width of the render size
  20684. */
  20685. getRenderSize(): number;
  20686. /**
  20687. * Gets the actual render width of the texture.
  20688. * @returns the width of the render size
  20689. */
  20690. getRenderWidth(): number;
  20691. /**
  20692. * Gets the actual render height of the texture.
  20693. * @returns the height of the render size
  20694. */
  20695. getRenderHeight(): number;
  20696. /**
  20697. * Gets the actual number of layers of the texture.
  20698. * @returns the number of layers
  20699. */
  20700. getRenderLayers(): number;
  20701. /**
  20702. * Get if the texture can be rescaled or not.
  20703. */
  20704. get canRescale(): boolean;
  20705. /**
  20706. * Resize the texture using a ratio.
  20707. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20708. */
  20709. scale(ratio: number): void;
  20710. /**
  20711. * Get the texture reflection matrix used to rotate/transform the reflection.
  20712. * @returns the reflection matrix
  20713. */
  20714. getReflectionTextureMatrix(): Matrix;
  20715. /**
  20716. * Resize the texture to a new desired size.
  20717. * Be carrefull as it will recreate all the data in the new texture.
  20718. * @param size Define the new size. It can be:
  20719. * - a number for squared texture,
  20720. * - an object containing { width: number, height: number }
  20721. * - or an object containing a ratio { ratio: number }
  20722. */
  20723. resize(size: number | {
  20724. width: number;
  20725. height: number;
  20726. } | {
  20727. ratio: number;
  20728. }): void;
  20729. private _defaultRenderListPrepared;
  20730. /**
  20731. * Renders all the objects from the render list into the texture.
  20732. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20733. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20734. */
  20735. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20736. private _bestReflectionRenderTargetDimension;
  20737. private _prepareRenderingManager;
  20738. /**
  20739. * @hidden
  20740. * @param faceIndex face index to bind to if this is a cubetexture
  20741. * @param layer defines the index of the texture to bind in the array
  20742. */
  20743. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20744. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20745. private renderToTarget;
  20746. /**
  20747. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20748. * This allowed control for front to back rendering or reversly depending of the special needs.
  20749. *
  20750. * @param renderingGroupId The rendering group id corresponding to its index
  20751. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20752. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20753. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20754. */
  20755. 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;
  20756. /**
  20757. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20758. *
  20759. * @param renderingGroupId The rendering group id corresponding to its index
  20760. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20761. */
  20762. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20763. /**
  20764. * Clones the texture.
  20765. * @returns the cloned texture
  20766. */
  20767. clone(): RenderTargetTexture;
  20768. /**
  20769. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20770. * @returns The JSON representation of the texture
  20771. */
  20772. serialize(): any;
  20773. /**
  20774. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20775. */
  20776. disposeFramebufferObjects(): void;
  20777. /**
  20778. * Dispose the texture and release its associated resources.
  20779. */
  20780. dispose(): void;
  20781. /** @hidden */
  20782. _rebuild(): void;
  20783. /**
  20784. * Clear the info related to rendering groups preventing retention point in material dispose.
  20785. */
  20786. freeRenderingGroups(): void;
  20787. /**
  20788. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20789. * @returns the view count
  20790. */
  20791. getViewCount(): number;
  20792. }
  20793. }
  20794. declare module BABYLON {
  20795. /**
  20796. * Options for compiling materials.
  20797. */
  20798. export interface IMaterialCompilationOptions {
  20799. /**
  20800. * Defines whether clip planes are enabled.
  20801. */
  20802. clipPlane: boolean;
  20803. /**
  20804. * Defines whether instances are enabled.
  20805. */
  20806. useInstances: boolean;
  20807. }
  20808. /**
  20809. * Base class for the main features of a material in Babylon.js
  20810. */
  20811. export class Material implements IAnimatable {
  20812. /**
  20813. * Returns the triangle fill mode
  20814. */
  20815. static readonly TriangleFillMode: number;
  20816. /**
  20817. * Returns the wireframe mode
  20818. */
  20819. static readonly WireFrameFillMode: number;
  20820. /**
  20821. * Returns the point fill mode
  20822. */
  20823. static readonly PointFillMode: number;
  20824. /**
  20825. * Returns the point list draw mode
  20826. */
  20827. static readonly PointListDrawMode: number;
  20828. /**
  20829. * Returns the line list draw mode
  20830. */
  20831. static readonly LineListDrawMode: number;
  20832. /**
  20833. * Returns the line loop draw mode
  20834. */
  20835. static readonly LineLoopDrawMode: number;
  20836. /**
  20837. * Returns the line strip draw mode
  20838. */
  20839. static readonly LineStripDrawMode: number;
  20840. /**
  20841. * Returns the triangle strip draw mode
  20842. */
  20843. static readonly TriangleStripDrawMode: number;
  20844. /**
  20845. * Returns the triangle fan draw mode
  20846. */
  20847. static readonly TriangleFanDrawMode: number;
  20848. /**
  20849. * Stores the clock-wise side orientation
  20850. */
  20851. static readonly ClockWiseSideOrientation: number;
  20852. /**
  20853. * Stores the counter clock-wise side orientation
  20854. */
  20855. static readonly CounterClockWiseSideOrientation: number;
  20856. /**
  20857. * The dirty texture flag value
  20858. */
  20859. static readonly TextureDirtyFlag: number;
  20860. /**
  20861. * The dirty light flag value
  20862. */
  20863. static readonly LightDirtyFlag: number;
  20864. /**
  20865. * The dirty fresnel flag value
  20866. */
  20867. static readonly FresnelDirtyFlag: number;
  20868. /**
  20869. * The dirty attribute flag value
  20870. */
  20871. static readonly AttributesDirtyFlag: number;
  20872. /**
  20873. * The dirty misc flag value
  20874. */
  20875. static readonly MiscDirtyFlag: number;
  20876. /**
  20877. * The all dirty flag value
  20878. */
  20879. static readonly AllDirtyFlag: number;
  20880. /**
  20881. * The ID of the material
  20882. */
  20883. id: string;
  20884. /**
  20885. * Gets or sets the unique id of the material
  20886. */
  20887. uniqueId: number;
  20888. /**
  20889. * The name of the material
  20890. */
  20891. name: string;
  20892. /**
  20893. * Gets or sets user defined metadata
  20894. */
  20895. metadata: any;
  20896. /**
  20897. * For internal use only. Please do not use.
  20898. */
  20899. reservedDataStore: any;
  20900. /**
  20901. * Specifies if the ready state should be checked on each call
  20902. */
  20903. checkReadyOnEveryCall: boolean;
  20904. /**
  20905. * Specifies if the ready state should be checked once
  20906. */
  20907. checkReadyOnlyOnce: boolean;
  20908. /**
  20909. * The state of the material
  20910. */
  20911. state: string;
  20912. /**
  20913. * The alpha value of the material
  20914. */
  20915. protected _alpha: number;
  20916. /**
  20917. * List of inspectable custom properties (used by the Inspector)
  20918. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20919. */
  20920. inspectableCustomProperties: IInspectable[];
  20921. /**
  20922. * Sets the alpha value of the material
  20923. */
  20924. set alpha(value: number);
  20925. /**
  20926. * Gets the alpha value of the material
  20927. */
  20928. get alpha(): number;
  20929. /**
  20930. * Specifies if back face culling is enabled
  20931. */
  20932. protected _backFaceCulling: boolean;
  20933. /**
  20934. * Sets the back-face culling state
  20935. */
  20936. set backFaceCulling(value: boolean);
  20937. /**
  20938. * Gets the back-face culling state
  20939. */
  20940. get backFaceCulling(): boolean;
  20941. /**
  20942. * Stores the value for side orientation
  20943. */
  20944. sideOrientation: number;
  20945. /**
  20946. * Callback triggered when the material is compiled
  20947. */
  20948. onCompiled: Nullable<(effect: Effect) => void>;
  20949. /**
  20950. * Callback triggered when an error occurs
  20951. */
  20952. onError: Nullable<(effect: Effect, errors: string) => void>;
  20953. /**
  20954. * Callback triggered to get the render target textures
  20955. */
  20956. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20957. /**
  20958. * Gets a boolean indicating that current material needs to register RTT
  20959. */
  20960. get hasRenderTargetTextures(): boolean;
  20961. /**
  20962. * Specifies if the material should be serialized
  20963. */
  20964. doNotSerialize: boolean;
  20965. /**
  20966. * @hidden
  20967. */
  20968. _storeEffectOnSubMeshes: boolean;
  20969. /**
  20970. * Stores the animations for the material
  20971. */
  20972. animations: Nullable<Array<Animation>>;
  20973. /**
  20974. * An event triggered when the material is disposed
  20975. */
  20976. onDisposeObservable: Observable<Material>;
  20977. /**
  20978. * An observer which watches for dispose events
  20979. */
  20980. private _onDisposeObserver;
  20981. private _onUnBindObservable;
  20982. /**
  20983. * Called during a dispose event
  20984. */
  20985. set onDispose(callback: () => void);
  20986. private _onBindObservable;
  20987. /**
  20988. * An event triggered when the material is bound
  20989. */
  20990. get onBindObservable(): Observable<AbstractMesh>;
  20991. /**
  20992. * An observer which watches for bind events
  20993. */
  20994. private _onBindObserver;
  20995. /**
  20996. * Called during a bind event
  20997. */
  20998. set onBind(callback: (Mesh: AbstractMesh) => void);
  20999. /**
  21000. * An event triggered when the material is unbound
  21001. */
  21002. get onUnBindObservable(): Observable<Material>;
  21003. /**
  21004. * Stores the value of the alpha mode
  21005. */
  21006. private _alphaMode;
  21007. /**
  21008. * Sets the value of the alpha mode.
  21009. *
  21010. * | Value | Type | Description |
  21011. * | --- | --- | --- |
  21012. * | 0 | ALPHA_DISABLE | |
  21013. * | 1 | ALPHA_ADD | |
  21014. * | 2 | ALPHA_COMBINE | |
  21015. * | 3 | ALPHA_SUBTRACT | |
  21016. * | 4 | ALPHA_MULTIPLY | |
  21017. * | 5 | ALPHA_MAXIMIZED | |
  21018. * | 6 | ALPHA_ONEONE | |
  21019. * | 7 | ALPHA_PREMULTIPLIED | |
  21020. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21021. * | 9 | ALPHA_INTERPOLATE | |
  21022. * | 10 | ALPHA_SCREENMODE | |
  21023. *
  21024. */
  21025. set alphaMode(value: number);
  21026. /**
  21027. * Gets the value of the alpha mode
  21028. */
  21029. get alphaMode(): number;
  21030. /**
  21031. * Stores the state of the need depth pre-pass value
  21032. */
  21033. private _needDepthPrePass;
  21034. /**
  21035. * Sets the need depth pre-pass value
  21036. */
  21037. set needDepthPrePass(value: boolean);
  21038. /**
  21039. * Gets the depth pre-pass value
  21040. */
  21041. get needDepthPrePass(): boolean;
  21042. /**
  21043. * Specifies if depth writing should be disabled
  21044. */
  21045. disableDepthWrite: boolean;
  21046. /**
  21047. * Specifies if depth writing should be forced
  21048. */
  21049. forceDepthWrite: boolean;
  21050. /**
  21051. * Specifies the depth function that should be used. 0 means the default engine function
  21052. */
  21053. depthFunction: number;
  21054. /**
  21055. * Specifies if there should be a separate pass for culling
  21056. */
  21057. separateCullingPass: boolean;
  21058. /**
  21059. * Stores the state specifing if fog should be enabled
  21060. */
  21061. private _fogEnabled;
  21062. /**
  21063. * Sets the state for enabling fog
  21064. */
  21065. set fogEnabled(value: boolean);
  21066. /**
  21067. * Gets the value of the fog enabled state
  21068. */
  21069. get fogEnabled(): boolean;
  21070. /**
  21071. * Stores the size of points
  21072. */
  21073. pointSize: number;
  21074. /**
  21075. * Stores the z offset value
  21076. */
  21077. zOffset: number;
  21078. /**
  21079. * Gets a value specifying if wireframe mode is enabled
  21080. */
  21081. get wireframe(): boolean;
  21082. /**
  21083. * Sets the state of wireframe mode
  21084. */
  21085. set wireframe(value: boolean);
  21086. /**
  21087. * Gets the value specifying if point clouds are enabled
  21088. */
  21089. get pointsCloud(): boolean;
  21090. /**
  21091. * Sets the state of point cloud mode
  21092. */
  21093. set pointsCloud(value: boolean);
  21094. /**
  21095. * Gets the material fill mode
  21096. */
  21097. get fillMode(): number;
  21098. /**
  21099. * Sets the material fill mode
  21100. */
  21101. set fillMode(value: number);
  21102. /**
  21103. * @hidden
  21104. * Stores the effects for the material
  21105. */
  21106. _effect: Nullable<Effect>;
  21107. /**
  21108. * Specifies if uniform buffers should be used
  21109. */
  21110. private _useUBO;
  21111. /**
  21112. * Stores a reference to the scene
  21113. */
  21114. private _scene;
  21115. /**
  21116. * Stores the fill mode state
  21117. */
  21118. private _fillMode;
  21119. /**
  21120. * Specifies if the depth write state should be cached
  21121. */
  21122. private _cachedDepthWriteState;
  21123. /**
  21124. * Specifies if the depth function state should be cached
  21125. */
  21126. private _cachedDepthFunctionState;
  21127. /**
  21128. * Stores the uniform buffer
  21129. */
  21130. protected _uniformBuffer: UniformBuffer;
  21131. /** @hidden */
  21132. _indexInSceneMaterialArray: number;
  21133. /** @hidden */
  21134. meshMap: Nullable<{
  21135. [id: string]: AbstractMesh | undefined;
  21136. }>;
  21137. /**
  21138. * Creates a material instance
  21139. * @param name defines the name of the material
  21140. * @param scene defines the scene to reference
  21141. * @param doNotAdd specifies if the material should be added to the scene
  21142. */
  21143. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21144. /**
  21145. * Returns a string representation of the current material
  21146. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21147. * @returns a string with material information
  21148. */
  21149. toString(fullDetails?: boolean): string;
  21150. /**
  21151. * Gets the class name of the material
  21152. * @returns a string with the class name of the material
  21153. */
  21154. getClassName(): string;
  21155. /**
  21156. * Specifies if updates for the material been locked
  21157. */
  21158. get isFrozen(): boolean;
  21159. /**
  21160. * Locks updates for the material
  21161. */
  21162. freeze(): void;
  21163. /**
  21164. * Unlocks updates for the material
  21165. */
  21166. unfreeze(): void;
  21167. /**
  21168. * Specifies if the material is ready to be used
  21169. * @param mesh defines the mesh to check
  21170. * @param useInstances specifies if instances should be used
  21171. * @returns a boolean indicating if the material is ready to be used
  21172. */
  21173. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21174. /**
  21175. * Specifies that the submesh is ready to be used
  21176. * @param mesh defines the mesh to check
  21177. * @param subMesh defines which submesh to check
  21178. * @param useInstances specifies that instances should be used
  21179. * @returns a boolean indicating that the submesh is ready or not
  21180. */
  21181. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21182. /**
  21183. * Returns the material effect
  21184. * @returns the effect associated with the material
  21185. */
  21186. getEffect(): Nullable<Effect>;
  21187. /**
  21188. * Returns the current scene
  21189. * @returns a Scene
  21190. */
  21191. getScene(): Scene;
  21192. /**
  21193. * Specifies if the material will require alpha blending
  21194. * @returns a boolean specifying if alpha blending is needed
  21195. */
  21196. needAlphaBlending(): boolean;
  21197. /**
  21198. * Specifies if the mesh will require alpha blending
  21199. * @param mesh defines the mesh to check
  21200. * @returns a boolean specifying if alpha blending is needed for the mesh
  21201. */
  21202. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21203. /**
  21204. * Specifies if this material should be rendered in alpha test mode
  21205. * @returns a boolean specifying if an alpha test is needed.
  21206. */
  21207. needAlphaTesting(): boolean;
  21208. /**
  21209. * Gets the texture used for the alpha test
  21210. * @returns the texture to use for alpha testing
  21211. */
  21212. getAlphaTestTexture(): Nullable<BaseTexture>;
  21213. /**
  21214. * Marks the material to indicate that it needs to be re-calculated
  21215. */
  21216. markDirty(): void;
  21217. /** @hidden */
  21218. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21219. /**
  21220. * Binds the material to the mesh
  21221. * @param world defines the world transformation matrix
  21222. * @param mesh defines the mesh to bind the material to
  21223. */
  21224. bind(world: Matrix, mesh?: Mesh): void;
  21225. /**
  21226. * Binds the submesh to the material
  21227. * @param world defines the world transformation matrix
  21228. * @param mesh defines the mesh containing the submesh
  21229. * @param subMesh defines the submesh to bind the material to
  21230. */
  21231. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21232. /**
  21233. * Binds the world matrix to the material
  21234. * @param world defines the world transformation matrix
  21235. */
  21236. bindOnlyWorldMatrix(world: Matrix): void;
  21237. /**
  21238. * Binds the scene's uniform buffer to the effect.
  21239. * @param effect defines the effect to bind to the scene uniform buffer
  21240. * @param sceneUbo defines the uniform buffer storing scene data
  21241. */
  21242. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21243. /**
  21244. * Binds the view matrix to the effect
  21245. * @param effect defines the effect to bind the view matrix to
  21246. */
  21247. bindView(effect: Effect): void;
  21248. /**
  21249. * Binds the view projection matrix to the effect
  21250. * @param effect defines the effect to bind the view projection matrix to
  21251. */
  21252. bindViewProjection(effect: Effect): void;
  21253. /**
  21254. * Specifies if material alpha testing should be turned on for the mesh
  21255. * @param mesh defines the mesh to check
  21256. */
  21257. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21258. /**
  21259. * Processes to execute after binding the material to a mesh
  21260. * @param mesh defines the rendered mesh
  21261. */
  21262. protected _afterBind(mesh?: Mesh): void;
  21263. /**
  21264. * Unbinds the material from the mesh
  21265. */
  21266. unbind(): void;
  21267. /**
  21268. * Gets the active textures from the material
  21269. * @returns an array of textures
  21270. */
  21271. getActiveTextures(): BaseTexture[];
  21272. /**
  21273. * Specifies if the material uses a texture
  21274. * @param texture defines the texture to check against the material
  21275. * @returns a boolean specifying if the material uses the texture
  21276. */
  21277. hasTexture(texture: BaseTexture): boolean;
  21278. /**
  21279. * Makes a duplicate of the material, and gives it a new name
  21280. * @param name defines the new name for the duplicated material
  21281. * @returns the cloned material
  21282. */
  21283. clone(name: string): Nullable<Material>;
  21284. /**
  21285. * Gets the meshes bound to the material
  21286. * @returns an array of meshes bound to the material
  21287. */
  21288. getBindedMeshes(): AbstractMesh[];
  21289. /**
  21290. * Force shader compilation
  21291. * @param mesh defines the mesh associated with this material
  21292. * @param onCompiled defines a function to execute once the material is compiled
  21293. * @param options defines the options to configure the compilation
  21294. * @param onError defines a function to execute if the material fails compiling
  21295. */
  21296. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21297. /**
  21298. * Force shader compilation
  21299. * @param mesh defines the mesh that will use this material
  21300. * @param options defines additional options for compiling the shaders
  21301. * @returns a promise that resolves when the compilation completes
  21302. */
  21303. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21304. private static readonly _AllDirtyCallBack;
  21305. private static readonly _ImageProcessingDirtyCallBack;
  21306. private static readonly _TextureDirtyCallBack;
  21307. private static readonly _FresnelDirtyCallBack;
  21308. private static readonly _MiscDirtyCallBack;
  21309. private static readonly _LightsDirtyCallBack;
  21310. private static readonly _AttributeDirtyCallBack;
  21311. private static _FresnelAndMiscDirtyCallBack;
  21312. private static _TextureAndMiscDirtyCallBack;
  21313. private static readonly _DirtyCallbackArray;
  21314. private static readonly _RunDirtyCallBacks;
  21315. /**
  21316. * Marks a define in the material to indicate that it needs to be re-computed
  21317. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21318. */
  21319. markAsDirty(flag: number): void;
  21320. /**
  21321. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21322. * @param func defines a function which checks material defines against the submeshes
  21323. */
  21324. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21325. /**
  21326. * Indicates that we need to re-calculated for all submeshes
  21327. */
  21328. protected _markAllSubMeshesAsAllDirty(): void;
  21329. /**
  21330. * Indicates that image processing needs to be re-calculated for all submeshes
  21331. */
  21332. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21333. /**
  21334. * Indicates that textures need to be re-calculated for all submeshes
  21335. */
  21336. protected _markAllSubMeshesAsTexturesDirty(): void;
  21337. /**
  21338. * Indicates that fresnel needs to be re-calculated for all submeshes
  21339. */
  21340. protected _markAllSubMeshesAsFresnelDirty(): void;
  21341. /**
  21342. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21343. */
  21344. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21345. /**
  21346. * Indicates that lights need to be re-calculated for all submeshes
  21347. */
  21348. protected _markAllSubMeshesAsLightsDirty(): void;
  21349. /**
  21350. * Indicates that attributes need to be re-calculated for all submeshes
  21351. */
  21352. protected _markAllSubMeshesAsAttributesDirty(): void;
  21353. /**
  21354. * Indicates that misc needs to be re-calculated for all submeshes
  21355. */
  21356. protected _markAllSubMeshesAsMiscDirty(): void;
  21357. /**
  21358. * Indicates that textures and misc need to be re-calculated for all submeshes
  21359. */
  21360. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21361. /**
  21362. * Disposes the material
  21363. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21364. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21365. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21366. */
  21367. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21368. /** @hidden */
  21369. private releaseVertexArrayObject;
  21370. /**
  21371. * Serializes this material
  21372. * @returns the serialized material object
  21373. */
  21374. serialize(): any;
  21375. /**
  21376. * Creates a material from parsed material data
  21377. * @param parsedMaterial defines parsed material data
  21378. * @param scene defines the hosting scene
  21379. * @param rootUrl defines the root URL to use to load textures
  21380. * @returns a new material
  21381. */
  21382. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21383. }
  21384. }
  21385. declare module BABYLON {
  21386. /**
  21387. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21388. * separate meshes. This can be use to improve performances.
  21389. * @see http://doc.babylonjs.com/how_to/multi_materials
  21390. */
  21391. export class MultiMaterial extends Material {
  21392. private _subMaterials;
  21393. /**
  21394. * Gets or Sets the list of Materials used within the multi material.
  21395. * They need to be ordered according to the submeshes order in the associated mesh
  21396. */
  21397. get subMaterials(): Nullable<Material>[];
  21398. set subMaterials(value: Nullable<Material>[]);
  21399. /**
  21400. * Function used to align with Node.getChildren()
  21401. * @returns the list of Materials used within the multi material
  21402. */
  21403. getChildren(): Nullable<Material>[];
  21404. /**
  21405. * Instantiates a new Multi Material
  21406. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21407. * separate meshes. This can be use to improve performances.
  21408. * @see http://doc.babylonjs.com/how_to/multi_materials
  21409. * @param name Define the name in the scene
  21410. * @param scene Define the scene the material belongs to
  21411. */
  21412. constructor(name: string, scene: Scene);
  21413. private _hookArray;
  21414. /**
  21415. * Get one of the submaterial by its index in the submaterials array
  21416. * @param index The index to look the sub material at
  21417. * @returns The Material if the index has been defined
  21418. */
  21419. getSubMaterial(index: number): Nullable<Material>;
  21420. /**
  21421. * Get the list of active textures for the whole sub materials list.
  21422. * @returns All the textures that will be used during the rendering
  21423. */
  21424. getActiveTextures(): BaseTexture[];
  21425. /**
  21426. * Gets the current class name of the material e.g. "MultiMaterial"
  21427. * Mainly use in serialization.
  21428. * @returns the class name
  21429. */
  21430. getClassName(): string;
  21431. /**
  21432. * Checks if the material is ready to render the requested sub mesh
  21433. * @param mesh Define the mesh the submesh belongs to
  21434. * @param subMesh Define the sub mesh to look readyness for
  21435. * @param useInstances Define whether or not the material is used with instances
  21436. * @returns true if ready, otherwise false
  21437. */
  21438. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21439. /**
  21440. * Clones the current material and its related sub materials
  21441. * @param name Define the name of the newly cloned material
  21442. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21443. * @returns the cloned material
  21444. */
  21445. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21446. /**
  21447. * Serializes the materials into a JSON representation.
  21448. * @returns the JSON representation
  21449. */
  21450. serialize(): any;
  21451. /**
  21452. * Dispose the material and release its associated resources
  21453. * @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)
  21454. * @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)
  21455. * @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)
  21456. */
  21457. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21458. /**
  21459. * Creates a MultiMaterial from parsed MultiMaterial data.
  21460. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21461. * @param scene defines the hosting scene
  21462. * @returns a new MultiMaterial
  21463. */
  21464. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21465. }
  21466. }
  21467. declare module BABYLON {
  21468. /**
  21469. * Base class for submeshes
  21470. */
  21471. export class BaseSubMesh {
  21472. /** @hidden */
  21473. _materialDefines: Nullable<MaterialDefines>;
  21474. /** @hidden */
  21475. _materialEffect: Nullable<Effect>;
  21476. /**
  21477. * Gets material defines used by the effect associated to the sub mesh
  21478. */
  21479. get materialDefines(): Nullable<MaterialDefines>;
  21480. /**
  21481. * Sets material defines used by the effect associated to the sub mesh
  21482. */
  21483. set materialDefines(defines: Nullable<MaterialDefines>);
  21484. /**
  21485. * Gets associated effect
  21486. */
  21487. get effect(): Nullable<Effect>;
  21488. /**
  21489. * Sets associated effect (effect used to render this submesh)
  21490. * @param effect defines the effect to associate with
  21491. * @param defines defines the set of defines used to compile this effect
  21492. */
  21493. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21494. }
  21495. /**
  21496. * Defines a subdivision inside a mesh
  21497. */
  21498. export class SubMesh extends BaseSubMesh implements ICullable {
  21499. /** the material index to use */
  21500. materialIndex: number;
  21501. /** vertex index start */
  21502. verticesStart: number;
  21503. /** vertices count */
  21504. verticesCount: number;
  21505. /** index start */
  21506. indexStart: number;
  21507. /** indices count */
  21508. indexCount: number;
  21509. /** @hidden */
  21510. _linesIndexCount: number;
  21511. private _mesh;
  21512. private _renderingMesh;
  21513. private _boundingInfo;
  21514. private _linesIndexBuffer;
  21515. /** @hidden */
  21516. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21517. /** @hidden */
  21518. _trianglePlanes: Plane[];
  21519. /** @hidden */
  21520. _lastColliderTransformMatrix: Nullable<Matrix>;
  21521. /** @hidden */
  21522. _renderId: number;
  21523. /** @hidden */
  21524. _alphaIndex: number;
  21525. /** @hidden */
  21526. _distanceToCamera: number;
  21527. /** @hidden */
  21528. _id: number;
  21529. private _currentMaterial;
  21530. /**
  21531. * Add a new submesh to a mesh
  21532. * @param materialIndex defines the material index to use
  21533. * @param verticesStart defines vertex index start
  21534. * @param verticesCount defines vertices count
  21535. * @param indexStart defines index start
  21536. * @param indexCount defines indices count
  21537. * @param mesh defines the parent mesh
  21538. * @param renderingMesh defines an optional rendering mesh
  21539. * @param createBoundingBox defines if bounding box should be created for this submesh
  21540. * @returns the new submesh
  21541. */
  21542. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21543. /**
  21544. * Creates a new submesh
  21545. * @param materialIndex defines the material index to use
  21546. * @param verticesStart defines vertex index start
  21547. * @param verticesCount defines vertices count
  21548. * @param indexStart defines index start
  21549. * @param indexCount defines indices count
  21550. * @param mesh defines the parent mesh
  21551. * @param renderingMesh defines an optional rendering mesh
  21552. * @param createBoundingBox defines if bounding box should be created for this submesh
  21553. */
  21554. constructor(
  21555. /** the material index to use */
  21556. materialIndex: number,
  21557. /** vertex index start */
  21558. verticesStart: number,
  21559. /** vertices count */
  21560. verticesCount: number,
  21561. /** index start */
  21562. indexStart: number,
  21563. /** indices count */
  21564. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21565. /**
  21566. * Returns true if this submesh covers the entire parent mesh
  21567. * @ignorenaming
  21568. */
  21569. get IsGlobal(): boolean;
  21570. /**
  21571. * Returns the submesh BoudingInfo object
  21572. * @returns current bounding info (or mesh's one if the submesh is global)
  21573. */
  21574. getBoundingInfo(): BoundingInfo;
  21575. /**
  21576. * Sets the submesh BoundingInfo
  21577. * @param boundingInfo defines the new bounding info to use
  21578. * @returns the SubMesh
  21579. */
  21580. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21581. /**
  21582. * Returns the mesh of the current submesh
  21583. * @return the parent mesh
  21584. */
  21585. getMesh(): AbstractMesh;
  21586. /**
  21587. * Returns the rendering mesh of the submesh
  21588. * @returns the rendering mesh (could be different from parent mesh)
  21589. */
  21590. getRenderingMesh(): Mesh;
  21591. /**
  21592. * Returns the submesh material
  21593. * @returns null or the current material
  21594. */
  21595. getMaterial(): Nullable<Material>;
  21596. /**
  21597. * Sets a new updated BoundingInfo object to the submesh
  21598. * @param data defines an optional position array to use to determine the bounding info
  21599. * @returns the SubMesh
  21600. */
  21601. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21602. /** @hidden */
  21603. _checkCollision(collider: Collider): boolean;
  21604. /**
  21605. * Updates the submesh BoundingInfo
  21606. * @param world defines the world matrix to use to update the bounding info
  21607. * @returns the submesh
  21608. */
  21609. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21610. /**
  21611. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21612. * @param frustumPlanes defines the frustum planes
  21613. * @returns true if the submesh is intersecting with the frustum
  21614. */
  21615. isInFrustum(frustumPlanes: Plane[]): boolean;
  21616. /**
  21617. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21618. * @param frustumPlanes defines the frustum planes
  21619. * @returns true if the submesh is inside the frustum
  21620. */
  21621. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21622. /**
  21623. * Renders the submesh
  21624. * @param enableAlphaMode defines if alpha needs to be used
  21625. * @returns the submesh
  21626. */
  21627. render(enableAlphaMode: boolean): SubMesh;
  21628. /**
  21629. * @hidden
  21630. */
  21631. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21632. /**
  21633. * Checks if the submesh intersects with a ray
  21634. * @param ray defines the ray to test
  21635. * @returns true is the passed ray intersects the submesh bounding box
  21636. */
  21637. canIntersects(ray: Ray): boolean;
  21638. /**
  21639. * Intersects current submesh with a ray
  21640. * @param ray defines the ray to test
  21641. * @param positions defines mesh's positions array
  21642. * @param indices defines mesh's indices array
  21643. * @param fastCheck defines if only bounding info should be used
  21644. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21645. * @returns intersection info or null if no intersection
  21646. */
  21647. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21648. /** @hidden */
  21649. private _intersectLines;
  21650. /** @hidden */
  21651. private _intersectUnIndexedLines;
  21652. /** @hidden */
  21653. private _intersectTriangles;
  21654. /** @hidden */
  21655. private _intersectUnIndexedTriangles;
  21656. /** @hidden */
  21657. _rebuild(): void;
  21658. /**
  21659. * Creates a new submesh from the passed mesh
  21660. * @param newMesh defines the new hosting mesh
  21661. * @param newRenderingMesh defines an optional rendering mesh
  21662. * @returns the new submesh
  21663. */
  21664. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21665. /**
  21666. * Release associated resources
  21667. */
  21668. dispose(): void;
  21669. /**
  21670. * Gets the class name
  21671. * @returns the string "SubMesh".
  21672. */
  21673. getClassName(): string;
  21674. /**
  21675. * Creates a new submesh from indices data
  21676. * @param materialIndex the index of the main mesh material
  21677. * @param startIndex the index where to start the copy in the mesh indices array
  21678. * @param indexCount the number of indices to copy then from the startIndex
  21679. * @param mesh the main mesh to create the submesh from
  21680. * @param renderingMesh the optional rendering mesh
  21681. * @returns a new submesh
  21682. */
  21683. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21684. }
  21685. }
  21686. declare module BABYLON {
  21687. /**
  21688. * Class used to represent data loading progression
  21689. */
  21690. export class SceneLoaderFlags {
  21691. private static _ForceFullSceneLoadingForIncremental;
  21692. private static _ShowLoadingScreen;
  21693. private static _CleanBoneMatrixWeights;
  21694. private static _loggingLevel;
  21695. /**
  21696. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21697. */
  21698. static get ForceFullSceneLoadingForIncremental(): boolean;
  21699. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21700. /**
  21701. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21702. */
  21703. static get ShowLoadingScreen(): boolean;
  21704. static set ShowLoadingScreen(value: boolean);
  21705. /**
  21706. * Defines the current logging level (while loading the scene)
  21707. * @ignorenaming
  21708. */
  21709. static get loggingLevel(): number;
  21710. static set loggingLevel(value: number);
  21711. /**
  21712. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21713. */
  21714. static get CleanBoneMatrixWeights(): boolean;
  21715. static set CleanBoneMatrixWeights(value: boolean);
  21716. }
  21717. }
  21718. declare module BABYLON {
  21719. /**
  21720. * Class used to store geometry data (vertex buffers + index buffer)
  21721. */
  21722. export class Geometry implements IGetSetVerticesData {
  21723. /**
  21724. * Gets or sets the ID of the geometry
  21725. */
  21726. id: string;
  21727. /**
  21728. * Gets or sets the unique ID of the geometry
  21729. */
  21730. uniqueId: number;
  21731. /**
  21732. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21733. */
  21734. delayLoadState: number;
  21735. /**
  21736. * Gets the file containing the data to load when running in delay load state
  21737. */
  21738. delayLoadingFile: Nullable<string>;
  21739. /**
  21740. * Callback called when the geometry is updated
  21741. */
  21742. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21743. private _scene;
  21744. private _engine;
  21745. private _meshes;
  21746. private _totalVertices;
  21747. /** @hidden */
  21748. _indices: IndicesArray;
  21749. /** @hidden */
  21750. _vertexBuffers: {
  21751. [key: string]: VertexBuffer;
  21752. };
  21753. private _isDisposed;
  21754. private _extend;
  21755. private _boundingBias;
  21756. /** @hidden */
  21757. _delayInfo: Array<string>;
  21758. private _indexBuffer;
  21759. private _indexBufferIsUpdatable;
  21760. /** @hidden */
  21761. _boundingInfo: Nullable<BoundingInfo>;
  21762. /** @hidden */
  21763. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21764. /** @hidden */
  21765. _softwareSkinningFrameId: number;
  21766. private _vertexArrayObjects;
  21767. private _updatable;
  21768. /** @hidden */
  21769. _positions: Nullable<Vector3[]>;
  21770. /**
  21771. * 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
  21772. */
  21773. get boundingBias(): Vector2;
  21774. /**
  21775. * 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
  21776. */
  21777. set boundingBias(value: Vector2);
  21778. /**
  21779. * Static function used to attach a new empty geometry to a mesh
  21780. * @param mesh defines the mesh to attach the geometry to
  21781. * @returns the new Geometry
  21782. */
  21783. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21784. /**
  21785. * Creates a new geometry
  21786. * @param id defines the unique ID
  21787. * @param scene defines the hosting scene
  21788. * @param vertexData defines the VertexData used to get geometry data
  21789. * @param updatable defines if geometry must be updatable (false by default)
  21790. * @param mesh defines the mesh that will be associated with the geometry
  21791. */
  21792. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21793. /**
  21794. * Gets the current extend of the geometry
  21795. */
  21796. get extend(): {
  21797. minimum: Vector3;
  21798. maximum: Vector3;
  21799. };
  21800. /**
  21801. * Gets the hosting scene
  21802. * @returns the hosting Scene
  21803. */
  21804. getScene(): Scene;
  21805. /**
  21806. * Gets the hosting engine
  21807. * @returns the hosting Engine
  21808. */
  21809. getEngine(): Engine;
  21810. /**
  21811. * Defines if the geometry is ready to use
  21812. * @returns true if the geometry is ready to be used
  21813. */
  21814. isReady(): boolean;
  21815. /**
  21816. * Gets a value indicating that the geometry should not be serialized
  21817. */
  21818. get doNotSerialize(): boolean;
  21819. /** @hidden */
  21820. _rebuild(): void;
  21821. /**
  21822. * Affects all geometry data in one call
  21823. * @param vertexData defines the geometry data
  21824. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21825. */
  21826. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21827. /**
  21828. * Set specific vertex data
  21829. * @param kind defines the data kind (Position, normal, etc...)
  21830. * @param data defines the vertex data to use
  21831. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21832. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21833. */
  21834. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21835. /**
  21836. * Removes a specific vertex data
  21837. * @param kind defines the data kind (Position, normal, etc...)
  21838. */
  21839. removeVerticesData(kind: string): void;
  21840. /**
  21841. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21842. * @param buffer defines the vertex buffer to use
  21843. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21844. */
  21845. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21846. /**
  21847. * Update a specific vertex buffer
  21848. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21849. * It will do nothing if the buffer is not updatable
  21850. * @param kind defines the data kind (Position, normal, etc...)
  21851. * @param data defines the data to use
  21852. * @param offset defines the offset in the target buffer where to store the data
  21853. * @param useBytes set to true if the offset is in bytes
  21854. */
  21855. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21856. /**
  21857. * Update a specific vertex buffer
  21858. * This function will create a new buffer if the current one is not updatable
  21859. * @param kind defines the data kind (Position, normal, etc...)
  21860. * @param data defines the data to use
  21861. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21862. */
  21863. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21864. private _updateBoundingInfo;
  21865. /** @hidden */
  21866. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21867. /**
  21868. * Gets total number of vertices
  21869. * @returns the total number of vertices
  21870. */
  21871. getTotalVertices(): number;
  21872. /**
  21873. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21874. * @param kind defines the data kind (Position, normal, etc...)
  21875. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21876. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21877. * @returns a float array containing vertex data
  21878. */
  21879. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21880. /**
  21881. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21882. * @param kind defines the data kind (Position, normal, etc...)
  21883. * @returns true if the vertex buffer with the specified kind is updatable
  21884. */
  21885. isVertexBufferUpdatable(kind: string): boolean;
  21886. /**
  21887. * Gets a specific vertex buffer
  21888. * @param kind defines the data kind (Position, normal, etc...)
  21889. * @returns a VertexBuffer
  21890. */
  21891. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21892. /**
  21893. * Returns all vertex buffers
  21894. * @return an object holding all vertex buffers indexed by kind
  21895. */
  21896. getVertexBuffers(): Nullable<{
  21897. [key: string]: VertexBuffer;
  21898. }>;
  21899. /**
  21900. * Gets a boolean indicating if specific vertex buffer is present
  21901. * @param kind defines the data kind (Position, normal, etc...)
  21902. * @returns true if data is present
  21903. */
  21904. isVerticesDataPresent(kind: string): boolean;
  21905. /**
  21906. * Gets a list of all attached data kinds (Position, normal, etc...)
  21907. * @returns a list of string containing all kinds
  21908. */
  21909. getVerticesDataKinds(): string[];
  21910. /**
  21911. * Update index buffer
  21912. * @param indices defines the indices to store in the index buffer
  21913. * @param offset defines the offset in the target buffer where to store the data
  21914. * @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)
  21915. */
  21916. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21917. /**
  21918. * Creates a new index buffer
  21919. * @param indices defines the indices to store in the index buffer
  21920. * @param totalVertices defines the total number of vertices (could be null)
  21921. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21922. */
  21923. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21924. /**
  21925. * Return the total number of indices
  21926. * @returns the total number of indices
  21927. */
  21928. getTotalIndices(): number;
  21929. /**
  21930. * Gets the index buffer array
  21931. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21932. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21933. * @returns the index buffer array
  21934. */
  21935. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21936. /**
  21937. * Gets the index buffer
  21938. * @return the index buffer
  21939. */
  21940. getIndexBuffer(): Nullable<DataBuffer>;
  21941. /** @hidden */
  21942. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21943. /**
  21944. * Release the associated resources for a specific mesh
  21945. * @param mesh defines the source mesh
  21946. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21947. */
  21948. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21949. /**
  21950. * Apply current geometry to a given mesh
  21951. * @param mesh defines the mesh to apply geometry to
  21952. */
  21953. applyToMesh(mesh: Mesh): void;
  21954. private _updateExtend;
  21955. private _applyToMesh;
  21956. private notifyUpdate;
  21957. /**
  21958. * Load the geometry if it was flagged as delay loaded
  21959. * @param scene defines the hosting scene
  21960. * @param onLoaded defines a callback called when the geometry is loaded
  21961. */
  21962. load(scene: Scene, onLoaded?: () => void): void;
  21963. private _queueLoad;
  21964. /**
  21965. * Invert the geometry to move from a right handed system to a left handed one.
  21966. */
  21967. toLeftHanded(): void;
  21968. /** @hidden */
  21969. _resetPointsArrayCache(): void;
  21970. /** @hidden */
  21971. _generatePointsArray(): boolean;
  21972. /**
  21973. * Gets a value indicating if the geometry is disposed
  21974. * @returns true if the geometry was disposed
  21975. */
  21976. isDisposed(): boolean;
  21977. private _disposeVertexArrayObjects;
  21978. /**
  21979. * Free all associated resources
  21980. */
  21981. dispose(): void;
  21982. /**
  21983. * Clone the current geometry into a new geometry
  21984. * @param id defines the unique ID of the new geometry
  21985. * @returns a new geometry object
  21986. */
  21987. copy(id: string): Geometry;
  21988. /**
  21989. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21990. * @return a JSON representation of the current geometry data (without the vertices data)
  21991. */
  21992. serialize(): any;
  21993. private toNumberArray;
  21994. /**
  21995. * Serialize all vertices data into a JSON oject
  21996. * @returns a JSON representation of the current geometry data
  21997. */
  21998. serializeVerticeData(): any;
  21999. /**
  22000. * Extracts a clone of a mesh geometry
  22001. * @param mesh defines the source mesh
  22002. * @param id defines the unique ID of the new geometry object
  22003. * @returns the new geometry object
  22004. */
  22005. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22006. /**
  22007. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22008. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22009. * Be aware Math.random() could cause collisions, but:
  22010. * "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"
  22011. * @returns a string containing a new GUID
  22012. */
  22013. static RandomId(): string;
  22014. /** @hidden */
  22015. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22016. private static _CleanMatricesWeights;
  22017. /**
  22018. * Create a new geometry from persisted data (Using .babylon file format)
  22019. * @param parsedVertexData defines the persisted data
  22020. * @param scene defines the hosting scene
  22021. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22022. * @returns the new geometry object
  22023. */
  22024. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22025. }
  22026. }
  22027. declare module BABYLON {
  22028. /**
  22029. * Define an interface for all classes that will get and set the data on vertices
  22030. */
  22031. export interface IGetSetVerticesData {
  22032. /**
  22033. * Gets a boolean indicating if specific vertex data is present
  22034. * @param kind defines the vertex data kind to use
  22035. * @returns true is data kind is present
  22036. */
  22037. isVerticesDataPresent(kind: string): boolean;
  22038. /**
  22039. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22040. * @param kind defines the data kind (Position, normal, etc...)
  22041. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22042. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22043. * @returns a float array containing vertex data
  22044. */
  22045. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22046. /**
  22047. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22048. * @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.
  22049. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22050. * @returns the indices array or an empty array if the mesh has no geometry
  22051. */
  22052. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22053. /**
  22054. * Set specific vertex data
  22055. * @param kind defines the data kind (Position, normal, etc...)
  22056. * @param data defines the vertex data to use
  22057. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22058. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22059. */
  22060. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22061. /**
  22062. * Update a specific associated vertex buffer
  22063. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22064. * - VertexBuffer.PositionKind
  22065. * - VertexBuffer.UVKind
  22066. * - VertexBuffer.UV2Kind
  22067. * - VertexBuffer.UV3Kind
  22068. * - VertexBuffer.UV4Kind
  22069. * - VertexBuffer.UV5Kind
  22070. * - VertexBuffer.UV6Kind
  22071. * - VertexBuffer.ColorKind
  22072. * - VertexBuffer.MatricesIndicesKind
  22073. * - VertexBuffer.MatricesIndicesExtraKind
  22074. * - VertexBuffer.MatricesWeightsKind
  22075. * - VertexBuffer.MatricesWeightsExtraKind
  22076. * @param data defines the data source
  22077. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22078. * @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)
  22079. */
  22080. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22081. /**
  22082. * Creates a new index buffer
  22083. * @param indices defines the indices to store in the index buffer
  22084. * @param totalVertices defines the total number of vertices (could be null)
  22085. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22086. */
  22087. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22088. }
  22089. /**
  22090. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22091. */
  22092. export class VertexData {
  22093. /**
  22094. * Mesh side orientation : usually the external or front surface
  22095. */
  22096. static readonly FRONTSIDE: number;
  22097. /**
  22098. * Mesh side orientation : usually the internal or back surface
  22099. */
  22100. static readonly BACKSIDE: number;
  22101. /**
  22102. * Mesh side orientation : both internal and external or front and back surfaces
  22103. */
  22104. static readonly DOUBLESIDE: number;
  22105. /**
  22106. * Mesh side orientation : by default, `FRONTSIDE`
  22107. */
  22108. static readonly DEFAULTSIDE: number;
  22109. /**
  22110. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22111. */
  22112. positions: Nullable<FloatArray>;
  22113. /**
  22114. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22115. */
  22116. normals: Nullable<FloatArray>;
  22117. /**
  22118. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22119. */
  22120. tangents: Nullable<FloatArray>;
  22121. /**
  22122. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22123. */
  22124. uvs: Nullable<FloatArray>;
  22125. /**
  22126. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22127. */
  22128. uvs2: Nullable<FloatArray>;
  22129. /**
  22130. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22131. */
  22132. uvs3: Nullable<FloatArray>;
  22133. /**
  22134. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22135. */
  22136. uvs4: Nullable<FloatArray>;
  22137. /**
  22138. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22139. */
  22140. uvs5: Nullable<FloatArray>;
  22141. /**
  22142. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22143. */
  22144. uvs6: Nullable<FloatArray>;
  22145. /**
  22146. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22147. */
  22148. colors: Nullable<FloatArray>;
  22149. /**
  22150. * 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).
  22151. */
  22152. matricesIndices: Nullable<FloatArray>;
  22153. /**
  22154. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22155. */
  22156. matricesWeights: Nullable<FloatArray>;
  22157. /**
  22158. * An array extending the number of possible indices
  22159. */
  22160. matricesIndicesExtra: Nullable<FloatArray>;
  22161. /**
  22162. * An array extending the number of possible weights when the number of indices is extended
  22163. */
  22164. matricesWeightsExtra: Nullable<FloatArray>;
  22165. /**
  22166. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22167. */
  22168. indices: Nullable<IndicesArray>;
  22169. /**
  22170. * Uses the passed data array to set the set the values for the specified kind of data
  22171. * @param data a linear array of floating numbers
  22172. * @param kind the type of data that is being set, eg positions, colors etc
  22173. */
  22174. set(data: FloatArray, kind: string): void;
  22175. /**
  22176. * Associates the vertexData to the passed Mesh.
  22177. * Sets it as updatable or not (default `false`)
  22178. * @param mesh the mesh the vertexData is applied to
  22179. * @param updatable when used and having the value true allows new data to update the vertexData
  22180. * @returns the VertexData
  22181. */
  22182. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22183. /**
  22184. * Associates the vertexData to the passed Geometry.
  22185. * Sets it as updatable or not (default `false`)
  22186. * @param geometry the geometry the vertexData is applied to
  22187. * @param updatable when used and having the value true allows new data to update the vertexData
  22188. * @returns VertexData
  22189. */
  22190. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22191. /**
  22192. * Updates the associated mesh
  22193. * @param mesh the mesh to be updated
  22194. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22195. * @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
  22196. * @returns VertexData
  22197. */
  22198. updateMesh(mesh: Mesh): VertexData;
  22199. /**
  22200. * Updates the associated geometry
  22201. * @param geometry the geometry to be updated
  22202. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22203. * @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
  22204. * @returns VertexData.
  22205. */
  22206. updateGeometry(geometry: Geometry): VertexData;
  22207. private _applyTo;
  22208. private _update;
  22209. /**
  22210. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22211. * @param matrix the transforming matrix
  22212. * @returns the VertexData
  22213. */
  22214. transform(matrix: Matrix): VertexData;
  22215. /**
  22216. * Merges the passed VertexData into the current one
  22217. * @param other the VertexData to be merged into the current one
  22218. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22219. * @returns the modified VertexData
  22220. */
  22221. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22222. private _mergeElement;
  22223. private _validate;
  22224. /**
  22225. * Serializes the VertexData
  22226. * @returns a serialized object
  22227. */
  22228. serialize(): any;
  22229. /**
  22230. * Extracts the vertexData from a mesh
  22231. * @param mesh the mesh from which to extract the VertexData
  22232. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22233. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22234. * @returns the object VertexData associated to the passed mesh
  22235. */
  22236. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22237. /**
  22238. * Extracts the vertexData from the geometry
  22239. * @param geometry the geometry from which to extract the VertexData
  22240. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22241. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22242. * @returns the object VertexData associated to the passed mesh
  22243. */
  22244. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22245. private static _ExtractFrom;
  22246. /**
  22247. * Creates the VertexData for a Ribbon
  22248. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22249. * * pathArray array of paths, each of which an array of successive Vector3
  22250. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22251. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22252. * * 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
  22253. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22254. * * 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)
  22255. * * 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)
  22256. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22257. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22258. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22259. * @returns the VertexData of the ribbon
  22260. */
  22261. static CreateRibbon(options: {
  22262. pathArray: Vector3[][];
  22263. closeArray?: boolean;
  22264. closePath?: boolean;
  22265. offset?: number;
  22266. sideOrientation?: number;
  22267. frontUVs?: Vector4;
  22268. backUVs?: Vector4;
  22269. invertUV?: boolean;
  22270. uvs?: Vector2[];
  22271. colors?: Color4[];
  22272. }): VertexData;
  22273. /**
  22274. * Creates the VertexData for a box
  22275. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22276. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22277. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22278. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22279. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22280. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22281. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22282. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22283. * * 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)
  22284. * * 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)
  22285. * @returns the VertexData of the box
  22286. */
  22287. static CreateBox(options: {
  22288. size?: number;
  22289. width?: number;
  22290. height?: number;
  22291. depth?: number;
  22292. faceUV?: Vector4[];
  22293. faceColors?: Color4[];
  22294. sideOrientation?: number;
  22295. frontUVs?: Vector4;
  22296. backUVs?: Vector4;
  22297. }): VertexData;
  22298. /**
  22299. * Creates the VertexData for a tiled box
  22300. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22301. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22302. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22303. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22304. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22305. * @returns the VertexData of the box
  22306. */
  22307. static CreateTiledBox(options: {
  22308. pattern?: number;
  22309. width?: number;
  22310. height?: number;
  22311. depth?: number;
  22312. tileSize?: number;
  22313. tileWidth?: number;
  22314. tileHeight?: number;
  22315. alignHorizontal?: number;
  22316. alignVertical?: number;
  22317. faceUV?: Vector4[];
  22318. faceColors?: Color4[];
  22319. sideOrientation?: number;
  22320. }): VertexData;
  22321. /**
  22322. * Creates the VertexData for a tiled plane
  22323. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22324. * * pattern a limited pattern arrangement depending on the number
  22325. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22326. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22327. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22329. * * 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)
  22330. * * 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)
  22331. * @returns the VertexData of the tiled plane
  22332. */
  22333. static CreateTiledPlane(options: {
  22334. pattern?: number;
  22335. tileSize?: number;
  22336. tileWidth?: number;
  22337. tileHeight?: number;
  22338. size?: number;
  22339. width?: number;
  22340. height?: number;
  22341. alignHorizontal?: number;
  22342. alignVertical?: number;
  22343. sideOrientation?: number;
  22344. frontUVs?: Vector4;
  22345. backUVs?: Vector4;
  22346. }): VertexData;
  22347. /**
  22348. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22349. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22350. * * segments sets the number of horizontal strips optional, default 32
  22351. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22352. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22353. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22354. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22355. * * 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
  22356. * * 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
  22357. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22358. * * 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)
  22359. * * 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)
  22360. * @returns the VertexData of the ellipsoid
  22361. */
  22362. static CreateSphere(options: {
  22363. segments?: number;
  22364. diameter?: number;
  22365. diameterX?: number;
  22366. diameterY?: number;
  22367. diameterZ?: number;
  22368. arc?: number;
  22369. slice?: number;
  22370. sideOrientation?: number;
  22371. frontUVs?: Vector4;
  22372. backUVs?: Vector4;
  22373. }): VertexData;
  22374. /**
  22375. * Creates the VertexData for a cylinder, cone or prism
  22376. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22377. * * height sets the height (y direction) of the cylinder, optional, default 2
  22378. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22379. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22380. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22381. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22382. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22383. * * 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
  22384. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22385. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22386. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22387. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22388. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22389. * * 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)
  22390. * * 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)
  22391. * @returns the VertexData of the cylinder, cone or prism
  22392. */
  22393. static CreateCylinder(options: {
  22394. height?: number;
  22395. diameterTop?: number;
  22396. diameterBottom?: number;
  22397. diameter?: number;
  22398. tessellation?: number;
  22399. subdivisions?: number;
  22400. arc?: number;
  22401. faceColors?: Color4[];
  22402. faceUV?: Vector4[];
  22403. hasRings?: boolean;
  22404. enclose?: boolean;
  22405. sideOrientation?: number;
  22406. frontUVs?: Vector4;
  22407. backUVs?: Vector4;
  22408. }): VertexData;
  22409. /**
  22410. * Creates the VertexData for a torus
  22411. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22412. * * diameter the diameter of the torus, optional default 1
  22413. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22414. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22415. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22416. * * 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)
  22417. * * 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)
  22418. * @returns the VertexData of the torus
  22419. */
  22420. static CreateTorus(options: {
  22421. diameter?: number;
  22422. thickness?: number;
  22423. tessellation?: number;
  22424. sideOrientation?: number;
  22425. frontUVs?: Vector4;
  22426. backUVs?: Vector4;
  22427. }): VertexData;
  22428. /**
  22429. * Creates the VertexData of the LineSystem
  22430. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22431. * - lines an array of lines, each line being an array of successive Vector3
  22432. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22433. * @returns the VertexData of the LineSystem
  22434. */
  22435. static CreateLineSystem(options: {
  22436. lines: Vector3[][];
  22437. colors?: Nullable<Color4[][]>;
  22438. }): VertexData;
  22439. /**
  22440. * Create the VertexData for a DashedLines
  22441. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22442. * - points an array successive Vector3
  22443. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22444. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22445. * - dashNb the intended total number of dashes, optional, default 200
  22446. * @returns the VertexData for the DashedLines
  22447. */
  22448. static CreateDashedLines(options: {
  22449. points: Vector3[];
  22450. dashSize?: number;
  22451. gapSize?: number;
  22452. dashNb?: number;
  22453. }): VertexData;
  22454. /**
  22455. * Creates the VertexData for a Ground
  22456. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22457. * - width the width (x direction) of the ground, optional, default 1
  22458. * - height the height (z direction) of the ground, optional, default 1
  22459. * - subdivisions the number of subdivisions per side, optional, default 1
  22460. * @returns the VertexData of the Ground
  22461. */
  22462. static CreateGround(options: {
  22463. width?: number;
  22464. height?: number;
  22465. subdivisions?: number;
  22466. subdivisionsX?: number;
  22467. subdivisionsY?: number;
  22468. }): VertexData;
  22469. /**
  22470. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22471. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22472. * * xmin the ground minimum X coordinate, optional, default -1
  22473. * * zmin the ground minimum Z coordinate, optional, default -1
  22474. * * xmax the ground maximum X coordinate, optional, default 1
  22475. * * zmax the ground maximum Z coordinate, optional, default 1
  22476. * * 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}
  22477. * * 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}
  22478. * @returns the VertexData of the TiledGround
  22479. */
  22480. static CreateTiledGround(options: {
  22481. xmin: number;
  22482. zmin: number;
  22483. xmax: number;
  22484. zmax: number;
  22485. subdivisions?: {
  22486. w: number;
  22487. h: number;
  22488. };
  22489. precision?: {
  22490. w: number;
  22491. h: number;
  22492. };
  22493. }): VertexData;
  22494. /**
  22495. * Creates the VertexData of the Ground designed from a heightmap
  22496. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22497. * * width the width (x direction) of the ground
  22498. * * height the height (z direction) of the ground
  22499. * * subdivisions the number of subdivisions per side
  22500. * * minHeight the minimum altitude on the ground, optional, default 0
  22501. * * maxHeight the maximum altitude on the ground, optional default 1
  22502. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22503. * * buffer the array holding the image color data
  22504. * * bufferWidth the width of image
  22505. * * bufferHeight the height of image
  22506. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22507. * @returns the VertexData of the Ground designed from a heightmap
  22508. */
  22509. static CreateGroundFromHeightMap(options: {
  22510. width: number;
  22511. height: number;
  22512. subdivisions: number;
  22513. minHeight: number;
  22514. maxHeight: number;
  22515. colorFilter: Color3;
  22516. buffer: Uint8Array;
  22517. bufferWidth: number;
  22518. bufferHeight: number;
  22519. alphaFilter: number;
  22520. }): VertexData;
  22521. /**
  22522. * Creates the VertexData for a Plane
  22523. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22524. * * size sets the width and height of the plane to the value of size, optional default 1
  22525. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22526. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22528. * * 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)
  22529. * * 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)
  22530. * @returns the VertexData of the box
  22531. */
  22532. static CreatePlane(options: {
  22533. size?: number;
  22534. width?: number;
  22535. height?: number;
  22536. sideOrientation?: number;
  22537. frontUVs?: Vector4;
  22538. backUVs?: Vector4;
  22539. }): VertexData;
  22540. /**
  22541. * Creates the VertexData of the Disc or regular Polygon
  22542. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22543. * * radius the radius of the disc, optional default 0.5
  22544. * * tessellation the number of polygon sides, optional, default 64
  22545. * * 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
  22546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22547. * * 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)
  22548. * * 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)
  22549. * @returns the VertexData of the box
  22550. */
  22551. static CreateDisc(options: {
  22552. radius?: number;
  22553. tessellation?: number;
  22554. arc?: number;
  22555. sideOrientation?: number;
  22556. frontUVs?: Vector4;
  22557. backUVs?: Vector4;
  22558. }): VertexData;
  22559. /**
  22560. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22561. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22562. * @param polygon a mesh built from polygonTriangulation.build()
  22563. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22564. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22565. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22566. * @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)
  22567. * @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)
  22568. * @returns the VertexData of the Polygon
  22569. */
  22570. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22571. /**
  22572. * Creates the VertexData of the IcoSphere
  22573. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22574. * * radius the radius of the IcoSphere, optional default 1
  22575. * * radiusX allows stretching in the x direction, optional, default radius
  22576. * * radiusY allows stretching in the y direction, optional, default radius
  22577. * * radiusZ allows stretching in the z direction, optional, default radius
  22578. * * flat when true creates a flat shaded mesh, optional, default true
  22579. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22581. * * 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)
  22582. * * 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)
  22583. * @returns the VertexData of the IcoSphere
  22584. */
  22585. static CreateIcoSphere(options: {
  22586. radius?: number;
  22587. radiusX?: number;
  22588. radiusY?: number;
  22589. radiusZ?: number;
  22590. flat?: boolean;
  22591. subdivisions?: number;
  22592. sideOrientation?: number;
  22593. frontUVs?: Vector4;
  22594. backUVs?: Vector4;
  22595. }): VertexData;
  22596. /**
  22597. * Creates the VertexData for a Polyhedron
  22598. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22599. * * type provided types are:
  22600. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22601. * * 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)
  22602. * * size the size of the IcoSphere, optional default 1
  22603. * * sizeX allows stretching in the x direction, optional, default size
  22604. * * sizeY allows stretching in the y direction, optional, default size
  22605. * * sizeZ allows stretching in the z direction, optional, default size
  22606. * * 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
  22607. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22608. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22609. * * flat when true creates a flat shaded mesh, optional, default true
  22610. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22611. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22612. * * 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)
  22613. * * 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)
  22614. * @returns the VertexData of the Polyhedron
  22615. */
  22616. static CreatePolyhedron(options: {
  22617. type?: number;
  22618. size?: number;
  22619. sizeX?: number;
  22620. sizeY?: number;
  22621. sizeZ?: number;
  22622. custom?: any;
  22623. faceUV?: Vector4[];
  22624. faceColors?: Color4[];
  22625. flat?: boolean;
  22626. sideOrientation?: number;
  22627. frontUVs?: Vector4;
  22628. backUVs?: Vector4;
  22629. }): VertexData;
  22630. /**
  22631. * Creates the VertexData for a TorusKnot
  22632. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22633. * * radius the radius of the torus knot, optional, default 2
  22634. * * tube the thickness of the tube, optional, default 0.5
  22635. * * radialSegments the number of sides on each tube segments, optional, default 32
  22636. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22637. * * p the number of windings around the z axis, optional, default 2
  22638. * * q the number of windings around the x axis, optional, default 3
  22639. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22640. * * 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)
  22641. * * 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)
  22642. * @returns the VertexData of the Torus Knot
  22643. */
  22644. static CreateTorusKnot(options: {
  22645. radius?: number;
  22646. tube?: number;
  22647. radialSegments?: number;
  22648. tubularSegments?: number;
  22649. p?: number;
  22650. q?: number;
  22651. sideOrientation?: number;
  22652. frontUVs?: Vector4;
  22653. backUVs?: Vector4;
  22654. }): VertexData;
  22655. /**
  22656. * Compute normals for given positions and indices
  22657. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22658. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22659. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22660. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22661. * * facetNormals : optional array of facet normals (vector3)
  22662. * * facetPositions : optional array of facet positions (vector3)
  22663. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22664. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22665. * * bInfo : optional bounding info, required for facetPartitioning computation
  22666. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22667. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22668. * * useRightHandedSystem: optional boolean to for right handed system computation
  22669. * * depthSort : optional boolean to enable the facet depth sort computation
  22670. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22671. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22672. */
  22673. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22674. facetNormals?: any;
  22675. facetPositions?: any;
  22676. facetPartitioning?: any;
  22677. ratio?: number;
  22678. bInfo?: any;
  22679. bbSize?: Vector3;
  22680. subDiv?: any;
  22681. useRightHandedSystem?: boolean;
  22682. depthSort?: boolean;
  22683. distanceTo?: Vector3;
  22684. depthSortedFacets?: any;
  22685. }): void;
  22686. /** @hidden */
  22687. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22688. /**
  22689. * Applies VertexData created from the imported parameters to the geometry
  22690. * @param parsedVertexData the parsed data from an imported file
  22691. * @param geometry the geometry to apply the VertexData to
  22692. */
  22693. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22694. }
  22695. }
  22696. declare module BABYLON {
  22697. /**
  22698. * Defines a target to use with MorphTargetManager
  22699. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22700. */
  22701. export class MorphTarget implements IAnimatable {
  22702. /** defines the name of the target */
  22703. name: string;
  22704. /**
  22705. * Gets or sets the list of animations
  22706. */
  22707. animations: Animation[];
  22708. private _scene;
  22709. private _positions;
  22710. private _normals;
  22711. private _tangents;
  22712. private _uvs;
  22713. private _influence;
  22714. private _uniqueId;
  22715. /**
  22716. * Observable raised when the influence changes
  22717. */
  22718. onInfluenceChanged: Observable<boolean>;
  22719. /** @hidden */
  22720. _onDataLayoutChanged: Observable<void>;
  22721. /**
  22722. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22723. */
  22724. get influence(): number;
  22725. set influence(influence: number);
  22726. /**
  22727. * Gets or sets the id of the morph Target
  22728. */
  22729. id: string;
  22730. private _animationPropertiesOverride;
  22731. /**
  22732. * Gets or sets the animation properties override
  22733. */
  22734. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22735. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22736. /**
  22737. * Creates a new MorphTarget
  22738. * @param name defines the name of the target
  22739. * @param influence defines the influence to use
  22740. * @param scene defines the scene the morphtarget belongs to
  22741. */
  22742. constructor(
  22743. /** defines the name of the target */
  22744. name: string, influence?: number, scene?: Nullable<Scene>);
  22745. /**
  22746. * Gets the unique ID of this manager
  22747. */
  22748. get uniqueId(): number;
  22749. /**
  22750. * Gets a boolean defining if the target contains position data
  22751. */
  22752. get hasPositions(): boolean;
  22753. /**
  22754. * Gets a boolean defining if the target contains normal data
  22755. */
  22756. get hasNormals(): boolean;
  22757. /**
  22758. * Gets a boolean defining if the target contains tangent data
  22759. */
  22760. get hasTangents(): boolean;
  22761. /**
  22762. * Gets a boolean defining if the target contains texture coordinates data
  22763. */
  22764. get hasUVs(): boolean;
  22765. /**
  22766. * Affects position data to this target
  22767. * @param data defines the position data to use
  22768. */
  22769. setPositions(data: Nullable<FloatArray>): void;
  22770. /**
  22771. * Gets the position data stored in this target
  22772. * @returns a FloatArray containing the position data (or null if not present)
  22773. */
  22774. getPositions(): Nullable<FloatArray>;
  22775. /**
  22776. * Affects normal data to this target
  22777. * @param data defines the normal data to use
  22778. */
  22779. setNormals(data: Nullable<FloatArray>): void;
  22780. /**
  22781. * Gets the normal data stored in this target
  22782. * @returns a FloatArray containing the normal data (or null if not present)
  22783. */
  22784. getNormals(): Nullable<FloatArray>;
  22785. /**
  22786. * Affects tangent data to this target
  22787. * @param data defines the tangent data to use
  22788. */
  22789. setTangents(data: Nullable<FloatArray>): void;
  22790. /**
  22791. * Gets the tangent data stored in this target
  22792. * @returns a FloatArray containing the tangent data (or null if not present)
  22793. */
  22794. getTangents(): Nullable<FloatArray>;
  22795. /**
  22796. * Affects texture coordinates data to this target
  22797. * @param data defines the texture coordinates data to use
  22798. */
  22799. setUVs(data: Nullable<FloatArray>): void;
  22800. /**
  22801. * Gets the texture coordinates data stored in this target
  22802. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22803. */
  22804. getUVs(): Nullable<FloatArray>;
  22805. /**
  22806. * Clone the current target
  22807. * @returns a new MorphTarget
  22808. */
  22809. clone(): MorphTarget;
  22810. /**
  22811. * Serializes the current target into a Serialization object
  22812. * @returns the serialized object
  22813. */
  22814. serialize(): any;
  22815. /**
  22816. * Returns the string "MorphTarget"
  22817. * @returns "MorphTarget"
  22818. */
  22819. getClassName(): string;
  22820. /**
  22821. * Creates a new target from serialized data
  22822. * @param serializationObject defines the serialized data to use
  22823. * @returns a new MorphTarget
  22824. */
  22825. static Parse(serializationObject: any): MorphTarget;
  22826. /**
  22827. * Creates a MorphTarget from mesh data
  22828. * @param mesh defines the source mesh
  22829. * @param name defines the name to use for the new target
  22830. * @param influence defines the influence to attach to the target
  22831. * @returns a new MorphTarget
  22832. */
  22833. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22834. }
  22835. }
  22836. declare module BABYLON {
  22837. /**
  22838. * This class is used to deform meshes using morphing between different targets
  22839. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22840. */
  22841. export class MorphTargetManager {
  22842. private _targets;
  22843. private _targetInfluenceChangedObservers;
  22844. private _targetDataLayoutChangedObservers;
  22845. private _activeTargets;
  22846. private _scene;
  22847. private _influences;
  22848. private _supportsNormals;
  22849. private _supportsTangents;
  22850. private _supportsUVs;
  22851. private _vertexCount;
  22852. private _uniqueId;
  22853. private _tempInfluences;
  22854. /**
  22855. * Gets or sets a boolean indicating if normals must be morphed
  22856. */
  22857. enableNormalMorphing: boolean;
  22858. /**
  22859. * Gets or sets a boolean indicating if tangents must be morphed
  22860. */
  22861. enableTangentMorphing: boolean;
  22862. /**
  22863. * Gets or sets a boolean indicating if UV must be morphed
  22864. */
  22865. enableUVMorphing: boolean;
  22866. /**
  22867. * Creates a new MorphTargetManager
  22868. * @param scene defines the current scene
  22869. */
  22870. constructor(scene?: Nullable<Scene>);
  22871. /**
  22872. * Gets the unique ID of this manager
  22873. */
  22874. get uniqueId(): number;
  22875. /**
  22876. * Gets the number of vertices handled by this manager
  22877. */
  22878. get vertexCount(): number;
  22879. /**
  22880. * Gets a boolean indicating if this manager supports morphing of normals
  22881. */
  22882. get supportsNormals(): boolean;
  22883. /**
  22884. * Gets a boolean indicating if this manager supports morphing of tangents
  22885. */
  22886. get supportsTangents(): boolean;
  22887. /**
  22888. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22889. */
  22890. get supportsUVs(): boolean;
  22891. /**
  22892. * Gets the number of targets stored in this manager
  22893. */
  22894. get numTargets(): number;
  22895. /**
  22896. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22897. */
  22898. get numInfluencers(): number;
  22899. /**
  22900. * Gets the list of influences (one per target)
  22901. */
  22902. get influences(): Float32Array;
  22903. /**
  22904. * Gets the active target at specified index. An active target is a target with an influence > 0
  22905. * @param index defines the index to check
  22906. * @returns the requested target
  22907. */
  22908. getActiveTarget(index: number): MorphTarget;
  22909. /**
  22910. * Gets the target at specified index
  22911. * @param index defines the index to check
  22912. * @returns the requested target
  22913. */
  22914. getTarget(index: number): MorphTarget;
  22915. /**
  22916. * Add a new target to this manager
  22917. * @param target defines the target to add
  22918. */
  22919. addTarget(target: MorphTarget): void;
  22920. /**
  22921. * Removes a target from the manager
  22922. * @param target defines the target to remove
  22923. */
  22924. removeTarget(target: MorphTarget): void;
  22925. /**
  22926. * Clone the current manager
  22927. * @returns a new MorphTargetManager
  22928. */
  22929. clone(): MorphTargetManager;
  22930. /**
  22931. * Serializes the current manager into a Serialization object
  22932. * @returns the serialized object
  22933. */
  22934. serialize(): any;
  22935. private _syncActiveTargets;
  22936. /**
  22937. * Syncrhonize the targets with all the meshes using this morph target manager
  22938. */
  22939. synchronize(): void;
  22940. /**
  22941. * Creates a new MorphTargetManager from serialized data
  22942. * @param serializationObject defines the serialized data
  22943. * @param scene defines the hosting scene
  22944. * @returns the new MorphTargetManager
  22945. */
  22946. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22947. }
  22948. }
  22949. declare module BABYLON {
  22950. /**
  22951. * Class used to represent a specific level of detail of a mesh
  22952. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22953. */
  22954. export class MeshLODLevel {
  22955. /** Defines the distance where this level should start being displayed */
  22956. distance: number;
  22957. /** Defines the mesh to use to render this level */
  22958. mesh: Nullable<Mesh>;
  22959. /**
  22960. * Creates a new LOD level
  22961. * @param distance defines the distance where this level should star being displayed
  22962. * @param mesh defines the mesh to use to render this level
  22963. */
  22964. constructor(
  22965. /** Defines the distance where this level should start being displayed */
  22966. distance: number,
  22967. /** Defines the mesh to use to render this level */
  22968. mesh: Nullable<Mesh>);
  22969. }
  22970. }
  22971. declare module BABYLON {
  22972. /**
  22973. * Mesh representing the gorund
  22974. */
  22975. export class GroundMesh extends Mesh {
  22976. /** If octree should be generated */
  22977. generateOctree: boolean;
  22978. private _heightQuads;
  22979. /** @hidden */
  22980. _subdivisionsX: number;
  22981. /** @hidden */
  22982. _subdivisionsY: number;
  22983. /** @hidden */
  22984. _width: number;
  22985. /** @hidden */
  22986. _height: number;
  22987. /** @hidden */
  22988. _minX: number;
  22989. /** @hidden */
  22990. _maxX: number;
  22991. /** @hidden */
  22992. _minZ: number;
  22993. /** @hidden */
  22994. _maxZ: number;
  22995. constructor(name: string, scene: Scene);
  22996. /**
  22997. * "GroundMesh"
  22998. * @returns "GroundMesh"
  22999. */
  23000. getClassName(): string;
  23001. /**
  23002. * The minimum of x and y subdivisions
  23003. */
  23004. get subdivisions(): number;
  23005. /**
  23006. * X subdivisions
  23007. */
  23008. get subdivisionsX(): number;
  23009. /**
  23010. * Y subdivisions
  23011. */
  23012. get subdivisionsY(): number;
  23013. /**
  23014. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23015. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23016. * @param chunksCount the number of subdivisions for x and y
  23017. * @param octreeBlocksSize (Default: 32)
  23018. */
  23019. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23020. /**
  23021. * Returns a height (y) value in the Worl system :
  23022. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23023. * @param x x coordinate
  23024. * @param z z coordinate
  23025. * @returns the ground y position if (x, z) are outside the ground surface.
  23026. */
  23027. getHeightAtCoordinates(x: number, z: number): number;
  23028. /**
  23029. * Returns a normalized vector (Vector3) orthogonal to the ground
  23030. * at the ground coordinates (x, z) expressed in the World system.
  23031. * @param x x coordinate
  23032. * @param z z coordinate
  23033. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23034. */
  23035. getNormalAtCoordinates(x: number, z: number): Vector3;
  23036. /**
  23037. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23038. * at the ground coordinates (x, z) expressed in the World system.
  23039. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23040. * @param x x coordinate
  23041. * @param z z coordinate
  23042. * @param ref vector to store the result
  23043. * @returns the GroundMesh.
  23044. */
  23045. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23046. /**
  23047. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23048. * if the ground has been updated.
  23049. * This can be used in the render loop.
  23050. * @returns the GroundMesh.
  23051. */
  23052. updateCoordinateHeights(): GroundMesh;
  23053. private _getFacetAt;
  23054. private _initHeightQuads;
  23055. private _computeHeightQuads;
  23056. /**
  23057. * Serializes this ground mesh
  23058. * @param serializationObject object to write serialization to
  23059. */
  23060. serialize(serializationObject: any): void;
  23061. /**
  23062. * Parses a serialized ground mesh
  23063. * @param parsedMesh the serialized mesh
  23064. * @param scene the scene to create the ground mesh in
  23065. * @returns the created ground mesh
  23066. */
  23067. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23068. }
  23069. }
  23070. declare module BABYLON {
  23071. /**
  23072. * Interface for Physics-Joint data
  23073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23074. */
  23075. export interface PhysicsJointData {
  23076. /**
  23077. * The main pivot of the joint
  23078. */
  23079. mainPivot?: Vector3;
  23080. /**
  23081. * The connected pivot of the joint
  23082. */
  23083. connectedPivot?: Vector3;
  23084. /**
  23085. * The main axis of the joint
  23086. */
  23087. mainAxis?: Vector3;
  23088. /**
  23089. * The connected axis of the joint
  23090. */
  23091. connectedAxis?: Vector3;
  23092. /**
  23093. * The collision of the joint
  23094. */
  23095. collision?: boolean;
  23096. /**
  23097. * Native Oimo/Cannon/Energy data
  23098. */
  23099. nativeParams?: any;
  23100. }
  23101. /**
  23102. * This is a holder class for the physics joint created by the physics plugin
  23103. * It holds a set of functions to control the underlying joint
  23104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23105. */
  23106. export class PhysicsJoint {
  23107. /**
  23108. * The type of the physics joint
  23109. */
  23110. type: number;
  23111. /**
  23112. * The data for the physics joint
  23113. */
  23114. jointData: PhysicsJointData;
  23115. private _physicsJoint;
  23116. protected _physicsPlugin: IPhysicsEnginePlugin;
  23117. /**
  23118. * Initializes the physics joint
  23119. * @param type The type of the physics joint
  23120. * @param jointData The data for the physics joint
  23121. */
  23122. constructor(
  23123. /**
  23124. * The type of the physics joint
  23125. */
  23126. type: number,
  23127. /**
  23128. * The data for the physics joint
  23129. */
  23130. jointData: PhysicsJointData);
  23131. /**
  23132. * Gets the physics joint
  23133. */
  23134. get physicsJoint(): any;
  23135. /**
  23136. * Sets the physics joint
  23137. */
  23138. set physicsJoint(newJoint: any);
  23139. /**
  23140. * Sets the physics plugin
  23141. */
  23142. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23143. /**
  23144. * Execute a function that is physics-plugin specific.
  23145. * @param {Function} func the function that will be executed.
  23146. * It accepts two parameters: the physics world and the physics joint
  23147. */
  23148. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23149. /**
  23150. * Distance-Joint type
  23151. */
  23152. static DistanceJoint: number;
  23153. /**
  23154. * Hinge-Joint type
  23155. */
  23156. static HingeJoint: number;
  23157. /**
  23158. * Ball-and-Socket joint type
  23159. */
  23160. static BallAndSocketJoint: number;
  23161. /**
  23162. * Wheel-Joint type
  23163. */
  23164. static WheelJoint: number;
  23165. /**
  23166. * Slider-Joint type
  23167. */
  23168. static SliderJoint: number;
  23169. /**
  23170. * Prismatic-Joint type
  23171. */
  23172. static PrismaticJoint: number;
  23173. /**
  23174. * Universal-Joint type
  23175. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23176. */
  23177. static UniversalJoint: number;
  23178. /**
  23179. * Hinge-Joint 2 type
  23180. */
  23181. static Hinge2Joint: number;
  23182. /**
  23183. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23184. */
  23185. static PointToPointJoint: number;
  23186. /**
  23187. * Spring-Joint type
  23188. */
  23189. static SpringJoint: number;
  23190. /**
  23191. * Lock-Joint type
  23192. */
  23193. static LockJoint: number;
  23194. }
  23195. /**
  23196. * A class representing a physics distance joint
  23197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23198. */
  23199. export class DistanceJoint extends PhysicsJoint {
  23200. /**
  23201. *
  23202. * @param jointData The data for the Distance-Joint
  23203. */
  23204. constructor(jointData: DistanceJointData);
  23205. /**
  23206. * Update the predefined distance.
  23207. * @param maxDistance The maximum preferred distance
  23208. * @param minDistance The minimum preferred distance
  23209. */
  23210. updateDistance(maxDistance: number, minDistance?: number): void;
  23211. }
  23212. /**
  23213. * Represents a Motor-Enabled Joint
  23214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23215. */
  23216. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23217. /**
  23218. * Initializes the Motor-Enabled Joint
  23219. * @param type The type of the joint
  23220. * @param jointData The physica joint data for the joint
  23221. */
  23222. constructor(type: number, jointData: PhysicsJointData);
  23223. /**
  23224. * Set the motor values.
  23225. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23226. * @param force the force to apply
  23227. * @param maxForce max force for this motor.
  23228. */
  23229. setMotor(force?: number, maxForce?: number): void;
  23230. /**
  23231. * Set the motor's limits.
  23232. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23233. * @param upperLimit The upper limit of the motor
  23234. * @param lowerLimit The lower limit of the motor
  23235. */
  23236. setLimit(upperLimit: number, lowerLimit?: number): void;
  23237. }
  23238. /**
  23239. * This class represents a single physics Hinge-Joint
  23240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23241. */
  23242. export class HingeJoint extends MotorEnabledJoint {
  23243. /**
  23244. * Initializes the Hinge-Joint
  23245. * @param jointData The joint data for the Hinge-Joint
  23246. */
  23247. constructor(jointData: PhysicsJointData);
  23248. /**
  23249. * Set the motor values.
  23250. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23251. * @param {number} force the force to apply
  23252. * @param {number} maxForce max force for this motor.
  23253. */
  23254. setMotor(force?: number, maxForce?: number): void;
  23255. /**
  23256. * Set the motor's limits.
  23257. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23258. * @param upperLimit The upper limit of the motor
  23259. * @param lowerLimit The lower limit of the motor
  23260. */
  23261. setLimit(upperLimit: number, lowerLimit?: number): void;
  23262. }
  23263. /**
  23264. * This class represents a dual hinge physics joint (same as wheel joint)
  23265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23266. */
  23267. export class Hinge2Joint extends MotorEnabledJoint {
  23268. /**
  23269. * Initializes the Hinge2-Joint
  23270. * @param jointData The joint data for the Hinge2-Joint
  23271. */
  23272. constructor(jointData: PhysicsJointData);
  23273. /**
  23274. * Set the motor values.
  23275. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23276. * @param {number} targetSpeed the speed the motor is to reach
  23277. * @param {number} maxForce max force for this motor.
  23278. * @param {motorIndex} the motor's index, 0 or 1.
  23279. */
  23280. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23281. /**
  23282. * Set the motor limits.
  23283. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23284. * @param {number} upperLimit the upper limit
  23285. * @param {number} lowerLimit lower limit
  23286. * @param {motorIndex} the motor's index, 0 or 1.
  23287. */
  23288. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23289. }
  23290. /**
  23291. * Interface for a motor enabled joint
  23292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23293. */
  23294. export interface IMotorEnabledJoint {
  23295. /**
  23296. * Physics joint
  23297. */
  23298. physicsJoint: any;
  23299. /**
  23300. * Sets the motor of the motor-enabled joint
  23301. * @param force The force of the motor
  23302. * @param maxForce The maximum force of the motor
  23303. * @param motorIndex The index of the motor
  23304. */
  23305. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23306. /**
  23307. * Sets the limit of the motor
  23308. * @param upperLimit The upper limit of the motor
  23309. * @param lowerLimit The lower limit of the motor
  23310. * @param motorIndex The index of the motor
  23311. */
  23312. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23313. }
  23314. /**
  23315. * Joint data for a Distance-Joint
  23316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23317. */
  23318. export interface DistanceJointData extends PhysicsJointData {
  23319. /**
  23320. * Max distance the 2 joint objects can be apart
  23321. */
  23322. maxDistance: number;
  23323. }
  23324. /**
  23325. * Joint data from a spring joint
  23326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23327. */
  23328. export interface SpringJointData extends PhysicsJointData {
  23329. /**
  23330. * Length of the spring
  23331. */
  23332. length: number;
  23333. /**
  23334. * Stiffness of the spring
  23335. */
  23336. stiffness: number;
  23337. /**
  23338. * Damping of the spring
  23339. */
  23340. damping: number;
  23341. /** this callback will be called when applying the force to the impostors. */
  23342. forceApplicationCallback: () => void;
  23343. }
  23344. }
  23345. declare module BABYLON {
  23346. /**
  23347. * Holds the data for the raycast result
  23348. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23349. */
  23350. export class PhysicsRaycastResult {
  23351. private _hasHit;
  23352. private _hitDistance;
  23353. private _hitNormalWorld;
  23354. private _hitPointWorld;
  23355. private _rayFromWorld;
  23356. private _rayToWorld;
  23357. /**
  23358. * Gets if there was a hit
  23359. */
  23360. get hasHit(): boolean;
  23361. /**
  23362. * Gets the distance from the hit
  23363. */
  23364. get hitDistance(): number;
  23365. /**
  23366. * Gets the hit normal/direction in the world
  23367. */
  23368. get hitNormalWorld(): Vector3;
  23369. /**
  23370. * Gets the hit point in the world
  23371. */
  23372. get hitPointWorld(): Vector3;
  23373. /**
  23374. * Gets the ray "start point" of the ray in the world
  23375. */
  23376. get rayFromWorld(): Vector3;
  23377. /**
  23378. * Gets the ray "end point" of the ray in the world
  23379. */
  23380. get rayToWorld(): Vector3;
  23381. /**
  23382. * Sets the hit data (normal & point in world space)
  23383. * @param hitNormalWorld defines the normal in world space
  23384. * @param hitPointWorld defines the point in world space
  23385. */
  23386. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23387. /**
  23388. * Sets the distance from the start point to the hit point
  23389. * @param distance
  23390. */
  23391. setHitDistance(distance: number): void;
  23392. /**
  23393. * Calculates the distance manually
  23394. */
  23395. calculateHitDistance(): void;
  23396. /**
  23397. * Resets all the values to default
  23398. * @param from The from point on world space
  23399. * @param to The to point on world space
  23400. */
  23401. reset(from?: Vector3, to?: Vector3): void;
  23402. }
  23403. /**
  23404. * Interface for the size containing width and height
  23405. */
  23406. interface IXYZ {
  23407. /**
  23408. * X
  23409. */
  23410. x: number;
  23411. /**
  23412. * Y
  23413. */
  23414. y: number;
  23415. /**
  23416. * Z
  23417. */
  23418. z: number;
  23419. }
  23420. }
  23421. declare module BABYLON {
  23422. /**
  23423. * Interface used to describe a physics joint
  23424. */
  23425. export interface PhysicsImpostorJoint {
  23426. /** Defines the main impostor to which the joint is linked */
  23427. mainImpostor: PhysicsImpostor;
  23428. /** Defines the impostor that is connected to the main impostor using this joint */
  23429. connectedImpostor: PhysicsImpostor;
  23430. /** Defines the joint itself */
  23431. joint: PhysicsJoint;
  23432. }
  23433. /** @hidden */
  23434. export interface IPhysicsEnginePlugin {
  23435. world: any;
  23436. name: string;
  23437. setGravity(gravity: Vector3): void;
  23438. setTimeStep(timeStep: number): void;
  23439. getTimeStep(): number;
  23440. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23441. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23442. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23443. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23444. removePhysicsBody(impostor: PhysicsImpostor): void;
  23445. generateJoint(joint: PhysicsImpostorJoint): void;
  23446. removeJoint(joint: PhysicsImpostorJoint): void;
  23447. isSupported(): boolean;
  23448. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23449. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23450. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23451. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23452. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23453. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23454. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23455. getBodyMass(impostor: PhysicsImpostor): number;
  23456. getBodyFriction(impostor: PhysicsImpostor): number;
  23457. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23458. getBodyRestitution(impostor: PhysicsImpostor): number;
  23459. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23460. getBodyPressure?(impostor: PhysicsImpostor): number;
  23461. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23462. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23463. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23464. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23465. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23466. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23467. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23468. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23469. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23470. sleepBody(impostor: PhysicsImpostor): void;
  23471. wakeUpBody(impostor: PhysicsImpostor): void;
  23472. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23473. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23474. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23475. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23476. getRadius(impostor: PhysicsImpostor): number;
  23477. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23478. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23479. dispose(): void;
  23480. }
  23481. /**
  23482. * Interface used to define a physics engine
  23483. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23484. */
  23485. export interface IPhysicsEngine {
  23486. /**
  23487. * Gets the gravity vector used by the simulation
  23488. */
  23489. gravity: Vector3;
  23490. /**
  23491. * Sets the gravity vector used by the simulation
  23492. * @param gravity defines the gravity vector to use
  23493. */
  23494. setGravity(gravity: Vector3): void;
  23495. /**
  23496. * Set the time step of the physics engine.
  23497. * Default is 1/60.
  23498. * To slow it down, enter 1/600 for example.
  23499. * To speed it up, 1/30
  23500. * @param newTimeStep the new timestep to apply to this world.
  23501. */
  23502. setTimeStep(newTimeStep: number): void;
  23503. /**
  23504. * Get the time step of the physics engine.
  23505. * @returns the current time step
  23506. */
  23507. getTimeStep(): number;
  23508. /**
  23509. * Set the sub time step of the physics engine.
  23510. * Default is 0 meaning there is no sub steps
  23511. * To increase physics resolution precision, set a small value (like 1 ms)
  23512. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23513. */
  23514. setSubTimeStep(subTimeStep: number): void;
  23515. /**
  23516. * Get the sub time step of the physics engine.
  23517. * @returns the current sub time step
  23518. */
  23519. getSubTimeStep(): number;
  23520. /**
  23521. * Release all resources
  23522. */
  23523. dispose(): void;
  23524. /**
  23525. * Gets the name of the current physics plugin
  23526. * @returns the name of the plugin
  23527. */
  23528. getPhysicsPluginName(): string;
  23529. /**
  23530. * Adding a new impostor for the impostor tracking.
  23531. * This will be done by the impostor itself.
  23532. * @param impostor the impostor to add
  23533. */
  23534. addImpostor(impostor: PhysicsImpostor): void;
  23535. /**
  23536. * Remove an impostor from the engine.
  23537. * This impostor and its mesh will not longer be updated by the physics engine.
  23538. * @param impostor the impostor to remove
  23539. */
  23540. removeImpostor(impostor: PhysicsImpostor): void;
  23541. /**
  23542. * Add a joint to the physics engine
  23543. * @param mainImpostor defines the main impostor to which the joint is added.
  23544. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23545. * @param joint defines the joint that will connect both impostors.
  23546. */
  23547. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23548. /**
  23549. * Removes a joint from the simulation
  23550. * @param mainImpostor defines the impostor used with the joint
  23551. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23552. * @param joint defines the joint to remove
  23553. */
  23554. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23555. /**
  23556. * Gets the current plugin used to run the simulation
  23557. * @returns current plugin
  23558. */
  23559. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23560. /**
  23561. * Gets the list of physic impostors
  23562. * @returns an array of PhysicsImpostor
  23563. */
  23564. getImpostors(): Array<PhysicsImpostor>;
  23565. /**
  23566. * Gets the impostor for a physics enabled object
  23567. * @param object defines the object impersonated by the impostor
  23568. * @returns the PhysicsImpostor or null if not found
  23569. */
  23570. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23571. /**
  23572. * Gets the impostor for a physics body object
  23573. * @param body defines physics body used by the impostor
  23574. * @returns the PhysicsImpostor or null if not found
  23575. */
  23576. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23577. /**
  23578. * Does a raycast in the physics world
  23579. * @param from when should the ray start?
  23580. * @param to when should the ray end?
  23581. * @returns PhysicsRaycastResult
  23582. */
  23583. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23584. /**
  23585. * Called by the scene. No need to call it.
  23586. * @param delta defines the timespam between frames
  23587. */
  23588. _step(delta: number): void;
  23589. }
  23590. }
  23591. declare module BABYLON {
  23592. /**
  23593. * The interface for the physics imposter parameters
  23594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23595. */
  23596. export interface PhysicsImpostorParameters {
  23597. /**
  23598. * The mass of the physics imposter
  23599. */
  23600. mass: number;
  23601. /**
  23602. * The friction of the physics imposter
  23603. */
  23604. friction?: number;
  23605. /**
  23606. * The coefficient of restitution of the physics imposter
  23607. */
  23608. restitution?: number;
  23609. /**
  23610. * The native options of the physics imposter
  23611. */
  23612. nativeOptions?: any;
  23613. /**
  23614. * Specifies if the parent should be ignored
  23615. */
  23616. ignoreParent?: boolean;
  23617. /**
  23618. * Specifies if bi-directional transformations should be disabled
  23619. */
  23620. disableBidirectionalTransformation?: boolean;
  23621. /**
  23622. * The pressure inside the physics imposter, soft object only
  23623. */
  23624. pressure?: number;
  23625. /**
  23626. * The stiffness the physics imposter, soft object only
  23627. */
  23628. stiffness?: number;
  23629. /**
  23630. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23631. */
  23632. velocityIterations?: number;
  23633. /**
  23634. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23635. */
  23636. positionIterations?: number;
  23637. /**
  23638. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23639. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23640. * Add to fix multiple points
  23641. */
  23642. fixedPoints?: number;
  23643. /**
  23644. * The collision margin around a soft object
  23645. */
  23646. margin?: number;
  23647. /**
  23648. * The collision margin around a soft object
  23649. */
  23650. damping?: number;
  23651. /**
  23652. * The path for a rope based on an extrusion
  23653. */
  23654. path?: any;
  23655. /**
  23656. * The shape of an extrusion used for a rope based on an extrusion
  23657. */
  23658. shape?: any;
  23659. }
  23660. /**
  23661. * Interface for a physics-enabled object
  23662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23663. */
  23664. export interface IPhysicsEnabledObject {
  23665. /**
  23666. * The position of the physics-enabled object
  23667. */
  23668. position: Vector3;
  23669. /**
  23670. * The rotation of the physics-enabled object
  23671. */
  23672. rotationQuaternion: Nullable<Quaternion>;
  23673. /**
  23674. * The scale of the physics-enabled object
  23675. */
  23676. scaling: Vector3;
  23677. /**
  23678. * The rotation of the physics-enabled object
  23679. */
  23680. rotation?: Vector3;
  23681. /**
  23682. * The parent of the physics-enabled object
  23683. */
  23684. parent?: any;
  23685. /**
  23686. * The bounding info of the physics-enabled object
  23687. * @returns The bounding info of the physics-enabled object
  23688. */
  23689. getBoundingInfo(): BoundingInfo;
  23690. /**
  23691. * Computes the world matrix
  23692. * @param force Specifies if the world matrix should be computed by force
  23693. * @returns A world matrix
  23694. */
  23695. computeWorldMatrix(force: boolean): Matrix;
  23696. /**
  23697. * Gets the world matrix
  23698. * @returns A world matrix
  23699. */
  23700. getWorldMatrix?(): Matrix;
  23701. /**
  23702. * Gets the child meshes
  23703. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23704. * @returns An array of abstract meshes
  23705. */
  23706. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23707. /**
  23708. * Gets the vertex data
  23709. * @param kind The type of vertex data
  23710. * @returns A nullable array of numbers, or a float32 array
  23711. */
  23712. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23713. /**
  23714. * Gets the indices from the mesh
  23715. * @returns A nullable array of index arrays
  23716. */
  23717. getIndices?(): Nullable<IndicesArray>;
  23718. /**
  23719. * Gets the scene from the mesh
  23720. * @returns the indices array or null
  23721. */
  23722. getScene?(): Scene;
  23723. /**
  23724. * Gets the absolute position from the mesh
  23725. * @returns the absolute position
  23726. */
  23727. getAbsolutePosition(): Vector3;
  23728. /**
  23729. * Gets the absolute pivot point from the mesh
  23730. * @returns the absolute pivot point
  23731. */
  23732. getAbsolutePivotPoint(): Vector3;
  23733. /**
  23734. * Rotates the mesh
  23735. * @param axis The axis of rotation
  23736. * @param amount The amount of rotation
  23737. * @param space The space of the rotation
  23738. * @returns The rotation transform node
  23739. */
  23740. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23741. /**
  23742. * Translates the mesh
  23743. * @param axis The axis of translation
  23744. * @param distance The distance of translation
  23745. * @param space The space of the translation
  23746. * @returns The transform node
  23747. */
  23748. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23749. /**
  23750. * Sets the absolute position of the mesh
  23751. * @param absolutePosition The absolute position of the mesh
  23752. * @returns The transform node
  23753. */
  23754. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23755. /**
  23756. * Gets the class name of the mesh
  23757. * @returns The class name
  23758. */
  23759. getClassName(): string;
  23760. }
  23761. /**
  23762. * Represents a physics imposter
  23763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23764. */
  23765. export class PhysicsImpostor {
  23766. /**
  23767. * The physics-enabled object used as the physics imposter
  23768. */
  23769. object: IPhysicsEnabledObject;
  23770. /**
  23771. * The type of the physics imposter
  23772. */
  23773. type: number;
  23774. private _options;
  23775. private _scene?;
  23776. /**
  23777. * The default object size of the imposter
  23778. */
  23779. static DEFAULT_OBJECT_SIZE: Vector3;
  23780. /**
  23781. * The identity quaternion of the imposter
  23782. */
  23783. static IDENTITY_QUATERNION: Quaternion;
  23784. /** @hidden */
  23785. _pluginData: any;
  23786. private _physicsEngine;
  23787. private _physicsBody;
  23788. private _bodyUpdateRequired;
  23789. private _onBeforePhysicsStepCallbacks;
  23790. private _onAfterPhysicsStepCallbacks;
  23791. /** @hidden */
  23792. _onPhysicsCollideCallbacks: Array<{
  23793. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23794. otherImpostors: Array<PhysicsImpostor>;
  23795. }>;
  23796. private _deltaPosition;
  23797. private _deltaRotation;
  23798. private _deltaRotationConjugated;
  23799. /** @hidden */
  23800. _isFromLine: boolean;
  23801. private _parent;
  23802. private _isDisposed;
  23803. private static _tmpVecs;
  23804. private static _tmpQuat;
  23805. /**
  23806. * Specifies if the physics imposter is disposed
  23807. */
  23808. get isDisposed(): boolean;
  23809. /**
  23810. * Gets the mass of the physics imposter
  23811. */
  23812. get mass(): number;
  23813. set mass(value: number);
  23814. /**
  23815. * Gets the coefficient of friction
  23816. */
  23817. get friction(): number;
  23818. /**
  23819. * Sets the coefficient of friction
  23820. */
  23821. set friction(value: number);
  23822. /**
  23823. * Gets the coefficient of restitution
  23824. */
  23825. get restitution(): number;
  23826. /**
  23827. * Sets the coefficient of restitution
  23828. */
  23829. set restitution(value: number);
  23830. /**
  23831. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23832. */
  23833. get pressure(): number;
  23834. /**
  23835. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23836. */
  23837. set pressure(value: number);
  23838. /**
  23839. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23840. */
  23841. get stiffness(): number;
  23842. /**
  23843. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23844. */
  23845. set stiffness(value: number);
  23846. /**
  23847. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23848. */
  23849. get velocityIterations(): number;
  23850. /**
  23851. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23852. */
  23853. set velocityIterations(value: number);
  23854. /**
  23855. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23856. */
  23857. get positionIterations(): number;
  23858. /**
  23859. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23860. */
  23861. set positionIterations(value: number);
  23862. /**
  23863. * The unique id of the physics imposter
  23864. * set by the physics engine when adding this impostor to the array
  23865. */
  23866. uniqueId: number;
  23867. /**
  23868. * @hidden
  23869. */
  23870. soft: boolean;
  23871. /**
  23872. * @hidden
  23873. */
  23874. segments: number;
  23875. private _joints;
  23876. /**
  23877. * Initializes the physics imposter
  23878. * @param object The physics-enabled object used as the physics imposter
  23879. * @param type The type of the physics imposter
  23880. * @param _options The options for the physics imposter
  23881. * @param _scene The Babylon scene
  23882. */
  23883. constructor(
  23884. /**
  23885. * The physics-enabled object used as the physics imposter
  23886. */
  23887. object: IPhysicsEnabledObject,
  23888. /**
  23889. * The type of the physics imposter
  23890. */
  23891. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23892. /**
  23893. * This function will completly initialize this impostor.
  23894. * It will create a new body - but only if this mesh has no parent.
  23895. * If it has, this impostor will not be used other than to define the impostor
  23896. * of the child mesh.
  23897. * @hidden
  23898. */
  23899. _init(): void;
  23900. private _getPhysicsParent;
  23901. /**
  23902. * Should a new body be generated.
  23903. * @returns boolean specifying if body initialization is required
  23904. */
  23905. isBodyInitRequired(): boolean;
  23906. /**
  23907. * Sets the updated scaling
  23908. * @param updated Specifies if the scaling is updated
  23909. */
  23910. setScalingUpdated(): void;
  23911. /**
  23912. * Force a regeneration of this or the parent's impostor's body.
  23913. * Use under cautious - This will remove all joints already implemented.
  23914. */
  23915. forceUpdate(): void;
  23916. /**
  23917. * Gets the body that holds this impostor. Either its own, or its parent.
  23918. */
  23919. get physicsBody(): any;
  23920. /**
  23921. * Get the parent of the physics imposter
  23922. * @returns Physics imposter or null
  23923. */
  23924. get parent(): Nullable<PhysicsImpostor>;
  23925. /**
  23926. * Sets the parent of the physics imposter
  23927. */
  23928. set parent(value: Nullable<PhysicsImpostor>);
  23929. /**
  23930. * Set the physics body. Used mainly by the physics engine/plugin
  23931. */
  23932. set physicsBody(physicsBody: any);
  23933. /**
  23934. * Resets the update flags
  23935. */
  23936. resetUpdateFlags(): void;
  23937. /**
  23938. * Gets the object extend size
  23939. * @returns the object extend size
  23940. */
  23941. getObjectExtendSize(): Vector3;
  23942. /**
  23943. * Gets the object center
  23944. * @returns The object center
  23945. */
  23946. getObjectCenter(): Vector3;
  23947. /**
  23948. * Get a specific parameter from the options parameters
  23949. * @param paramName The object parameter name
  23950. * @returns The object parameter
  23951. */
  23952. getParam(paramName: string): any;
  23953. /**
  23954. * Sets a specific parameter in the options given to the physics plugin
  23955. * @param paramName The parameter name
  23956. * @param value The value of the parameter
  23957. */
  23958. setParam(paramName: string, value: number): void;
  23959. /**
  23960. * Specifically change the body's mass option. Won't recreate the physics body object
  23961. * @param mass The mass of the physics imposter
  23962. */
  23963. setMass(mass: number): void;
  23964. /**
  23965. * Gets the linear velocity
  23966. * @returns linear velocity or null
  23967. */
  23968. getLinearVelocity(): Nullable<Vector3>;
  23969. /**
  23970. * Sets the linear velocity
  23971. * @param velocity linear velocity or null
  23972. */
  23973. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23974. /**
  23975. * Gets the angular velocity
  23976. * @returns angular velocity or null
  23977. */
  23978. getAngularVelocity(): Nullable<Vector3>;
  23979. /**
  23980. * Sets the angular velocity
  23981. * @param velocity The velocity or null
  23982. */
  23983. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23984. /**
  23985. * Execute a function with the physics plugin native code
  23986. * Provide a function the will have two variables - the world object and the physics body object
  23987. * @param func The function to execute with the physics plugin native code
  23988. */
  23989. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23990. /**
  23991. * Register a function that will be executed before the physics world is stepping forward
  23992. * @param func The function to execute before the physics world is stepped forward
  23993. */
  23994. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23995. /**
  23996. * Unregister a function that will be executed before the physics world is stepping forward
  23997. * @param func The function to execute before the physics world is stepped forward
  23998. */
  23999. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24000. /**
  24001. * Register a function that will be executed after the physics step
  24002. * @param func The function to execute after physics step
  24003. */
  24004. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24005. /**
  24006. * Unregisters a function that will be executed after the physics step
  24007. * @param func The function to execute after physics step
  24008. */
  24009. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24010. /**
  24011. * register a function that will be executed when this impostor collides against a different body
  24012. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24013. * @param func Callback that is executed on collision
  24014. */
  24015. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24016. /**
  24017. * Unregisters the physics imposter on contact
  24018. * @param collideAgainst The physics object to collide against
  24019. * @param func Callback to execute on collision
  24020. */
  24021. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24022. private _tmpQuat;
  24023. private _tmpQuat2;
  24024. /**
  24025. * Get the parent rotation
  24026. * @returns The parent rotation
  24027. */
  24028. getParentsRotation(): Quaternion;
  24029. /**
  24030. * this function is executed by the physics engine.
  24031. */
  24032. beforeStep: () => void;
  24033. /**
  24034. * this function is executed by the physics engine
  24035. */
  24036. afterStep: () => void;
  24037. /**
  24038. * Legacy collision detection event support
  24039. */
  24040. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24041. /**
  24042. * event and body object due to cannon's event-based architecture.
  24043. */
  24044. onCollide: (e: {
  24045. body: any;
  24046. }) => void;
  24047. /**
  24048. * Apply a force
  24049. * @param force The force to apply
  24050. * @param contactPoint The contact point for the force
  24051. * @returns The physics imposter
  24052. */
  24053. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24054. /**
  24055. * Apply an impulse
  24056. * @param force The impulse force
  24057. * @param contactPoint The contact point for the impulse force
  24058. * @returns The physics imposter
  24059. */
  24060. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24061. /**
  24062. * A help function to create a joint
  24063. * @param otherImpostor A physics imposter used to create a joint
  24064. * @param jointType The type of joint
  24065. * @param jointData The data for the joint
  24066. * @returns The physics imposter
  24067. */
  24068. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24069. /**
  24070. * Add a joint to this impostor with a different impostor
  24071. * @param otherImpostor A physics imposter used to add a joint
  24072. * @param joint The joint to add
  24073. * @returns The physics imposter
  24074. */
  24075. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24076. /**
  24077. * Add an anchor to a cloth impostor
  24078. * @param otherImpostor rigid impostor to anchor to
  24079. * @param width ratio across width from 0 to 1
  24080. * @param height ratio up height from 0 to 1
  24081. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24082. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24083. * @returns impostor the soft imposter
  24084. */
  24085. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24086. /**
  24087. * Add a hook to a rope impostor
  24088. * @param otherImpostor rigid impostor to anchor to
  24089. * @param length ratio across rope from 0 to 1
  24090. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24091. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24092. * @returns impostor the rope imposter
  24093. */
  24094. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24095. /**
  24096. * Will keep this body still, in a sleep mode.
  24097. * @returns the physics imposter
  24098. */
  24099. sleep(): PhysicsImpostor;
  24100. /**
  24101. * Wake the body up.
  24102. * @returns The physics imposter
  24103. */
  24104. wakeUp(): PhysicsImpostor;
  24105. /**
  24106. * Clones the physics imposter
  24107. * @param newObject The physics imposter clones to this physics-enabled object
  24108. * @returns A nullable physics imposter
  24109. */
  24110. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24111. /**
  24112. * Disposes the physics imposter
  24113. */
  24114. dispose(): void;
  24115. /**
  24116. * Sets the delta position
  24117. * @param position The delta position amount
  24118. */
  24119. setDeltaPosition(position: Vector3): void;
  24120. /**
  24121. * Sets the delta rotation
  24122. * @param rotation The delta rotation amount
  24123. */
  24124. setDeltaRotation(rotation: Quaternion): void;
  24125. /**
  24126. * Gets the box size of the physics imposter and stores the result in the input parameter
  24127. * @param result Stores the box size
  24128. * @returns The physics imposter
  24129. */
  24130. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24131. /**
  24132. * Gets the radius of the physics imposter
  24133. * @returns Radius of the physics imposter
  24134. */
  24135. getRadius(): number;
  24136. /**
  24137. * Sync a bone with this impostor
  24138. * @param bone The bone to sync to the impostor.
  24139. * @param boneMesh The mesh that the bone is influencing.
  24140. * @param jointPivot The pivot of the joint / bone in local space.
  24141. * @param distToJoint Optional distance from the impostor to the joint.
  24142. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24143. */
  24144. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24145. /**
  24146. * Sync impostor to a bone
  24147. * @param bone The bone that the impostor will be synced to.
  24148. * @param boneMesh The mesh that the bone is influencing.
  24149. * @param jointPivot The pivot of the joint / bone in local space.
  24150. * @param distToJoint Optional distance from the impostor to the joint.
  24151. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24152. * @param boneAxis Optional vector3 axis the bone is aligned with
  24153. */
  24154. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24155. /**
  24156. * No-Imposter type
  24157. */
  24158. static NoImpostor: number;
  24159. /**
  24160. * Sphere-Imposter type
  24161. */
  24162. static SphereImpostor: number;
  24163. /**
  24164. * Box-Imposter type
  24165. */
  24166. static BoxImpostor: number;
  24167. /**
  24168. * Plane-Imposter type
  24169. */
  24170. static PlaneImpostor: number;
  24171. /**
  24172. * Mesh-imposter type
  24173. */
  24174. static MeshImpostor: number;
  24175. /**
  24176. * Capsule-Impostor type (Ammo.js plugin only)
  24177. */
  24178. static CapsuleImpostor: number;
  24179. /**
  24180. * Cylinder-Imposter type
  24181. */
  24182. static CylinderImpostor: number;
  24183. /**
  24184. * Particle-Imposter type
  24185. */
  24186. static ParticleImpostor: number;
  24187. /**
  24188. * Heightmap-Imposter type
  24189. */
  24190. static HeightmapImpostor: number;
  24191. /**
  24192. * ConvexHull-Impostor type (Ammo.js plugin only)
  24193. */
  24194. static ConvexHullImpostor: number;
  24195. /**
  24196. * Custom-Imposter type (Ammo.js plugin only)
  24197. */
  24198. static CustomImpostor: number;
  24199. /**
  24200. * Rope-Imposter type
  24201. */
  24202. static RopeImpostor: number;
  24203. /**
  24204. * Cloth-Imposter type
  24205. */
  24206. static ClothImpostor: number;
  24207. /**
  24208. * Softbody-Imposter type
  24209. */
  24210. static SoftbodyImpostor: number;
  24211. }
  24212. }
  24213. declare module BABYLON {
  24214. /**
  24215. * @hidden
  24216. **/
  24217. export class _CreationDataStorage {
  24218. closePath?: boolean;
  24219. closeArray?: boolean;
  24220. idx: number[];
  24221. dashSize: number;
  24222. gapSize: number;
  24223. path3D: Path3D;
  24224. pathArray: Vector3[][];
  24225. arc: number;
  24226. radius: number;
  24227. cap: number;
  24228. tessellation: number;
  24229. }
  24230. /**
  24231. * @hidden
  24232. **/
  24233. class _InstanceDataStorage {
  24234. visibleInstances: any;
  24235. batchCache: _InstancesBatch;
  24236. instancesBufferSize: number;
  24237. instancesBuffer: Nullable<Buffer>;
  24238. instancesData: Float32Array;
  24239. overridenInstanceCount: number;
  24240. isFrozen: boolean;
  24241. previousBatch: Nullable<_InstancesBatch>;
  24242. hardwareInstancedRendering: boolean;
  24243. sideOrientation: number;
  24244. manualUpdate: boolean;
  24245. }
  24246. /**
  24247. * @hidden
  24248. **/
  24249. export class _InstancesBatch {
  24250. mustReturn: boolean;
  24251. visibleInstances: Nullable<InstancedMesh[]>[];
  24252. renderSelf: boolean[];
  24253. hardwareInstancedRendering: boolean[];
  24254. }
  24255. /**
  24256. * Class used to represent renderable models
  24257. */
  24258. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24259. /**
  24260. * Mesh side orientation : usually the external or front surface
  24261. */
  24262. static readonly FRONTSIDE: number;
  24263. /**
  24264. * Mesh side orientation : usually the internal or back surface
  24265. */
  24266. static readonly BACKSIDE: number;
  24267. /**
  24268. * Mesh side orientation : both internal and external or front and back surfaces
  24269. */
  24270. static readonly DOUBLESIDE: number;
  24271. /**
  24272. * Mesh side orientation : by default, `FRONTSIDE`
  24273. */
  24274. static readonly DEFAULTSIDE: number;
  24275. /**
  24276. * Mesh cap setting : no cap
  24277. */
  24278. static readonly NO_CAP: number;
  24279. /**
  24280. * Mesh cap setting : one cap at the beginning of the mesh
  24281. */
  24282. static readonly CAP_START: number;
  24283. /**
  24284. * Mesh cap setting : one cap at the end of the mesh
  24285. */
  24286. static readonly CAP_END: number;
  24287. /**
  24288. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24289. */
  24290. static readonly CAP_ALL: number;
  24291. /**
  24292. * Mesh pattern setting : no flip or rotate
  24293. */
  24294. static readonly NO_FLIP: number;
  24295. /**
  24296. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24297. */
  24298. static readonly FLIP_TILE: number;
  24299. /**
  24300. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24301. */
  24302. static readonly ROTATE_TILE: number;
  24303. /**
  24304. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24305. */
  24306. static readonly FLIP_ROW: number;
  24307. /**
  24308. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24309. */
  24310. static readonly ROTATE_ROW: number;
  24311. /**
  24312. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24313. */
  24314. static readonly FLIP_N_ROTATE_TILE: number;
  24315. /**
  24316. * Mesh pattern setting : rotate pattern and rotate
  24317. */
  24318. static readonly FLIP_N_ROTATE_ROW: number;
  24319. /**
  24320. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24321. */
  24322. static readonly CENTER: number;
  24323. /**
  24324. * Mesh tile positioning : part tiles on left
  24325. */
  24326. static readonly LEFT: number;
  24327. /**
  24328. * Mesh tile positioning : part tiles on right
  24329. */
  24330. static readonly RIGHT: number;
  24331. /**
  24332. * Mesh tile positioning : part tiles on top
  24333. */
  24334. static readonly TOP: number;
  24335. /**
  24336. * Mesh tile positioning : part tiles on bottom
  24337. */
  24338. static readonly BOTTOM: number;
  24339. /**
  24340. * Gets the default side orientation.
  24341. * @param orientation the orientation to value to attempt to get
  24342. * @returns the default orientation
  24343. * @hidden
  24344. */
  24345. static _GetDefaultSideOrientation(orientation?: number): number;
  24346. private _internalMeshDataInfo;
  24347. /**
  24348. * An event triggered before rendering the mesh
  24349. */
  24350. get onBeforeRenderObservable(): Observable<Mesh>;
  24351. /**
  24352. * An event triggered before binding the mesh
  24353. */
  24354. get onBeforeBindObservable(): Observable<Mesh>;
  24355. /**
  24356. * An event triggered after rendering the mesh
  24357. */
  24358. get onAfterRenderObservable(): Observable<Mesh>;
  24359. /**
  24360. * An event triggered before drawing the mesh
  24361. */
  24362. get onBeforeDrawObservable(): Observable<Mesh>;
  24363. private _onBeforeDrawObserver;
  24364. /**
  24365. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24366. */
  24367. set onBeforeDraw(callback: () => void);
  24368. get hasInstances(): boolean;
  24369. /**
  24370. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24371. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24372. */
  24373. delayLoadState: number;
  24374. /**
  24375. * Gets the list of instances created from this mesh
  24376. * it is not supposed to be modified manually.
  24377. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24378. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24379. */
  24380. instances: InstancedMesh[];
  24381. /**
  24382. * Gets the file containing delay loading data for this mesh
  24383. */
  24384. delayLoadingFile: string;
  24385. /** @hidden */
  24386. _binaryInfo: any;
  24387. /**
  24388. * User defined function used to change how LOD level selection is done
  24389. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24390. */
  24391. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24392. /**
  24393. * Gets or sets the morph target manager
  24394. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24395. */
  24396. get morphTargetManager(): Nullable<MorphTargetManager>;
  24397. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24398. /** @hidden */
  24399. _creationDataStorage: Nullable<_CreationDataStorage>;
  24400. /** @hidden */
  24401. _geometry: Nullable<Geometry>;
  24402. /** @hidden */
  24403. _delayInfo: Array<string>;
  24404. /** @hidden */
  24405. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24406. /** @hidden */
  24407. _instanceDataStorage: _InstanceDataStorage;
  24408. private _effectiveMaterial;
  24409. /** @hidden */
  24410. _shouldGenerateFlatShading: boolean;
  24411. /** @hidden */
  24412. _originalBuilderSideOrientation: number;
  24413. /**
  24414. * Use this property to change the original side orientation defined at construction time
  24415. */
  24416. overrideMaterialSideOrientation: Nullable<number>;
  24417. /**
  24418. * Gets the source mesh (the one used to clone this one from)
  24419. */
  24420. get source(): Nullable<Mesh>;
  24421. /**
  24422. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24423. */
  24424. get isUnIndexed(): boolean;
  24425. set isUnIndexed(value: boolean);
  24426. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24427. get worldMatrixInstancedBuffer(): Float32Array;
  24428. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24429. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24430. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24431. /**
  24432. * @constructor
  24433. * @param name The value used by scene.getMeshByName() to do a lookup.
  24434. * @param scene The scene to add this mesh to.
  24435. * @param parent The parent of this mesh, if it has one
  24436. * @param source An optional Mesh from which geometry is shared, cloned.
  24437. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24438. * When false, achieved by calling a clone(), also passing False.
  24439. * This will make creation of children, recursive.
  24440. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24441. */
  24442. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24443. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24444. doNotInstantiate: boolean;
  24445. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24446. /**
  24447. * Gets the class name
  24448. * @returns the string "Mesh".
  24449. */
  24450. getClassName(): string;
  24451. /** @hidden */
  24452. get _isMesh(): boolean;
  24453. /**
  24454. * Returns a description of this mesh
  24455. * @param fullDetails define if full details about this mesh must be used
  24456. * @returns a descriptive string representing this mesh
  24457. */
  24458. toString(fullDetails?: boolean): string;
  24459. /** @hidden */
  24460. _unBindEffect(): void;
  24461. /**
  24462. * Gets a boolean indicating if this mesh has LOD
  24463. */
  24464. get hasLODLevels(): boolean;
  24465. /**
  24466. * Gets the list of MeshLODLevel associated with the current mesh
  24467. * @returns an array of MeshLODLevel
  24468. */
  24469. getLODLevels(): MeshLODLevel[];
  24470. private _sortLODLevels;
  24471. /**
  24472. * Add a mesh as LOD level triggered at the given distance.
  24473. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24474. * @param distance The distance from the center of the object to show this level
  24475. * @param mesh The mesh to be added as LOD level (can be null)
  24476. * @return This mesh (for chaining)
  24477. */
  24478. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24479. /**
  24480. * Returns the LOD level mesh at the passed distance or null if not found.
  24481. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24482. * @param distance The distance from the center of the object to show this level
  24483. * @returns a Mesh or `null`
  24484. */
  24485. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24486. /**
  24487. * Remove a mesh from the LOD array
  24488. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24489. * @param mesh defines the mesh to be removed
  24490. * @return This mesh (for chaining)
  24491. */
  24492. removeLODLevel(mesh: Mesh): Mesh;
  24493. /**
  24494. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24495. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24496. * @param camera defines the camera to use to compute distance
  24497. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24498. * @return This mesh (for chaining)
  24499. */
  24500. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24501. /**
  24502. * Gets the mesh internal Geometry object
  24503. */
  24504. get geometry(): Nullable<Geometry>;
  24505. /**
  24506. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24507. * @returns the total number of vertices
  24508. */
  24509. getTotalVertices(): number;
  24510. /**
  24511. * Returns the content of an associated vertex buffer
  24512. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24513. * - VertexBuffer.PositionKind
  24514. * - VertexBuffer.UVKind
  24515. * - VertexBuffer.UV2Kind
  24516. * - VertexBuffer.UV3Kind
  24517. * - VertexBuffer.UV4Kind
  24518. * - VertexBuffer.UV5Kind
  24519. * - VertexBuffer.UV6Kind
  24520. * - VertexBuffer.ColorKind
  24521. * - VertexBuffer.MatricesIndicesKind
  24522. * - VertexBuffer.MatricesIndicesExtraKind
  24523. * - VertexBuffer.MatricesWeightsKind
  24524. * - VertexBuffer.MatricesWeightsExtraKind
  24525. * @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
  24526. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24527. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24528. */
  24529. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24530. /**
  24531. * Returns the mesh VertexBuffer object from the requested `kind`
  24532. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24533. * - VertexBuffer.PositionKind
  24534. * - VertexBuffer.NormalKind
  24535. * - VertexBuffer.UVKind
  24536. * - VertexBuffer.UV2Kind
  24537. * - VertexBuffer.UV3Kind
  24538. * - VertexBuffer.UV4Kind
  24539. * - VertexBuffer.UV5Kind
  24540. * - VertexBuffer.UV6Kind
  24541. * - VertexBuffer.ColorKind
  24542. * - VertexBuffer.MatricesIndicesKind
  24543. * - VertexBuffer.MatricesIndicesExtraKind
  24544. * - VertexBuffer.MatricesWeightsKind
  24545. * - VertexBuffer.MatricesWeightsExtraKind
  24546. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24547. */
  24548. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24549. /**
  24550. * Tests if a specific vertex buffer is associated with this mesh
  24551. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24552. * - VertexBuffer.PositionKind
  24553. * - VertexBuffer.NormalKind
  24554. * - VertexBuffer.UVKind
  24555. * - VertexBuffer.UV2Kind
  24556. * - VertexBuffer.UV3Kind
  24557. * - VertexBuffer.UV4Kind
  24558. * - VertexBuffer.UV5Kind
  24559. * - VertexBuffer.UV6Kind
  24560. * - VertexBuffer.ColorKind
  24561. * - VertexBuffer.MatricesIndicesKind
  24562. * - VertexBuffer.MatricesIndicesExtraKind
  24563. * - VertexBuffer.MatricesWeightsKind
  24564. * - VertexBuffer.MatricesWeightsExtraKind
  24565. * @returns a boolean
  24566. */
  24567. isVerticesDataPresent(kind: string): boolean;
  24568. /**
  24569. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24570. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24571. * - VertexBuffer.PositionKind
  24572. * - VertexBuffer.UVKind
  24573. * - VertexBuffer.UV2Kind
  24574. * - VertexBuffer.UV3Kind
  24575. * - VertexBuffer.UV4Kind
  24576. * - VertexBuffer.UV5Kind
  24577. * - VertexBuffer.UV6Kind
  24578. * - VertexBuffer.ColorKind
  24579. * - VertexBuffer.MatricesIndicesKind
  24580. * - VertexBuffer.MatricesIndicesExtraKind
  24581. * - VertexBuffer.MatricesWeightsKind
  24582. * - VertexBuffer.MatricesWeightsExtraKind
  24583. * @returns a boolean
  24584. */
  24585. isVertexBufferUpdatable(kind: string): boolean;
  24586. /**
  24587. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24588. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24589. * - VertexBuffer.PositionKind
  24590. * - VertexBuffer.NormalKind
  24591. * - VertexBuffer.UVKind
  24592. * - VertexBuffer.UV2Kind
  24593. * - VertexBuffer.UV3Kind
  24594. * - VertexBuffer.UV4Kind
  24595. * - VertexBuffer.UV5Kind
  24596. * - VertexBuffer.UV6Kind
  24597. * - VertexBuffer.ColorKind
  24598. * - VertexBuffer.MatricesIndicesKind
  24599. * - VertexBuffer.MatricesIndicesExtraKind
  24600. * - VertexBuffer.MatricesWeightsKind
  24601. * - VertexBuffer.MatricesWeightsExtraKind
  24602. * @returns an array of strings
  24603. */
  24604. getVerticesDataKinds(): string[];
  24605. /**
  24606. * Returns a positive integer : the total number of indices in this mesh geometry.
  24607. * @returns the numner of indices or zero if the mesh has no geometry.
  24608. */
  24609. getTotalIndices(): number;
  24610. /**
  24611. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24612. * @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.
  24613. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24614. * @returns the indices array or an empty array if the mesh has no geometry
  24615. */
  24616. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24617. get isBlocked(): boolean;
  24618. /**
  24619. * Determine if the current mesh is ready to be rendered
  24620. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24621. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24622. * @returns true if all associated assets are ready (material, textures, shaders)
  24623. */
  24624. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24625. /**
  24626. * 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.
  24627. */
  24628. get areNormalsFrozen(): boolean;
  24629. /**
  24630. * 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.
  24631. * @returns the current mesh
  24632. */
  24633. freezeNormals(): Mesh;
  24634. /**
  24635. * 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
  24636. * @returns the current mesh
  24637. */
  24638. unfreezeNormals(): Mesh;
  24639. /**
  24640. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24641. */
  24642. set overridenInstanceCount(count: number);
  24643. /** @hidden */
  24644. _preActivate(): Mesh;
  24645. /** @hidden */
  24646. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24647. /** @hidden */
  24648. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24649. /**
  24650. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24651. * This means the mesh underlying bounding box and sphere are recomputed.
  24652. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24653. * @returns the current mesh
  24654. */
  24655. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24656. /** @hidden */
  24657. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24658. /**
  24659. * This function will subdivide the mesh into multiple submeshes
  24660. * @param count defines the expected number of submeshes
  24661. */
  24662. subdivide(count: number): void;
  24663. /**
  24664. * Copy a FloatArray into a specific associated vertex buffer
  24665. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24666. * - VertexBuffer.PositionKind
  24667. * - VertexBuffer.UVKind
  24668. * - VertexBuffer.UV2Kind
  24669. * - VertexBuffer.UV3Kind
  24670. * - VertexBuffer.UV4Kind
  24671. * - VertexBuffer.UV5Kind
  24672. * - VertexBuffer.UV6Kind
  24673. * - VertexBuffer.ColorKind
  24674. * - VertexBuffer.MatricesIndicesKind
  24675. * - VertexBuffer.MatricesIndicesExtraKind
  24676. * - VertexBuffer.MatricesWeightsKind
  24677. * - VertexBuffer.MatricesWeightsExtraKind
  24678. * @param data defines the data source
  24679. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24680. * @param stride defines the data stride size (can be null)
  24681. * @returns the current mesh
  24682. */
  24683. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24684. /**
  24685. * Delete a vertex buffer associated with this mesh
  24686. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24687. * - VertexBuffer.PositionKind
  24688. * - VertexBuffer.UVKind
  24689. * - VertexBuffer.UV2Kind
  24690. * - VertexBuffer.UV3Kind
  24691. * - VertexBuffer.UV4Kind
  24692. * - VertexBuffer.UV5Kind
  24693. * - VertexBuffer.UV6Kind
  24694. * - VertexBuffer.ColorKind
  24695. * - VertexBuffer.MatricesIndicesKind
  24696. * - VertexBuffer.MatricesIndicesExtraKind
  24697. * - VertexBuffer.MatricesWeightsKind
  24698. * - VertexBuffer.MatricesWeightsExtraKind
  24699. */
  24700. removeVerticesData(kind: string): void;
  24701. /**
  24702. * Flags an associated vertex buffer as updatable
  24703. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24704. * - VertexBuffer.PositionKind
  24705. * - VertexBuffer.UVKind
  24706. * - VertexBuffer.UV2Kind
  24707. * - VertexBuffer.UV3Kind
  24708. * - VertexBuffer.UV4Kind
  24709. * - VertexBuffer.UV5Kind
  24710. * - VertexBuffer.UV6Kind
  24711. * - VertexBuffer.ColorKind
  24712. * - VertexBuffer.MatricesIndicesKind
  24713. * - VertexBuffer.MatricesIndicesExtraKind
  24714. * - VertexBuffer.MatricesWeightsKind
  24715. * - VertexBuffer.MatricesWeightsExtraKind
  24716. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24717. */
  24718. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24719. /**
  24720. * Sets the mesh global Vertex Buffer
  24721. * @param buffer defines the buffer to use
  24722. * @returns the current mesh
  24723. */
  24724. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24725. /**
  24726. * Update a specific associated vertex buffer
  24727. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24728. * - VertexBuffer.PositionKind
  24729. * - VertexBuffer.UVKind
  24730. * - VertexBuffer.UV2Kind
  24731. * - VertexBuffer.UV3Kind
  24732. * - VertexBuffer.UV4Kind
  24733. * - VertexBuffer.UV5Kind
  24734. * - VertexBuffer.UV6Kind
  24735. * - VertexBuffer.ColorKind
  24736. * - VertexBuffer.MatricesIndicesKind
  24737. * - VertexBuffer.MatricesIndicesExtraKind
  24738. * - VertexBuffer.MatricesWeightsKind
  24739. * - VertexBuffer.MatricesWeightsExtraKind
  24740. * @param data defines the data source
  24741. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24742. * @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)
  24743. * @returns the current mesh
  24744. */
  24745. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24746. /**
  24747. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24748. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24749. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24750. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24751. * @returns the current mesh
  24752. */
  24753. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24754. /**
  24755. * Creates a un-shared specific occurence of the geometry for the mesh.
  24756. * @returns the current mesh
  24757. */
  24758. makeGeometryUnique(): Mesh;
  24759. /**
  24760. * Set the index buffer of this mesh
  24761. * @param indices defines the source data
  24762. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24763. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24764. * @returns the current mesh
  24765. */
  24766. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24767. /**
  24768. * Update the current index buffer
  24769. * @param indices defines the source data
  24770. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24771. * @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)
  24772. * @returns the current mesh
  24773. */
  24774. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24775. /**
  24776. * Invert the geometry to move from a right handed system to a left handed one.
  24777. * @returns the current mesh
  24778. */
  24779. toLeftHanded(): Mesh;
  24780. /** @hidden */
  24781. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24782. /** @hidden */
  24783. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24784. /**
  24785. * Registers for this mesh a javascript function called just before the rendering process
  24786. * @param func defines the function to call before rendering this mesh
  24787. * @returns the current mesh
  24788. */
  24789. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24790. /**
  24791. * Disposes a previously registered javascript function called before the rendering
  24792. * @param func defines the function to remove
  24793. * @returns the current mesh
  24794. */
  24795. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24796. /**
  24797. * Registers for this mesh a javascript function called just after the rendering is complete
  24798. * @param func defines the function to call after rendering this mesh
  24799. * @returns the current mesh
  24800. */
  24801. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24802. /**
  24803. * Disposes a previously registered javascript function called after the rendering.
  24804. * @param func defines the function to remove
  24805. * @returns the current mesh
  24806. */
  24807. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24808. /** @hidden */
  24809. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24810. /** @hidden */
  24811. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24812. /** @hidden */
  24813. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24814. /** @hidden */
  24815. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24816. /** @hidden */
  24817. _rebuild(): void;
  24818. /** @hidden */
  24819. _freeze(): void;
  24820. /** @hidden */
  24821. _unFreeze(): void;
  24822. /**
  24823. * 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
  24824. * @param subMesh defines the subMesh to render
  24825. * @param enableAlphaMode defines if alpha mode can be changed
  24826. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24827. * @returns the current mesh
  24828. */
  24829. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24830. private _onBeforeDraw;
  24831. /**
  24832. * Renormalize the mesh and patch it up if there are no weights
  24833. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24834. * However in the case of zero weights then we set just a single influence to 1.
  24835. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24836. */
  24837. cleanMatrixWeights(): void;
  24838. private normalizeSkinFourWeights;
  24839. private normalizeSkinWeightsAndExtra;
  24840. /**
  24841. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24842. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24843. * the user know there was an issue with importing the mesh
  24844. * @returns a validation object with skinned, valid and report string
  24845. */
  24846. validateSkinning(): {
  24847. skinned: boolean;
  24848. valid: boolean;
  24849. report: string;
  24850. };
  24851. /** @hidden */
  24852. _checkDelayState(): Mesh;
  24853. private _queueLoad;
  24854. /**
  24855. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24856. * A mesh is in the frustum if its bounding box intersects the frustum
  24857. * @param frustumPlanes defines the frustum to test
  24858. * @returns true if the mesh is in the frustum planes
  24859. */
  24860. isInFrustum(frustumPlanes: Plane[]): boolean;
  24861. /**
  24862. * Sets the mesh material by the material or multiMaterial `id` property
  24863. * @param id is a string identifying the material or the multiMaterial
  24864. * @returns the current mesh
  24865. */
  24866. setMaterialByID(id: string): Mesh;
  24867. /**
  24868. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24869. * @returns an array of IAnimatable
  24870. */
  24871. getAnimatables(): IAnimatable[];
  24872. /**
  24873. * Modifies the mesh geometry according to the passed transformation matrix.
  24874. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24875. * The mesh normals are modified using the same transformation.
  24876. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24877. * @param transform defines the transform matrix to use
  24878. * @see http://doc.babylonjs.com/resources/baking_transformations
  24879. * @returns the current mesh
  24880. */
  24881. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24882. /**
  24883. * Modifies the mesh geometry according to its own current World Matrix.
  24884. * The mesh World Matrix is then reset.
  24885. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24886. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24887. * @see http://doc.babylonjs.com/resources/baking_transformations
  24888. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24889. * @returns the current mesh
  24890. */
  24891. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24892. /** @hidden */
  24893. get _positions(): Nullable<Vector3[]>;
  24894. /** @hidden */
  24895. _resetPointsArrayCache(): Mesh;
  24896. /** @hidden */
  24897. _generatePointsArray(): boolean;
  24898. /**
  24899. * Returns a new Mesh object generated from the current mesh properties.
  24900. * This method must not get confused with createInstance()
  24901. * @param name is a string, the name given to the new mesh
  24902. * @param newParent can be any Node object (default `null`)
  24903. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24904. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24905. * @returns a new mesh
  24906. */
  24907. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24908. /**
  24909. * Releases resources associated with this mesh.
  24910. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24911. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24912. */
  24913. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24914. /** @hidden */
  24915. _disposeInstanceSpecificData(): void;
  24916. /**
  24917. * Modifies the mesh geometry according to a displacement map.
  24918. * 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.
  24919. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24920. * @param url is a string, the URL from the image file is to be downloaded.
  24921. * @param minHeight is the lower limit of the displacement.
  24922. * @param maxHeight is the upper limit of the displacement.
  24923. * @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.
  24924. * @param uvOffset is an optional vector2 used to offset UV.
  24925. * @param uvScale is an optional vector2 used to scale UV.
  24926. * @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.
  24927. * @returns the Mesh.
  24928. */
  24929. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24930. /**
  24931. * Modifies the mesh geometry according to a displacementMap buffer.
  24932. * 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.
  24933. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24934. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24935. * @param heightMapWidth is the width of the buffer image.
  24936. * @param heightMapHeight is the height of the buffer image.
  24937. * @param minHeight is the lower limit of the displacement.
  24938. * @param maxHeight is the upper limit of the displacement.
  24939. * @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.
  24940. * @param uvOffset is an optional vector2 used to offset UV.
  24941. * @param uvScale is an optional vector2 used to scale UV.
  24942. * @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.
  24943. * @returns the Mesh.
  24944. */
  24945. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24946. /**
  24947. * Modify the mesh to get a flat shading rendering.
  24948. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24949. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24950. * @returns current mesh
  24951. */
  24952. convertToFlatShadedMesh(): Mesh;
  24953. /**
  24954. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24955. * In other words, more vertices, no more indices and a single bigger VBO.
  24956. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24957. * @returns current mesh
  24958. */
  24959. convertToUnIndexedMesh(): Mesh;
  24960. /**
  24961. * Inverses facet orientations.
  24962. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24963. * @param flipNormals will also inverts the normals
  24964. * @returns current mesh
  24965. */
  24966. flipFaces(flipNormals?: boolean): Mesh;
  24967. /**
  24968. * Increase the number of facets and hence vertices in a mesh
  24969. * Vertex normals are interpolated from existing vertex normals
  24970. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24971. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24972. */
  24973. increaseVertices(numberPerEdge: number): void;
  24974. /**
  24975. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24976. * This will undo any application of covertToFlatShadedMesh
  24977. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24978. */
  24979. forceSharedVertices(): void;
  24980. /** @hidden */
  24981. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24982. /** @hidden */
  24983. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24984. /**
  24985. * Creates a new InstancedMesh object from the mesh model.
  24986. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24987. * @param name defines the name of the new instance
  24988. * @returns a new InstancedMesh
  24989. */
  24990. createInstance(name: string): InstancedMesh;
  24991. /**
  24992. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24993. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24994. * @returns the current mesh
  24995. */
  24996. synchronizeInstances(): Mesh;
  24997. /**
  24998. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24999. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25000. * This should be used together with the simplification to avoid disappearing triangles.
  25001. * @param successCallback an optional success callback to be called after the optimization finished.
  25002. * @returns the current mesh
  25003. */
  25004. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25005. /**
  25006. * Serialize current mesh
  25007. * @param serializationObject defines the object which will receive the serialization data
  25008. */
  25009. serialize(serializationObject: any): void;
  25010. /** @hidden */
  25011. _syncGeometryWithMorphTargetManager(): void;
  25012. /** @hidden */
  25013. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25014. /**
  25015. * Returns a new Mesh object parsed from the source provided.
  25016. * @param parsedMesh is the source
  25017. * @param scene defines the hosting scene
  25018. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25019. * @returns a new Mesh
  25020. */
  25021. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25022. /**
  25023. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25024. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25025. * @param name defines the name of the mesh to create
  25026. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25027. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25028. * @param closePath creates a seam between the first and the last points of each path of the path array
  25029. * @param offset is taken in account only if the `pathArray` is containing a single path
  25030. * @param scene defines the hosting scene
  25031. * @param updatable defines if the mesh must be flagged as updatable
  25032. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25033. * @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)
  25034. * @returns a new Mesh
  25035. */
  25036. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25037. /**
  25038. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25039. * @param name defines the name of the mesh to create
  25040. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25041. * @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
  25042. * @param scene defines the hosting scene
  25043. * @param updatable defines if the mesh must be flagged as updatable
  25044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25045. * @returns a new Mesh
  25046. */
  25047. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25048. /**
  25049. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25050. * @param name defines the name of the mesh to create
  25051. * @param size sets the size (float) of each box side (default 1)
  25052. * @param scene defines the hosting scene
  25053. * @param updatable defines if the mesh must be flagged as updatable
  25054. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25055. * @returns a new Mesh
  25056. */
  25057. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25058. /**
  25059. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25060. * @param name defines the name of the mesh to create
  25061. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25062. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25063. * @param scene defines the hosting scene
  25064. * @param updatable defines if the mesh must be flagged as updatable
  25065. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25066. * @returns a new Mesh
  25067. */
  25068. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25069. /**
  25070. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25071. * @param name defines the name of the mesh to create
  25072. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25073. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25074. * @param scene defines the hosting scene
  25075. * @returns a new Mesh
  25076. */
  25077. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25078. /**
  25079. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25080. * @param name defines the name of the mesh to create
  25081. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25082. * @param diameterTop set the top cap diameter (floats, default 1)
  25083. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25084. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25085. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25086. * @param scene defines the hosting scene
  25087. * @param updatable defines if the mesh must be flagged as updatable
  25088. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25089. * @returns a new Mesh
  25090. */
  25091. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25092. /**
  25093. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25094. * @param name defines the name of the mesh to create
  25095. * @param diameter sets the diameter size (float) of the torus (default 1)
  25096. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25097. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25098. * @param scene defines the hosting scene
  25099. * @param updatable defines if the mesh must be flagged as updatable
  25100. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25101. * @returns a new Mesh
  25102. */
  25103. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25104. /**
  25105. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25106. * @param name defines the name of the mesh to create
  25107. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25108. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25109. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25110. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25111. * @param p the number of windings on X axis (positive integers, default 2)
  25112. * @param q the number of windings on Y axis (positive integers, default 3)
  25113. * @param scene defines the hosting scene
  25114. * @param updatable defines if the mesh must be flagged as updatable
  25115. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25116. * @returns a new Mesh
  25117. */
  25118. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25119. /**
  25120. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25121. * @param name defines the name of the mesh to create
  25122. * @param points is an array successive Vector3
  25123. * @param scene defines the hosting scene
  25124. * @param updatable defines if the mesh must be flagged as updatable
  25125. * @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).
  25126. * @returns a new Mesh
  25127. */
  25128. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25129. /**
  25130. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25131. * @param name defines the name of the mesh to create
  25132. * @param points is an array successive Vector3
  25133. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25134. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25135. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25136. * @param scene defines the hosting scene
  25137. * @param updatable defines if the mesh must be flagged as updatable
  25138. * @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)
  25139. * @returns a new Mesh
  25140. */
  25141. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25142. /**
  25143. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25144. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25145. * 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.
  25146. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25147. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25148. * Remember you can only change the shape positions, not their number when updating a polygon.
  25149. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25150. * @param name defines the name of the mesh to create
  25151. * @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
  25152. * @param scene defines the hosting scene
  25153. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25154. * @param updatable defines if the mesh must be flagged as updatable
  25155. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25156. * @param earcutInjection can be used to inject your own earcut reference
  25157. * @returns a new Mesh
  25158. */
  25159. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25160. /**
  25161. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25162. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25163. * @param name defines the name of the mesh to create
  25164. * @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
  25165. * @param depth defines the height of extrusion
  25166. * @param scene defines the hosting scene
  25167. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25168. * @param updatable defines if the mesh must be flagged as updatable
  25169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25170. * @param earcutInjection can be used to inject your own earcut reference
  25171. * @returns a new Mesh
  25172. */
  25173. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25174. /**
  25175. * Creates an extruded shape mesh.
  25176. * 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
  25177. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25178. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25179. * @param name defines the name of the mesh to create
  25180. * @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
  25181. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25182. * @param scale is the value to scale the shape
  25183. * @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
  25184. * @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
  25185. * @param scene defines the hosting scene
  25186. * @param updatable defines if the mesh must be flagged as updatable
  25187. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25188. * @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)
  25189. * @returns a new Mesh
  25190. */
  25191. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25192. /**
  25193. * Creates an custom extruded shape mesh.
  25194. * The custom extrusion is a parametric shape.
  25195. * It has no predefined shape. Its final shape will depend on the input parameters.
  25196. * Please consider using the same method from the MeshBuilder class instead
  25197. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25198. * @param name defines the name of the mesh to create
  25199. * @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
  25200. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25201. * @param scaleFunction is a custom Javascript function called on each path point
  25202. * @param rotationFunction is a custom Javascript function called on each path point
  25203. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25204. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25205. * @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
  25206. * @param scene defines the hosting scene
  25207. * @param updatable defines if the mesh must be flagged as updatable
  25208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25209. * @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)
  25210. * @returns a new Mesh
  25211. */
  25212. 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;
  25213. /**
  25214. * Creates lathe mesh.
  25215. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25216. * Please consider using the same method from the MeshBuilder class instead
  25217. * @param name defines the name of the mesh to create
  25218. * @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
  25219. * @param radius is the radius value of the lathe
  25220. * @param tessellation is the side number of the lathe.
  25221. * @param scene defines the hosting scene
  25222. * @param updatable defines if the mesh must be flagged as updatable
  25223. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25224. * @returns a new Mesh
  25225. */
  25226. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25227. /**
  25228. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25229. * @param name defines the name of the mesh to create
  25230. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25231. * @param scene defines the hosting scene
  25232. * @param updatable defines if the mesh must be flagged as updatable
  25233. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25234. * @returns a new Mesh
  25235. */
  25236. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25237. /**
  25238. * Creates a ground mesh.
  25239. * Please consider using the same method from the MeshBuilder class instead
  25240. * @param name defines the name of the mesh to create
  25241. * @param width set the width of the ground
  25242. * @param height set the height of the ground
  25243. * @param subdivisions sets the number of subdivisions per side
  25244. * @param scene defines the hosting scene
  25245. * @param updatable defines if the mesh must be flagged as updatable
  25246. * @returns a new Mesh
  25247. */
  25248. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25249. /**
  25250. * Creates a tiled ground mesh.
  25251. * Please consider using the same method from the MeshBuilder class instead
  25252. * @param name defines the name of the mesh to create
  25253. * @param xmin set the ground minimum X coordinate
  25254. * @param zmin set the ground minimum Y coordinate
  25255. * @param xmax set the ground maximum X coordinate
  25256. * @param zmax set the ground maximum Z coordinate
  25257. * @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
  25258. * @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
  25259. * @param scene defines the hosting scene
  25260. * @param updatable defines if the mesh must be flagged as updatable
  25261. * @returns a new Mesh
  25262. */
  25263. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25264. w: number;
  25265. h: number;
  25266. }, precision: {
  25267. w: number;
  25268. h: number;
  25269. }, scene: Scene, updatable?: boolean): Mesh;
  25270. /**
  25271. * Creates a ground mesh from a height map.
  25272. * Please consider using the same method from the MeshBuilder class instead
  25273. * @see http://doc.babylonjs.com/babylon101/height_map
  25274. * @param name defines the name of the mesh to create
  25275. * @param url sets the URL of the height map image resource
  25276. * @param width set the ground width size
  25277. * @param height set the ground height size
  25278. * @param subdivisions sets the number of subdivision per side
  25279. * @param minHeight is the minimum altitude on the ground
  25280. * @param maxHeight is the maximum altitude on the ground
  25281. * @param scene defines the hosting scene
  25282. * @param updatable defines if the mesh must be flagged as updatable
  25283. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25284. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25285. * @returns a new Mesh
  25286. */
  25287. 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;
  25288. /**
  25289. * Creates a tube mesh.
  25290. * The tube is a parametric shape.
  25291. * It has no predefined shape. Its final shape will depend on the input parameters.
  25292. * Please consider using the same method from the MeshBuilder class instead
  25293. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25294. * @param name defines the name of the mesh to create
  25295. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25296. * @param radius sets the tube radius size
  25297. * @param tessellation is the number of sides on the tubular surface
  25298. * @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
  25299. * @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
  25300. * @param scene defines the hosting scene
  25301. * @param updatable defines if the mesh must be flagged as updatable
  25302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25303. * @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)
  25304. * @returns a new Mesh
  25305. */
  25306. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25307. (i: number, distance: number): number;
  25308. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25309. /**
  25310. * Creates a polyhedron mesh.
  25311. * Please consider using the same method from the MeshBuilder class instead.
  25312. * * 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
  25313. * * The parameter `size` (positive float, default 1) sets the polygon size
  25314. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25315. * * 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`
  25316. * * 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
  25317. * * 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)`)
  25318. * * 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
  25319. * * 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
  25320. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25321. * * 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
  25322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25323. * @param name defines the name of the mesh to create
  25324. * @param options defines the options used to create the mesh
  25325. * @param scene defines the hosting scene
  25326. * @returns a new Mesh
  25327. */
  25328. static CreatePolyhedron(name: string, options: {
  25329. type?: number;
  25330. size?: number;
  25331. sizeX?: number;
  25332. sizeY?: number;
  25333. sizeZ?: number;
  25334. custom?: any;
  25335. faceUV?: Vector4[];
  25336. faceColors?: Color4[];
  25337. updatable?: boolean;
  25338. sideOrientation?: number;
  25339. }, scene: Scene): Mesh;
  25340. /**
  25341. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25342. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25343. * * 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`)
  25344. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25345. * * 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
  25346. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25347. * * 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
  25348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25349. * @param name defines the name of the mesh
  25350. * @param options defines the options used to create the mesh
  25351. * @param scene defines the hosting scene
  25352. * @returns a new Mesh
  25353. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25354. */
  25355. static CreateIcoSphere(name: string, options: {
  25356. radius?: number;
  25357. flat?: boolean;
  25358. subdivisions?: number;
  25359. sideOrientation?: number;
  25360. updatable?: boolean;
  25361. }, scene: Scene): Mesh;
  25362. /**
  25363. * Creates a decal mesh.
  25364. * Please consider using the same method from the MeshBuilder class instead.
  25365. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25366. * @param name defines the name of the mesh
  25367. * @param sourceMesh defines the mesh receiving the decal
  25368. * @param position sets the position of the decal in world coordinates
  25369. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25370. * @param size sets the decal scaling
  25371. * @param angle sets the angle to rotate the decal
  25372. * @returns a new Mesh
  25373. */
  25374. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25375. /**
  25376. * Prepare internal position array for software CPU skinning
  25377. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25378. */
  25379. setPositionsForCPUSkinning(): Float32Array;
  25380. /**
  25381. * Prepare internal normal array for software CPU skinning
  25382. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25383. */
  25384. setNormalsForCPUSkinning(): Float32Array;
  25385. /**
  25386. * Updates the vertex buffer by applying transformation from the bones
  25387. * @param skeleton defines the skeleton to apply to current mesh
  25388. * @returns the current mesh
  25389. */
  25390. applySkeleton(skeleton: Skeleton): Mesh;
  25391. /**
  25392. * 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
  25393. * @param meshes defines the list of meshes to scan
  25394. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25395. */
  25396. static MinMax(meshes: AbstractMesh[]): {
  25397. min: Vector3;
  25398. max: Vector3;
  25399. };
  25400. /**
  25401. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25402. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25403. * @returns a vector3
  25404. */
  25405. static Center(meshesOrMinMaxVector: {
  25406. min: Vector3;
  25407. max: Vector3;
  25408. } | AbstractMesh[]): Vector3;
  25409. /**
  25410. * Merge the array of meshes into a single mesh for performance reasons.
  25411. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25412. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25413. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25414. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25415. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25416. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25417. * @returns a new mesh
  25418. */
  25419. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25420. /** @hidden */
  25421. addInstance(instance: InstancedMesh): void;
  25422. /** @hidden */
  25423. removeInstance(instance: InstancedMesh): void;
  25424. }
  25425. }
  25426. declare module BABYLON {
  25427. /**
  25428. * This is the base class of all the camera used in the application.
  25429. * @see http://doc.babylonjs.com/features/cameras
  25430. */
  25431. export class Camera extends Node {
  25432. /** @hidden */
  25433. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25434. /**
  25435. * This is the default projection mode used by the cameras.
  25436. * It helps recreating a feeling of perspective and better appreciate depth.
  25437. * This is the best way to simulate real life cameras.
  25438. */
  25439. static readonly PERSPECTIVE_CAMERA: number;
  25440. /**
  25441. * This helps creating camera with an orthographic mode.
  25442. * 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.
  25443. */
  25444. static readonly ORTHOGRAPHIC_CAMERA: number;
  25445. /**
  25446. * This is the default FOV mode for perspective cameras.
  25447. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25448. */
  25449. static readonly FOVMODE_VERTICAL_FIXED: number;
  25450. /**
  25451. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25452. */
  25453. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25454. /**
  25455. * This specifies ther is no need for a camera rig.
  25456. * Basically only one eye is rendered corresponding to the camera.
  25457. */
  25458. static readonly RIG_MODE_NONE: number;
  25459. /**
  25460. * Simulates a camera Rig with one blue eye and one red eye.
  25461. * This can be use with 3d blue and red glasses.
  25462. */
  25463. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25464. /**
  25465. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25466. */
  25467. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25468. /**
  25469. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25470. */
  25471. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25472. /**
  25473. * Defines that both eyes of the camera will be rendered over under each other.
  25474. */
  25475. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25476. /**
  25477. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25478. */
  25479. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25480. /**
  25481. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25482. */
  25483. static readonly RIG_MODE_VR: number;
  25484. /**
  25485. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25486. */
  25487. static readonly RIG_MODE_WEBVR: number;
  25488. /**
  25489. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25490. */
  25491. static readonly RIG_MODE_CUSTOM: number;
  25492. /**
  25493. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25494. */
  25495. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25496. /**
  25497. * Define the input manager associated with the camera.
  25498. */
  25499. inputs: CameraInputsManager<Camera>;
  25500. /** @hidden */
  25501. _position: Vector3;
  25502. /**
  25503. * Define the current local position of the camera in the scene
  25504. */
  25505. get position(): Vector3;
  25506. set position(newPosition: Vector3);
  25507. /**
  25508. * The vector the camera should consider as up.
  25509. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25510. */
  25511. upVector: Vector3;
  25512. /**
  25513. * Define the current limit on the left side for an orthographic camera
  25514. * In scene unit
  25515. */
  25516. orthoLeft: Nullable<number>;
  25517. /**
  25518. * Define the current limit on the right side for an orthographic camera
  25519. * In scene unit
  25520. */
  25521. orthoRight: Nullable<number>;
  25522. /**
  25523. * Define the current limit on the bottom side for an orthographic camera
  25524. * In scene unit
  25525. */
  25526. orthoBottom: Nullable<number>;
  25527. /**
  25528. * Define the current limit on the top side for an orthographic camera
  25529. * In scene unit
  25530. */
  25531. orthoTop: Nullable<number>;
  25532. /**
  25533. * Field Of View is set in Radians. (default is 0.8)
  25534. */
  25535. fov: number;
  25536. /**
  25537. * Define the minimum distance the camera can see from.
  25538. * This is important to note that the depth buffer are not infinite and the closer it starts
  25539. * the more your scene might encounter depth fighting issue.
  25540. */
  25541. minZ: number;
  25542. /**
  25543. * Define the maximum distance the camera can see to.
  25544. * This is important to note that the depth buffer are not infinite and the further it end
  25545. * the more your scene might encounter depth fighting issue.
  25546. */
  25547. maxZ: number;
  25548. /**
  25549. * Define the default inertia of the camera.
  25550. * This helps giving a smooth feeling to the camera movement.
  25551. */
  25552. inertia: number;
  25553. /**
  25554. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25555. */
  25556. mode: number;
  25557. /**
  25558. * Define whether the camera is intermediate.
  25559. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25560. */
  25561. isIntermediate: boolean;
  25562. /**
  25563. * Define the viewport of the camera.
  25564. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25565. */
  25566. viewport: Viewport;
  25567. /**
  25568. * Restricts the camera to viewing objects with the same layerMask.
  25569. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25570. */
  25571. layerMask: number;
  25572. /**
  25573. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25574. */
  25575. fovMode: number;
  25576. /**
  25577. * Rig mode of the camera.
  25578. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25579. * This is normally controlled byt the camera themselves as internal use.
  25580. */
  25581. cameraRigMode: number;
  25582. /**
  25583. * Defines the distance between both "eyes" in case of a RIG
  25584. */
  25585. interaxialDistance: number;
  25586. /**
  25587. * Defines if stereoscopic rendering is done side by side or over under.
  25588. */
  25589. isStereoscopicSideBySide: boolean;
  25590. /**
  25591. * 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
  25592. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25593. * else in the scene. (Eg. security camera)
  25594. *
  25595. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25596. */
  25597. customRenderTargets: RenderTargetTexture[];
  25598. /**
  25599. * When set, the camera will render to this render target instead of the default canvas
  25600. *
  25601. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25602. */
  25603. outputRenderTarget: Nullable<RenderTargetTexture>;
  25604. /**
  25605. * Observable triggered when the camera view matrix has changed.
  25606. */
  25607. onViewMatrixChangedObservable: Observable<Camera>;
  25608. /**
  25609. * Observable triggered when the camera Projection matrix has changed.
  25610. */
  25611. onProjectionMatrixChangedObservable: Observable<Camera>;
  25612. /**
  25613. * Observable triggered when the inputs have been processed.
  25614. */
  25615. onAfterCheckInputsObservable: Observable<Camera>;
  25616. /**
  25617. * Observable triggered when reset has been called and applied to the camera.
  25618. */
  25619. onRestoreStateObservable: Observable<Camera>;
  25620. /**
  25621. * Is this camera a part of a rig system?
  25622. */
  25623. isRigCamera: boolean;
  25624. /**
  25625. * If isRigCamera set to true this will be set with the parent camera.
  25626. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25627. */
  25628. rigParent?: Camera;
  25629. /** @hidden */
  25630. _cameraRigParams: any;
  25631. /** @hidden */
  25632. _rigCameras: Camera[];
  25633. /** @hidden */
  25634. _rigPostProcess: Nullable<PostProcess>;
  25635. protected _webvrViewMatrix: Matrix;
  25636. /** @hidden */
  25637. _skipRendering: boolean;
  25638. /** @hidden */
  25639. _projectionMatrix: Matrix;
  25640. /** @hidden */
  25641. _postProcesses: Nullable<PostProcess>[];
  25642. /** @hidden */
  25643. _activeMeshes: SmartArray<AbstractMesh>;
  25644. protected _globalPosition: Vector3;
  25645. /** @hidden */
  25646. _computedViewMatrix: Matrix;
  25647. private _doNotComputeProjectionMatrix;
  25648. private _transformMatrix;
  25649. private _frustumPlanes;
  25650. private _refreshFrustumPlanes;
  25651. private _storedFov;
  25652. private _stateStored;
  25653. /**
  25654. * Instantiates a new camera object.
  25655. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25656. * @see http://doc.babylonjs.com/features/cameras
  25657. * @param name Defines the name of the camera in the scene
  25658. * @param position Defines the position of the camera
  25659. * @param scene Defines the scene the camera belongs too
  25660. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25661. */
  25662. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25663. /**
  25664. * Store current camera state (fov, position, etc..)
  25665. * @returns the camera
  25666. */
  25667. storeState(): Camera;
  25668. /**
  25669. * Restores the camera state values if it has been stored. You must call storeState() first
  25670. */
  25671. protected _restoreStateValues(): boolean;
  25672. /**
  25673. * Restored camera state. You must call storeState() first.
  25674. * @returns true if restored and false otherwise
  25675. */
  25676. restoreState(): boolean;
  25677. /**
  25678. * Gets the class name of the camera.
  25679. * @returns the class name
  25680. */
  25681. getClassName(): string;
  25682. /** @hidden */
  25683. readonly _isCamera: boolean;
  25684. /**
  25685. * Gets a string representation of the camera useful for debug purpose.
  25686. * @param fullDetails Defines that a more verboe level of logging is required
  25687. * @returns the string representation
  25688. */
  25689. toString(fullDetails?: boolean): string;
  25690. /**
  25691. * Gets the current world space position of the camera.
  25692. */
  25693. get globalPosition(): Vector3;
  25694. /**
  25695. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25696. * @returns the active meshe list
  25697. */
  25698. getActiveMeshes(): SmartArray<AbstractMesh>;
  25699. /**
  25700. * Check whether a mesh is part of the current active mesh list of the camera
  25701. * @param mesh Defines the mesh to check
  25702. * @returns true if active, false otherwise
  25703. */
  25704. isActiveMesh(mesh: Mesh): boolean;
  25705. /**
  25706. * Is this camera ready to be used/rendered
  25707. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25708. * @return true if the camera is ready
  25709. */
  25710. isReady(completeCheck?: boolean): boolean;
  25711. /** @hidden */
  25712. _initCache(): void;
  25713. /** @hidden */
  25714. _updateCache(ignoreParentClass?: boolean): void;
  25715. /** @hidden */
  25716. _isSynchronized(): boolean;
  25717. /** @hidden */
  25718. _isSynchronizedViewMatrix(): boolean;
  25719. /** @hidden */
  25720. _isSynchronizedProjectionMatrix(): boolean;
  25721. /**
  25722. * Attach the input controls to a specific dom element to get the input from.
  25723. * @param element Defines the element the controls should be listened from
  25724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25725. */
  25726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25727. /**
  25728. * Detach the current controls from the specified dom element.
  25729. * @param element Defines the element to stop listening the inputs from
  25730. */
  25731. detachControl(element: HTMLElement): void;
  25732. /**
  25733. * Update the camera state according to the different inputs gathered during the frame.
  25734. */
  25735. update(): void;
  25736. /** @hidden */
  25737. _checkInputs(): void;
  25738. /** @hidden */
  25739. get rigCameras(): Camera[];
  25740. /**
  25741. * Gets the post process used by the rig cameras
  25742. */
  25743. get rigPostProcess(): Nullable<PostProcess>;
  25744. /**
  25745. * Internal, gets the first post proces.
  25746. * @returns the first post process to be run on this camera.
  25747. */
  25748. _getFirstPostProcess(): Nullable<PostProcess>;
  25749. private _cascadePostProcessesToRigCams;
  25750. /**
  25751. * Attach a post process to the camera.
  25752. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25753. * @param postProcess The post process to attach to the camera
  25754. * @param insertAt The position of the post process in case several of them are in use in the scene
  25755. * @returns the position the post process has been inserted at
  25756. */
  25757. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25758. /**
  25759. * Detach a post process to the camera.
  25760. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25761. * @param postProcess The post process to detach from the camera
  25762. */
  25763. detachPostProcess(postProcess: PostProcess): void;
  25764. /**
  25765. * Gets the current world matrix of the camera
  25766. */
  25767. getWorldMatrix(): Matrix;
  25768. /** @hidden */
  25769. _getViewMatrix(): Matrix;
  25770. /**
  25771. * Gets the current view matrix of the camera.
  25772. * @param force forces the camera to recompute the matrix without looking at the cached state
  25773. * @returns the view matrix
  25774. */
  25775. getViewMatrix(force?: boolean): Matrix;
  25776. /**
  25777. * Freeze the projection matrix.
  25778. * It will prevent the cache check of the camera projection compute and can speed up perf
  25779. * if no parameter of the camera are meant to change
  25780. * @param projection Defines manually a projection if necessary
  25781. */
  25782. freezeProjectionMatrix(projection?: Matrix): void;
  25783. /**
  25784. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25785. */
  25786. unfreezeProjectionMatrix(): void;
  25787. /**
  25788. * Gets the current projection matrix of the camera.
  25789. * @param force forces the camera to recompute the matrix without looking at the cached state
  25790. * @returns the projection matrix
  25791. */
  25792. getProjectionMatrix(force?: boolean): Matrix;
  25793. /**
  25794. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25795. * @returns a Matrix
  25796. */
  25797. getTransformationMatrix(): Matrix;
  25798. private _updateFrustumPlanes;
  25799. /**
  25800. * Checks if a cullable object (mesh...) is in the camera frustum
  25801. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25802. * @param target The object to check
  25803. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25804. * @returns true if the object is in frustum otherwise false
  25805. */
  25806. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25807. /**
  25808. * Checks if a cullable object (mesh...) is in the camera frustum
  25809. * Unlike isInFrustum this cheks the full bounding box
  25810. * @param target The object to check
  25811. * @returns true if the object is in frustum otherwise false
  25812. */
  25813. isCompletelyInFrustum(target: ICullable): boolean;
  25814. /**
  25815. * Gets a ray in the forward direction from the camera.
  25816. * @param length Defines the length of the ray to create
  25817. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25818. * @param origin Defines the start point of the ray which defaults to the camera position
  25819. * @returns the forward ray
  25820. */
  25821. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25822. /**
  25823. * Releases resources associated with this node.
  25824. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25825. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25826. */
  25827. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25828. /** @hidden */
  25829. _isLeftCamera: boolean;
  25830. /**
  25831. * Gets the left camera of a rig setup in case of Rigged Camera
  25832. */
  25833. get isLeftCamera(): boolean;
  25834. /** @hidden */
  25835. _isRightCamera: boolean;
  25836. /**
  25837. * Gets the right camera of a rig setup in case of Rigged Camera
  25838. */
  25839. get isRightCamera(): boolean;
  25840. /**
  25841. * Gets the left camera of a rig setup in case of Rigged Camera
  25842. */
  25843. get leftCamera(): Nullable<FreeCamera>;
  25844. /**
  25845. * Gets the right camera of a rig setup in case of Rigged Camera
  25846. */
  25847. get rightCamera(): Nullable<FreeCamera>;
  25848. /**
  25849. * Gets the left camera target of a rig setup in case of Rigged Camera
  25850. * @returns the target position
  25851. */
  25852. getLeftTarget(): Nullable<Vector3>;
  25853. /**
  25854. * Gets the right camera target of a rig setup in case of Rigged Camera
  25855. * @returns the target position
  25856. */
  25857. getRightTarget(): Nullable<Vector3>;
  25858. /**
  25859. * @hidden
  25860. */
  25861. setCameraRigMode(mode: number, rigParams: any): void;
  25862. /** @hidden */
  25863. static _setStereoscopicRigMode(camera: Camera): void;
  25864. /** @hidden */
  25865. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25866. /** @hidden */
  25867. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25868. /** @hidden */
  25869. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25870. /** @hidden */
  25871. _getVRProjectionMatrix(): Matrix;
  25872. protected _updateCameraRotationMatrix(): void;
  25873. protected _updateWebVRCameraRotationMatrix(): void;
  25874. /**
  25875. * This function MUST be overwritten by the different WebVR cameras available.
  25876. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25877. * @hidden
  25878. */
  25879. _getWebVRProjectionMatrix(): Matrix;
  25880. /**
  25881. * This function MUST be overwritten by the different WebVR cameras available.
  25882. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25883. * @hidden
  25884. */
  25885. _getWebVRViewMatrix(): Matrix;
  25886. /** @hidden */
  25887. setCameraRigParameter(name: string, value: any): void;
  25888. /**
  25889. * needs to be overridden by children so sub has required properties to be copied
  25890. * @hidden
  25891. */
  25892. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25893. /**
  25894. * May need to be overridden by children
  25895. * @hidden
  25896. */
  25897. _updateRigCameras(): void;
  25898. /** @hidden */
  25899. _setupInputs(): void;
  25900. /**
  25901. * Serialiaze the camera setup to a json represention
  25902. * @returns the JSON representation
  25903. */
  25904. serialize(): any;
  25905. /**
  25906. * Clones the current camera.
  25907. * @param name The cloned camera name
  25908. * @returns the cloned camera
  25909. */
  25910. clone(name: string): Camera;
  25911. /**
  25912. * Gets the direction of the camera relative to a given local axis.
  25913. * @param localAxis Defines the reference axis to provide a relative direction.
  25914. * @return the direction
  25915. */
  25916. getDirection(localAxis: Vector3): Vector3;
  25917. /**
  25918. * Returns the current camera absolute rotation
  25919. */
  25920. get absoluteRotation(): Quaternion;
  25921. /**
  25922. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25923. * @param localAxis Defines the reference axis to provide a relative direction.
  25924. * @param result Defines the vector to store the result in
  25925. */
  25926. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25927. /**
  25928. * Gets a camera constructor for a given camera type
  25929. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25930. * @param name The name of the camera the result will be able to instantiate
  25931. * @param scene The scene the result will construct the camera in
  25932. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25933. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25934. * @returns a factory method to construc the camera
  25935. */
  25936. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25937. /**
  25938. * Compute the world matrix of the camera.
  25939. * @returns the camera world matrix
  25940. */
  25941. computeWorldMatrix(): Matrix;
  25942. /**
  25943. * Parse a JSON and creates the camera from the parsed information
  25944. * @param parsedCamera The JSON to parse
  25945. * @param scene The scene to instantiate the camera in
  25946. * @returns the newly constructed camera
  25947. */
  25948. static Parse(parsedCamera: any, scene: Scene): Camera;
  25949. }
  25950. }
  25951. declare module BABYLON {
  25952. /**
  25953. * Class containing static functions to help procedurally build meshes
  25954. */
  25955. export class DiscBuilder {
  25956. /**
  25957. * Creates a plane polygonal mesh. By default, this is a disc
  25958. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25959. * * 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
  25960. * * 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
  25961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25962. * * 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
  25963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25964. * @param name defines the name of the mesh
  25965. * @param options defines the options used to create the mesh
  25966. * @param scene defines the hosting scene
  25967. * @returns the plane polygonal mesh
  25968. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25969. */
  25970. static CreateDisc(name: string, options: {
  25971. radius?: number;
  25972. tessellation?: number;
  25973. arc?: number;
  25974. updatable?: boolean;
  25975. sideOrientation?: number;
  25976. frontUVs?: Vector4;
  25977. backUVs?: Vector4;
  25978. }, scene?: Nullable<Scene>): Mesh;
  25979. }
  25980. }
  25981. declare module BABYLON {
  25982. /**
  25983. * This represents all the required information to add a fresnel effect on a material:
  25984. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25985. */
  25986. export class FresnelParameters {
  25987. private _isEnabled;
  25988. /**
  25989. * Define if the fresnel effect is enable or not.
  25990. */
  25991. get isEnabled(): boolean;
  25992. set isEnabled(value: boolean);
  25993. /**
  25994. * Define the color used on edges (grazing angle)
  25995. */
  25996. leftColor: Color3;
  25997. /**
  25998. * Define the color used on center
  25999. */
  26000. rightColor: Color3;
  26001. /**
  26002. * Define bias applied to computed fresnel term
  26003. */
  26004. bias: number;
  26005. /**
  26006. * Defined the power exponent applied to fresnel term
  26007. */
  26008. power: number;
  26009. /**
  26010. * Clones the current fresnel and its valuues
  26011. * @returns a clone fresnel configuration
  26012. */
  26013. clone(): FresnelParameters;
  26014. /**
  26015. * Serializes the current fresnel parameters to a JSON representation.
  26016. * @return the JSON serialization
  26017. */
  26018. serialize(): any;
  26019. /**
  26020. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26021. * @param parsedFresnelParameters Define the JSON representation
  26022. * @returns the parsed parameters
  26023. */
  26024. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26025. }
  26026. }
  26027. declare module BABYLON {
  26028. /**
  26029. * Base class of materials working in push mode in babylon JS
  26030. * @hidden
  26031. */
  26032. export class PushMaterial extends Material {
  26033. protected _activeEffect: Effect;
  26034. protected _normalMatrix: Matrix;
  26035. /**
  26036. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26037. * This means that the material can keep using a previous shader while a new one is being compiled.
  26038. * This is mostly used when shader parallel compilation is supported (true by default)
  26039. */
  26040. allowShaderHotSwapping: boolean;
  26041. constructor(name: string, scene: Scene);
  26042. getEffect(): Effect;
  26043. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26044. /**
  26045. * Binds the given world matrix to the active effect
  26046. *
  26047. * @param world the matrix to bind
  26048. */
  26049. bindOnlyWorldMatrix(world: Matrix): void;
  26050. /**
  26051. * Binds the given normal matrix to the active effect
  26052. *
  26053. * @param normalMatrix the matrix to bind
  26054. */
  26055. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26056. bind(world: Matrix, mesh?: Mesh): void;
  26057. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26058. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26059. }
  26060. }
  26061. declare module BABYLON {
  26062. /**
  26063. * This groups all the flags used to control the materials channel.
  26064. */
  26065. export class MaterialFlags {
  26066. private static _DiffuseTextureEnabled;
  26067. /**
  26068. * Are diffuse textures enabled in the application.
  26069. */
  26070. static get DiffuseTextureEnabled(): boolean;
  26071. static set DiffuseTextureEnabled(value: boolean);
  26072. private static _AmbientTextureEnabled;
  26073. /**
  26074. * Are ambient textures enabled in the application.
  26075. */
  26076. static get AmbientTextureEnabled(): boolean;
  26077. static set AmbientTextureEnabled(value: boolean);
  26078. private static _OpacityTextureEnabled;
  26079. /**
  26080. * Are opacity textures enabled in the application.
  26081. */
  26082. static get OpacityTextureEnabled(): boolean;
  26083. static set OpacityTextureEnabled(value: boolean);
  26084. private static _ReflectionTextureEnabled;
  26085. /**
  26086. * Are reflection textures enabled in the application.
  26087. */
  26088. static get ReflectionTextureEnabled(): boolean;
  26089. static set ReflectionTextureEnabled(value: boolean);
  26090. private static _EmissiveTextureEnabled;
  26091. /**
  26092. * Are emissive textures enabled in the application.
  26093. */
  26094. static get EmissiveTextureEnabled(): boolean;
  26095. static set EmissiveTextureEnabled(value: boolean);
  26096. private static _SpecularTextureEnabled;
  26097. /**
  26098. * Are specular textures enabled in the application.
  26099. */
  26100. static get SpecularTextureEnabled(): boolean;
  26101. static set SpecularTextureEnabled(value: boolean);
  26102. private static _BumpTextureEnabled;
  26103. /**
  26104. * Are bump textures enabled in the application.
  26105. */
  26106. static get BumpTextureEnabled(): boolean;
  26107. static set BumpTextureEnabled(value: boolean);
  26108. private static _LightmapTextureEnabled;
  26109. /**
  26110. * Are lightmap textures enabled in the application.
  26111. */
  26112. static get LightmapTextureEnabled(): boolean;
  26113. static set LightmapTextureEnabled(value: boolean);
  26114. private static _RefractionTextureEnabled;
  26115. /**
  26116. * Are refraction textures enabled in the application.
  26117. */
  26118. static get RefractionTextureEnabled(): boolean;
  26119. static set RefractionTextureEnabled(value: boolean);
  26120. private static _ColorGradingTextureEnabled;
  26121. /**
  26122. * Are color grading textures enabled in the application.
  26123. */
  26124. static get ColorGradingTextureEnabled(): boolean;
  26125. static set ColorGradingTextureEnabled(value: boolean);
  26126. private static _FresnelEnabled;
  26127. /**
  26128. * Are fresnels enabled in the application.
  26129. */
  26130. static get FresnelEnabled(): boolean;
  26131. static set FresnelEnabled(value: boolean);
  26132. private static _ClearCoatTextureEnabled;
  26133. /**
  26134. * Are clear coat textures enabled in the application.
  26135. */
  26136. static get ClearCoatTextureEnabled(): boolean;
  26137. static set ClearCoatTextureEnabled(value: boolean);
  26138. private static _ClearCoatBumpTextureEnabled;
  26139. /**
  26140. * Are clear coat bump textures enabled in the application.
  26141. */
  26142. static get ClearCoatBumpTextureEnabled(): boolean;
  26143. static set ClearCoatBumpTextureEnabled(value: boolean);
  26144. private static _ClearCoatTintTextureEnabled;
  26145. /**
  26146. * Are clear coat tint textures enabled in the application.
  26147. */
  26148. static get ClearCoatTintTextureEnabled(): boolean;
  26149. static set ClearCoatTintTextureEnabled(value: boolean);
  26150. private static _SheenTextureEnabled;
  26151. /**
  26152. * Are sheen textures enabled in the application.
  26153. */
  26154. static get SheenTextureEnabled(): boolean;
  26155. static set SheenTextureEnabled(value: boolean);
  26156. private static _AnisotropicTextureEnabled;
  26157. /**
  26158. * Are anisotropic textures enabled in the application.
  26159. */
  26160. static get AnisotropicTextureEnabled(): boolean;
  26161. static set AnisotropicTextureEnabled(value: boolean);
  26162. private static _ThicknessTextureEnabled;
  26163. /**
  26164. * Are thickness textures enabled in the application.
  26165. */
  26166. static get ThicknessTextureEnabled(): boolean;
  26167. static set ThicknessTextureEnabled(value: boolean);
  26168. }
  26169. }
  26170. declare module BABYLON {
  26171. /** @hidden */
  26172. export var defaultFragmentDeclaration: {
  26173. name: string;
  26174. shader: string;
  26175. };
  26176. }
  26177. declare module BABYLON {
  26178. /** @hidden */
  26179. export var defaultUboDeclaration: {
  26180. name: string;
  26181. shader: string;
  26182. };
  26183. }
  26184. declare module BABYLON {
  26185. /** @hidden */
  26186. export var lightFragmentDeclaration: {
  26187. name: string;
  26188. shader: string;
  26189. };
  26190. }
  26191. declare module BABYLON {
  26192. /** @hidden */
  26193. export var lightUboDeclaration: {
  26194. name: string;
  26195. shader: string;
  26196. };
  26197. }
  26198. declare module BABYLON {
  26199. /** @hidden */
  26200. export var lightsFragmentFunctions: {
  26201. name: string;
  26202. shader: string;
  26203. };
  26204. }
  26205. declare module BABYLON {
  26206. /** @hidden */
  26207. export var shadowsFragmentFunctions: {
  26208. name: string;
  26209. shader: string;
  26210. };
  26211. }
  26212. declare module BABYLON {
  26213. /** @hidden */
  26214. export var fresnelFunction: {
  26215. name: string;
  26216. shader: string;
  26217. };
  26218. }
  26219. declare module BABYLON {
  26220. /** @hidden */
  26221. export var reflectionFunction: {
  26222. name: string;
  26223. shader: string;
  26224. };
  26225. }
  26226. declare module BABYLON {
  26227. /** @hidden */
  26228. export var bumpFragmentFunctions: {
  26229. name: string;
  26230. shader: string;
  26231. };
  26232. }
  26233. declare module BABYLON {
  26234. /** @hidden */
  26235. export var logDepthDeclaration: {
  26236. name: string;
  26237. shader: string;
  26238. };
  26239. }
  26240. declare module BABYLON {
  26241. /** @hidden */
  26242. export var bumpFragment: {
  26243. name: string;
  26244. shader: string;
  26245. };
  26246. }
  26247. declare module BABYLON {
  26248. /** @hidden */
  26249. export var depthPrePass: {
  26250. name: string;
  26251. shader: string;
  26252. };
  26253. }
  26254. declare module BABYLON {
  26255. /** @hidden */
  26256. export var lightFragment: {
  26257. name: string;
  26258. shader: string;
  26259. };
  26260. }
  26261. declare module BABYLON {
  26262. /** @hidden */
  26263. export var logDepthFragment: {
  26264. name: string;
  26265. shader: string;
  26266. };
  26267. }
  26268. declare module BABYLON {
  26269. /** @hidden */
  26270. export var defaultPixelShader: {
  26271. name: string;
  26272. shader: string;
  26273. };
  26274. }
  26275. declare module BABYLON {
  26276. /** @hidden */
  26277. export var defaultVertexDeclaration: {
  26278. name: string;
  26279. shader: string;
  26280. };
  26281. }
  26282. declare module BABYLON {
  26283. /** @hidden */
  26284. export var bumpVertexDeclaration: {
  26285. name: string;
  26286. shader: string;
  26287. };
  26288. }
  26289. declare module BABYLON {
  26290. /** @hidden */
  26291. export var bumpVertex: {
  26292. name: string;
  26293. shader: string;
  26294. };
  26295. }
  26296. declare module BABYLON {
  26297. /** @hidden */
  26298. export var fogVertex: {
  26299. name: string;
  26300. shader: string;
  26301. };
  26302. }
  26303. declare module BABYLON {
  26304. /** @hidden */
  26305. export var shadowsVertex: {
  26306. name: string;
  26307. shader: string;
  26308. };
  26309. }
  26310. declare module BABYLON {
  26311. /** @hidden */
  26312. export var pointCloudVertex: {
  26313. name: string;
  26314. shader: string;
  26315. };
  26316. }
  26317. declare module BABYLON {
  26318. /** @hidden */
  26319. export var logDepthVertex: {
  26320. name: string;
  26321. shader: string;
  26322. };
  26323. }
  26324. declare module BABYLON {
  26325. /** @hidden */
  26326. export var defaultVertexShader: {
  26327. name: string;
  26328. shader: string;
  26329. };
  26330. }
  26331. declare module BABYLON {
  26332. /** @hidden */
  26333. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26334. MAINUV1: boolean;
  26335. MAINUV2: boolean;
  26336. DIFFUSE: boolean;
  26337. DIFFUSEDIRECTUV: number;
  26338. AMBIENT: boolean;
  26339. AMBIENTDIRECTUV: number;
  26340. OPACITY: boolean;
  26341. OPACITYDIRECTUV: number;
  26342. OPACITYRGB: boolean;
  26343. REFLECTION: boolean;
  26344. EMISSIVE: boolean;
  26345. EMISSIVEDIRECTUV: number;
  26346. SPECULAR: boolean;
  26347. SPECULARDIRECTUV: number;
  26348. BUMP: boolean;
  26349. BUMPDIRECTUV: number;
  26350. PARALLAX: boolean;
  26351. PARALLAXOCCLUSION: boolean;
  26352. SPECULAROVERALPHA: boolean;
  26353. CLIPPLANE: boolean;
  26354. CLIPPLANE2: boolean;
  26355. CLIPPLANE3: boolean;
  26356. CLIPPLANE4: boolean;
  26357. CLIPPLANE5: boolean;
  26358. CLIPPLANE6: boolean;
  26359. ALPHATEST: boolean;
  26360. DEPTHPREPASS: boolean;
  26361. ALPHAFROMDIFFUSE: boolean;
  26362. POINTSIZE: boolean;
  26363. FOG: boolean;
  26364. SPECULARTERM: boolean;
  26365. DIFFUSEFRESNEL: boolean;
  26366. OPACITYFRESNEL: boolean;
  26367. REFLECTIONFRESNEL: boolean;
  26368. REFRACTIONFRESNEL: boolean;
  26369. EMISSIVEFRESNEL: boolean;
  26370. FRESNEL: boolean;
  26371. NORMAL: boolean;
  26372. UV1: boolean;
  26373. UV2: boolean;
  26374. VERTEXCOLOR: boolean;
  26375. VERTEXALPHA: boolean;
  26376. NUM_BONE_INFLUENCERS: number;
  26377. BonesPerMesh: number;
  26378. BONETEXTURE: boolean;
  26379. INSTANCES: boolean;
  26380. GLOSSINESS: boolean;
  26381. ROUGHNESS: boolean;
  26382. EMISSIVEASILLUMINATION: boolean;
  26383. LINKEMISSIVEWITHDIFFUSE: boolean;
  26384. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26385. LIGHTMAP: boolean;
  26386. LIGHTMAPDIRECTUV: number;
  26387. OBJECTSPACE_NORMALMAP: boolean;
  26388. USELIGHTMAPASSHADOWMAP: boolean;
  26389. REFLECTIONMAP_3D: boolean;
  26390. REFLECTIONMAP_SPHERICAL: boolean;
  26391. REFLECTIONMAP_PLANAR: boolean;
  26392. REFLECTIONMAP_CUBIC: boolean;
  26393. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26394. REFLECTIONMAP_PROJECTION: boolean;
  26395. REFLECTIONMAP_SKYBOX: boolean;
  26396. REFLECTIONMAP_EXPLICIT: boolean;
  26397. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26398. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26399. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26400. INVERTCUBICMAP: boolean;
  26401. LOGARITHMICDEPTH: boolean;
  26402. REFRACTION: boolean;
  26403. REFRACTIONMAP_3D: boolean;
  26404. REFLECTIONOVERALPHA: boolean;
  26405. TWOSIDEDLIGHTING: boolean;
  26406. SHADOWFLOAT: boolean;
  26407. MORPHTARGETS: boolean;
  26408. MORPHTARGETS_NORMAL: boolean;
  26409. MORPHTARGETS_TANGENT: boolean;
  26410. MORPHTARGETS_UV: boolean;
  26411. NUM_MORPH_INFLUENCERS: number;
  26412. NONUNIFORMSCALING: boolean;
  26413. PREMULTIPLYALPHA: boolean;
  26414. IMAGEPROCESSING: boolean;
  26415. VIGNETTE: boolean;
  26416. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26417. VIGNETTEBLENDMODEOPAQUE: boolean;
  26418. TONEMAPPING: boolean;
  26419. TONEMAPPING_ACES: boolean;
  26420. CONTRAST: boolean;
  26421. COLORCURVES: boolean;
  26422. COLORGRADING: boolean;
  26423. COLORGRADING3D: boolean;
  26424. SAMPLER3DGREENDEPTH: boolean;
  26425. SAMPLER3DBGRMAP: boolean;
  26426. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26427. MULTIVIEW: boolean;
  26428. /**
  26429. * If the reflection texture on this material is in linear color space
  26430. * @hidden
  26431. */
  26432. IS_REFLECTION_LINEAR: boolean;
  26433. /**
  26434. * If the refraction texture on this material is in linear color space
  26435. * @hidden
  26436. */
  26437. IS_REFRACTION_LINEAR: boolean;
  26438. EXPOSURE: boolean;
  26439. constructor();
  26440. setReflectionMode(modeToEnable: string): void;
  26441. }
  26442. /**
  26443. * This is the default material used in Babylon. It is the best trade off between quality
  26444. * and performances.
  26445. * @see http://doc.babylonjs.com/babylon101/materials
  26446. */
  26447. export class StandardMaterial extends PushMaterial {
  26448. private _diffuseTexture;
  26449. /**
  26450. * The basic texture of the material as viewed under a light.
  26451. */
  26452. diffuseTexture: Nullable<BaseTexture>;
  26453. private _ambientTexture;
  26454. /**
  26455. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26456. */
  26457. ambientTexture: Nullable<BaseTexture>;
  26458. private _opacityTexture;
  26459. /**
  26460. * Define the transparency of the material from a texture.
  26461. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26462. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26463. */
  26464. opacityTexture: Nullable<BaseTexture>;
  26465. private _reflectionTexture;
  26466. /**
  26467. * Define the texture used to display the reflection.
  26468. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26469. */
  26470. reflectionTexture: Nullable<BaseTexture>;
  26471. private _emissiveTexture;
  26472. /**
  26473. * Define texture of the material as if self lit.
  26474. * This will be mixed in the final result even in the absence of light.
  26475. */
  26476. emissiveTexture: Nullable<BaseTexture>;
  26477. private _specularTexture;
  26478. /**
  26479. * Define how the color and intensity of the highlight given by the light in the material.
  26480. */
  26481. specularTexture: Nullable<BaseTexture>;
  26482. private _bumpTexture;
  26483. /**
  26484. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26485. * 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.
  26486. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26487. */
  26488. bumpTexture: Nullable<BaseTexture>;
  26489. private _lightmapTexture;
  26490. /**
  26491. * Complex lighting can be computationally expensive to compute at runtime.
  26492. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26493. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26494. */
  26495. lightmapTexture: Nullable<BaseTexture>;
  26496. private _refractionTexture;
  26497. /**
  26498. * Define the texture used to display the refraction.
  26499. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26500. */
  26501. refractionTexture: Nullable<BaseTexture>;
  26502. /**
  26503. * The color of the material lit by the environmental background lighting.
  26504. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26505. */
  26506. ambientColor: Color3;
  26507. /**
  26508. * The basic color of the material as viewed under a light.
  26509. */
  26510. diffuseColor: Color3;
  26511. /**
  26512. * Define how the color and intensity of the highlight given by the light in the material.
  26513. */
  26514. specularColor: Color3;
  26515. /**
  26516. * Define the color of the material as if self lit.
  26517. * This will be mixed in the final result even in the absence of light.
  26518. */
  26519. emissiveColor: Color3;
  26520. /**
  26521. * Defines how sharp are the highlights in the material.
  26522. * The bigger the value the sharper giving a more glossy feeling to the result.
  26523. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26524. */
  26525. specularPower: number;
  26526. private _useAlphaFromDiffuseTexture;
  26527. /**
  26528. * Does the transparency come from the diffuse texture alpha channel.
  26529. */
  26530. useAlphaFromDiffuseTexture: boolean;
  26531. private _useEmissiveAsIllumination;
  26532. /**
  26533. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26534. */
  26535. useEmissiveAsIllumination: boolean;
  26536. private _linkEmissiveWithDiffuse;
  26537. /**
  26538. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26539. * the emissive level when the final color is close to one.
  26540. */
  26541. linkEmissiveWithDiffuse: boolean;
  26542. private _useSpecularOverAlpha;
  26543. /**
  26544. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26545. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26546. */
  26547. useSpecularOverAlpha: boolean;
  26548. private _useReflectionOverAlpha;
  26549. /**
  26550. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26551. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26552. */
  26553. useReflectionOverAlpha: boolean;
  26554. private _disableLighting;
  26555. /**
  26556. * Does lights from the scene impacts this material.
  26557. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26558. */
  26559. disableLighting: boolean;
  26560. private _useObjectSpaceNormalMap;
  26561. /**
  26562. * Allows using an object space normal map (instead of tangent space).
  26563. */
  26564. useObjectSpaceNormalMap: boolean;
  26565. private _useParallax;
  26566. /**
  26567. * Is parallax enabled or not.
  26568. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26569. */
  26570. useParallax: boolean;
  26571. private _useParallaxOcclusion;
  26572. /**
  26573. * Is parallax occlusion enabled or not.
  26574. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26575. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26576. */
  26577. useParallaxOcclusion: boolean;
  26578. /**
  26579. * 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.
  26580. */
  26581. parallaxScaleBias: number;
  26582. private _roughness;
  26583. /**
  26584. * Helps to define how blurry the reflections should appears in the material.
  26585. */
  26586. roughness: number;
  26587. /**
  26588. * In case of refraction, define the value of the index of refraction.
  26589. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26590. */
  26591. indexOfRefraction: number;
  26592. /**
  26593. * Invert the refraction texture alongside the y axis.
  26594. * It can be useful with procedural textures or probe for instance.
  26595. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26596. */
  26597. invertRefractionY: boolean;
  26598. /**
  26599. * Defines the alpha limits in alpha test mode.
  26600. */
  26601. alphaCutOff: number;
  26602. private _useLightmapAsShadowmap;
  26603. /**
  26604. * In case of light mapping, define whether the map contains light or shadow informations.
  26605. */
  26606. useLightmapAsShadowmap: boolean;
  26607. private _diffuseFresnelParameters;
  26608. /**
  26609. * Define the diffuse fresnel parameters of the material.
  26610. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26611. */
  26612. diffuseFresnelParameters: FresnelParameters;
  26613. private _opacityFresnelParameters;
  26614. /**
  26615. * Define the opacity fresnel parameters of the material.
  26616. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26617. */
  26618. opacityFresnelParameters: FresnelParameters;
  26619. private _reflectionFresnelParameters;
  26620. /**
  26621. * Define the reflection fresnel parameters of the material.
  26622. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26623. */
  26624. reflectionFresnelParameters: FresnelParameters;
  26625. private _refractionFresnelParameters;
  26626. /**
  26627. * Define the refraction fresnel parameters of the material.
  26628. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26629. */
  26630. refractionFresnelParameters: FresnelParameters;
  26631. private _emissiveFresnelParameters;
  26632. /**
  26633. * Define the emissive fresnel parameters of the material.
  26634. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26635. */
  26636. emissiveFresnelParameters: FresnelParameters;
  26637. private _useReflectionFresnelFromSpecular;
  26638. /**
  26639. * If true automatically deducts the fresnels values from the material specularity.
  26640. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26641. */
  26642. useReflectionFresnelFromSpecular: boolean;
  26643. private _useGlossinessFromSpecularMapAlpha;
  26644. /**
  26645. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26646. */
  26647. useGlossinessFromSpecularMapAlpha: boolean;
  26648. private _maxSimultaneousLights;
  26649. /**
  26650. * Defines the maximum number of lights that can be used in the material
  26651. */
  26652. maxSimultaneousLights: number;
  26653. private _invertNormalMapX;
  26654. /**
  26655. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26656. */
  26657. invertNormalMapX: boolean;
  26658. private _invertNormalMapY;
  26659. /**
  26660. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26661. */
  26662. invertNormalMapY: boolean;
  26663. private _twoSidedLighting;
  26664. /**
  26665. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26666. */
  26667. twoSidedLighting: boolean;
  26668. /**
  26669. * Default configuration related to image processing available in the standard Material.
  26670. */
  26671. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26672. /**
  26673. * Gets the image processing configuration used either in this material.
  26674. */
  26675. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26676. /**
  26677. * Sets the Default image processing configuration used either in the this material.
  26678. *
  26679. * If sets to null, the scene one is in use.
  26680. */
  26681. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26682. /**
  26683. * Keep track of the image processing observer to allow dispose and replace.
  26684. */
  26685. private _imageProcessingObserver;
  26686. /**
  26687. * Attaches a new image processing configuration to the Standard Material.
  26688. * @param configuration
  26689. */
  26690. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26691. /**
  26692. * Gets wether the color curves effect is enabled.
  26693. */
  26694. get cameraColorCurvesEnabled(): boolean;
  26695. /**
  26696. * Sets wether the color curves effect is enabled.
  26697. */
  26698. set cameraColorCurvesEnabled(value: boolean);
  26699. /**
  26700. * Gets wether the color grading effect is enabled.
  26701. */
  26702. get cameraColorGradingEnabled(): boolean;
  26703. /**
  26704. * Gets wether the color grading effect is enabled.
  26705. */
  26706. set cameraColorGradingEnabled(value: boolean);
  26707. /**
  26708. * Gets wether tonemapping is enabled or not.
  26709. */
  26710. get cameraToneMappingEnabled(): boolean;
  26711. /**
  26712. * Sets wether tonemapping is enabled or not
  26713. */
  26714. set cameraToneMappingEnabled(value: boolean);
  26715. /**
  26716. * The camera exposure used on this material.
  26717. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26718. * This corresponds to a photographic exposure.
  26719. */
  26720. get cameraExposure(): number;
  26721. /**
  26722. * The camera exposure used on this material.
  26723. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26724. * This corresponds to a photographic exposure.
  26725. */
  26726. set cameraExposure(value: number);
  26727. /**
  26728. * Gets The camera contrast used on this material.
  26729. */
  26730. get cameraContrast(): number;
  26731. /**
  26732. * Sets The camera contrast used on this material.
  26733. */
  26734. set cameraContrast(value: number);
  26735. /**
  26736. * Gets the Color Grading 2D Lookup Texture.
  26737. */
  26738. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26739. /**
  26740. * Sets the Color Grading 2D Lookup Texture.
  26741. */
  26742. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26743. /**
  26744. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26745. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26746. * 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;
  26747. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26748. */
  26749. get cameraColorCurves(): Nullable<ColorCurves>;
  26750. /**
  26751. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26752. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26753. * 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;
  26754. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26755. */
  26756. set cameraColorCurves(value: Nullable<ColorCurves>);
  26757. /**
  26758. * Custom callback helping to override the default shader used in the material.
  26759. */
  26760. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26761. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26762. protected _worldViewProjectionMatrix: Matrix;
  26763. protected _globalAmbientColor: Color3;
  26764. protected _useLogarithmicDepth: boolean;
  26765. protected _rebuildInParallel: boolean;
  26766. /**
  26767. * Instantiates a new standard material.
  26768. * This is the default material used in Babylon. It is the best trade off between quality
  26769. * and performances.
  26770. * @see http://doc.babylonjs.com/babylon101/materials
  26771. * @param name Define the name of the material in the scene
  26772. * @param scene Define the scene the material belong to
  26773. */
  26774. constructor(name: string, scene: Scene);
  26775. /**
  26776. * Gets a boolean indicating that current material needs to register RTT
  26777. */
  26778. get hasRenderTargetTextures(): boolean;
  26779. /**
  26780. * Gets the current class name of the material e.g. "StandardMaterial"
  26781. * Mainly use in serialization.
  26782. * @returns the class name
  26783. */
  26784. getClassName(): string;
  26785. /**
  26786. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26787. * You can try switching to logarithmic depth.
  26788. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26789. */
  26790. get useLogarithmicDepth(): boolean;
  26791. set useLogarithmicDepth(value: boolean);
  26792. /**
  26793. * Specifies if the material will require alpha blending
  26794. * @returns a boolean specifying if alpha blending is needed
  26795. */
  26796. needAlphaBlending(): boolean;
  26797. /**
  26798. * Specifies if this material should be rendered in alpha test mode
  26799. * @returns a boolean specifying if an alpha test is needed.
  26800. */
  26801. needAlphaTesting(): boolean;
  26802. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26803. /**
  26804. * Get the texture used for alpha test purpose.
  26805. * @returns the diffuse texture in case of the standard material.
  26806. */
  26807. getAlphaTestTexture(): Nullable<BaseTexture>;
  26808. /**
  26809. * Get if the submesh is ready to be used and all its information available.
  26810. * Child classes can use it to update shaders
  26811. * @param mesh defines the mesh to check
  26812. * @param subMesh defines which submesh to check
  26813. * @param useInstances specifies that instances should be used
  26814. * @returns a boolean indicating that the submesh is ready or not
  26815. */
  26816. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26817. /**
  26818. * Builds the material UBO layouts.
  26819. * Used internally during the effect preparation.
  26820. */
  26821. buildUniformLayout(): void;
  26822. /**
  26823. * Unbinds the material from the mesh
  26824. */
  26825. unbind(): void;
  26826. /**
  26827. * Binds the submesh to this material by preparing the effect and shader to draw
  26828. * @param world defines the world transformation matrix
  26829. * @param mesh defines the mesh containing the submesh
  26830. * @param subMesh defines the submesh to bind the material to
  26831. */
  26832. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26833. /**
  26834. * Get the list of animatables in the material.
  26835. * @returns the list of animatables object used in the material
  26836. */
  26837. getAnimatables(): IAnimatable[];
  26838. /**
  26839. * Gets the active textures from the material
  26840. * @returns an array of textures
  26841. */
  26842. getActiveTextures(): BaseTexture[];
  26843. /**
  26844. * Specifies if the material uses a texture
  26845. * @param texture defines the texture to check against the material
  26846. * @returns a boolean specifying if the material uses the texture
  26847. */
  26848. hasTexture(texture: BaseTexture): boolean;
  26849. /**
  26850. * Disposes the material
  26851. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26852. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26853. */
  26854. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26855. /**
  26856. * Makes a duplicate of the material, and gives it a new name
  26857. * @param name defines the new name for the duplicated material
  26858. * @returns the cloned material
  26859. */
  26860. clone(name: string): StandardMaterial;
  26861. /**
  26862. * Serializes this material in a JSON representation
  26863. * @returns the serialized material object
  26864. */
  26865. serialize(): any;
  26866. /**
  26867. * Creates a standard material from parsed material data
  26868. * @param source defines the JSON representation of the material
  26869. * @param scene defines the hosting scene
  26870. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26871. * @returns a new standard material
  26872. */
  26873. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26874. /**
  26875. * Are diffuse textures enabled in the application.
  26876. */
  26877. static get DiffuseTextureEnabled(): boolean;
  26878. static set DiffuseTextureEnabled(value: boolean);
  26879. /**
  26880. * Are ambient textures enabled in the application.
  26881. */
  26882. static get AmbientTextureEnabled(): boolean;
  26883. static set AmbientTextureEnabled(value: boolean);
  26884. /**
  26885. * Are opacity textures enabled in the application.
  26886. */
  26887. static get OpacityTextureEnabled(): boolean;
  26888. static set OpacityTextureEnabled(value: boolean);
  26889. /**
  26890. * Are reflection textures enabled in the application.
  26891. */
  26892. static get ReflectionTextureEnabled(): boolean;
  26893. static set ReflectionTextureEnabled(value: boolean);
  26894. /**
  26895. * Are emissive textures enabled in the application.
  26896. */
  26897. static get EmissiveTextureEnabled(): boolean;
  26898. static set EmissiveTextureEnabled(value: boolean);
  26899. /**
  26900. * Are specular textures enabled in the application.
  26901. */
  26902. static get SpecularTextureEnabled(): boolean;
  26903. static set SpecularTextureEnabled(value: boolean);
  26904. /**
  26905. * Are bump textures enabled in the application.
  26906. */
  26907. static get BumpTextureEnabled(): boolean;
  26908. static set BumpTextureEnabled(value: boolean);
  26909. /**
  26910. * Are lightmap textures enabled in the application.
  26911. */
  26912. static get LightmapTextureEnabled(): boolean;
  26913. static set LightmapTextureEnabled(value: boolean);
  26914. /**
  26915. * Are refraction textures enabled in the application.
  26916. */
  26917. static get RefractionTextureEnabled(): boolean;
  26918. static set RefractionTextureEnabled(value: boolean);
  26919. /**
  26920. * Are color grading textures enabled in the application.
  26921. */
  26922. static get ColorGradingTextureEnabled(): boolean;
  26923. static set ColorGradingTextureEnabled(value: boolean);
  26924. /**
  26925. * Are fresnels enabled in the application.
  26926. */
  26927. static get FresnelEnabled(): boolean;
  26928. static set FresnelEnabled(value: boolean);
  26929. }
  26930. }
  26931. declare module BABYLON {
  26932. /**
  26933. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26934. *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.
  26935. * The SPS is also a particle system. It provides some methods to manage the particles.
  26936. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26937. *
  26938. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26939. */
  26940. export class SolidParticleSystem implements IDisposable {
  26941. /**
  26942. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26943. * Example : var p = SPS.particles[i];
  26944. */
  26945. particles: SolidParticle[];
  26946. /**
  26947. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26948. */
  26949. nbParticles: number;
  26950. /**
  26951. * If the particles must ever face the camera (default false). Useful for planar particles.
  26952. */
  26953. billboard: boolean;
  26954. /**
  26955. * Recompute normals when adding a shape
  26956. */
  26957. recomputeNormals: boolean;
  26958. /**
  26959. * This a counter ofr your own usage. It's not set by any SPS functions.
  26960. */
  26961. counter: number;
  26962. /**
  26963. * The SPS name. This name is also given to the underlying mesh.
  26964. */
  26965. name: string;
  26966. /**
  26967. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26968. */
  26969. mesh: Mesh;
  26970. /**
  26971. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26972. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26973. */
  26974. vars: any;
  26975. /**
  26976. * This array is populated when the SPS is set as 'pickable'.
  26977. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26978. * Each element of this array is an object `{idx: int, faceId: int}`.
  26979. * `idx` is the picked particle index in the `SPS.particles` array
  26980. * `faceId` is the picked face index counted within this particle.
  26981. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26982. */
  26983. pickedParticles: {
  26984. idx: number;
  26985. faceId: number;
  26986. }[];
  26987. /**
  26988. * This array is populated when `enableDepthSort` is set to true.
  26989. * Each element of this array is an instance of the class DepthSortedParticle.
  26990. */
  26991. depthSortedParticles: DepthSortedParticle[];
  26992. /**
  26993. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26994. * @hidden
  26995. */
  26996. _bSphereOnly: boolean;
  26997. /**
  26998. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26999. * @hidden
  27000. */
  27001. _bSphereRadiusFactor: number;
  27002. private _scene;
  27003. private _positions;
  27004. private _indices;
  27005. private _normals;
  27006. private _colors;
  27007. private _uvs;
  27008. private _indices32;
  27009. private _positions32;
  27010. private _normals32;
  27011. private _fixedNormal32;
  27012. private _colors32;
  27013. private _uvs32;
  27014. private _index;
  27015. private _updatable;
  27016. private _pickable;
  27017. private _isVisibilityBoxLocked;
  27018. private _alwaysVisible;
  27019. private _depthSort;
  27020. private _expandable;
  27021. private _shapeCounter;
  27022. private _copy;
  27023. private _color;
  27024. private _computeParticleColor;
  27025. private _computeParticleTexture;
  27026. private _computeParticleRotation;
  27027. private _computeParticleVertex;
  27028. private _computeBoundingBox;
  27029. private _depthSortParticles;
  27030. private _camera;
  27031. private _mustUnrotateFixedNormals;
  27032. private _particlesIntersect;
  27033. private _needs32Bits;
  27034. private _isNotBuilt;
  27035. private _lastParticleId;
  27036. private _idxOfId;
  27037. private _multimaterialEnabled;
  27038. private _useModelMaterial;
  27039. private _indicesByMaterial;
  27040. private _materialIndexes;
  27041. private _depthSortFunction;
  27042. private _materialSortFunction;
  27043. private _materials;
  27044. private _multimaterial;
  27045. private _materialIndexesById;
  27046. private _defaultMaterial;
  27047. private _autoUpdateSubMeshes;
  27048. /**
  27049. * Creates a SPS (Solid Particle System) object.
  27050. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27051. * @param scene (Scene) is the scene in which the SPS is added.
  27052. * @param options defines the options of the sps e.g.
  27053. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27054. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27055. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27056. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27057. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27058. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27059. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27060. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27061. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27062. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27063. */
  27064. constructor(name: string, scene: Scene, options?: {
  27065. updatable?: boolean;
  27066. isPickable?: boolean;
  27067. enableDepthSort?: boolean;
  27068. particleIntersection?: boolean;
  27069. boundingSphereOnly?: boolean;
  27070. bSphereRadiusFactor?: number;
  27071. expandable?: boolean;
  27072. useModelMaterial?: boolean;
  27073. enableMultiMaterial?: boolean;
  27074. });
  27075. /**
  27076. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27077. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27078. * @returns the created mesh
  27079. */
  27080. buildMesh(): Mesh;
  27081. /**
  27082. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27083. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27084. * Thus the particles generated from `digest()` have their property `position` set yet.
  27085. * @param mesh ( Mesh ) is the mesh to be digested
  27086. * @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
  27087. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27088. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27089. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27090. * @returns the current SPS
  27091. */
  27092. digest(mesh: Mesh, options?: {
  27093. facetNb?: number;
  27094. number?: number;
  27095. delta?: number;
  27096. storage?: [];
  27097. }): SolidParticleSystem;
  27098. /**
  27099. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27100. * @hidden
  27101. */
  27102. private _unrotateFixedNormals;
  27103. /**
  27104. * Resets the temporary working copy particle
  27105. * @hidden
  27106. */
  27107. private _resetCopy;
  27108. /**
  27109. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27110. * @param p the current index in the positions array to be updated
  27111. * @param ind the current index in the indices array
  27112. * @param shape a Vector3 array, the shape geometry
  27113. * @param positions the positions array to be updated
  27114. * @param meshInd the shape indices array
  27115. * @param indices the indices array to be updated
  27116. * @param meshUV the shape uv array
  27117. * @param uvs the uv array to be updated
  27118. * @param meshCol the shape color array
  27119. * @param colors the color array to be updated
  27120. * @param meshNor the shape normals array
  27121. * @param normals the normals array to be updated
  27122. * @param idx the particle index
  27123. * @param idxInShape the particle index in its shape
  27124. * @param options the addShape() method passed options
  27125. * @model the particle model
  27126. * @hidden
  27127. */
  27128. private _meshBuilder;
  27129. /**
  27130. * Returns a shape Vector3 array from positions float array
  27131. * @param positions float array
  27132. * @returns a vector3 array
  27133. * @hidden
  27134. */
  27135. private _posToShape;
  27136. /**
  27137. * Returns a shapeUV array from a float uvs (array deep copy)
  27138. * @param uvs as a float array
  27139. * @returns a shapeUV array
  27140. * @hidden
  27141. */
  27142. private _uvsToShapeUV;
  27143. /**
  27144. * Adds a new particle object in the particles array
  27145. * @param idx particle index in particles array
  27146. * @param id particle id
  27147. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27148. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27149. * @param model particle ModelShape object
  27150. * @param shapeId model shape identifier
  27151. * @param idxInShape index of the particle in the current model
  27152. * @param bInfo model bounding info object
  27153. * @param storage target storage array, if any
  27154. * @hidden
  27155. */
  27156. private _addParticle;
  27157. /**
  27158. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27159. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27160. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27161. * @param nb (positive integer) the number of particles to be created from this model
  27162. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27163. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27164. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27165. * @returns the number of shapes in the system
  27166. */
  27167. addShape(mesh: Mesh, nb: number, options?: {
  27168. positionFunction?: any;
  27169. vertexFunction?: any;
  27170. storage?: [];
  27171. }): number;
  27172. /**
  27173. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27174. * @hidden
  27175. */
  27176. private _rebuildParticle;
  27177. /**
  27178. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27179. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27180. * @returns the SPS.
  27181. */
  27182. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27183. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27184. * Returns an array with the removed particles.
  27185. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27186. * The SPS can't be empty so at least one particle needs to remain in place.
  27187. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27188. * @param start index of the first particle to remove
  27189. * @param end index of the last particle to remove (included)
  27190. * @returns an array populated with the removed particles
  27191. */
  27192. removeParticles(start: number, end: number): SolidParticle[];
  27193. /**
  27194. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27195. * @param solidParticleArray an array populated with Solid Particles objects
  27196. * @returns the SPS
  27197. */
  27198. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27199. /**
  27200. * Creates a new particle and modifies the SPS mesh geometry :
  27201. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27202. * - calls _addParticle() to populate the particle array
  27203. * factorized code from addShape() and insertParticlesFromArray()
  27204. * @param idx particle index in the particles array
  27205. * @param i particle index in its shape
  27206. * @param modelShape particle ModelShape object
  27207. * @param shape shape vertex array
  27208. * @param meshInd shape indices array
  27209. * @param meshUV shape uv array
  27210. * @param meshCol shape color array
  27211. * @param meshNor shape normals array
  27212. * @param bbInfo shape bounding info
  27213. * @param storage target particle storage
  27214. * @options addShape() passed options
  27215. * @hidden
  27216. */
  27217. private _insertNewParticle;
  27218. /**
  27219. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27220. * This method calls `updateParticle()` for each particle of the SPS.
  27221. * For an animated SPS, it is usually called within the render loop.
  27222. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  27223. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27224. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27225. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27226. * @returns the SPS.
  27227. */
  27228. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27229. /**
  27230. * Disposes the SPS.
  27231. */
  27232. dispose(): void;
  27233. /**
  27234. * Returns a SolidParticle object from its identifier : particle.id
  27235. * @param id (integer) the particle Id
  27236. * @returns the searched particle or null if not found in the SPS.
  27237. */
  27238. getParticleById(id: number): Nullable<SolidParticle>;
  27239. /**
  27240. * Returns a new array populated with the particles having the passed shapeId.
  27241. * @param shapeId (integer) the shape identifier
  27242. * @returns a new solid particle array
  27243. */
  27244. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27245. /**
  27246. * Populates the passed array "ref" with the particles having the passed shapeId.
  27247. * @param shapeId the shape identifier
  27248. * @returns the SPS
  27249. * @param ref
  27250. */
  27251. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27252. /**
  27253. * Computes the required SubMeshes according the materials assigned to the particles.
  27254. * @returns the solid particle system.
  27255. * Does nothing if called before the SPS mesh is built.
  27256. */
  27257. computeSubMeshes(): SolidParticleSystem;
  27258. /**
  27259. * Sorts the solid particles by material when MultiMaterial is enabled.
  27260. * Updates the indices32 array.
  27261. * Updates the indicesByMaterial array.
  27262. * Updates the mesh indices array.
  27263. * @returns the SPS
  27264. * @hidden
  27265. */
  27266. private _sortParticlesByMaterial;
  27267. /**
  27268. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27269. * @hidden
  27270. */
  27271. private _setMaterialIndexesById;
  27272. /**
  27273. * Returns an array with unique values of Materials from the passed array
  27274. * @param array the material array to be checked and filtered
  27275. * @hidden
  27276. */
  27277. private _filterUniqueMaterialId;
  27278. /**
  27279. * Sets a new Standard Material as _defaultMaterial if not already set.
  27280. * @hidden
  27281. */
  27282. private _setDefaultMaterial;
  27283. /**
  27284. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27285. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27286. * @returns the SPS.
  27287. */
  27288. refreshVisibleSize(): SolidParticleSystem;
  27289. /**
  27290. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27291. * @param size the size (float) of the visibility box
  27292. * note : this doesn't lock the SPS mesh bounding box.
  27293. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27294. */
  27295. setVisibilityBox(size: number): void;
  27296. /**
  27297. * Gets whether the SPS as always visible or not
  27298. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27299. */
  27300. get isAlwaysVisible(): boolean;
  27301. /**
  27302. * Sets the SPS as always visible or not
  27303. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27304. */
  27305. set isAlwaysVisible(val: boolean);
  27306. /**
  27307. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27308. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27309. */
  27310. set isVisibilityBoxLocked(val: boolean);
  27311. /**
  27312. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27313. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27314. */
  27315. get isVisibilityBoxLocked(): boolean;
  27316. /**
  27317. * Tells to `setParticles()` to compute the particle rotations or not.
  27318. * Default value : true. The SPS is faster when it's set to false.
  27319. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27320. */
  27321. set computeParticleRotation(val: boolean);
  27322. /**
  27323. * Tells to `setParticles()` to compute the particle colors or not.
  27324. * Default value : true. The SPS is faster when it's set to false.
  27325. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27326. */
  27327. set computeParticleColor(val: boolean);
  27328. set computeParticleTexture(val: boolean);
  27329. /**
  27330. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27331. * Default value : false. The SPS is faster when it's set to false.
  27332. * Note : the particle custom vertex positions aren't stored values.
  27333. */
  27334. set computeParticleVertex(val: boolean);
  27335. /**
  27336. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27337. */
  27338. set computeBoundingBox(val: boolean);
  27339. /**
  27340. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27341. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27342. * Default : `true`
  27343. */
  27344. set depthSortParticles(val: boolean);
  27345. /**
  27346. * Gets if `setParticles()` computes the particle rotations or not.
  27347. * Default value : true. The SPS is faster when it's set to false.
  27348. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27349. */
  27350. get computeParticleRotation(): boolean;
  27351. /**
  27352. * Gets if `setParticles()` computes the particle colors or not.
  27353. * Default value : true. The SPS is faster when it's set to false.
  27354. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27355. */
  27356. get computeParticleColor(): boolean;
  27357. /**
  27358. * Gets if `setParticles()` computes the particle textures or not.
  27359. * Default value : true. The SPS is faster when it's set to false.
  27360. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27361. */
  27362. get computeParticleTexture(): boolean;
  27363. /**
  27364. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27365. * Default value : false. The SPS is faster when it's set to false.
  27366. * Note : the particle custom vertex positions aren't stored values.
  27367. */
  27368. get computeParticleVertex(): boolean;
  27369. /**
  27370. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27371. */
  27372. get computeBoundingBox(): boolean;
  27373. /**
  27374. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27375. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27376. * Default : `true`
  27377. */
  27378. get depthSortParticles(): boolean;
  27379. /**
  27380. * Gets if the SPS is created as expandable at construction time.
  27381. * Default : `false`
  27382. */
  27383. get expandable(): boolean;
  27384. /**
  27385. * Gets if the SPS supports the Multi Materials
  27386. */
  27387. get multimaterialEnabled(): boolean;
  27388. /**
  27389. * Gets if the SPS uses the model materials for its own multimaterial.
  27390. */
  27391. get useModelMaterial(): boolean;
  27392. /**
  27393. * The SPS used material array.
  27394. */
  27395. get materials(): Material[];
  27396. /**
  27397. * Sets the SPS MultiMaterial from the passed materials.
  27398. * Note : the passed array is internally copied and not used then by reference.
  27399. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27400. */
  27401. setMultiMaterial(materials: Material[]): void;
  27402. /**
  27403. * The SPS computed multimaterial object
  27404. */
  27405. get multimaterial(): MultiMaterial;
  27406. set multimaterial(mm: MultiMaterial);
  27407. /**
  27408. * If the subMeshes must be updated on the next call to setParticles()
  27409. */
  27410. get autoUpdateSubMeshes(): boolean;
  27411. set autoUpdateSubMeshes(val: boolean);
  27412. /**
  27413. * This function does nothing. It may be overwritten to set all the particle first values.
  27414. * The SPS doesn't call this function, you may have to call it by your own.
  27415. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27416. */
  27417. initParticles(): void;
  27418. /**
  27419. * This function does nothing. It may be overwritten to recycle a particle.
  27420. * The SPS doesn't call this function, you may have to call it by your own.
  27421. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27422. * @param particle The particle to recycle
  27423. * @returns the recycled particle
  27424. */
  27425. recycleParticle(particle: SolidParticle): SolidParticle;
  27426. /**
  27427. * Updates a particle : this function should be overwritten by the user.
  27428. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27429. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27430. * @example : just set a particle position or velocity and recycle conditions
  27431. * @param particle The particle to update
  27432. * @returns the updated particle
  27433. */
  27434. updateParticle(particle: SolidParticle): SolidParticle;
  27435. /**
  27436. * Updates a vertex of a particle : it can be overwritten by the user.
  27437. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27438. * @param particle the current particle
  27439. * @param vertex the current index of the current particle
  27440. * @param pt the index of the current vertex in the particle shape
  27441. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27442. * @example : just set a vertex particle position
  27443. * @returns the updated vertex
  27444. */
  27445. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27446. /**
  27447. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27448. * This does nothing and may be overwritten by the user.
  27449. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27450. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27451. * @param update the boolean update value actually passed to setParticles()
  27452. */
  27453. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27454. /**
  27455. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27456. * This will be passed three parameters.
  27457. * This does nothing and may be overwritten by the user.
  27458. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27459. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27460. * @param update the boolean update value actually passed to setParticles()
  27461. */
  27462. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27463. }
  27464. }
  27465. declare module BABYLON {
  27466. /**
  27467. * Represents one particle of a solid particle system.
  27468. */
  27469. export class SolidParticle {
  27470. /**
  27471. * particle global index
  27472. */
  27473. idx: number;
  27474. /**
  27475. * particle identifier
  27476. */
  27477. id: number;
  27478. /**
  27479. * The color of the particle
  27480. */
  27481. color: Nullable<Color4>;
  27482. /**
  27483. * The world space position of the particle.
  27484. */
  27485. position: Vector3;
  27486. /**
  27487. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27488. */
  27489. rotation: Vector3;
  27490. /**
  27491. * The world space rotation quaternion of the particle.
  27492. */
  27493. rotationQuaternion: Nullable<Quaternion>;
  27494. /**
  27495. * The scaling of the particle.
  27496. */
  27497. scaling: Vector3;
  27498. /**
  27499. * The uvs of the particle.
  27500. */
  27501. uvs: Vector4;
  27502. /**
  27503. * The current speed of the particle.
  27504. */
  27505. velocity: Vector3;
  27506. /**
  27507. * The pivot point in the particle local space.
  27508. */
  27509. pivot: Vector3;
  27510. /**
  27511. * Must the particle be translated from its pivot point in its local space ?
  27512. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27513. * Default : false
  27514. */
  27515. translateFromPivot: boolean;
  27516. /**
  27517. * Is the particle active or not ?
  27518. */
  27519. alive: boolean;
  27520. /**
  27521. * Is the particle visible or not ?
  27522. */
  27523. isVisible: boolean;
  27524. /**
  27525. * Index of this particle in the global "positions" array (Internal use)
  27526. * @hidden
  27527. */
  27528. _pos: number;
  27529. /**
  27530. * @hidden Index of this particle in the global "indices" array (Internal use)
  27531. */
  27532. _ind: number;
  27533. /**
  27534. * @hidden ModelShape of this particle (Internal use)
  27535. */
  27536. _model: ModelShape;
  27537. /**
  27538. * ModelShape id of this particle
  27539. */
  27540. shapeId: number;
  27541. /**
  27542. * Index of the particle in its shape id
  27543. */
  27544. idxInShape: number;
  27545. /**
  27546. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27547. */
  27548. _modelBoundingInfo: BoundingInfo;
  27549. /**
  27550. * @hidden Particle BoundingInfo object (Internal use)
  27551. */
  27552. _boundingInfo: BoundingInfo;
  27553. /**
  27554. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27555. */
  27556. _sps: SolidParticleSystem;
  27557. /**
  27558. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27559. */
  27560. _stillInvisible: boolean;
  27561. /**
  27562. * @hidden Last computed particle rotation matrix
  27563. */
  27564. _rotationMatrix: number[];
  27565. /**
  27566. * Parent particle Id, if any.
  27567. * Default null.
  27568. */
  27569. parentId: Nullable<number>;
  27570. /**
  27571. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27572. */
  27573. materialIndex: Nullable<number>;
  27574. /**
  27575. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27576. * The possible values are :
  27577. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27578. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27579. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27580. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27581. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27582. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27583. * */
  27584. cullingStrategy: number;
  27585. /**
  27586. * @hidden Internal global position in the SPS.
  27587. */
  27588. _globalPosition: Vector3;
  27589. /**
  27590. * Creates a Solid Particle object.
  27591. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27592. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27593. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27594. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27595. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27596. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27597. * @param shapeId (integer) is the model shape identifier in the SPS.
  27598. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27599. * @param sps defines the sps it is associated to
  27600. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27601. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27602. */
  27603. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27604. /**
  27605. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27606. * @param target the particle target
  27607. * @returns the current particle
  27608. */
  27609. copyToRef(target: SolidParticle): SolidParticle;
  27610. /**
  27611. * Legacy support, changed scale to scaling
  27612. */
  27613. get scale(): Vector3;
  27614. /**
  27615. * Legacy support, changed scale to scaling
  27616. */
  27617. set scale(scale: Vector3);
  27618. /**
  27619. * Legacy support, changed quaternion to rotationQuaternion
  27620. */
  27621. get quaternion(): Nullable<Quaternion>;
  27622. /**
  27623. * Legacy support, changed quaternion to rotationQuaternion
  27624. */
  27625. set quaternion(q: Nullable<Quaternion>);
  27626. /**
  27627. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27628. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27629. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27630. * @returns true if it intersects
  27631. */
  27632. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27633. /**
  27634. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27635. * A particle is in the frustum if its bounding box intersects the frustum
  27636. * @param frustumPlanes defines the frustum to test
  27637. * @returns true if the particle is in the frustum planes
  27638. */
  27639. isInFrustum(frustumPlanes: Plane[]): boolean;
  27640. /**
  27641. * get the rotation matrix of the particle
  27642. * @hidden
  27643. */
  27644. getRotationMatrix(m: Matrix): void;
  27645. }
  27646. /**
  27647. * Represents the shape of the model used by one particle of a solid particle system.
  27648. * SPS internal tool, don't use it manually.
  27649. */
  27650. export class ModelShape {
  27651. /**
  27652. * The shape id
  27653. * @hidden
  27654. */
  27655. shapeID: number;
  27656. /**
  27657. * flat array of model positions (internal use)
  27658. * @hidden
  27659. */
  27660. _shape: Vector3[];
  27661. /**
  27662. * flat array of model UVs (internal use)
  27663. * @hidden
  27664. */
  27665. _shapeUV: number[];
  27666. /**
  27667. * color array of the model
  27668. * @hidden
  27669. */
  27670. _shapeColors: number[];
  27671. /**
  27672. * indices array of the model
  27673. * @hidden
  27674. */
  27675. _indices: number[];
  27676. /**
  27677. * normals array of the model
  27678. * @hidden
  27679. */
  27680. _normals: number[];
  27681. /**
  27682. * length of the shape in the model indices array (internal use)
  27683. * @hidden
  27684. */
  27685. _indicesLength: number;
  27686. /**
  27687. * Custom position function (internal use)
  27688. * @hidden
  27689. */
  27690. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27691. /**
  27692. * Custom vertex function (internal use)
  27693. * @hidden
  27694. */
  27695. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27696. /**
  27697. * Model material (internal use)
  27698. * @hidden
  27699. */
  27700. _material: Nullable<Material>;
  27701. /**
  27702. * 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.
  27703. * SPS internal tool, don't use it manually.
  27704. * @hidden
  27705. */
  27706. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  27707. }
  27708. /**
  27709. * Represents a Depth Sorted Particle in the solid particle system.
  27710. * @hidden
  27711. */
  27712. export class DepthSortedParticle {
  27713. /**
  27714. * Index of the particle in the "indices" array
  27715. */
  27716. ind: number;
  27717. /**
  27718. * Length of the particle shape in the "indices" array
  27719. */
  27720. indicesLength: number;
  27721. /**
  27722. * Squared distance from the particle to the camera
  27723. */
  27724. sqDistance: number;
  27725. /**
  27726. * Material index when used with MultiMaterials
  27727. */
  27728. materialIndex: number;
  27729. /**
  27730. * Creates a new sorted particle
  27731. * @param materialIndex
  27732. */
  27733. constructor(ind: number, indLength: number, materialIndex: number);
  27734. }
  27735. }
  27736. declare module BABYLON {
  27737. /**
  27738. * @hidden
  27739. */
  27740. export class _MeshCollisionData {
  27741. _checkCollisions: boolean;
  27742. _collisionMask: number;
  27743. _collisionGroup: number;
  27744. _collider: Nullable<Collider>;
  27745. _oldPositionForCollisions: Vector3;
  27746. _diffPositionForCollisions: Vector3;
  27747. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27748. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27749. }
  27750. }
  27751. declare module BABYLON {
  27752. /** @hidden */
  27753. class _FacetDataStorage {
  27754. facetPositions: Vector3[];
  27755. facetNormals: Vector3[];
  27756. facetPartitioning: number[][];
  27757. facetNb: number;
  27758. partitioningSubdivisions: number;
  27759. partitioningBBoxRatio: number;
  27760. facetDataEnabled: boolean;
  27761. facetParameters: any;
  27762. bbSize: Vector3;
  27763. subDiv: {
  27764. max: number;
  27765. X: number;
  27766. Y: number;
  27767. Z: number;
  27768. };
  27769. facetDepthSort: boolean;
  27770. facetDepthSortEnabled: boolean;
  27771. depthSortedIndices: IndicesArray;
  27772. depthSortedFacets: {
  27773. ind: number;
  27774. sqDistance: number;
  27775. }[];
  27776. facetDepthSortFunction: (f1: {
  27777. ind: number;
  27778. sqDistance: number;
  27779. }, f2: {
  27780. ind: number;
  27781. sqDistance: number;
  27782. }) => number;
  27783. facetDepthSortFrom: Vector3;
  27784. facetDepthSortOrigin: Vector3;
  27785. invertedMatrix: Matrix;
  27786. }
  27787. /**
  27788. * @hidden
  27789. **/
  27790. class _InternalAbstractMeshDataInfo {
  27791. _hasVertexAlpha: boolean;
  27792. _useVertexColors: boolean;
  27793. _numBoneInfluencers: number;
  27794. _applyFog: boolean;
  27795. _receiveShadows: boolean;
  27796. _facetData: _FacetDataStorage;
  27797. _visibility: number;
  27798. _skeleton: Nullable<Skeleton>;
  27799. _layerMask: number;
  27800. _computeBonesUsingShaders: boolean;
  27801. _isActive: boolean;
  27802. _onlyForInstances: boolean;
  27803. _isActiveIntermediate: boolean;
  27804. _onlyForInstancesIntermediate: boolean;
  27805. _actAsRegularMesh: boolean;
  27806. }
  27807. /**
  27808. * Class used to store all common mesh properties
  27809. */
  27810. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27811. /** No occlusion */
  27812. static OCCLUSION_TYPE_NONE: number;
  27813. /** Occlusion set to optimisitic */
  27814. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27815. /** Occlusion set to strict */
  27816. static OCCLUSION_TYPE_STRICT: number;
  27817. /** Use an accurante occlusion algorithm */
  27818. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27819. /** Use a conservative occlusion algorithm */
  27820. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27821. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27822. * Test order :
  27823. * Is the bounding sphere outside the frustum ?
  27824. * If not, are the bounding box vertices outside the frustum ?
  27825. * It not, then the cullable object is in the frustum.
  27826. */
  27827. static readonly CULLINGSTRATEGY_STANDARD: number;
  27828. /** Culling strategy : Bounding Sphere Only.
  27829. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27830. * It's also less accurate than the standard because some not visible objects can still be selected.
  27831. * Test : is the bounding sphere outside the frustum ?
  27832. * If not, then the cullable object is in the frustum.
  27833. */
  27834. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27835. /** Culling strategy : Optimistic Inclusion.
  27836. * This in an inclusion test first, then the standard exclusion test.
  27837. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27838. * 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.
  27839. * Anyway, it's as accurate as the standard strategy.
  27840. * Test :
  27841. * Is the cullable object bounding sphere center in the frustum ?
  27842. * If not, apply the default culling strategy.
  27843. */
  27844. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27845. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27846. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27847. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27848. * 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.
  27849. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27850. * Test :
  27851. * Is the cullable object bounding sphere center in the frustum ?
  27852. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27853. */
  27854. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27855. /**
  27856. * No billboard
  27857. */
  27858. static get BILLBOARDMODE_NONE(): number;
  27859. /** Billboard on X axis */
  27860. static get BILLBOARDMODE_X(): number;
  27861. /** Billboard on Y axis */
  27862. static get BILLBOARDMODE_Y(): number;
  27863. /** Billboard on Z axis */
  27864. static get BILLBOARDMODE_Z(): number;
  27865. /** Billboard on all axes */
  27866. static get BILLBOARDMODE_ALL(): number;
  27867. /** Billboard on using position instead of orientation */
  27868. static get BILLBOARDMODE_USE_POSITION(): number;
  27869. /** @hidden */
  27870. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27871. /**
  27872. * The culling strategy to use to check whether the mesh must be rendered or not.
  27873. * This value can be changed at any time and will be used on the next render mesh selection.
  27874. * The possible values are :
  27875. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27876. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27877. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27878. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27879. * Please read each static variable documentation to get details about the culling process.
  27880. * */
  27881. cullingStrategy: number;
  27882. /**
  27883. * Gets the number of facets in the mesh
  27884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27885. */
  27886. get facetNb(): number;
  27887. /**
  27888. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27890. */
  27891. get partitioningSubdivisions(): number;
  27892. set partitioningSubdivisions(nb: number);
  27893. /**
  27894. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27895. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27896. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27897. */
  27898. get partitioningBBoxRatio(): number;
  27899. set partitioningBBoxRatio(ratio: number);
  27900. /**
  27901. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27902. * Works only for updatable meshes.
  27903. * Doesn't work with multi-materials
  27904. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27905. */
  27906. get mustDepthSortFacets(): boolean;
  27907. set mustDepthSortFacets(sort: boolean);
  27908. /**
  27909. * The location (Vector3) where the facet depth sort must be computed from.
  27910. * By default, the active camera position.
  27911. * Used only when facet depth sort is enabled
  27912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27913. */
  27914. get facetDepthSortFrom(): Vector3;
  27915. set facetDepthSortFrom(location: Vector3);
  27916. /**
  27917. * gets a boolean indicating if facetData is enabled
  27918. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27919. */
  27920. get isFacetDataEnabled(): boolean;
  27921. /** @hidden */
  27922. _updateNonUniformScalingState(value: boolean): boolean;
  27923. /**
  27924. * An event triggered when this mesh collides with another one
  27925. */
  27926. onCollideObservable: Observable<AbstractMesh>;
  27927. /** Set a function to call when this mesh collides with another one */
  27928. set onCollide(callback: () => void);
  27929. /**
  27930. * An event triggered when the collision's position changes
  27931. */
  27932. onCollisionPositionChangeObservable: Observable<Vector3>;
  27933. /** Set a function to call when the collision's position changes */
  27934. set onCollisionPositionChange(callback: () => void);
  27935. /**
  27936. * An event triggered when material is changed
  27937. */
  27938. onMaterialChangedObservable: Observable<AbstractMesh>;
  27939. /**
  27940. * Gets or sets the orientation for POV movement & rotation
  27941. */
  27942. definedFacingForward: boolean;
  27943. /** @hidden */
  27944. _occlusionQuery: Nullable<WebGLQuery>;
  27945. /** @hidden */
  27946. _renderingGroup: Nullable<RenderingGroup>;
  27947. /**
  27948. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27949. */
  27950. get visibility(): number;
  27951. /**
  27952. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27953. */
  27954. set visibility(value: number);
  27955. /** Gets or sets the alpha index used to sort transparent meshes
  27956. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27957. */
  27958. alphaIndex: number;
  27959. /**
  27960. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27961. */
  27962. isVisible: boolean;
  27963. /**
  27964. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27965. */
  27966. isPickable: boolean;
  27967. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27968. showSubMeshesBoundingBox: boolean;
  27969. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27970. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27971. */
  27972. isBlocker: boolean;
  27973. /**
  27974. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27975. */
  27976. enablePointerMoveEvents: boolean;
  27977. /**
  27978. * Specifies the rendering group id for this mesh (0 by default)
  27979. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27980. */
  27981. renderingGroupId: number;
  27982. private _material;
  27983. /** Gets or sets current material */
  27984. get material(): Nullable<Material>;
  27985. set material(value: Nullable<Material>);
  27986. /**
  27987. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27988. * @see http://doc.babylonjs.com/babylon101/shadows
  27989. */
  27990. get receiveShadows(): boolean;
  27991. set receiveShadows(value: boolean);
  27992. /** Defines color to use when rendering outline */
  27993. outlineColor: Color3;
  27994. /** Define width to use when rendering outline */
  27995. outlineWidth: number;
  27996. /** Defines color to use when rendering overlay */
  27997. overlayColor: Color3;
  27998. /** Defines alpha to use when rendering overlay */
  27999. overlayAlpha: number;
  28000. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28001. get hasVertexAlpha(): boolean;
  28002. set hasVertexAlpha(value: boolean);
  28003. /** 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) */
  28004. get useVertexColors(): boolean;
  28005. set useVertexColors(value: boolean);
  28006. /**
  28007. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28008. */
  28009. get computeBonesUsingShaders(): boolean;
  28010. set computeBonesUsingShaders(value: boolean);
  28011. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28012. get numBoneInfluencers(): number;
  28013. set numBoneInfluencers(value: number);
  28014. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28015. get applyFog(): boolean;
  28016. set applyFog(value: boolean);
  28017. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28018. useOctreeForRenderingSelection: boolean;
  28019. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28020. useOctreeForPicking: boolean;
  28021. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28022. useOctreeForCollisions: boolean;
  28023. /**
  28024. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28025. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28026. */
  28027. get layerMask(): number;
  28028. set layerMask(value: number);
  28029. /**
  28030. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28031. */
  28032. alwaysSelectAsActiveMesh: boolean;
  28033. /**
  28034. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28035. */
  28036. doNotSyncBoundingInfo: boolean;
  28037. /**
  28038. * Gets or sets the current action manager
  28039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28040. */
  28041. actionManager: Nullable<AbstractActionManager>;
  28042. private _meshCollisionData;
  28043. /**
  28044. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28045. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28046. */
  28047. ellipsoid: Vector3;
  28048. /**
  28049. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28050. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28051. */
  28052. ellipsoidOffset: Vector3;
  28053. /**
  28054. * Gets or sets a collision mask used to mask collisions (default is -1).
  28055. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28056. */
  28057. get collisionMask(): number;
  28058. set collisionMask(mask: number);
  28059. /**
  28060. * Gets or sets the current collision group mask (-1 by default).
  28061. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28062. */
  28063. get collisionGroup(): number;
  28064. set collisionGroup(mask: number);
  28065. /**
  28066. * Defines edge width used when edgesRenderer is enabled
  28067. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28068. */
  28069. edgesWidth: number;
  28070. /**
  28071. * Defines edge color used when edgesRenderer is enabled
  28072. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28073. */
  28074. edgesColor: Color4;
  28075. /** @hidden */
  28076. _edgesRenderer: Nullable<IEdgesRenderer>;
  28077. /** @hidden */
  28078. _masterMesh: Nullable<AbstractMesh>;
  28079. /** @hidden */
  28080. _boundingInfo: Nullable<BoundingInfo>;
  28081. /** @hidden */
  28082. _renderId: number;
  28083. /**
  28084. * Gets or sets the list of subMeshes
  28085. * @see http://doc.babylonjs.com/how_to/multi_materials
  28086. */
  28087. subMeshes: SubMesh[];
  28088. /** @hidden */
  28089. _intersectionsInProgress: AbstractMesh[];
  28090. /** @hidden */
  28091. _unIndexed: boolean;
  28092. /** @hidden */
  28093. _lightSources: Light[];
  28094. /** Gets the list of lights affecting that mesh */
  28095. get lightSources(): Light[];
  28096. /** @hidden */
  28097. get _positions(): Nullable<Vector3[]>;
  28098. /** @hidden */
  28099. _waitingData: {
  28100. lods: Nullable<any>;
  28101. actions: Nullable<any>;
  28102. freezeWorldMatrix: Nullable<boolean>;
  28103. };
  28104. /** @hidden */
  28105. _bonesTransformMatrices: Nullable<Float32Array>;
  28106. /** @hidden */
  28107. _transformMatrixTexture: Nullable<RawTexture>;
  28108. /**
  28109. * Gets or sets a skeleton to apply skining transformations
  28110. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28111. */
  28112. set skeleton(value: Nullable<Skeleton>);
  28113. get skeleton(): Nullable<Skeleton>;
  28114. /**
  28115. * An event triggered when the mesh is rebuilt.
  28116. */
  28117. onRebuildObservable: Observable<AbstractMesh>;
  28118. /**
  28119. * Creates a new AbstractMesh
  28120. * @param name defines the name of the mesh
  28121. * @param scene defines the hosting scene
  28122. */
  28123. constructor(name: string, scene?: Nullable<Scene>);
  28124. /**
  28125. * Returns the string "AbstractMesh"
  28126. * @returns "AbstractMesh"
  28127. */
  28128. getClassName(): string;
  28129. /**
  28130. * Gets a string representation of the current mesh
  28131. * @param fullDetails defines a boolean indicating if full details must be included
  28132. * @returns a string representation of the current mesh
  28133. */
  28134. toString(fullDetails?: boolean): string;
  28135. /**
  28136. * @hidden
  28137. */
  28138. protected _getEffectiveParent(): Nullable<Node>;
  28139. /** @hidden */
  28140. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28141. /** @hidden */
  28142. _rebuild(): void;
  28143. /** @hidden */
  28144. _resyncLightSources(): void;
  28145. /** @hidden */
  28146. _resyncLightSource(light: Light): void;
  28147. /** @hidden */
  28148. _unBindEffect(): void;
  28149. /** @hidden */
  28150. _removeLightSource(light: Light, dispose: boolean): void;
  28151. private _markSubMeshesAsDirty;
  28152. /** @hidden */
  28153. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28154. /** @hidden */
  28155. _markSubMeshesAsAttributesDirty(): void;
  28156. /** @hidden */
  28157. _markSubMeshesAsMiscDirty(): void;
  28158. /**
  28159. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28160. */
  28161. get scaling(): Vector3;
  28162. set scaling(newScaling: Vector3);
  28163. /**
  28164. * Returns true if the mesh is blocked. Implemented by child classes
  28165. */
  28166. get isBlocked(): boolean;
  28167. /**
  28168. * Returns the mesh itself by default. Implemented by child classes
  28169. * @param camera defines the camera to use to pick the right LOD level
  28170. * @returns the currentAbstractMesh
  28171. */
  28172. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28173. /**
  28174. * Returns 0 by default. Implemented by child classes
  28175. * @returns an integer
  28176. */
  28177. getTotalVertices(): number;
  28178. /**
  28179. * Returns a positive integer : the total number of indices in this mesh geometry.
  28180. * @returns the numner of indices or zero if the mesh has no geometry.
  28181. */
  28182. getTotalIndices(): number;
  28183. /**
  28184. * Returns null by default. Implemented by child classes
  28185. * @returns null
  28186. */
  28187. getIndices(): Nullable<IndicesArray>;
  28188. /**
  28189. * Returns the array of the requested vertex data kind. Implemented by child classes
  28190. * @param kind defines the vertex data kind to use
  28191. * @returns null
  28192. */
  28193. getVerticesData(kind: string): Nullable<FloatArray>;
  28194. /**
  28195. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28196. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28197. * Note that a new underlying VertexBuffer object is created each call.
  28198. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28199. * @param kind defines vertex data kind:
  28200. * * VertexBuffer.PositionKind
  28201. * * VertexBuffer.UVKind
  28202. * * VertexBuffer.UV2Kind
  28203. * * VertexBuffer.UV3Kind
  28204. * * VertexBuffer.UV4Kind
  28205. * * VertexBuffer.UV5Kind
  28206. * * VertexBuffer.UV6Kind
  28207. * * VertexBuffer.ColorKind
  28208. * * VertexBuffer.MatricesIndicesKind
  28209. * * VertexBuffer.MatricesIndicesExtraKind
  28210. * * VertexBuffer.MatricesWeightsKind
  28211. * * VertexBuffer.MatricesWeightsExtraKind
  28212. * @param data defines the data source
  28213. * @param updatable defines if the data must be flagged as updatable (or static)
  28214. * @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
  28215. * @returns the current mesh
  28216. */
  28217. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28218. /**
  28219. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28220. * If the mesh has no geometry, it is simply returned as it is.
  28221. * @param kind defines vertex data kind:
  28222. * * VertexBuffer.PositionKind
  28223. * * VertexBuffer.UVKind
  28224. * * VertexBuffer.UV2Kind
  28225. * * VertexBuffer.UV3Kind
  28226. * * VertexBuffer.UV4Kind
  28227. * * VertexBuffer.UV5Kind
  28228. * * VertexBuffer.UV6Kind
  28229. * * VertexBuffer.ColorKind
  28230. * * VertexBuffer.MatricesIndicesKind
  28231. * * VertexBuffer.MatricesIndicesExtraKind
  28232. * * VertexBuffer.MatricesWeightsKind
  28233. * * VertexBuffer.MatricesWeightsExtraKind
  28234. * @param data defines the data source
  28235. * @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
  28236. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28237. * @returns the current mesh
  28238. */
  28239. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28240. /**
  28241. * Sets the mesh indices,
  28242. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28243. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28244. * @param totalVertices Defines the total number of vertices
  28245. * @returns the current mesh
  28246. */
  28247. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28248. /**
  28249. * Gets a boolean indicating if specific vertex data is present
  28250. * @param kind defines the vertex data kind to use
  28251. * @returns true is data kind is present
  28252. */
  28253. isVerticesDataPresent(kind: string): boolean;
  28254. /**
  28255. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28256. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28257. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28258. * @returns a BoundingInfo
  28259. */
  28260. getBoundingInfo(): BoundingInfo;
  28261. /**
  28262. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28263. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28264. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28265. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28266. * @returns the current mesh
  28267. */
  28268. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28269. /**
  28270. * Overwrite the current bounding info
  28271. * @param boundingInfo defines the new bounding info
  28272. * @returns the current mesh
  28273. */
  28274. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28275. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28276. get useBones(): boolean;
  28277. /** @hidden */
  28278. _preActivate(): void;
  28279. /** @hidden */
  28280. _preActivateForIntermediateRendering(renderId: number): void;
  28281. /** @hidden */
  28282. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28283. /** @hidden */
  28284. _postActivate(): void;
  28285. /** @hidden */
  28286. _freeze(): void;
  28287. /** @hidden */
  28288. _unFreeze(): void;
  28289. /**
  28290. * Gets the current world matrix
  28291. * @returns a Matrix
  28292. */
  28293. getWorldMatrix(): Matrix;
  28294. /** @hidden */
  28295. _getWorldMatrixDeterminant(): number;
  28296. /**
  28297. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28298. */
  28299. get isAnInstance(): boolean;
  28300. /**
  28301. * Gets a boolean indicating if this mesh has instances
  28302. */
  28303. get hasInstances(): boolean;
  28304. /**
  28305. * Perform relative position change from the point of view of behind the front of the mesh.
  28306. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28307. * Supports definition of mesh facing forward or backward
  28308. * @param amountRight defines the distance on the right axis
  28309. * @param amountUp defines the distance on the up axis
  28310. * @param amountForward defines the distance on the forward axis
  28311. * @returns the current mesh
  28312. */
  28313. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28314. /**
  28315. * Calculate relative position change from the point of view of behind the front of the mesh.
  28316. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28317. * Supports definition of mesh facing forward or backward
  28318. * @param amountRight defines the distance on the right axis
  28319. * @param amountUp defines the distance on the up axis
  28320. * @param amountForward defines the distance on the forward axis
  28321. * @returns the new displacement vector
  28322. */
  28323. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28324. /**
  28325. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28326. * Supports definition of mesh facing forward or backward
  28327. * @param flipBack defines the flip
  28328. * @param twirlClockwise defines the twirl
  28329. * @param tiltRight defines the tilt
  28330. * @returns the current mesh
  28331. */
  28332. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28333. /**
  28334. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28335. * Supports definition of mesh facing forward or backward.
  28336. * @param flipBack defines the flip
  28337. * @param twirlClockwise defines the twirl
  28338. * @param tiltRight defines the tilt
  28339. * @returns the new rotation vector
  28340. */
  28341. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28342. /**
  28343. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28344. * This means the mesh underlying bounding box and sphere are recomputed.
  28345. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28346. * @returns the current mesh
  28347. */
  28348. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28349. /** @hidden */
  28350. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28351. /** @hidden */
  28352. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28353. /** @hidden */
  28354. _updateBoundingInfo(): AbstractMesh;
  28355. /** @hidden */
  28356. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28357. /** @hidden */
  28358. protected _afterComputeWorldMatrix(): void;
  28359. /** @hidden */
  28360. get _effectiveMesh(): AbstractMesh;
  28361. /**
  28362. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28363. * A mesh is in the frustum if its bounding box intersects the frustum
  28364. * @param frustumPlanes defines the frustum to test
  28365. * @returns true if the mesh is in the frustum planes
  28366. */
  28367. isInFrustum(frustumPlanes: Plane[]): boolean;
  28368. /**
  28369. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28370. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28371. * @param frustumPlanes defines the frustum to test
  28372. * @returns true if the mesh is completely in the frustum planes
  28373. */
  28374. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28375. /**
  28376. * True if the mesh intersects another mesh or a SolidParticle object
  28377. * @param mesh defines a target mesh or SolidParticle to test
  28378. * @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)
  28379. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28380. * @returns true if there is an intersection
  28381. */
  28382. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28383. /**
  28384. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28385. * @param point defines the point to test
  28386. * @returns true if there is an intersection
  28387. */
  28388. intersectsPoint(point: Vector3): boolean;
  28389. /**
  28390. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28392. */
  28393. get checkCollisions(): boolean;
  28394. set checkCollisions(collisionEnabled: boolean);
  28395. /**
  28396. * Gets Collider object used to compute collisions (not physics)
  28397. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28398. */
  28399. get collider(): Nullable<Collider>;
  28400. /**
  28401. * Move the mesh using collision engine
  28402. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28403. * @param displacement defines the requested displacement vector
  28404. * @returns the current mesh
  28405. */
  28406. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28407. private _onCollisionPositionChange;
  28408. /** @hidden */
  28409. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28410. /** @hidden */
  28411. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28412. /** @hidden */
  28413. _checkCollision(collider: Collider): AbstractMesh;
  28414. /** @hidden */
  28415. _generatePointsArray(): boolean;
  28416. /**
  28417. * Checks if the passed Ray intersects with the mesh
  28418. * @param ray defines the ray to use
  28419. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28420. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28421. * @returns the picking info
  28422. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28423. */
  28424. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28425. /**
  28426. * Clones the current mesh
  28427. * @param name defines the mesh name
  28428. * @param newParent defines the new mesh parent
  28429. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28430. * @returns the new mesh
  28431. */
  28432. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28433. /**
  28434. * Disposes all the submeshes of the current meshnp
  28435. * @returns the current mesh
  28436. */
  28437. releaseSubMeshes(): AbstractMesh;
  28438. /**
  28439. * Releases resources associated with this abstract mesh.
  28440. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28441. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28442. */
  28443. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28444. /**
  28445. * Adds the passed mesh as a child to the current mesh
  28446. * @param mesh defines the child mesh
  28447. * @returns the current mesh
  28448. */
  28449. addChild(mesh: AbstractMesh): AbstractMesh;
  28450. /**
  28451. * Removes the passed mesh from the current mesh children list
  28452. * @param mesh defines the child mesh
  28453. * @returns the current mesh
  28454. */
  28455. removeChild(mesh: AbstractMesh): AbstractMesh;
  28456. /** @hidden */
  28457. private _initFacetData;
  28458. /**
  28459. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28460. * This method can be called within the render loop.
  28461. * 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
  28462. * @returns the current mesh
  28463. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28464. */
  28465. updateFacetData(): AbstractMesh;
  28466. /**
  28467. * Returns the facetLocalNormals array.
  28468. * The normals are expressed in the mesh local spac
  28469. * @returns an array of Vector3
  28470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28471. */
  28472. getFacetLocalNormals(): Vector3[];
  28473. /**
  28474. * Returns the facetLocalPositions array.
  28475. * The facet positions are expressed in the mesh local space
  28476. * @returns an array of Vector3
  28477. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28478. */
  28479. getFacetLocalPositions(): Vector3[];
  28480. /**
  28481. * Returns the facetLocalPartioning array
  28482. * @returns an array of array of numbers
  28483. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28484. */
  28485. getFacetLocalPartitioning(): number[][];
  28486. /**
  28487. * Returns the i-th facet position in the world system.
  28488. * This method allocates a new Vector3 per call
  28489. * @param i defines the facet index
  28490. * @returns a new Vector3
  28491. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28492. */
  28493. getFacetPosition(i: number): Vector3;
  28494. /**
  28495. * Sets the reference Vector3 with the i-th facet position in the world system
  28496. * @param i defines the facet index
  28497. * @param ref defines the target vector
  28498. * @returns the current mesh
  28499. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28500. */
  28501. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28502. /**
  28503. * Returns the i-th facet normal in the world system.
  28504. * This method allocates a new Vector3 per call
  28505. * @param i defines the facet index
  28506. * @returns a new Vector3
  28507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28508. */
  28509. getFacetNormal(i: number): Vector3;
  28510. /**
  28511. * Sets the reference Vector3 with the i-th facet normal in the world system
  28512. * @param i defines the facet index
  28513. * @param ref defines the target vector
  28514. * @returns the current mesh
  28515. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28516. */
  28517. getFacetNormalToRef(i: number, ref: Vector3): this;
  28518. /**
  28519. * 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)
  28520. * @param x defines x coordinate
  28521. * @param y defines y coordinate
  28522. * @param z defines z coordinate
  28523. * @returns the array of facet indexes
  28524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28525. */
  28526. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28527. /**
  28528. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28529. * @param projected sets as the (x,y,z) world projection on the facet
  28530. * @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
  28531. * @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
  28532. * @param x defines x coordinate
  28533. * @param y defines y coordinate
  28534. * @param z defines z coordinate
  28535. * @returns the face index if found (or null instead)
  28536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28537. */
  28538. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28539. /**
  28540. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28541. * @param projected sets as the (x,y,z) local projection on the facet
  28542. * @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
  28543. * @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
  28544. * @param x defines x coordinate
  28545. * @param y defines y coordinate
  28546. * @param z defines z coordinate
  28547. * @returns the face index if found (or null instead)
  28548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28549. */
  28550. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28551. /**
  28552. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28553. * @returns the parameters
  28554. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28555. */
  28556. getFacetDataParameters(): any;
  28557. /**
  28558. * Disables the feature FacetData and frees the related memory
  28559. * @returns the current mesh
  28560. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28561. */
  28562. disableFacetData(): AbstractMesh;
  28563. /**
  28564. * Updates the AbstractMesh indices array
  28565. * @param indices defines the data source
  28566. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28567. * @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)
  28568. * @returns the current mesh
  28569. */
  28570. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28571. /**
  28572. * Creates new normals data for the mesh
  28573. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28574. * @returns the current mesh
  28575. */
  28576. createNormals(updatable: boolean): AbstractMesh;
  28577. /**
  28578. * Align the mesh with a normal
  28579. * @param normal defines the normal to use
  28580. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28581. * @returns the current mesh
  28582. */
  28583. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28584. /** @hidden */
  28585. _checkOcclusionQuery(): boolean;
  28586. /**
  28587. * Disables the mesh edge rendering mode
  28588. * @returns the currentAbstractMesh
  28589. */
  28590. disableEdgesRendering(): AbstractMesh;
  28591. /**
  28592. * Enables the edge rendering mode on the mesh.
  28593. * This mode makes the mesh edges visible
  28594. * @param epsilon defines the maximal distance between two angles to detect a face
  28595. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28596. * @returns the currentAbstractMesh
  28597. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28598. */
  28599. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28600. }
  28601. }
  28602. declare module BABYLON {
  28603. /**
  28604. * Interface used to define ActionEvent
  28605. */
  28606. export interface IActionEvent {
  28607. /** The mesh or sprite that triggered the action */
  28608. source: any;
  28609. /** The X mouse cursor position at the time of the event */
  28610. pointerX: number;
  28611. /** The Y mouse cursor position at the time of the event */
  28612. pointerY: number;
  28613. /** The mesh that is currently pointed at (can be null) */
  28614. meshUnderPointer: Nullable<AbstractMesh>;
  28615. /** the original (browser) event that triggered the ActionEvent */
  28616. sourceEvent?: any;
  28617. /** additional data for the event */
  28618. additionalData?: any;
  28619. }
  28620. /**
  28621. * ActionEvent is the event being sent when an action is triggered.
  28622. */
  28623. export class ActionEvent implements IActionEvent {
  28624. /** The mesh or sprite that triggered the action */
  28625. source: any;
  28626. /** The X mouse cursor position at the time of the event */
  28627. pointerX: number;
  28628. /** The Y mouse cursor position at the time of the event */
  28629. pointerY: number;
  28630. /** The mesh that is currently pointed at (can be null) */
  28631. meshUnderPointer: Nullable<AbstractMesh>;
  28632. /** the original (browser) event that triggered the ActionEvent */
  28633. sourceEvent?: any;
  28634. /** additional data for the event */
  28635. additionalData?: any;
  28636. /**
  28637. * Creates a new ActionEvent
  28638. * @param source The mesh or sprite that triggered the action
  28639. * @param pointerX The X mouse cursor position at the time of the event
  28640. * @param pointerY The Y mouse cursor position at the time of the event
  28641. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28642. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28643. * @param additionalData additional data for the event
  28644. */
  28645. constructor(
  28646. /** The mesh or sprite that triggered the action */
  28647. source: any,
  28648. /** The X mouse cursor position at the time of the event */
  28649. pointerX: number,
  28650. /** The Y mouse cursor position at the time of the event */
  28651. pointerY: number,
  28652. /** The mesh that is currently pointed at (can be null) */
  28653. meshUnderPointer: Nullable<AbstractMesh>,
  28654. /** the original (browser) event that triggered the ActionEvent */
  28655. sourceEvent?: any,
  28656. /** additional data for the event */
  28657. additionalData?: any);
  28658. /**
  28659. * Helper function to auto-create an ActionEvent from a source mesh.
  28660. * @param source The source mesh that triggered the event
  28661. * @param evt The original (browser) event
  28662. * @param additionalData additional data for the event
  28663. * @returns the new ActionEvent
  28664. */
  28665. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28666. /**
  28667. * Helper function to auto-create an ActionEvent from a source sprite
  28668. * @param source The source sprite that triggered the event
  28669. * @param scene Scene associated with the sprite
  28670. * @param evt The original (browser) event
  28671. * @param additionalData additional data for the event
  28672. * @returns the new ActionEvent
  28673. */
  28674. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28675. /**
  28676. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28677. * @param scene the scene where the event occurred
  28678. * @param evt The original (browser) event
  28679. * @returns the new ActionEvent
  28680. */
  28681. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28682. /**
  28683. * Helper function to auto-create an ActionEvent from a primitive
  28684. * @param prim defines the target primitive
  28685. * @param pointerPos defines the pointer position
  28686. * @param evt The original (browser) event
  28687. * @param additionalData additional data for the event
  28688. * @returns the new ActionEvent
  28689. */
  28690. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28691. }
  28692. }
  28693. declare module BABYLON {
  28694. /**
  28695. * Abstract class used to decouple action Manager from scene and meshes.
  28696. * Do not instantiate.
  28697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28698. */
  28699. export abstract class AbstractActionManager implements IDisposable {
  28700. /** Gets the list of active triggers */
  28701. static Triggers: {
  28702. [key: string]: number;
  28703. };
  28704. /** Gets the cursor to use when hovering items */
  28705. hoverCursor: string;
  28706. /** Gets the list of actions */
  28707. actions: IAction[];
  28708. /**
  28709. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28710. */
  28711. isRecursive: boolean;
  28712. /**
  28713. * Releases all associated resources
  28714. */
  28715. abstract dispose(): void;
  28716. /**
  28717. * Does this action manager has pointer triggers
  28718. */
  28719. abstract get hasPointerTriggers(): boolean;
  28720. /**
  28721. * Does this action manager has pick triggers
  28722. */
  28723. abstract get hasPickTriggers(): boolean;
  28724. /**
  28725. * Process a specific trigger
  28726. * @param trigger defines the trigger to process
  28727. * @param evt defines the event details to be processed
  28728. */
  28729. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28730. /**
  28731. * Does this action manager handles actions of any of the given triggers
  28732. * @param triggers defines the triggers to be tested
  28733. * @return a boolean indicating whether one (or more) of the triggers is handled
  28734. */
  28735. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28736. /**
  28737. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28738. * speed.
  28739. * @param triggerA defines the trigger to be tested
  28740. * @param triggerB defines the trigger to be tested
  28741. * @return a boolean indicating whether one (or more) of the triggers is handled
  28742. */
  28743. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28744. /**
  28745. * Does this action manager handles actions of a given trigger
  28746. * @param trigger defines the trigger to be tested
  28747. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28748. * @return whether the trigger is handled
  28749. */
  28750. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28751. /**
  28752. * Serialize this manager to a JSON object
  28753. * @param name defines the property name to store this manager
  28754. * @returns a JSON representation of this manager
  28755. */
  28756. abstract serialize(name: string): any;
  28757. /**
  28758. * Registers an action to this action manager
  28759. * @param action defines the action to be registered
  28760. * @return the action amended (prepared) after registration
  28761. */
  28762. abstract registerAction(action: IAction): Nullable<IAction>;
  28763. /**
  28764. * Unregisters an action to this action manager
  28765. * @param action defines the action to be unregistered
  28766. * @return a boolean indicating whether the action has been unregistered
  28767. */
  28768. abstract unregisterAction(action: IAction): Boolean;
  28769. /**
  28770. * Does exist one action manager with at least one trigger
  28771. **/
  28772. static get HasTriggers(): boolean;
  28773. /**
  28774. * Does exist one action manager with at least one pick trigger
  28775. **/
  28776. static get HasPickTriggers(): boolean;
  28777. /**
  28778. * Does exist one action manager that handles actions of a given trigger
  28779. * @param trigger defines the trigger to be tested
  28780. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28781. **/
  28782. static HasSpecificTrigger(trigger: number): boolean;
  28783. }
  28784. }
  28785. declare module BABYLON {
  28786. /**
  28787. * Defines how a node can be built from a string name.
  28788. */
  28789. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28790. /**
  28791. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28792. */
  28793. export class Node implements IBehaviorAware<Node> {
  28794. /** @hidden */
  28795. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28796. private static _NodeConstructors;
  28797. /**
  28798. * Add a new node constructor
  28799. * @param type defines the type name of the node to construct
  28800. * @param constructorFunc defines the constructor function
  28801. */
  28802. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28803. /**
  28804. * Returns a node constructor based on type name
  28805. * @param type defines the type name
  28806. * @param name defines the new node name
  28807. * @param scene defines the hosting scene
  28808. * @param options defines optional options to transmit to constructors
  28809. * @returns the new constructor or null
  28810. */
  28811. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28812. /**
  28813. * Gets or sets the name of the node
  28814. */
  28815. name: string;
  28816. /**
  28817. * Gets or sets the id of the node
  28818. */
  28819. id: string;
  28820. /**
  28821. * Gets or sets the unique id of the node
  28822. */
  28823. uniqueId: number;
  28824. /**
  28825. * Gets or sets a string used to store user defined state for the node
  28826. */
  28827. state: string;
  28828. /**
  28829. * Gets or sets an object used to store user defined information for the node
  28830. */
  28831. metadata: any;
  28832. /**
  28833. * For internal use only. Please do not use.
  28834. */
  28835. reservedDataStore: any;
  28836. /**
  28837. * List of inspectable custom properties (used by the Inspector)
  28838. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28839. */
  28840. inspectableCustomProperties: IInspectable[];
  28841. private _doNotSerialize;
  28842. /**
  28843. * Gets or sets a boolean used to define if the node must be serialized
  28844. */
  28845. get doNotSerialize(): boolean;
  28846. set doNotSerialize(value: boolean);
  28847. /** @hidden */
  28848. _isDisposed: boolean;
  28849. /**
  28850. * Gets a list of Animations associated with the node
  28851. */
  28852. animations: Animation[];
  28853. protected _ranges: {
  28854. [name: string]: Nullable<AnimationRange>;
  28855. };
  28856. /**
  28857. * Callback raised when the node is ready to be used
  28858. */
  28859. onReady: Nullable<(node: Node) => void>;
  28860. private _isEnabled;
  28861. private _isParentEnabled;
  28862. private _isReady;
  28863. /** @hidden */
  28864. _currentRenderId: number;
  28865. private _parentUpdateId;
  28866. /** @hidden */
  28867. _childUpdateId: number;
  28868. /** @hidden */
  28869. _waitingParentId: Nullable<string>;
  28870. /** @hidden */
  28871. _scene: Scene;
  28872. /** @hidden */
  28873. _cache: any;
  28874. private _parentNode;
  28875. private _children;
  28876. /** @hidden */
  28877. _worldMatrix: Matrix;
  28878. /** @hidden */
  28879. _worldMatrixDeterminant: number;
  28880. /** @hidden */
  28881. _worldMatrixDeterminantIsDirty: boolean;
  28882. /** @hidden */
  28883. private _sceneRootNodesIndex;
  28884. /**
  28885. * Gets a boolean indicating if the node has been disposed
  28886. * @returns true if the node was disposed
  28887. */
  28888. isDisposed(): boolean;
  28889. /**
  28890. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28891. * @see https://doc.babylonjs.com/how_to/parenting
  28892. */
  28893. set parent(parent: Nullable<Node>);
  28894. get parent(): Nullable<Node>;
  28895. /** @hidden */
  28896. _addToSceneRootNodes(): void;
  28897. /** @hidden */
  28898. _removeFromSceneRootNodes(): void;
  28899. private _animationPropertiesOverride;
  28900. /**
  28901. * Gets or sets the animation properties override
  28902. */
  28903. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28904. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28905. /**
  28906. * Gets a string idenfifying the name of the class
  28907. * @returns "Node" string
  28908. */
  28909. getClassName(): string;
  28910. /** @hidden */
  28911. readonly _isNode: boolean;
  28912. /**
  28913. * An event triggered when the mesh is disposed
  28914. */
  28915. onDisposeObservable: Observable<Node>;
  28916. private _onDisposeObserver;
  28917. /**
  28918. * Sets a callback that will be raised when the node will be disposed
  28919. */
  28920. set onDispose(callback: () => void);
  28921. /**
  28922. * Creates a new Node
  28923. * @param name the name and id to be given to this node
  28924. * @param scene the scene this node will be added to
  28925. */
  28926. constructor(name: string, scene?: Nullable<Scene>);
  28927. /**
  28928. * Gets the scene of the node
  28929. * @returns a scene
  28930. */
  28931. getScene(): Scene;
  28932. /**
  28933. * Gets the engine of the node
  28934. * @returns a Engine
  28935. */
  28936. getEngine(): Engine;
  28937. private _behaviors;
  28938. /**
  28939. * Attach a behavior to the node
  28940. * @see http://doc.babylonjs.com/features/behaviour
  28941. * @param behavior defines the behavior to attach
  28942. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28943. * @returns the current Node
  28944. */
  28945. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28946. /**
  28947. * Remove an attached behavior
  28948. * @see http://doc.babylonjs.com/features/behaviour
  28949. * @param behavior defines the behavior to attach
  28950. * @returns the current Node
  28951. */
  28952. removeBehavior(behavior: Behavior<Node>): Node;
  28953. /**
  28954. * Gets the list of attached behaviors
  28955. * @see http://doc.babylonjs.com/features/behaviour
  28956. */
  28957. get behaviors(): Behavior<Node>[];
  28958. /**
  28959. * Gets an attached behavior by name
  28960. * @param name defines the name of the behavior to look for
  28961. * @see http://doc.babylonjs.com/features/behaviour
  28962. * @returns null if behavior was not found else the requested behavior
  28963. */
  28964. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28965. /**
  28966. * Returns the latest update of the World matrix
  28967. * @returns a Matrix
  28968. */
  28969. getWorldMatrix(): Matrix;
  28970. /** @hidden */
  28971. _getWorldMatrixDeterminant(): number;
  28972. /**
  28973. * Returns directly the latest state of the mesh World matrix.
  28974. * A Matrix is returned.
  28975. */
  28976. get worldMatrixFromCache(): Matrix;
  28977. /** @hidden */
  28978. _initCache(): void;
  28979. /** @hidden */
  28980. updateCache(force?: boolean): void;
  28981. /** @hidden */
  28982. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28983. /** @hidden */
  28984. _updateCache(ignoreParentClass?: boolean): void;
  28985. /** @hidden */
  28986. _isSynchronized(): boolean;
  28987. /** @hidden */
  28988. _markSyncedWithParent(): void;
  28989. /** @hidden */
  28990. isSynchronizedWithParent(): boolean;
  28991. /** @hidden */
  28992. isSynchronized(): boolean;
  28993. /**
  28994. * Is this node ready to be used/rendered
  28995. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28996. * @return true if the node is ready
  28997. */
  28998. isReady(completeCheck?: boolean): boolean;
  28999. /**
  29000. * Is this node enabled?
  29001. * 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
  29002. * @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
  29003. * @return whether this node (and its parent) is enabled
  29004. */
  29005. isEnabled(checkAncestors?: boolean): boolean;
  29006. /** @hidden */
  29007. protected _syncParentEnabledState(): void;
  29008. /**
  29009. * Set the enabled state of this node
  29010. * @param value defines the new enabled state
  29011. */
  29012. setEnabled(value: boolean): void;
  29013. /**
  29014. * Is this node a descendant of the given node?
  29015. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29016. * @param ancestor defines the parent node to inspect
  29017. * @returns a boolean indicating if this node is a descendant of the given node
  29018. */
  29019. isDescendantOf(ancestor: Node): boolean;
  29020. /** @hidden */
  29021. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29022. /**
  29023. * Will return all nodes that have this node as ascendant
  29024. * @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
  29025. * @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
  29026. * @return all children nodes of all types
  29027. */
  29028. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29029. /**
  29030. * Get all child-meshes of this node
  29031. * @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)
  29032. * @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
  29033. * @returns an array of AbstractMesh
  29034. */
  29035. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29036. /**
  29037. * Get all direct children of this node
  29038. * @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
  29039. * @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)
  29040. * @returns an array of Node
  29041. */
  29042. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29043. /** @hidden */
  29044. _setReady(state: boolean): void;
  29045. /**
  29046. * Get an animation by name
  29047. * @param name defines the name of the animation to look for
  29048. * @returns null if not found else the requested animation
  29049. */
  29050. getAnimationByName(name: string): Nullable<Animation>;
  29051. /**
  29052. * Creates an animation range for this node
  29053. * @param name defines the name of the range
  29054. * @param from defines the starting key
  29055. * @param to defines the end key
  29056. */
  29057. createAnimationRange(name: string, from: number, to: number): void;
  29058. /**
  29059. * Delete a specific animation range
  29060. * @param name defines the name of the range to delete
  29061. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29062. */
  29063. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29064. /**
  29065. * Get an animation range by name
  29066. * @param name defines the name of the animation range to look for
  29067. * @returns null if not found else the requested animation range
  29068. */
  29069. getAnimationRange(name: string): Nullable<AnimationRange>;
  29070. /**
  29071. * Gets the list of all animation ranges defined on this node
  29072. * @returns an array
  29073. */
  29074. getAnimationRanges(): Nullable<AnimationRange>[];
  29075. /**
  29076. * Will start the animation sequence
  29077. * @param name defines the range frames for animation sequence
  29078. * @param loop defines if the animation should loop (false by default)
  29079. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29080. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29081. * @returns the object created for this animation. If range does not exist, it will return null
  29082. */
  29083. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29084. /**
  29085. * Serialize animation ranges into a JSON compatible object
  29086. * @returns serialization object
  29087. */
  29088. serializeAnimationRanges(): any;
  29089. /**
  29090. * Computes the world matrix of the node
  29091. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29092. * @returns the world matrix
  29093. */
  29094. computeWorldMatrix(force?: boolean): Matrix;
  29095. /**
  29096. * Releases resources associated with this node.
  29097. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29098. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29099. */
  29100. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29101. /**
  29102. * Parse animation range data from a serialization object and store them into a given node
  29103. * @param node defines where to store the animation ranges
  29104. * @param parsedNode defines the serialization object to read data from
  29105. * @param scene defines the hosting scene
  29106. */
  29107. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29108. /**
  29109. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29110. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29111. * @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
  29112. * @returns the new bounding vectors
  29113. */
  29114. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29115. min: Vector3;
  29116. max: Vector3;
  29117. };
  29118. }
  29119. }
  29120. declare module BABYLON {
  29121. /**
  29122. * @hidden
  29123. */
  29124. export class _IAnimationState {
  29125. key: number;
  29126. repeatCount: number;
  29127. workValue?: any;
  29128. loopMode?: number;
  29129. offsetValue?: any;
  29130. highLimitValue?: any;
  29131. }
  29132. /**
  29133. * Class used to store any kind of animation
  29134. */
  29135. export class Animation {
  29136. /**Name of the animation */
  29137. name: string;
  29138. /**Property to animate */
  29139. targetProperty: string;
  29140. /**The frames per second of the animation */
  29141. framePerSecond: number;
  29142. /**The data type of the animation */
  29143. dataType: number;
  29144. /**The loop mode of the animation */
  29145. loopMode?: number | undefined;
  29146. /**Specifies if blending should be enabled */
  29147. enableBlending?: boolean | undefined;
  29148. /**
  29149. * Use matrix interpolation instead of using direct key value when animating matrices
  29150. */
  29151. static AllowMatricesInterpolation: boolean;
  29152. /**
  29153. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29154. */
  29155. static AllowMatrixDecomposeForInterpolation: boolean;
  29156. /**
  29157. * Stores the key frames of the animation
  29158. */
  29159. private _keys;
  29160. /**
  29161. * Stores the easing function of the animation
  29162. */
  29163. private _easingFunction;
  29164. /**
  29165. * @hidden Internal use only
  29166. */
  29167. _runtimeAnimations: RuntimeAnimation[];
  29168. /**
  29169. * The set of event that will be linked to this animation
  29170. */
  29171. private _events;
  29172. /**
  29173. * Stores an array of target property paths
  29174. */
  29175. targetPropertyPath: string[];
  29176. /**
  29177. * Stores the blending speed of the animation
  29178. */
  29179. blendingSpeed: number;
  29180. /**
  29181. * Stores the animation ranges for the animation
  29182. */
  29183. private _ranges;
  29184. /**
  29185. * @hidden Internal use
  29186. */
  29187. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29188. /**
  29189. * Sets up an animation
  29190. * @param property The property to animate
  29191. * @param animationType The animation type to apply
  29192. * @param framePerSecond The frames per second of the animation
  29193. * @param easingFunction The easing function used in the animation
  29194. * @returns The created animation
  29195. */
  29196. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29197. /**
  29198. * Create and start an animation on a node
  29199. * @param name defines the name of the global animation that will be run on all nodes
  29200. * @param node defines the root node where the animation will take place
  29201. * @param targetProperty defines property to animate
  29202. * @param framePerSecond defines the number of frame per second yo use
  29203. * @param totalFrame defines the number of frames in total
  29204. * @param from defines the initial value
  29205. * @param to defines the final value
  29206. * @param loopMode defines which loop mode you want to use (off by default)
  29207. * @param easingFunction defines the easing function to use (linear by default)
  29208. * @param onAnimationEnd defines the callback to call when animation end
  29209. * @returns the animatable created for this animation
  29210. */
  29211. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29212. /**
  29213. * Create and start an animation on a node and its descendants
  29214. * @param name defines the name of the global animation that will be run on all nodes
  29215. * @param node defines the root node where the animation will take place
  29216. * @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
  29217. * @param targetProperty defines property to animate
  29218. * @param framePerSecond defines the number of frame per second to use
  29219. * @param totalFrame defines the number of frames in total
  29220. * @param from defines the initial value
  29221. * @param to defines the final value
  29222. * @param loopMode defines which loop mode you want to use (off by default)
  29223. * @param easingFunction defines the easing function to use (linear by default)
  29224. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29225. * @returns the list of animatables created for all nodes
  29226. * @example https://www.babylonjs-playground.com/#MH0VLI
  29227. */
  29228. 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[]>;
  29229. /**
  29230. * Creates a new animation, merges it with the existing animations and starts it
  29231. * @param name Name of the animation
  29232. * @param node Node which contains the scene that begins the animations
  29233. * @param targetProperty Specifies which property to animate
  29234. * @param framePerSecond The frames per second of the animation
  29235. * @param totalFrame The total number of frames
  29236. * @param from The frame at the beginning of the animation
  29237. * @param to The frame at the end of the animation
  29238. * @param loopMode Specifies the loop mode of the animation
  29239. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29240. * @param onAnimationEnd Callback to run once the animation is complete
  29241. * @returns Nullable animation
  29242. */
  29243. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29244. /**
  29245. * Transition property of an host to the target Value
  29246. * @param property The property to transition
  29247. * @param targetValue The target Value of the property
  29248. * @param host The object where the property to animate belongs
  29249. * @param scene Scene used to run the animation
  29250. * @param frameRate Framerate (in frame/s) to use
  29251. * @param transition The transition type we want to use
  29252. * @param duration The duration of the animation, in milliseconds
  29253. * @param onAnimationEnd Callback trigger at the end of the animation
  29254. * @returns Nullable animation
  29255. */
  29256. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29257. /**
  29258. * Return the array of runtime animations currently using this animation
  29259. */
  29260. get runtimeAnimations(): RuntimeAnimation[];
  29261. /**
  29262. * Specifies if any of the runtime animations are currently running
  29263. */
  29264. get hasRunningRuntimeAnimations(): boolean;
  29265. /**
  29266. * Initializes the animation
  29267. * @param name Name of the animation
  29268. * @param targetProperty Property to animate
  29269. * @param framePerSecond The frames per second of the animation
  29270. * @param dataType The data type of the animation
  29271. * @param loopMode The loop mode of the animation
  29272. * @param enableBlending Specifies if blending should be enabled
  29273. */
  29274. constructor(
  29275. /**Name of the animation */
  29276. name: string,
  29277. /**Property to animate */
  29278. targetProperty: string,
  29279. /**The frames per second of the animation */
  29280. framePerSecond: number,
  29281. /**The data type of the animation */
  29282. dataType: number,
  29283. /**The loop mode of the animation */
  29284. loopMode?: number | undefined,
  29285. /**Specifies if blending should be enabled */
  29286. enableBlending?: boolean | undefined);
  29287. /**
  29288. * Converts the animation to a string
  29289. * @param fullDetails support for multiple levels of logging within scene loading
  29290. * @returns String form of the animation
  29291. */
  29292. toString(fullDetails?: boolean): string;
  29293. /**
  29294. * Add an event to this animation
  29295. * @param event Event to add
  29296. */
  29297. addEvent(event: AnimationEvent): void;
  29298. /**
  29299. * Remove all events found at the given frame
  29300. * @param frame The frame to remove events from
  29301. */
  29302. removeEvents(frame: number): void;
  29303. /**
  29304. * Retrieves all the events from the animation
  29305. * @returns Events from the animation
  29306. */
  29307. getEvents(): AnimationEvent[];
  29308. /**
  29309. * Creates an animation range
  29310. * @param name Name of the animation range
  29311. * @param from Starting frame of the animation range
  29312. * @param to Ending frame of the animation
  29313. */
  29314. createRange(name: string, from: number, to: number): void;
  29315. /**
  29316. * Deletes an animation range by name
  29317. * @param name Name of the animation range to delete
  29318. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29319. */
  29320. deleteRange(name: string, deleteFrames?: boolean): void;
  29321. /**
  29322. * Gets the animation range by name, or null if not defined
  29323. * @param name Name of the animation range
  29324. * @returns Nullable animation range
  29325. */
  29326. getRange(name: string): Nullable<AnimationRange>;
  29327. /**
  29328. * Gets the key frames from the animation
  29329. * @returns The key frames of the animation
  29330. */
  29331. getKeys(): Array<IAnimationKey>;
  29332. /**
  29333. * Gets the highest frame rate of the animation
  29334. * @returns Highest frame rate of the animation
  29335. */
  29336. getHighestFrame(): number;
  29337. /**
  29338. * Gets the easing function of the animation
  29339. * @returns Easing function of the animation
  29340. */
  29341. getEasingFunction(): IEasingFunction;
  29342. /**
  29343. * Sets the easing function of the animation
  29344. * @param easingFunction A custom mathematical formula for animation
  29345. */
  29346. setEasingFunction(easingFunction: EasingFunction): void;
  29347. /**
  29348. * Interpolates a scalar linearly
  29349. * @param startValue Start value of the animation curve
  29350. * @param endValue End value of the animation curve
  29351. * @param gradient Scalar amount to interpolate
  29352. * @returns Interpolated scalar value
  29353. */
  29354. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29355. /**
  29356. * Interpolates a scalar cubically
  29357. * @param startValue Start value of the animation curve
  29358. * @param outTangent End tangent of the animation
  29359. * @param endValue End value of the animation curve
  29360. * @param inTangent Start tangent of the animation curve
  29361. * @param gradient Scalar amount to interpolate
  29362. * @returns Interpolated scalar value
  29363. */
  29364. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29365. /**
  29366. * Interpolates a quaternion using a spherical linear interpolation
  29367. * @param startValue Start value of the animation curve
  29368. * @param endValue End value of the animation curve
  29369. * @param gradient Scalar amount to interpolate
  29370. * @returns Interpolated quaternion value
  29371. */
  29372. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29373. /**
  29374. * Interpolates a quaternion cubically
  29375. * @param startValue Start value of the animation curve
  29376. * @param outTangent End tangent of the animation curve
  29377. * @param endValue End value of the animation curve
  29378. * @param inTangent Start tangent of the animation curve
  29379. * @param gradient Scalar amount to interpolate
  29380. * @returns Interpolated quaternion value
  29381. */
  29382. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29383. /**
  29384. * Interpolates a Vector3 linearl
  29385. * @param startValue Start value of the animation curve
  29386. * @param endValue End value of the animation curve
  29387. * @param gradient Scalar amount to interpolate
  29388. * @returns Interpolated scalar value
  29389. */
  29390. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29391. /**
  29392. * Interpolates a Vector3 cubically
  29393. * @param startValue Start value of the animation curve
  29394. * @param outTangent End tangent of the animation
  29395. * @param endValue End value of the animation curve
  29396. * @param inTangent Start tangent of the animation curve
  29397. * @param gradient Scalar amount to interpolate
  29398. * @returns InterpolatedVector3 value
  29399. */
  29400. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29401. /**
  29402. * Interpolates a Vector2 linearly
  29403. * @param startValue Start value of the animation curve
  29404. * @param endValue End value of the animation curve
  29405. * @param gradient Scalar amount to interpolate
  29406. * @returns Interpolated Vector2 value
  29407. */
  29408. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29409. /**
  29410. * Interpolates a Vector2 cubically
  29411. * @param startValue Start value of the animation curve
  29412. * @param outTangent End tangent of the animation
  29413. * @param endValue End value of the animation curve
  29414. * @param inTangent Start tangent of the animation curve
  29415. * @param gradient Scalar amount to interpolate
  29416. * @returns Interpolated Vector2 value
  29417. */
  29418. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29419. /**
  29420. * Interpolates a size linearly
  29421. * @param startValue Start value of the animation curve
  29422. * @param endValue End value of the animation curve
  29423. * @param gradient Scalar amount to interpolate
  29424. * @returns Interpolated Size value
  29425. */
  29426. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29427. /**
  29428. * Interpolates a Color3 linearly
  29429. * @param startValue Start value of the animation curve
  29430. * @param endValue End value of the animation curve
  29431. * @param gradient Scalar amount to interpolate
  29432. * @returns Interpolated Color3 value
  29433. */
  29434. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29435. /**
  29436. * Interpolates a Color4 linearly
  29437. * @param startValue Start value of the animation curve
  29438. * @param endValue End value of the animation curve
  29439. * @param gradient Scalar amount to interpolate
  29440. * @returns Interpolated Color3 value
  29441. */
  29442. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29443. /**
  29444. * @hidden Internal use only
  29445. */
  29446. _getKeyValue(value: any): any;
  29447. /**
  29448. * @hidden Internal use only
  29449. */
  29450. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29451. /**
  29452. * Defines the function to use to interpolate matrices
  29453. * @param startValue defines the start matrix
  29454. * @param endValue defines the end matrix
  29455. * @param gradient defines the gradient between both matrices
  29456. * @param result defines an optional target matrix where to store the interpolation
  29457. * @returns the interpolated matrix
  29458. */
  29459. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29460. /**
  29461. * Makes a copy of the animation
  29462. * @returns Cloned animation
  29463. */
  29464. clone(): Animation;
  29465. /**
  29466. * Sets the key frames of the animation
  29467. * @param values The animation key frames to set
  29468. */
  29469. setKeys(values: Array<IAnimationKey>): void;
  29470. /**
  29471. * Serializes the animation to an object
  29472. * @returns Serialized object
  29473. */
  29474. serialize(): any;
  29475. /**
  29476. * Float animation type
  29477. */
  29478. static readonly ANIMATIONTYPE_FLOAT: number;
  29479. /**
  29480. * Vector3 animation type
  29481. */
  29482. static readonly ANIMATIONTYPE_VECTOR3: number;
  29483. /**
  29484. * Quaternion animation type
  29485. */
  29486. static readonly ANIMATIONTYPE_QUATERNION: number;
  29487. /**
  29488. * Matrix animation type
  29489. */
  29490. static readonly ANIMATIONTYPE_MATRIX: number;
  29491. /**
  29492. * Color3 animation type
  29493. */
  29494. static readonly ANIMATIONTYPE_COLOR3: number;
  29495. /**
  29496. * Color3 animation type
  29497. */
  29498. static readonly ANIMATIONTYPE_COLOR4: number;
  29499. /**
  29500. * Vector2 animation type
  29501. */
  29502. static readonly ANIMATIONTYPE_VECTOR2: number;
  29503. /**
  29504. * Size animation type
  29505. */
  29506. static readonly ANIMATIONTYPE_SIZE: number;
  29507. /**
  29508. * Relative Loop Mode
  29509. */
  29510. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29511. /**
  29512. * Cycle Loop Mode
  29513. */
  29514. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29515. /**
  29516. * Constant Loop Mode
  29517. */
  29518. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29519. /** @hidden */
  29520. static _UniversalLerp(left: any, right: any, amount: number): any;
  29521. /**
  29522. * Parses an animation object and creates an animation
  29523. * @param parsedAnimation Parsed animation object
  29524. * @returns Animation object
  29525. */
  29526. static Parse(parsedAnimation: any): Animation;
  29527. /**
  29528. * Appends the serialized animations from the source animations
  29529. * @param source Source containing the animations
  29530. * @param destination Target to store the animations
  29531. */
  29532. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29533. }
  29534. }
  29535. declare module BABYLON {
  29536. /**
  29537. * Interface containing an array of animations
  29538. */
  29539. export interface IAnimatable {
  29540. /**
  29541. * Array of animations
  29542. */
  29543. animations: Nullable<Array<Animation>>;
  29544. }
  29545. }
  29546. declare module BABYLON {
  29547. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29548. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29549. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29550. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29551. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29552. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29553. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29554. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29555. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29556. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29557. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29558. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29559. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29560. /**
  29561. * Decorator used to define property that can be serialized as reference to a camera
  29562. * @param sourceName defines the name of the property to decorate
  29563. */
  29564. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29565. /**
  29566. * Class used to help serialization objects
  29567. */
  29568. export class SerializationHelper {
  29569. /** @hidden */
  29570. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29571. /** @hidden */
  29572. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29573. /** @hidden */
  29574. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29575. /** @hidden */
  29576. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29577. /**
  29578. * Appends the serialized animations from the source animations
  29579. * @param source Source containing the animations
  29580. * @param destination Target to store the animations
  29581. */
  29582. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29583. /**
  29584. * Static function used to serialized a specific entity
  29585. * @param entity defines the entity to serialize
  29586. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29587. * @returns a JSON compatible object representing the serialization of the entity
  29588. */
  29589. static Serialize<T>(entity: T, serializationObject?: any): any;
  29590. /**
  29591. * Creates a new entity from a serialization data object
  29592. * @param creationFunction defines a function used to instanciated the new entity
  29593. * @param source defines the source serialization data
  29594. * @param scene defines the hosting scene
  29595. * @param rootUrl defines the root url for resources
  29596. * @returns a new entity
  29597. */
  29598. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29599. /**
  29600. * Clones an object
  29601. * @param creationFunction defines the function used to instanciate the new object
  29602. * @param source defines the source object
  29603. * @returns the cloned object
  29604. */
  29605. static Clone<T>(creationFunction: () => T, source: T): T;
  29606. /**
  29607. * Instanciates a new object based on a source one (some data will be shared between both object)
  29608. * @param creationFunction defines the function used to instanciate the new object
  29609. * @param source defines the source object
  29610. * @returns the new object
  29611. */
  29612. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29613. }
  29614. }
  29615. declare module BABYLON {
  29616. /**
  29617. * Class used to manipulate GUIDs
  29618. */
  29619. export class GUID {
  29620. /**
  29621. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29622. * Be aware Math.random() could cause collisions, but:
  29623. * "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"
  29624. * @returns a pseudo random id
  29625. */
  29626. static RandomId(): string;
  29627. }
  29628. }
  29629. declare module BABYLON {
  29630. /**
  29631. * Base class of all the textures in babylon.
  29632. * It groups all the common properties the materials, post process, lights... might need
  29633. * in order to make a correct use of the texture.
  29634. */
  29635. export class BaseTexture implements IAnimatable {
  29636. /**
  29637. * Default anisotropic filtering level for the application.
  29638. * It is set to 4 as a good tradeoff between perf and quality.
  29639. */
  29640. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29641. /**
  29642. * Gets or sets the unique id of the texture
  29643. */
  29644. uniqueId: number;
  29645. /**
  29646. * Define the name of the texture.
  29647. */
  29648. name: string;
  29649. /**
  29650. * Gets or sets an object used to store user defined information.
  29651. */
  29652. metadata: any;
  29653. /**
  29654. * For internal use only. Please do not use.
  29655. */
  29656. reservedDataStore: any;
  29657. private _hasAlpha;
  29658. /**
  29659. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29660. */
  29661. set hasAlpha(value: boolean);
  29662. get hasAlpha(): boolean;
  29663. /**
  29664. * Defines if the alpha value should be determined via the rgb values.
  29665. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29666. */
  29667. getAlphaFromRGB: boolean;
  29668. /**
  29669. * Intensity or strength of the texture.
  29670. * It is commonly used by materials to fine tune the intensity of the texture
  29671. */
  29672. level: number;
  29673. /**
  29674. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29675. * This is part of the texture as textures usually maps to one uv set.
  29676. */
  29677. coordinatesIndex: number;
  29678. private _coordinatesMode;
  29679. /**
  29680. * How a texture is mapped.
  29681. *
  29682. * | Value | Type | Description |
  29683. * | ----- | ----------------------------------- | ----------- |
  29684. * | 0 | EXPLICIT_MODE | |
  29685. * | 1 | SPHERICAL_MODE | |
  29686. * | 2 | PLANAR_MODE | |
  29687. * | 3 | CUBIC_MODE | |
  29688. * | 4 | PROJECTION_MODE | |
  29689. * | 5 | SKYBOX_MODE | |
  29690. * | 6 | INVCUBIC_MODE | |
  29691. * | 7 | EQUIRECTANGULAR_MODE | |
  29692. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29693. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29694. */
  29695. set coordinatesMode(value: number);
  29696. get coordinatesMode(): number;
  29697. /**
  29698. * | Value | Type | Description |
  29699. * | ----- | ------------------ | ----------- |
  29700. * | 0 | CLAMP_ADDRESSMODE | |
  29701. * | 1 | WRAP_ADDRESSMODE | |
  29702. * | 2 | MIRROR_ADDRESSMODE | |
  29703. */
  29704. wrapU: number;
  29705. /**
  29706. * | Value | Type | Description |
  29707. * | ----- | ------------------ | ----------- |
  29708. * | 0 | CLAMP_ADDRESSMODE | |
  29709. * | 1 | WRAP_ADDRESSMODE | |
  29710. * | 2 | MIRROR_ADDRESSMODE | |
  29711. */
  29712. wrapV: number;
  29713. /**
  29714. * | Value | Type | Description |
  29715. * | ----- | ------------------ | ----------- |
  29716. * | 0 | CLAMP_ADDRESSMODE | |
  29717. * | 1 | WRAP_ADDRESSMODE | |
  29718. * | 2 | MIRROR_ADDRESSMODE | |
  29719. */
  29720. wrapR: number;
  29721. /**
  29722. * With compliant hardware and browser (supporting anisotropic filtering)
  29723. * this defines the level of anisotropic filtering in the texture.
  29724. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29725. */
  29726. anisotropicFilteringLevel: number;
  29727. /**
  29728. * Define if the texture is a cube texture or if false a 2d texture.
  29729. */
  29730. get isCube(): boolean;
  29731. set isCube(value: boolean);
  29732. /**
  29733. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29734. */
  29735. get is3D(): boolean;
  29736. set is3D(value: boolean);
  29737. /**
  29738. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29739. */
  29740. get is2DArray(): boolean;
  29741. set is2DArray(value: boolean);
  29742. /**
  29743. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29744. * HDR texture are usually stored in linear space.
  29745. * This only impacts the PBR and Background materials
  29746. */
  29747. gammaSpace: boolean;
  29748. /**
  29749. * Gets or sets whether or not the texture contains RGBD data.
  29750. */
  29751. get isRGBD(): boolean;
  29752. set isRGBD(value: boolean);
  29753. /**
  29754. * Is Z inverted in the texture (useful in a cube texture).
  29755. */
  29756. invertZ: boolean;
  29757. /**
  29758. * Are mip maps generated for this texture or not.
  29759. */
  29760. get noMipmap(): boolean;
  29761. /**
  29762. * @hidden
  29763. */
  29764. lodLevelInAlpha: boolean;
  29765. /**
  29766. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29767. */
  29768. get lodGenerationOffset(): number;
  29769. set lodGenerationOffset(value: number);
  29770. /**
  29771. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29772. */
  29773. get lodGenerationScale(): number;
  29774. set lodGenerationScale(value: number);
  29775. /**
  29776. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29777. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29778. * average roughness values.
  29779. */
  29780. get linearSpecularLOD(): boolean;
  29781. set linearSpecularLOD(value: boolean);
  29782. /**
  29783. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29784. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29785. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29786. */
  29787. get irradianceTexture(): Nullable<BaseTexture>;
  29788. set irradianceTexture(value: Nullable<BaseTexture>);
  29789. /**
  29790. * Define if the texture is a render target.
  29791. */
  29792. isRenderTarget: boolean;
  29793. /**
  29794. * Define the unique id of the texture in the scene.
  29795. */
  29796. get uid(): string;
  29797. /**
  29798. * Return a string representation of the texture.
  29799. * @returns the texture as a string
  29800. */
  29801. toString(): string;
  29802. /**
  29803. * Get the class name of the texture.
  29804. * @returns "BaseTexture"
  29805. */
  29806. getClassName(): string;
  29807. /**
  29808. * Define the list of animation attached to the texture.
  29809. */
  29810. animations: Animation[];
  29811. /**
  29812. * An event triggered when the texture is disposed.
  29813. */
  29814. onDisposeObservable: Observable<BaseTexture>;
  29815. private _onDisposeObserver;
  29816. /**
  29817. * Callback triggered when the texture has been disposed.
  29818. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29819. */
  29820. set onDispose(callback: () => void);
  29821. /**
  29822. * Define the current state of the loading sequence when in delayed load mode.
  29823. */
  29824. delayLoadState: number;
  29825. private _scene;
  29826. /** @hidden */
  29827. _texture: Nullable<InternalTexture>;
  29828. private _uid;
  29829. /**
  29830. * Define if the texture is preventinga material to render or not.
  29831. * If not and the texture is not ready, the engine will use a default black texture instead.
  29832. */
  29833. get isBlocking(): boolean;
  29834. /**
  29835. * Instantiates a new BaseTexture.
  29836. * Base class of all the textures in babylon.
  29837. * It groups all the common properties the materials, post process, lights... might need
  29838. * in order to make a correct use of the texture.
  29839. * @param scene Define the scene the texture blongs to
  29840. */
  29841. constructor(scene: Nullable<Scene>);
  29842. /**
  29843. * Get the scene the texture belongs to.
  29844. * @returns the scene or null if undefined
  29845. */
  29846. getScene(): Nullable<Scene>;
  29847. /**
  29848. * Get the texture transform matrix used to offset tile the texture for istance.
  29849. * @returns the transformation matrix
  29850. */
  29851. getTextureMatrix(): Matrix;
  29852. /**
  29853. * Get the texture reflection matrix used to rotate/transform the reflection.
  29854. * @returns the reflection matrix
  29855. */
  29856. getReflectionTextureMatrix(): Matrix;
  29857. /**
  29858. * Get the underlying lower level texture from Babylon.
  29859. * @returns the insternal texture
  29860. */
  29861. getInternalTexture(): Nullable<InternalTexture>;
  29862. /**
  29863. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29864. * @returns true if ready or not blocking
  29865. */
  29866. isReadyOrNotBlocking(): boolean;
  29867. /**
  29868. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29869. * @returns true if fully ready
  29870. */
  29871. isReady(): boolean;
  29872. private _cachedSize;
  29873. /**
  29874. * Get the size of the texture.
  29875. * @returns the texture size.
  29876. */
  29877. getSize(): ISize;
  29878. /**
  29879. * Get the base size of the texture.
  29880. * It can be different from the size if the texture has been resized for POT for instance
  29881. * @returns the base size
  29882. */
  29883. getBaseSize(): ISize;
  29884. /**
  29885. * Update the sampling mode of the texture.
  29886. * Default is Trilinear mode.
  29887. *
  29888. * | Value | Type | Description |
  29889. * | ----- | ------------------ | ----------- |
  29890. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29891. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29892. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29893. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29894. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29895. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29896. * | 7 | NEAREST_LINEAR | |
  29897. * | 8 | NEAREST_NEAREST | |
  29898. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29899. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29900. * | 11 | LINEAR_LINEAR | |
  29901. * | 12 | LINEAR_NEAREST | |
  29902. *
  29903. * > _mag_: magnification filter (close to the viewer)
  29904. * > _min_: minification filter (far from the viewer)
  29905. * > _mip_: filter used between mip map levels
  29906. *@param samplingMode Define the new sampling mode of the texture
  29907. */
  29908. updateSamplingMode(samplingMode: number): void;
  29909. /**
  29910. * Scales the texture if is `canRescale()`
  29911. * @param ratio the resize factor we want to use to rescale
  29912. */
  29913. scale(ratio: number): void;
  29914. /**
  29915. * Get if the texture can rescale.
  29916. */
  29917. get canRescale(): boolean;
  29918. /** @hidden */
  29919. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29920. /** @hidden */
  29921. _rebuild(): void;
  29922. /**
  29923. * Triggers the load sequence in delayed load mode.
  29924. */
  29925. delayLoad(): void;
  29926. /**
  29927. * Clones the texture.
  29928. * @returns the cloned texture
  29929. */
  29930. clone(): Nullable<BaseTexture>;
  29931. /**
  29932. * Get the texture underlying type (INT, FLOAT...)
  29933. */
  29934. get textureType(): number;
  29935. /**
  29936. * Get the texture underlying format (RGB, RGBA...)
  29937. */
  29938. get textureFormat(): number;
  29939. /**
  29940. * Indicates that textures need to be re-calculated for all materials
  29941. */
  29942. protected _markAllSubMeshesAsTexturesDirty(): void;
  29943. /**
  29944. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29945. * This will returns an RGBA array buffer containing either in values (0-255) or
  29946. * float values (0-1) depending of the underlying buffer type.
  29947. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29948. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29949. * @param buffer defines a user defined buffer to fill with data (can be null)
  29950. * @returns The Array buffer containing the pixels data.
  29951. */
  29952. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29953. /**
  29954. * Release and destroy the underlying lower level texture aka internalTexture.
  29955. */
  29956. releaseInternalTexture(): void;
  29957. /** @hidden */
  29958. get _lodTextureHigh(): Nullable<BaseTexture>;
  29959. /** @hidden */
  29960. get _lodTextureMid(): Nullable<BaseTexture>;
  29961. /** @hidden */
  29962. get _lodTextureLow(): Nullable<BaseTexture>;
  29963. /**
  29964. * Dispose the texture and release its associated resources.
  29965. */
  29966. dispose(): void;
  29967. /**
  29968. * Serialize the texture into a JSON representation that can be parsed later on.
  29969. * @returns the JSON representation of the texture
  29970. */
  29971. serialize(): any;
  29972. /**
  29973. * Helper function to be called back once a list of texture contains only ready textures.
  29974. * @param textures Define the list of textures to wait for
  29975. * @param callback Define the callback triggered once the entire list will be ready
  29976. */
  29977. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29978. }
  29979. }
  29980. declare module BABYLON {
  29981. /**
  29982. * Options to be used when creating an effect.
  29983. */
  29984. export interface IEffectCreationOptions {
  29985. /**
  29986. * Atrributes that will be used in the shader.
  29987. */
  29988. attributes: string[];
  29989. /**
  29990. * Uniform varible names that will be set in the shader.
  29991. */
  29992. uniformsNames: string[];
  29993. /**
  29994. * Uniform buffer variable names that will be set in the shader.
  29995. */
  29996. uniformBuffersNames: string[];
  29997. /**
  29998. * Sampler texture variable names that will be set in the shader.
  29999. */
  30000. samplers: string[];
  30001. /**
  30002. * Define statements that will be set in the shader.
  30003. */
  30004. defines: any;
  30005. /**
  30006. * Possible fallbacks for this effect to improve performance when needed.
  30007. */
  30008. fallbacks: Nullable<IEffectFallbacks>;
  30009. /**
  30010. * Callback that will be called when the shader is compiled.
  30011. */
  30012. onCompiled: Nullable<(effect: Effect) => void>;
  30013. /**
  30014. * Callback that will be called if an error occurs during shader compilation.
  30015. */
  30016. onError: Nullable<(effect: Effect, errors: string) => void>;
  30017. /**
  30018. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30019. */
  30020. indexParameters?: any;
  30021. /**
  30022. * Max number of lights that can be used in the shader.
  30023. */
  30024. maxSimultaneousLights?: number;
  30025. /**
  30026. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30027. */
  30028. transformFeedbackVaryings?: Nullable<string[]>;
  30029. }
  30030. /**
  30031. * Effect containing vertex and fragment shader that can be executed on an object.
  30032. */
  30033. export class Effect implements IDisposable {
  30034. /**
  30035. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30036. */
  30037. static ShadersRepository: string;
  30038. /**
  30039. * Enable logging of the shader code when a compilation error occurs
  30040. */
  30041. static LogShaderCodeOnCompilationError: boolean;
  30042. /**
  30043. * Name of the effect.
  30044. */
  30045. name: any;
  30046. /**
  30047. * String container all the define statements that should be set on the shader.
  30048. */
  30049. defines: string;
  30050. /**
  30051. * Callback that will be called when the shader is compiled.
  30052. */
  30053. onCompiled: Nullable<(effect: Effect) => void>;
  30054. /**
  30055. * Callback that will be called if an error occurs during shader compilation.
  30056. */
  30057. onError: Nullable<(effect: Effect, errors: string) => void>;
  30058. /**
  30059. * Callback that will be called when effect is bound.
  30060. */
  30061. onBind: Nullable<(effect: Effect) => void>;
  30062. /**
  30063. * Unique ID of the effect.
  30064. */
  30065. uniqueId: number;
  30066. /**
  30067. * Observable that will be called when the shader is compiled.
  30068. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30069. */
  30070. onCompileObservable: Observable<Effect>;
  30071. /**
  30072. * Observable that will be called if an error occurs during shader compilation.
  30073. */
  30074. onErrorObservable: Observable<Effect>;
  30075. /** @hidden */
  30076. _onBindObservable: Nullable<Observable<Effect>>;
  30077. /**
  30078. * @hidden
  30079. * Specifies if the effect was previously ready
  30080. */
  30081. _wasPreviouslyReady: boolean;
  30082. /**
  30083. * Observable that will be called when effect is bound.
  30084. */
  30085. get onBindObservable(): Observable<Effect>;
  30086. /** @hidden */
  30087. _bonesComputationForcedToCPU: boolean;
  30088. private static _uniqueIdSeed;
  30089. private _engine;
  30090. private _uniformBuffersNames;
  30091. private _uniformsNames;
  30092. private _samplerList;
  30093. private _samplers;
  30094. private _isReady;
  30095. private _compilationError;
  30096. private _allFallbacksProcessed;
  30097. private _attributesNames;
  30098. private _attributes;
  30099. private _attributeLocationByName;
  30100. private _uniforms;
  30101. /**
  30102. * Key for the effect.
  30103. * @hidden
  30104. */
  30105. _key: string;
  30106. private _indexParameters;
  30107. private _fallbacks;
  30108. private _vertexSourceCode;
  30109. private _fragmentSourceCode;
  30110. private _vertexSourceCodeOverride;
  30111. private _fragmentSourceCodeOverride;
  30112. private _transformFeedbackVaryings;
  30113. /**
  30114. * Compiled shader to webGL program.
  30115. * @hidden
  30116. */
  30117. _pipelineContext: Nullable<IPipelineContext>;
  30118. private _valueCache;
  30119. private static _baseCache;
  30120. /**
  30121. * Instantiates an effect.
  30122. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30123. * @param baseName Name of the effect.
  30124. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30125. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30126. * @param samplers List of sampler variables that will be passed to the shader.
  30127. * @param engine Engine to be used to render the effect
  30128. * @param defines Define statements to be added to the shader.
  30129. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30130. * @param onCompiled Callback that will be called when the shader is compiled.
  30131. * @param onError Callback that will be called if an error occurs during shader compilation.
  30132. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30133. */
  30134. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30135. private _useFinalCode;
  30136. /**
  30137. * Unique key for this effect
  30138. */
  30139. get key(): string;
  30140. /**
  30141. * If the effect has been compiled and prepared.
  30142. * @returns if the effect is compiled and prepared.
  30143. */
  30144. isReady(): boolean;
  30145. private _isReadyInternal;
  30146. /**
  30147. * The engine the effect was initialized with.
  30148. * @returns the engine.
  30149. */
  30150. getEngine(): Engine;
  30151. /**
  30152. * The pipeline context for this effect
  30153. * @returns the associated pipeline context
  30154. */
  30155. getPipelineContext(): Nullable<IPipelineContext>;
  30156. /**
  30157. * The set of names of attribute variables for the shader.
  30158. * @returns An array of attribute names.
  30159. */
  30160. getAttributesNames(): string[];
  30161. /**
  30162. * Returns the attribute at the given index.
  30163. * @param index The index of the attribute.
  30164. * @returns The location of the attribute.
  30165. */
  30166. getAttributeLocation(index: number): number;
  30167. /**
  30168. * Returns the attribute based on the name of the variable.
  30169. * @param name of the attribute to look up.
  30170. * @returns the attribute location.
  30171. */
  30172. getAttributeLocationByName(name: string): number;
  30173. /**
  30174. * The number of attributes.
  30175. * @returns the numnber of attributes.
  30176. */
  30177. getAttributesCount(): number;
  30178. /**
  30179. * Gets the index of a uniform variable.
  30180. * @param uniformName of the uniform to look up.
  30181. * @returns the index.
  30182. */
  30183. getUniformIndex(uniformName: string): number;
  30184. /**
  30185. * Returns the attribute based on the name of the variable.
  30186. * @param uniformName of the uniform to look up.
  30187. * @returns the location of the uniform.
  30188. */
  30189. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30190. /**
  30191. * Returns an array of sampler variable names
  30192. * @returns The array of sampler variable neames.
  30193. */
  30194. getSamplers(): string[];
  30195. /**
  30196. * The error from the last compilation.
  30197. * @returns the error string.
  30198. */
  30199. getCompilationError(): string;
  30200. /**
  30201. * Gets a boolean indicating that all fallbacks were used during compilation
  30202. * @returns true if all fallbacks were used
  30203. */
  30204. allFallbacksProcessed(): boolean;
  30205. /**
  30206. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30207. * @param func The callback to be used.
  30208. */
  30209. executeWhenCompiled(func: (effect: Effect) => void): void;
  30210. private _checkIsReady;
  30211. private _loadShader;
  30212. /**
  30213. * Recompiles the webGL program
  30214. * @param vertexSourceCode The source code for the vertex shader.
  30215. * @param fragmentSourceCode The source code for the fragment shader.
  30216. * @param onCompiled Callback called when completed.
  30217. * @param onError Callback called on error.
  30218. * @hidden
  30219. */
  30220. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30221. /**
  30222. * Prepares the effect
  30223. * @hidden
  30224. */
  30225. _prepareEffect(): void;
  30226. private _getShaderCodeAndErrorLine;
  30227. private _processCompilationErrors;
  30228. /**
  30229. * Checks if the effect is supported. (Must be called after compilation)
  30230. */
  30231. get isSupported(): boolean;
  30232. /**
  30233. * Binds a texture to the engine to be used as output of the shader.
  30234. * @param channel Name of the output variable.
  30235. * @param texture Texture to bind.
  30236. * @hidden
  30237. */
  30238. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30239. /**
  30240. * Sets a texture on the engine to be used in the shader.
  30241. * @param channel Name of the sampler variable.
  30242. * @param texture Texture to set.
  30243. */
  30244. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30245. /**
  30246. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30247. * @param channel Name of the sampler variable.
  30248. * @param texture Texture to set.
  30249. */
  30250. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30251. /**
  30252. * Sets an array of textures on the engine to be used in the shader.
  30253. * @param channel Name of the variable.
  30254. * @param textures Textures to set.
  30255. */
  30256. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30257. /**
  30258. * 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)
  30259. * @param channel Name of the sampler variable.
  30260. * @param postProcess Post process to get the input texture from.
  30261. */
  30262. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30263. /**
  30264. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30265. * 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)
  30266. * @param channel Name of the sampler variable.
  30267. * @param postProcess Post process to get the output texture from.
  30268. */
  30269. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30270. /** @hidden */
  30271. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30272. /** @hidden */
  30273. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30274. /** @hidden */
  30275. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30276. /** @hidden */
  30277. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30278. /**
  30279. * Binds a buffer to a uniform.
  30280. * @param buffer Buffer to bind.
  30281. * @param name Name of the uniform variable to bind to.
  30282. */
  30283. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30284. /**
  30285. * Binds block to a uniform.
  30286. * @param blockName Name of the block to bind.
  30287. * @param index Index to bind.
  30288. */
  30289. bindUniformBlock(blockName: string, index: number): void;
  30290. /**
  30291. * Sets an interger value on a uniform variable.
  30292. * @param uniformName Name of the variable.
  30293. * @param value Value to be set.
  30294. * @returns this effect.
  30295. */
  30296. setInt(uniformName: string, value: number): Effect;
  30297. /**
  30298. * Sets an int array on a uniform variable.
  30299. * @param uniformName Name of the variable.
  30300. * @param array array to be set.
  30301. * @returns this effect.
  30302. */
  30303. setIntArray(uniformName: string, array: Int32Array): Effect;
  30304. /**
  30305. * 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)
  30306. * @param uniformName Name of the variable.
  30307. * @param array array to be set.
  30308. * @returns this effect.
  30309. */
  30310. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30311. /**
  30312. * 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)
  30313. * @param uniformName Name of the variable.
  30314. * @param array array to be set.
  30315. * @returns this effect.
  30316. */
  30317. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30318. /**
  30319. * 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)
  30320. * @param uniformName Name of the variable.
  30321. * @param array array to be set.
  30322. * @returns this effect.
  30323. */
  30324. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30325. /**
  30326. * Sets an float array on a uniform variable.
  30327. * @param uniformName Name of the variable.
  30328. * @param array array to be set.
  30329. * @returns this effect.
  30330. */
  30331. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30332. /**
  30333. * 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)
  30334. * @param uniformName Name of the variable.
  30335. * @param array array to be set.
  30336. * @returns this effect.
  30337. */
  30338. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30339. /**
  30340. * 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)
  30341. * @param uniformName Name of the variable.
  30342. * @param array array to be set.
  30343. * @returns this effect.
  30344. */
  30345. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30346. /**
  30347. * 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)
  30348. * @param uniformName Name of the variable.
  30349. * @param array array to be set.
  30350. * @returns this effect.
  30351. */
  30352. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30353. /**
  30354. * Sets an array on a uniform variable.
  30355. * @param uniformName Name of the variable.
  30356. * @param array array to be set.
  30357. * @returns this effect.
  30358. */
  30359. setArray(uniformName: string, array: number[]): Effect;
  30360. /**
  30361. * 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)
  30362. * @param uniformName Name of the variable.
  30363. * @param array array to be set.
  30364. * @returns this effect.
  30365. */
  30366. setArray2(uniformName: string, array: number[]): Effect;
  30367. /**
  30368. * 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)
  30369. * @param uniformName Name of the variable.
  30370. * @param array array to be set.
  30371. * @returns this effect.
  30372. */
  30373. setArray3(uniformName: string, array: number[]): Effect;
  30374. /**
  30375. * 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)
  30376. * @param uniformName Name of the variable.
  30377. * @param array array to be set.
  30378. * @returns this effect.
  30379. */
  30380. setArray4(uniformName: string, array: number[]): Effect;
  30381. /**
  30382. * Sets matrices on a uniform variable.
  30383. * @param uniformName Name of the variable.
  30384. * @param matrices matrices to be set.
  30385. * @returns this effect.
  30386. */
  30387. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30388. /**
  30389. * Sets matrix on a uniform variable.
  30390. * @param uniformName Name of the variable.
  30391. * @param matrix matrix to be set.
  30392. * @returns this effect.
  30393. */
  30394. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30395. /**
  30396. * 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)
  30397. * @param uniformName Name of the variable.
  30398. * @param matrix matrix to be set.
  30399. * @returns this effect.
  30400. */
  30401. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30402. /**
  30403. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30404. * @param uniformName Name of the variable.
  30405. * @param matrix matrix to be set.
  30406. * @returns this effect.
  30407. */
  30408. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30409. /**
  30410. * Sets a float on a uniform variable.
  30411. * @param uniformName Name of the variable.
  30412. * @param value value to be set.
  30413. * @returns this effect.
  30414. */
  30415. setFloat(uniformName: string, value: number): Effect;
  30416. /**
  30417. * Sets a boolean on a uniform variable.
  30418. * @param uniformName Name of the variable.
  30419. * @param bool value to be set.
  30420. * @returns this effect.
  30421. */
  30422. setBool(uniformName: string, bool: boolean): Effect;
  30423. /**
  30424. * Sets a Vector2 on a uniform variable.
  30425. * @param uniformName Name of the variable.
  30426. * @param vector2 vector2 to be set.
  30427. * @returns this effect.
  30428. */
  30429. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30430. /**
  30431. * Sets a float2 on a uniform variable.
  30432. * @param uniformName Name of the variable.
  30433. * @param x First float in float2.
  30434. * @param y Second float in float2.
  30435. * @returns this effect.
  30436. */
  30437. setFloat2(uniformName: string, x: number, y: number): Effect;
  30438. /**
  30439. * Sets a Vector3 on a uniform variable.
  30440. * @param uniformName Name of the variable.
  30441. * @param vector3 Value to be set.
  30442. * @returns this effect.
  30443. */
  30444. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30445. /**
  30446. * Sets a float3 on a uniform variable.
  30447. * @param uniformName Name of the variable.
  30448. * @param x First float in float3.
  30449. * @param y Second float in float3.
  30450. * @param z Third float in float3.
  30451. * @returns this effect.
  30452. */
  30453. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30454. /**
  30455. * Sets a Vector4 on a uniform variable.
  30456. * @param uniformName Name of the variable.
  30457. * @param vector4 Value to be set.
  30458. * @returns this effect.
  30459. */
  30460. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30461. /**
  30462. * Sets a float4 on a uniform variable.
  30463. * @param uniformName Name of the variable.
  30464. * @param x First float in float4.
  30465. * @param y Second float in float4.
  30466. * @param z Third float in float4.
  30467. * @param w Fourth float in float4.
  30468. * @returns this effect.
  30469. */
  30470. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30471. /**
  30472. * Sets a Color3 on a uniform variable.
  30473. * @param uniformName Name of the variable.
  30474. * @param color3 Value to be set.
  30475. * @returns this effect.
  30476. */
  30477. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30478. /**
  30479. * Sets a Color4 on a uniform variable.
  30480. * @param uniformName Name of the variable.
  30481. * @param color3 Value to be set.
  30482. * @param alpha Alpha value to be set.
  30483. * @returns this effect.
  30484. */
  30485. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30486. /**
  30487. * Sets a Color4 on a uniform variable
  30488. * @param uniformName defines the name of the variable
  30489. * @param color4 defines the value to be set
  30490. * @returns this effect.
  30491. */
  30492. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30493. /** Release all associated resources */
  30494. dispose(): void;
  30495. /**
  30496. * This function will add a new shader to the shader store
  30497. * @param name the name of the shader
  30498. * @param pixelShader optional pixel shader content
  30499. * @param vertexShader optional vertex shader content
  30500. */
  30501. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30502. /**
  30503. * Store of each shader (The can be looked up using effect.key)
  30504. */
  30505. static ShadersStore: {
  30506. [key: string]: string;
  30507. };
  30508. /**
  30509. * Store of each included file for a shader (The can be looked up using effect.key)
  30510. */
  30511. static IncludesShadersStore: {
  30512. [key: string]: string;
  30513. };
  30514. /**
  30515. * Resets the cache of effects.
  30516. */
  30517. static ResetCache(): void;
  30518. }
  30519. }
  30520. declare module BABYLON {
  30521. /**
  30522. * Interface used to describe the capabilities of the engine relatively to the current browser
  30523. */
  30524. export interface EngineCapabilities {
  30525. /** Maximum textures units per fragment shader */
  30526. maxTexturesImageUnits: number;
  30527. /** Maximum texture units per vertex shader */
  30528. maxVertexTextureImageUnits: number;
  30529. /** Maximum textures units in the entire pipeline */
  30530. maxCombinedTexturesImageUnits: number;
  30531. /** Maximum texture size */
  30532. maxTextureSize: number;
  30533. /** Maximum texture samples */
  30534. maxSamples?: number;
  30535. /** Maximum cube texture size */
  30536. maxCubemapTextureSize: number;
  30537. /** Maximum render texture size */
  30538. maxRenderTextureSize: number;
  30539. /** Maximum number of vertex attributes */
  30540. maxVertexAttribs: number;
  30541. /** Maximum number of varyings */
  30542. maxVaryingVectors: number;
  30543. /** Maximum number of uniforms per vertex shader */
  30544. maxVertexUniformVectors: number;
  30545. /** Maximum number of uniforms per fragment shader */
  30546. maxFragmentUniformVectors: number;
  30547. /** Defines if standard derivates (dx/dy) are supported */
  30548. standardDerivatives: boolean;
  30549. /** Defines if s3tc texture compression is supported */
  30550. s3tc?: WEBGL_compressed_texture_s3tc;
  30551. /** Defines if pvrtc texture compression is supported */
  30552. pvrtc: any;
  30553. /** Defines if etc1 texture compression is supported */
  30554. etc1: any;
  30555. /** Defines if etc2 texture compression is supported */
  30556. etc2: any;
  30557. /** Defines if astc texture compression is supported */
  30558. astc: any;
  30559. /** Defines if float textures are supported */
  30560. textureFloat: boolean;
  30561. /** Defines if vertex array objects are supported */
  30562. vertexArrayObject: boolean;
  30563. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30564. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30565. /** Gets the maximum level of anisotropy supported */
  30566. maxAnisotropy: number;
  30567. /** Defines if instancing is supported */
  30568. instancedArrays: boolean;
  30569. /** Defines if 32 bits indices are supported */
  30570. uintIndices: boolean;
  30571. /** Defines if high precision shaders are supported */
  30572. highPrecisionShaderSupported: boolean;
  30573. /** Defines if depth reading in the fragment shader is supported */
  30574. fragmentDepthSupported: boolean;
  30575. /** Defines if float texture linear filtering is supported*/
  30576. textureFloatLinearFiltering: boolean;
  30577. /** Defines if rendering to float textures is supported */
  30578. textureFloatRender: boolean;
  30579. /** Defines if half float textures are supported*/
  30580. textureHalfFloat: boolean;
  30581. /** Defines if half float texture linear filtering is supported*/
  30582. textureHalfFloatLinearFiltering: boolean;
  30583. /** Defines if rendering to half float textures is supported */
  30584. textureHalfFloatRender: boolean;
  30585. /** Defines if textureLOD shader command is supported */
  30586. textureLOD: boolean;
  30587. /** Defines if draw buffers extension is supported */
  30588. drawBuffersExtension: boolean;
  30589. /** Defines if depth textures are supported */
  30590. depthTextureExtension: boolean;
  30591. /** Defines if float color buffer are supported */
  30592. colorBufferFloat: boolean;
  30593. /** Gets disjoint timer query extension (null if not supported) */
  30594. timerQuery?: EXT_disjoint_timer_query;
  30595. /** Defines if timestamp can be used with timer query */
  30596. canUseTimestampForTimerQuery: boolean;
  30597. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30598. multiview?: any;
  30599. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30600. oculusMultiview?: any;
  30601. /** Function used to let the system compiles shaders in background */
  30602. parallelShaderCompile?: {
  30603. COMPLETION_STATUS_KHR: number;
  30604. };
  30605. /** Max number of texture samples for MSAA */
  30606. maxMSAASamples: number;
  30607. /** Defines if the blend min max extension is supported */
  30608. blendMinMax: boolean;
  30609. }
  30610. }
  30611. declare module BABYLON {
  30612. /**
  30613. * @hidden
  30614. **/
  30615. export class DepthCullingState {
  30616. private _isDepthTestDirty;
  30617. private _isDepthMaskDirty;
  30618. private _isDepthFuncDirty;
  30619. private _isCullFaceDirty;
  30620. private _isCullDirty;
  30621. private _isZOffsetDirty;
  30622. private _isFrontFaceDirty;
  30623. private _depthTest;
  30624. private _depthMask;
  30625. private _depthFunc;
  30626. private _cull;
  30627. private _cullFace;
  30628. private _zOffset;
  30629. private _frontFace;
  30630. /**
  30631. * Initializes the state.
  30632. */
  30633. constructor();
  30634. get isDirty(): boolean;
  30635. get zOffset(): number;
  30636. set zOffset(value: number);
  30637. get cullFace(): Nullable<number>;
  30638. set cullFace(value: Nullable<number>);
  30639. get cull(): Nullable<boolean>;
  30640. set cull(value: Nullable<boolean>);
  30641. get depthFunc(): Nullable<number>;
  30642. set depthFunc(value: Nullable<number>);
  30643. get depthMask(): boolean;
  30644. set depthMask(value: boolean);
  30645. get depthTest(): boolean;
  30646. set depthTest(value: boolean);
  30647. get frontFace(): Nullable<number>;
  30648. set frontFace(value: Nullable<number>);
  30649. reset(): void;
  30650. apply(gl: WebGLRenderingContext): void;
  30651. }
  30652. }
  30653. declare module BABYLON {
  30654. /**
  30655. * @hidden
  30656. **/
  30657. export class StencilState {
  30658. /** 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 */
  30659. static readonly ALWAYS: number;
  30660. /** Passed to stencilOperation to specify that stencil value must be kept */
  30661. static readonly KEEP: number;
  30662. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30663. static readonly REPLACE: number;
  30664. private _isStencilTestDirty;
  30665. private _isStencilMaskDirty;
  30666. private _isStencilFuncDirty;
  30667. private _isStencilOpDirty;
  30668. private _stencilTest;
  30669. private _stencilMask;
  30670. private _stencilFunc;
  30671. private _stencilFuncRef;
  30672. private _stencilFuncMask;
  30673. private _stencilOpStencilFail;
  30674. private _stencilOpDepthFail;
  30675. private _stencilOpStencilDepthPass;
  30676. get isDirty(): boolean;
  30677. get stencilFunc(): number;
  30678. set stencilFunc(value: number);
  30679. get stencilFuncRef(): number;
  30680. set stencilFuncRef(value: number);
  30681. get stencilFuncMask(): number;
  30682. set stencilFuncMask(value: number);
  30683. get stencilOpStencilFail(): number;
  30684. set stencilOpStencilFail(value: number);
  30685. get stencilOpDepthFail(): number;
  30686. set stencilOpDepthFail(value: number);
  30687. get stencilOpStencilDepthPass(): number;
  30688. set stencilOpStencilDepthPass(value: number);
  30689. get stencilMask(): number;
  30690. set stencilMask(value: number);
  30691. get stencilTest(): boolean;
  30692. set stencilTest(value: boolean);
  30693. constructor();
  30694. reset(): void;
  30695. apply(gl: WebGLRenderingContext): void;
  30696. }
  30697. }
  30698. declare module BABYLON {
  30699. /**
  30700. * @hidden
  30701. **/
  30702. export class AlphaState {
  30703. private _isAlphaBlendDirty;
  30704. private _isBlendFunctionParametersDirty;
  30705. private _isBlendEquationParametersDirty;
  30706. private _isBlendConstantsDirty;
  30707. private _alphaBlend;
  30708. private _blendFunctionParameters;
  30709. private _blendEquationParameters;
  30710. private _blendConstants;
  30711. /**
  30712. * Initializes the state.
  30713. */
  30714. constructor();
  30715. get isDirty(): boolean;
  30716. get alphaBlend(): boolean;
  30717. set alphaBlend(value: boolean);
  30718. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30719. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30720. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30721. reset(): void;
  30722. apply(gl: WebGLRenderingContext): void;
  30723. }
  30724. }
  30725. declare module BABYLON {
  30726. /** @hidden */
  30727. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30728. attributeProcessor(attribute: string): string;
  30729. varyingProcessor(varying: string, isFragment: boolean): string;
  30730. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30731. }
  30732. }
  30733. declare module BABYLON {
  30734. /**
  30735. * Interface for attribute information associated with buffer instanciation
  30736. */
  30737. export interface InstancingAttributeInfo {
  30738. /**
  30739. * Name of the GLSL attribute
  30740. * if attribute index is not specified, this is used to retrieve the index from the effect
  30741. */
  30742. attributeName: string;
  30743. /**
  30744. * Index/offset of the attribute in the vertex shader
  30745. * if not specified, this will be computes from the name.
  30746. */
  30747. index?: number;
  30748. /**
  30749. * size of the attribute, 1, 2, 3 or 4
  30750. */
  30751. attributeSize: number;
  30752. /**
  30753. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30754. */
  30755. offset: number;
  30756. /**
  30757. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30758. * default to 1
  30759. */
  30760. divisor?: number;
  30761. /**
  30762. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30763. * default is FLOAT
  30764. */
  30765. attributeType?: number;
  30766. /**
  30767. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30768. */
  30769. normalized?: boolean;
  30770. }
  30771. }
  30772. declare module BABYLON {
  30773. interface ThinEngine {
  30774. /**
  30775. * Update a video texture
  30776. * @param texture defines the texture to update
  30777. * @param video defines the video element to use
  30778. * @param invertY defines if data must be stored with Y axis inverted
  30779. */
  30780. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30781. }
  30782. }
  30783. declare module BABYLON {
  30784. /**
  30785. * Settings for finer control over video usage
  30786. */
  30787. export interface VideoTextureSettings {
  30788. /**
  30789. * Applies `autoplay` to video, if specified
  30790. */
  30791. autoPlay?: boolean;
  30792. /**
  30793. * Applies `loop` to video, if specified
  30794. */
  30795. loop?: boolean;
  30796. /**
  30797. * Automatically updates internal texture from video at every frame in the render loop
  30798. */
  30799. autoUpdateTexture: boolean;
  30800. /**
  30801. * Image src displayed during the video loading or until the user interacts with the video.
  30802. */
  30803. poster?: string;
  30804. }
  30805. /**
  30806. * If you want to display a video in your scene, this is the special texture for that.
  30807. * This special texture works similar to other textures, with the exception of a few parameters.
  30808. * @see https://doc.babylonjs.com/how_to/video_texture
  30809. */
  30810. export class VideoTexture extends Texture {
  30811. /**
  30812. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30813. */
  30814. readonly autoUpdateTexture: boolean;
  30815. /**
  30816. * The video instance used by the texture internally
  30817. */
  30818. readonly video: HTMLVideoElement;
  30819. private _onUserActionRequestedObservable;
  30820. /**
  30821. * Event triggerd when a dom action is required by the user to play the video.
  30822. * This happens due to recent changes in browser policies preventing video to auto start.
  30823. */
  30824. get onUserActionRequestedObservable(): Observable<Texture>;
  30825. private _generateMipMaps;
  30826. private _engine;
  30827. private _stillImageCaptured;
  30828. private _displayingPosterTexture;
  30829. private _settings;
  30830. private _createInternalTextureOnEvent;
  30831. private _frameId;
  30832. private _currentSrc;
  30833. /**
  30834. * Creates a video texture.
  30835. * If you want to display a video in your scene, this is the special texture for that.
  30836. * This special texture works similar to other textures, with the exception of a few parameters.
  30837. * @see https://doc.babylonjs.com/how_to/video_texture
  30838. * @param name optional name, will detect from video source, if not defined
  30839. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30840. * @param scene is obviously the current scene.
  30841. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30842. * @param invertY is false by default but can be used to invert video on Y axis
  30843. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30844. * @param settings allows finer control over video usage
  30845. */
  30846. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30847. private _getName;
  30848. private _getVideo;
  30849. private _createInternalTexture;
  30850. private reset;
  30851. /**
  30852. * @hidden Internal method to initiate `update`.
  30853. */
  30854. _rebuild(): void;
  30855. /**
  30856. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30857. */
  30858. update(): void;
  30859. /**
  30860. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30861. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30862. */
  30863. updateTexture(isVisible: boolean): void;
  30864. protected _updateInternalTexture: () => void;
  30865. /**
  30866. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30867. * @param url New url.
  30868. */
  30869. updateURL(url: string): void;
  30870. /**
  30871. * Clones the texture.
  30872. * @returns the cloned texture
  30873. */
  30874. clone(): VideoTexture;
  30875. /**
  30876. * Dispose the texture and release its associated resources.
  30877. */
  30878. dispose(): void;
  30879. /**
  30880. * Creates a video texture straight from a stream.
  30881. * @param scene Define the scene the texture should be created in
  30882. * @param stream Define the stream the texture should be created from
  30883. * @returns The created video texture as a promise
  30884. */
  30885. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30886. /**
  30887. * Creates a video texture straight from your WebCam video feed.
  30888. * @param scene Define the scene the texture should be created in
  30889. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30890. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30891. * @returns The created video texture as a promise
  30892. */
  30893. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30894. minWidth: number;
  30895. maxWidth: number;
  30896. minHeight: number;
  30897. maxHeight: number;
  30898. deviceId: string;
  30899. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30900. /**
  30901. * Creates a video texture straight from your WebCam video feed.
  30902. * @param scene Define the scene the texture should be created in
  30903. * @param onReady Define a callback to triggered once the texture will be ready
  30904. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30905. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30906. */
  30907. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30908. minWidth: number;
  30909. maxWidth: number;
  30910. minHeight: number;
  30911. maxHeight: number;
  30912. deviceId: string;
  30913. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30914. }
  30915. }
  30916. declare module BABYLON {
  30917. /**
  30918. * Defines the interface used by objects working like Scene
  30919. * @hidden
  30920. */
  30921. export interface ISceneLike {
  30922. _addPendingData(data: any): void;
  30923. _removePendingData(data: any): void;
  30924. offlineProvider: IOfflineProvider;
  30925. }
  30926. /** Interface defining initialization parameters for Engine class */
  30927. export interface EngineOptions extends WebGLContextAttributes {
  30928. /**
  30929. * Defines if the engine should no exceed a specified device ratio
  30930. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30931. */
  30932. limitDeviceRatio?: number;
  30933. /**
  30934. * Defines if webvr should be enabled automatically
  30935. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30936. */
  30937. autoEnableWebVR?: boolean;
  30938. /**
  30939. * Defines if webgl2 should be turned off even if supported
  30940. * @see http://doc.babylonjs.com/features/webgl2
  30941. */
  30942. disableWebGL2Support?: boolean;
  30943. /**
  30944. * Defines if webaudio should be initialized as well
  30945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30946. */
  30947. audioEngine?: boolean;
  30948. /**
  30949. * Defines if animations should run using a deterministic lock step
  30950. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30951. */
  30952. deterministicLockstep?: boolean;
  30953. /** Defines the maximum steps to use with deterministic lock step mode */
  30954. lockstepMaxSteps?: number;
  30955. /** Defines the seconds between each deterministic lock step */
  30956. timeStep?: number;
  30957. /**
  30958. * Defines that engine should ignore context lost events
  30959. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30960. */
  30961. doNotHandleContextLost?: boolean;
  30962. /**
  30963. * Defines that engine should ignore modifying touch action attribute and style
  30964. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30965. */
  30966. doNotHandleTouchAction?: boolean;
  30967. /**
  30968. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30969. */
  30970. useHighPrecisionFloats?: boolean;
  30971. }
  30972. /**
  30973. * The base engine class (root of all engines)
  30974. */
  30975. export class ThinEngine {
  30976. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30977. static ExceptionList: ({
  30978. key: string;
  30979. capture: string;
  30980. captureConstraint: number;
  30981. targets: string[];
  30982. } | {
  30983. key: string;
  30984. capture: null;
  30985. captureConstraint: null;
  30986. targets: string[];
  30987. })[];
  30988. /** @hidden */
  30989. static _TextureLoaders: IInternalTextureLoader[];
  30990. /**
  30991. * Returns the current npm package of the sdk
  30992. */
  30993. static get NpmPackage(): string;
  30994. /**
  30995. * Returns the current version of the framework
  30996. */
  30997. static get Version(): string;
  30998. /**
  30999. * Returns a string describing the current engine
  31000. */
  31001. get description(): string;
  31002. /**
  31003. * Gets or sets the epsilon value used by collision engine
  31004. */
  31005. static CollisionsEpsilon: number;
  31006. /**
  31007. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31008. */
  31009. static get ShadersRepository(): string;
  31010. static set ShadersRepository(value: string);
  31011. /** @hidden */
  31012. _shaderProcessor: IShaderProcessor;
  31013. /**
  31014. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31015. */
  31016. forcePOTTextures: boolean;
  31017. /**
  31018. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31019. */
  31020. isFullscreen: boolean;
  31021. /**
  31022. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31023. */
  31024. cullBackFaces: boolean;
  31025. /**
  31026. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31027. */
  31028. renderEvenInBackground: boolean;
  31029. /**
  31030. * Gets or sets a boolean indicating that cache can be kept between frames
  31031. */
  31032. preventCacheWipeBetweenFrames: boolean;
  31033. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31034. validateShaderPrograms: boolean;
  31035. /**
  31036. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31037. * This can provide greater z depth for distant objects.
  31038. */
  31039. useReverseDepthBuffer: boolean;
  31040. /**
  31041. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31042. */
  31043. disableUniformBuffers: boolean;
  31044. /** @hidden */
  31045. _uniformBuffers: UniformBuffer[];
  31046. /**
  31047. * Gets a boolean indicating that the engine supports uniform buffers
  31048. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31049. */
  31050. get supportsUniformBuffers(): boolean;
  31051. /** @hidden */
  31052. _gl: WebGLRenderingContext;
  31053. /** @hidden */
  31054. _webGLVersion: number;
  31055. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31056. protected _windowIsBackground: boolean;
  31057. protected _creationOptions: EngineOptions;
  31058. protected _highPrecisionShadersAllowed: boolean;
  31059. /** @hidden */
  31060. get _shouldUseHighPrecisionShader(): boolean;
  31061. /**
  31062. * Gets a boolean indicating that only power of 2 textures are supported
  31063. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31064. */
  31065. get needPOTTextures(): boolean;
  31066. /** @hidden */
  31067. _badOS: boolean;
  31068. /** @hidden */
  31069. _badDesktopOS: boolean;
  31070. private _hardwareScalingLevel;
  31071. /** @hidden */
  31072. _caps: EngineCapabilities;
  31073. private _isStencilEnable;
  31074. private _glVersion;
  31075. private _glRenderer;
  31076. private _glVendor;
  31077. /** @hidden */
  31078. _videoTextureSupported: boolean;
  31079. protected _renderingQueueLaunched: boolean;
  31080. protected _activeRenderLoops: (() => void)[];
  31081. /**
  31082. * Observable signaled when a context lost event is raised
  31083. */
  31084. onContextLostObservable: Observable<ThinEngine>;
  31085. /**
  31086. * Observable signaled when a context restored event is raised
  31087. */
  31088. onContextRestoredObservable: Observable<ThinEngine>;
  31089. private _onContextLost;
  31090. private _onContextRestored;
  31091. protected _contextWasLost: boolean;
  31092. /** @hidden */
  31093. _doNotHandleContextLost: boolean;
  31094. /**
  31095. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31097. */
  31098. get doNotHandleContextLost(): boolean;
  31099. set doNotHandleContextLost(value: boolean);
  31100. /**
  31101. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31102. */
  31103. disableVertexArrayObjects: boolean;
  31104. /** @hidden */
  31105. protected _colorWrite: boolean;
  31106. /** @hidden */
  31107. protected _colorWriteChanged: boolean;
  31108. /** @hidden */
  31109. protected _depthCullingState: DepthCullingState;
  31110. /** @hidden */
  31111. protected _stencilState: StencilState;
  31112. /** @hidden */
  31113. _alphaState: AlphaState;
  31114. /** @hidden */
  31115. _alphaMode: number;
  31116. /** @hidden */
  31117. _alphaEquation: number;
  31118. /** @hidden */
  31119. _internalTexturesCache: InternalTexture[];
  31120. /** @hidden */
  31121. protected _activeChannel: number;
  31122. private _currentTextureChannel;
  31123. /** @hidden */
  31124. protected _boundTexturesCache: {
  31125. [key: string]: Nullable<InternalTexture>;
  31126. };
  31127. /** @hidden */
  31128. protected _currentEffect: Nullable<Effect>;
  31129. /** @hidden */
  31130. protected _currentProgram: Nullable<WebGLProgram>;
  31131. private _compiledEffects;
  31132. private _vertexAttribArraysEnabled;
  31133. /** @hidden */
  31134. protected _cachedViewport: Nullable<IViewportLike>;
  31135. private _cachedVertexArrayObject;
  31136. /** @hidden */
  31137. protected _cachedVertexBuffers: any;
  31138. /** @hidden */
  31139. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31140. /** @hidden */
  31141. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31142. /** @hidden */
  31143. _currentRenderTarget: Nullable<InternalTexture>;
  31144. private _uintIndicesCurrentlySet;
  31145. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31146. /** @hidden */
  31147. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31148. private _currentBufferPointers;
  31149. private _currentInstanceLocations;
  31150. private _currentInstanceBuffers;
  31151. private _textureUnits;
  31152. /** @hidden */
  31153. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31154. /** @hidden */
  31155. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31156. /** @hidden */
  31157. _boundRenderFunction: any;
  31158. private _vaoRecordInProgress;
  31159. private _mustWipeVertexAttributes;
  31160. private _emptyTexture;
  31161. private _emptyCubeTexture;
  31162. private _emptyTexture3D;
  31163. private _emptyTexture2DArray;
  31164. /** @hidden */
  31165. _frameHandler: number;
  31166. private _nextFreeTextureSlots;
  31167. private _maxSimultaneousTextures;
  31168. private _activeRequests;
  31169. protected _texturesSupported: string[];
  31170. /** @hidden */
  31171. _textureFormatInUse: Nullable<string>;
  31172. protected get _supportsHardwareTextureRescaling(): boolean;
  31173. private _framebufferDimensionsObject;
  31174. /**
  31175. * sets the object from which width and height will be taken from when getting render width and height
  31176. * Will fallback to the gl object
  31177. * @param dimensions the framebuffer width and height that will be used.
  31178. */
  31179. set framebufferDimensionsObject(dimensions: Nullable<{
  31180. framebufferWidth: number;
  31181. framebufferHeight: number;
  31182. }>);
  31183. /**
  31184. * Gets the list of texture formats supported
  31185. */
  31186. get texturesSupported(): Array<string>;
  31187. /**
  31188. * Gets the list of texture formats in use
  31189. */
  31190. get textureFormatInUse(): Nullable<string>;
  31191. /**
  31192. * Gets the current viewport
  31193. */
  31194. get currentViewport(): Nullable<IViewportLike>;
  31195. /**
  31196. * Gets the default empty texture
  31197. */
  31198. get emptyTexture(): InternalTexture;
  31199. /**
  31200. * Gets the default empty 3D texture
  31201. */
  31202. get emptyTexture3D(): InternalTexture;
  31203. /**
  31204. * Gets the default empty 2D array texture
  31205. */
  31206. get emptyTexture2DArray(): InternalTexture;
  31207. /**
  31208. * Gets the default empty cube texture
  31209. */
  31210. get emptyCubeTexture(): InternalTexture;
  31211. /**
  31212. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31213. */
  31214. readonly premultipliedAlpha: boolean;
  31215. /**
  31216. * Observable event triggered before each texture is initialized
  31217. */
  31218. onBeforeTextureInitObservable: Observable<Texture>;
  31219. /**
  31220. * Creates a new engine
  31221. * @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
  31222. * @param antialias defines enable antialiasing (default: false)
  31223. * @param options defines further options to be sent to the getContext() function
  31224. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31225. */
  31226. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31227. private _rebuildInternalTextures;
  31228. private _rebuildEffects;
  31229. /**
  31230. * Gets a boolean indicating if all created effects are ready
  31231. * @returns true if all effects are ready
  31232. */
  31233. areAllEffectsReady(): boolean;
  31234. protected _rebuildBuffers(): void;
  31235. private _initGLContext;
  31236. /**
  31237. * Gets version of the current webGL context
  31238. */
  31239. get webGLVersion(): number;
  31240. /**
  31241. * Gets a string idenfifying the name of the class
  31242. * @returns "Engine" string
  31243. */
  31244. getClassName(): string;
  31245. /**
  31246. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31247. */
  31248. get isStencilEnable(): boolean;
  31249. /** @hidden */
  31250. _prepareWorkingCanvas(): void;
  31251. /**
  31252. * Reset the texture cache to empty state
  31253. */
  31254. resetTextureCache(): void;
  31255. /**
  31256. * Gets an object containing information about the current webGL context
  31257. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31258. */
  31259. getGlInfo(): {
  31260. vendor: string;
  31261. renderer: string;
  31262. version: string;
  31263. };
  31264. /**
  31265. * Defines the hardware scaling level.
  31266. * By default the hardware scaling level is computed from the window device ratio.
  31267. * 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.
  31268. * @param level defines the level to use
  31269. */
  31270. setHardwareScalingLevel(level: number): void;
  31271. /**
  31272. * Gets the current hardware scaling level.
  31273. * By default the hardware scaling level is computed from the window device ratio.
  31274. * 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.
  31275. * @returns a number indicating the current hardware scaling level
  31276. */
  31277. getHardwareScalingLevel(): number;
  31278. /**
  31279. * Gets the list of loaded textures
  31280. * @returns an array containing all loaded textures
  31281. */
  31282. getLoadedTexturesCache(): InternalTexture[];
  31283. /**
  31284. * Gets the object containing all engine capabilities
  31285. * @returns the EngineCapabilities object
  31286. */
  31287. getCaps(): EngineCapabilities;
  31288. /**
  31289. * stop executing a render loop function and remove it from the execution array
  31290. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31291. */
  31292. stopRenderLoop(renderFunction?: () => void): void;
  31293. /** @hidden */
  31294. _renderLoop(): void;
  31295. /**
  31296. * Gets the HTML canvas attached with the current webGL context
  31297. * @returns a HTML canvas
  31298. */
  31299. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31300. /**
  31301. * Gets host window
  31302. * @returns the host window object
  31303. */
  31304. getHostWindow(): Nullable<Window>;
  31305. /**
  31306. * Gets the current render width
  31307. * @param useScreen defines if screen size must be used (or the current render target if any)
  31308. * @returns a number defining the current render width
  31309. */
  31310. getRenderWidth(useScreen?: boolean): number;
  31311. /**
  31312. * Gets the current render height
  31313. * @param useScreen defines if screen size must be used (or the current render target if any)
  31314. * @returns a number defining the current render height
  31315. */
  31316. getRenderHeight(useScreen?: boolean): number;
  31317. /**
  31318. * Can be used to override the current requestAnimationFrame requester.
  31319. * @hidden
  31320. */
  31321. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31322. /**
  31323. * Register and execute a render loop. The engine can have more than one render function
  31324. * @param renderFunction defines the function to continuously execute
  31325. */
  31326. runRenderLoop(renderFunction: () => void): void;
  31327. /**
  31328. * Clear the current render buffer or the current render target (if any is set up)
  31329. * @param color defines the color to use
  31330. * @param backBuffer defines if the back buffer must be cleared
  31331. * @param depth defines if the depth buffer must be cleared
  31332. * @param stencil defines if the stencil buffer must be cleared
  31333. */
  31334. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31335. private _viewportCached;
  31336. /** @hidden */
  31337. _viewport(x: number, y: number, width: number, height: number): void;
  31338. /**
  31339. * Set the WebGL's viewport
  31340. * @param viewport defines the viewport element to be used
  31341. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31342. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31343. */
  31344. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31345. /**
  31346. * Begin a new frame
  31347. */
  31348. beginFrame(): void;
  31349. /**
  31350. * Enf the current frame
  31351. */
  31352. endFrame(): void;
  31353. /**
  31354. * Resize the view according to the canvas' size
  31355. */
  31356. resize(): void;
  31357. /**
  31358. * Force a specific size of the canvas
  31359. * @param width defines the new canvas' width
  31360. * @param height defines the new canvas' height
  31361. */
  31362. setSize(width: number, height: number): void;
  31363. /**
  31364. * Binds the frame buffer to the specified texture.
  31365. * @param texture The texture to render to or null for the default canvas
  31366. * @param faceIndex The face of the texture to render to in case of cube texture
  31367. * @param requiredWidth The width of the target to render to
  31368. * @param requiredHeight The height of the target to render to
  31369. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31370. * @param lodLevel defines the lod level to bind to the frame buffer
  31371. * @param layer defines the 2d array index to bind to frame buffer to
  31372. */
  31373. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31374. /** @hidden */
  31375. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31376. /**
  31377. * Unbind the current render target texture from the webGL context
  31378. * @param texture defines the render target texture to unbind
  31379. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31380. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31381. */
  31382. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31383. /**
  31384. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31385. */
  31386. flushFramebuffer(): void;
  31387. /**
  31388. * Unbind the current render target and bind the default framebuffer
  31389. */
  31390. restoreDefaultFramebuffer(): void;
  31391. /** @hidden */
  31392. protected _resetVertexBufferBinding(): void;
  31393. /**
  31394. * Creates a vertex buffer
  31395. * @param data the data for the vertex buffer
  31396. * @returns the new WebGL static buffer
  31397. */
  31398. createVertexBuffer(data: DataArray): DataBuffer;
  31399. private _createVertexBuffer;
  31400. /**
  31401. * Creates a dynamic vertex buffer
  31402. * @param data the data for the dynamic vertex buffer
  31403. * @returns the new WebGL dynamic buffer
  31404. */
  31405. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31406. protected _resetIndexBufferBinding(): void;
  31407. /**
  31408. * Creates a new index buffer
  31409. * @param indices defines the content of the index buffer
  31410. * @param updatable defines if the index buffer must be updatable
  31411. * @returns a new webGL buffer
  31412. */
  31413. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31414. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31415. /**
  31416. * Bind a webGL buffer to the webGL context
  31417. * @param buffer defines the buffer to bind
  31418. */
  31419. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31420. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31421. private bindBuffer;
  31422. /**
  31423. * update the bound buffer with the given data
  31424. * @param data defines the data to update
  31425. */
  31426. updateArrayBuffer(data: Float32Array): void;
  31427. private _vertexAttribPointer;
  31428. /** @hidden */
  31429. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31430. private _bindVertexBuffersAttributes;
  31431. /**
  31432. * Records a vertex array object
  31433. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31434. * @param vertexBuffers defines the list of vertex buffers to store
  31435. * @param indexBuffer defines the index buffer to store
  31436. * @param effect defines the effect to store
  31437. * @returns the new vertex array object
  31438. */
  31439. recordVertexArrayObject(vertexBuffers: {
  31440. [key: string]: VertexBuffer;
  31441. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31442. /**
  31443. * Bind a specific vertex array object
  31444. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31445. * @param vertexArrayObject defines the vertex array object to bind
  31446. * @param indexBuffer defines the index buffer to bind
  31447. */
  31448. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31449. /**
  31450. * Bind webGl buffers directly to the webGL context
  31451. * @param vertexBuffer defines the vertex buffer to bind
  31452. * @param indexBuffer defines the index buffer to bind
  31453. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31454. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31455. * @param effect defines the effect associated with the vertex buffer
  31456. */
  31457. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31458. private _unbindVertexArrayObject;
  31459. /**
  31460. * Bind a list of vertex buffers to the webGL context
  31461. * @param vertexBuffers defines the list of vertex buffers to bind
  31462. * @param indexBuffer defines the index buffer to bind
  31463. * @param effect defines the effect associated with the vertex buffers
  31464. */
  31465. bindBuffers(vertexBuffers: {
  31466. [key: string]: Nullable<VertexBuffer>;
  31467. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31468. /**
  31469. * Unbind all instance attributes
  31470. */
  31471. unbindInstanceAttributes(): void;
  31472. /**
  31473. * Release and free the memory of a vertex array object
  31474. * @param vao defines the vertex array object to delete
  31475. */
  31476. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31477. /** @hidden */
  31478. _releaseBuffer(buffer: DataBuffer): boolean;
  31479. protected _deleteBuffer(buffer: DataBuffer): void;
  31480. /**
  31481. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31482. * @param instancesBuffer defines the webGL buffer to update and bind
  31483. * @param data defines the data to store in the buffer
  31484. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31485. */
  31486. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31487. /**
  31488. * Bind the content of a webGL buffer used with instantiation
  31489. * @param instancesBuffer defines the webGL buffer to bind
  31490. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31491. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31492. */
  31493. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31494. /**
  31495. * Disable the instance attribute corresponding to the name in parameter
  31496. * @param name defines the name of the attribute to disable
  31497. */
  31498. disableInstanceAttributeByName(name: string): void;
  31499. /**
  31500. * Disable the instance attribute corresponding to the location in parameter
  31501. * @param attributeLocation defines the attribute location of the attribute to disable
  31502. */
  31503. disableInstanceAttribute(attributeLocation: number): void;
  31504. /**
  31505. * Disable the attribute corresponding to the location in parameter
  31506. * @param attributeLocation defines the attribute location of the attribute to disable
  31507. */
  31508. disableAttributeByIndex(attributeLocation: number): void;
  31509. /**
  31510. * Send a draw order
  31511. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31512. * @param indexStart defines the starting index
  31513. * @param indexCount defines the number of index to draw
  31514. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31515. */
  31516. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31517. /**
  31518. * Draw a list of points
  31519. * @param verticesStart defines the index of first vertex to draw
  31520. * @param verticesCount defines the count of vertices to draw
  31521. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31522. */
  31523. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31524. /**
  31525. * Draw a list of unindexed primitives
  31526. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31527. * @param verticesStart defines the index of first vertex to draw
  31528. * @param verticesCount defines the count of vertices to draw
  31529. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31530. */
  31531. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31532. /**
  31533. * Draw a list of indexed primitives
  31534. * @param fillMode defines the primitive to use
  31535. * @param indexStart defines the starting index
  31536. * @param indexCount defines the number of index to draw
  31537. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31538. */
  31539. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31540. /**
  31541. * Draw a list of unindexed primitives
  31542. * @param fillMode defines the primitive to use
  31543. * @param verticesStart defines the index of first vertex to draw
  31544. * @param verticesCount defines the count of vertices to draw
  31545. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31546. */
  31547. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31548. private _drawMode;
  31549. /** @hidden */
  31550. protected _reportDrawCall(): void;
  31551. /** @hidden */
  31552. _releaseEffect(effect: Effect): void;
  31553. /** @hidden */
  31554. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31555. /**
  31556. * Create a new effect (used to store vertex/fragment shaders)
  31557. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31558. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31559. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31560. * @param samplers defines an array of string used to represent textures
  31561. * @param defines defines the string containing the defines to use to compile the shaders
  31562. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31563. * @param onCompiled defines a function to call when the effect creation is successful
  31564. * @param onError defines a function to call when the effect creation has failed
  31565. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31566. * @returns the new Effect
  31567. */
  31568. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31569. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31570. private _compileShader;
  31571. private _compileRawShader;
  31572. /** @hidden */
  31573. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31574. /**
  31575. * Directly creates a webGL program
  31576. * @param pipelineContext defines the pipeline context to attach to
  31577. * @param vertexCode defines the vertex shader code to use
  31578. * @param fragmentCode defines the fragment shader code to use
  31579. * @param context defines the webGL context to use (if not set, the current one will be used)
  31580. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31581. * @returns the new webGL program
  31582. */
  31583. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31584. /**
  31585. * Creates a webGL program
  31586. * @param pipelineContext defines the pipeline context to attach to
  31587. * @param vertexCode defines the vertex shader code to use
  31588. * @param fragmentCode defines the fragment shader code to use
  31589. * @param defines defines the string containing the defines to use to compile the shaders
  31590. * @param context defines the webGL context to use (if not set, the current one will be used)
  31591. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31592. * @returns the new webGL program
  31593. */
  31594. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31595. /**
  31596. * Creates a new pipeline context
  31597. * @returns the new pipeline
  31598. */
  31599. createPipelineContext(): IPipelineContext;
  31600. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31601. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31602. /** @hidden */
  31603. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31604. /** @hidden */
  31605. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31606. /** @hidden */
  31607. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31608. /**
  31609. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31610. * @param pipelineContext defines the pipeline context to use
  31611. * @param uniformsNames defines the list of uniform names
  31612. * @returns an array of webGL uniform locations
  31613. */
  31614. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31615. /**
  31616. * Gets the lsit of active attributes for a given webGL program
  31617. * @param pipelineContext defines the pipeline context to use
  31618. * @param attributesNames defines the list of attribute names to get
  31619. * @returns an array of indices indicating the offset of each attribute
  31620. */
  31621. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31622. /**
  31623. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31624. * @param effect defines the effect to activate
  31625. */
  31626. enableEffect(effect: Nullable<Effect>): void;
  31627. /**
  31628. * Set the value of an uniform to a number (int)
  31629. * @param uniform defines the webGL uniform location where to store the value
  31630. * @param value defines the int number to store
  31631. */
  31632. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31633. /**
  31634. * Set the value of an uniform to an array of int32
  31635. * @param uniform defines the webGL uniform location where to store the value
  31636. * @param array defines the array of int32 to store
  31637. */
  31638. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31639. /**
  31640. * Set the value of an uniform to an array of int32 (stored as vec2)
  31641. * @param uniform defines the webGL uniform location where to store the value
  31642. * @param array defines the array of int32 to store
  31643. */
  31644. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31645. /**
  31646. * Set the value of an uniform to an array of int32 (stored as vec3)
  31647. * @param uniform defines the webGL uniform location where to store the value
  31648. * @param array defines the array of int32 to store
  31649. */
  31650. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31651. /**
  31652. * Set the value of an uniform to an array of int32 (stored as vec4)
  31653. * @param uniform defines the webGL uniform location where to store the value
  31654. * @param array defines the array of int32 to store
  31655. */
  31656. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31657. /**
  31658. * Set the value of an uniform to an array of number
  31659. * @param uniform defines the webGL uniform location where to store the value
  31660. * @param array defines the array of number to store
  31661. */
  31662. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31663. /**
  31664. * Set the value of an uniform to an array of number (stored as vec2)
  31665. * @param uniform defines the webGL uniform location where to store the value
  31666. * @param array defines the array of number to store
  31667. */
  31668. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31669. /**
  31670. * Set the value of an uniform to an array of number (stored as vec3)
  31671. * @param uniform defines the webGL uniform location where to store the value
  31672. * @param array defines the array of number to store
  31673. */
  31674. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31675. /**
  31676. * Set the value of an uniform to an array of number (stored as vec4)
  31677. * @param uniform defines the webGL uniform location where to store the value
  31678. * @param array defines the array of number to store
  31679. */
  31680. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31681. /**
  31682. * Set the value of an uniform to an array of float32 (stored as matrices)
  31683. * @param uniform defines the webGL uniform location where to store the value
  31684. * @param matrices defines the array of float32 to store
  31685. */
  31686. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31687. /**
  31688. * Set the value of an uniform to a matrix (3x3)
  31689. * @param uniform defines the webGL uniform location where to store the value
  31690. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31691. */
  31692. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31693. /**
  31694. * Set the value of an uniform to a matrix (2x2)
  31695. * @param uniform defines the webGL uniform location where to store the value
  31696. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31697. */
  31698. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31699. /**
  31700. * Set the value of an uniform to a number (float)
  31701. * @param uniform defines the webGL uniform location where to store the value
  31702. * @param value defines the float number to store
  31703. */
  31704. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31705. /**
  31706. * Set the value of an uniform to a vec2
  31707. * @param uniform defines the webGL uniform location where to store the value
  31708. * @param x defines the 1st component of the value
  31709. * @param y defines the 2nd component of the value
  31710. */
  31711. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31712. /**
  31713. * Set the value of an uniform to a vec3
  31714. * @param uniform defines the webGL uniform location where to store the value
  31715. * @param x defines the 1st component of the value
  31716. * @param y defines the 2nd component of the value
  31717. * @param z defines the 3rd component of the value
  31718. */
  31719. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31720. /**
  31721. * Set the value of an uniform to a vec4
  31722. * @param uniform defines the webGL uniform location where to store the value
  31723. * @param x defines the 1st component of the value
  31724. * @param y defines the 2nd component of the value
  31725. * @param z defines the 3rd component of the value
  31726. * @param w defines the 4th component of the value
  31727. */
  31728. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31729. /**
  31730. * Apply all cached states (depth, culling, stencil and alpha)
  31731. */
  31732. applyStates(): void;
  31733. /**
  31734. * Enable or disable color writing
  31735. * @param enable defines the state to set
  31736. */
  31737. setColorWrite(enable: boolean): void;
  31738. /**
  31739. * Gets a boolean indicating if color writing is enabled
  31740. * @returns the current color writing state
  31741. */
  31742. getColorWrite(): boolean;
  31743. /**
  31744. * Gets the depth culling state manager
  31745. */
  31746. get depthCullingState(): DepthCullingState;
  31747. /**
  31748. * Gets the alpha state manager
  31749. */
  31750. get alphaState(): AlphaState;
  31751. /**
  31752. * Gets the stencil state manager
  31753. */
  31754. get stencilState(): StencilState;
  31755. /**
  31756. * Clears the list of texture accessible through engine.
  31757. * This can help preventing texture load conflict due to name collision.
  31758. */
  31759. clearInternalTexturesCache(): void;
  31760. /**
  31761. * Force the entire cache to be cleared
  31762. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31763. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31764. */
  31765. wipeCaches(bruteForce?: boolean): void;
  31766. /** @hidden */
  31767. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31768. min: number;
  31769. mag: number;
  31770. };
  31771. /** @hidden */
  31772. _createTexture(): WebGLTexture;
  31773. /**
  31774. * Usually called from Texture.ts.
  31775. * Passed information to create a WebGLTexture
  31776. * @param urlArg defines a value which contains one of the following:
  31777. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31778. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31779. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31780. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31781. * @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)
  31782. * @param scene needed for loading to the correct scene
  31783. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31784. * @param onLoad optional callback to be called upon successful completion
  31785. * @param onError optional callback to be called upon failure
  31786. * @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
  31787. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31788. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31789. * @param forcedExtension defines the extension to use to pick the right loader
  31790. * @param mimeType defines an optional mime type
  31791. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31792. */
  31793. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  31794. /**
  31795. * Loads an image as an HTMLImageElement.
  31796. * @param input url string, ArrayBuffer, or Blob to load
  31797. * @param onLoad callback called when the image successfully loads
  31798. * @param onError callback called when the image fails to load
  31799. * @param offlineProvider offline provider for caching
  31800. * @param mimeType optional mime type
  31801. * @returns the HTMLImageElement of the loaded image
  31802. * @hidden
  31803. */
  31804. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  31805. /**
  31806. * @hidden
  31807. */
  31808. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31809. /**
  31810. * Creates a raw texture
  31811. * @param data defines the data to store in the texture
  31812. * @param width defines the width of the texture
  31813. * @param height defines the height of the texture
  31814. * @param format defines the format of the data
  31815. * @param generateMipMaps defines if the engine should generate the mip levels
  31816. * @param invertY defines if data must be stored with Y axis inverted
  31817. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31818. * @param compression defines the compression used (null by default)
  31819. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31820. * @returns the raw texture inside an InternalTexture
  31821. */
  31822. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31823. /**
  31824. * Creates a new raw cube texture
  31825. * @param data defines the array of data to use to create each face
  31826. * @param size defines the size of the textures
  31827. * @param format defines the format of the data
  31828. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31829. * @param generateMipMaps defines if the engine should generate the mip levels
  31830. * @param invertY defines if data must be stored with Y axis inverted
  31831. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31832. * @param compression defines the compression used (null by default)
  31833. * @returns the cube texture as an InternalTexture
  31834. */
  31835. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31836. /**
  31837. * Creates a new raw 3D texture
  31838. * @param data defines the data used to create the texture
  31839. * @param width defines the width of the texture
  31840. * @param height defines the height of the texture
  31841. * @param depth defines the depth of the texture
  31842. * @param format defines the format of the texture
  31843. * @param generateMipMaps defines if the engine must generate mip levels
  31844. * @param invertY defines if data must be stored with Y axis inverted
  31845. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31846. * @param compression defines the compressed used (can be null)
  31847. * @param textureType defines the compressed used (can be null)
  31848. * @returns a new raw 3D texture (stored in an InternalTexture)
  31849. */
  31850. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31851. /**
  31852. * Creates a new raw 2D array texture
  31853. * @param data defines the data used to create the texture
  31854. * @param width defines the width of the texture
  31855. * @param height defines the height of the texture
  31856. * @param depth defines the number of layers of the texture
  31857. * @param format defines the format of the texture
  31858. * @param generateMipMaps defines if the engine must generate mip levels
  31859. * @param invertY defines if data must be stored with Y axis inverted
  31860. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31861. * @param compression defines the compressed used (can be null)
  31862. * @param textureType defines the compressed used (can be null)
  31863. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31864. */
  31865. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31866. private _unpackFlipYCached;
  31867. /**
  31868. * In case you are sharing the context with other applications, it might
  31869. * be interested to not cache the unpack flip y state to ensure a consistent
  31870. * value would be set.
  31871. */
  31872. enableUnpackFlipYCached: boolean;
  31873. /** @hidden */
  31874. _unpackFlipY(value: boolean): void;
  31875. /** @hidden */
  31876. _getUnpackAlignement(): number;
  31877. private _getTextureTarget;
  31878. /**
  31879. * Update the sampling mode of a given texture
  31880. * @param samplingMode defines the required sampling mode
  31881. * @param texture defines the texture to update
  31882. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31883. */
  31884. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31885. /**
  31886. * Update the sampling mode of a given texture
  31887. * @param texture defines the texture to update
  31888. * @param wrapU defines the texture wrap mode of the u coordinates
  31889. * @param wrapV defines the texture wrap mode of the v coordinates
  31890. * @param wrapR defines the texture wrap mode of the r coordinates
  31891. */
  31892. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31893. /** @hidden */
  31894. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31895. width: number;
  31896. height: number;
  31897. layers?: number;
  31898. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31899. /** @hidden */
  31900. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31901. /** @hidden */
  31902. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31903. /**
  31904. * Update a portion of an internal texture
  31905. * @param texture defines the texture to update
  31906. * @param imageData defines the data to store into the texture
  31907. * @param xOffset defines the x coordinates of the update rectangle
  31908. * @param yOffset defines the y coordinates of the update rectangle
  31909. * @param width defines the width of the update rectangle
  31910. * @param height defines the height of the update rectangle
  31911. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31912. * @param lod defines the lod level to update (0 by default)
  31913. */
  31914. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31915. /** @hidden */
  31916. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31917. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31918. private _prepareWebGLTexture;
  31919. /** @hidden */
  31920. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31921. private _getDepthStencilBuffer;
  31922. /** @hidden */
  31923. _releaseFramebufferObjects(texture: InternalTexture): void;
  31924. /** @hidden */
  31925. _releaseTexture(texture: InternalTexture): void;
  31926. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31927. protected _setProgram(program: WebGLProgram): void;
  31928. protected _boundUniforms: {
  31929. [key: number]: WebGLUniformLocation;
  31930. };
  31931. /**
  31932. * Binds an effect to the webGL context
  31933. * @param effect defines the effect to bind
  31934. */
  31935. bindSamplers(effect: Effect): void;
  31936. private _activateCurrentTexture;
  31937. /** @hidden */
  31938. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31939. /** @hidden */
  31940. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31941. /**
  31942. * Unbind all textures from the webGL context
  31943. */
  31944. unbindAllTextures(): void;
  31945. /**
  31946. * Sets a texture to the according uniform.
  31947. * @param channel The texture channel
  31948. * @param uniform The uniform to set
  31949. * @param texture The texture to apply
  31950. */
  31951. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31952. private _bindSamplerUniformToChannel;
  31953. private _getTextureWrapMode;
  31954. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31955. /**
  31956. * Sets an array of texture to the webGL context
  31957. * @param channel defines the channel where the texture array must be set
  31958. * @param uniform defines the associated uniform location
  31959. * @param textures defines the array of textures to bind
  31960. */
  31961. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31962. /** @hidden */
  31963. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31964. private _setTextureParameterFloat;
  31965. private _setTextureParameterInteger;
  31966. /**
  31967. * Unbind all vertex attributes from the webGL context
  31968. */
  31969. unbindAllAttributes(): void;
  31970. /**
  31971. * 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
  31972. */
  31973. releaseEffects(): void;
  31974. /**
  31975. * Dispose and release all associated resources
  31976. */
  31977. dispose(): void;
  31978. /**
  31979. * Attach a new callback raised when context lost event is fired
  31980. * @param callback defines the callback to call
  31981. */
  31982. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31983. /**
  31984. * Attach a new callback raised when context restored event is fired
  31985. * @param callback defines the callback to call
  31986. */
  31987. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31988. /**
  31989. * Get the current error code of the webGL context
  31990. * @returns the error code
  31991. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31992. */
  31993. getError(): number;
  31994. private _canRenderToFloatFramebuffer;
  31995. private _canRenderToHalfFloatFramebuffer;
  31996. private _canRenderToFramebuffer;
  31997. /** @hidden */
  31998. _getWebGLTextureType(type: number): number;
  31999. /** @hidden */
  32000. _getInternalFormat(format: number): number;
  32001. /** @hidden */
  32002. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32003. /** @hidden */
  32004. _getRGBAMultiSampleBufferFormat(type: number): number;
  32005. /** @hidden */
  32006. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  32007. /**
  32008. * Loads a file from a url
  32009. * @param url url to load
  32010. * @param onSuccess callback called when the file successfully loads
  32011. * @param onProgress callback called while file is loading (if the server supports this mode)
  32012. * @param offlineProvider defines the offline provider for caching
  32013. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32014. * @param onError callback called when the file fails to load
  32015. * @returns a file request object
  32016. * @hidden
  32017. */
  32018. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  32019. /**
  32020. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32021. * @param x defines the x coordinate of the rectangle where pixels must be read
  32022. * @param y defines the y coordinate of the rectangle where pixels must be read
  32023. * @param width defines the width of the rectangle where pixels must be read
  32024. * @param height defines the height of the rectangle where pixels must be read
  32025. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32026. * @returns a Uint8Array containing RGBA colors
  32027. */
  32028. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32029. private static _isSupported;
  32030. /**
  32031. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32032. * @returns true if the engine can be created
  32033. * @ignorenaming
  32034. */
  32035. static isSupported(): boolean;
  32036. /**
  32037. * Find the next highest power of two.
  32038. * @param x Number to start search from.
  32039. * @return Next highest power of two.
  32040. */
  32041. static CeilingPOT(x: number): number;
  32042. /**
  32043. * Find the next lowest power of two.
  32044. * @param x Number to start search from.
  32045. * @return Next lowest power of two.
  32046. */
  32047. static FloorPOT(x: number): number;
  32048. /**
  32049. * Find the nearest power of two.
  32050. * @param x Number to start search from.
  32051. * @return Next nearest power of two.
  32052. */
  32053. static NearestPOT(x: number): number;
  32054. /**
  32055. * Get the closest exponent of two
  32056. * @param value defines the value to approximate
  32057. * @param max defines the maximum value to return
  32058. * @param mode defines how to define the closest value
  32059. * @returns closest exponent of two of the given value
  32060. */
  32061. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32062. /**
  32063. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32064. * @param func - the function to be called
  32065. * @param requester - the object that will request the next frame. Falls back to window.
  32066. * @returns frame number
  32067. */
  32068. static QueueNewFrame(func: () => void, requester?: any): number;
  32069. /**
  32070. * Gets host document
  32071. * @returns the host document object
  32072. */
  32073. getHostDocument(): Nullable<Document>;
  32074. }
  32075. }
  32076. declare module BABYLON {
  32077. /**
  32078. * Class representing spherical harmonics coefficients to the 3rd degree
  32079. */
  32080. export class SphericalHarmonics {
  32081. /**
  32082. * Defines whether or not the harmonics have been prescaled for rendering.
  32083. */
  32084. preScaled: boolean;
  32085. /**
  32086. * The l0,0 coefficients of the spherical harmonics
  32087. */
  32088. l00: Vector3;
  32089. /**
  32090. * The l1,-1 coefficients of the spherical harmonics
  32091. */
  32092. l1_1: Vector3;
  32093. /**
  32094. * The l1,0 coefficients of the spherical harmonics
  32095. */
  32096. l10: Vector3;
  32097. /**
  32098. * The l1,1 coefficients of the spherical harmonics
  32099. */
  32100. l11: Vector3;
  32101. /**
  32102. * The l2,-2 coefficients of the spherical harmonics
  32103. */
  32104. l2_2: Vector3;
  32105. /**
  32106. * The l2,-1 coefficients of the spherical harmonics
  32107. */
  32108. l2_1: Vector3;
  32109. /**
  32110. * The l2,0 coefficients of the spherical harmonics
  32111. */
  32112. l20: Vector3;
  32113. /**
  32114. * The l2,1 coefficients of the spherical harmonics
  32115. */
  32116. l21: Vector3;
  32117. /**
  32118. * The l2,2 coefficients of the spherical harmonics
  32119. */
  32120. l22: Vector3;
  32121. /**
  32122. * Adds a light to the spherical harmonics
  32123. * @param direction the direction of the light
  32124. * @param color the color of the light
  32125. * @param deltaSolidAngle the delta solid angle of the light
  32126. */
  32127. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32128. /**
  32129. * Scales the spherical harmonics by the given amount
  32130. * @param scale the amount to scale
  32131. */
  32132. scaleInPlace(scale: number): void;
  32133. /**
  32134. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32135. *
  32136. * ```
  32137. * E_lm = A_l * L_lm
  32138. * ```
  32139. *
  32140. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32141. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32142. * the scaling factors are given in equation 9.
  32143. */
  32144. convertIncidentRadianceToIrradiance(): void;
  32145. /**
  32146. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32147. *
  32148. * ```
  32149. * L = (1/pi) * E * rho
  32150. * ```
  32151. *
  32152. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32153. */
  32154. convertIrradianceToLambertianRadiance(): void;
  32155. /**
  32156. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32157. * required operations at run time.
  32158. *
  32159. * This is simply done by scaling back the SH with Ylm constants parameter.
  32160. * The trigonometric part being applied by the shader at run time.
  32161. */
  32162. preScaleForRendering(): void;
  32163. /**
  32164. * Constructs a spherical harmonics from an array.
  32165. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32166. * @returns the spherical harmonics
  32167. */
  32168. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32169. /**
  32170. * Gets the spherical harmonics from polynomial
  32171. * @param polynomial the spherical polynomial
  32172. * @returns the spherical harmonics
  32173. */
  32174. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32175. }
  32176. /**
  32177. * Class representing spherical polynomial coefficients to the 3rd degree
  32178. */
  32179. export class SphericalPolynomial {
  32180. private _harmonics;
  32181. /**
  32182. * The spherical harmonics used to create the polynomials.
  32183. */
  32184. get preScaledHarmonics(): SphericalHarmonics;
  32185. /**
  32186. * The x coefficients of the spherical polynomial
  32187. */
  32188. x: Vector3;
  32189. /**
  32190. * The y coefficients of the spherical polynomial
  32191. */
  32192. y: Vector3;
  32193. /**
  32194. * The z coefficients of the spherical polynomial
  32195. */
  32196. z: Vector3;
  32197. /**
  32198. * The xx coefficients of the spherical polynomial
  32199. */
  32200. xx: Vector3;
  32201. /**
  32202. * The yy coefficients of the spherical polynomial
  32203. */
  32204. yy: Vector3;
  32205. /**
  32206. * The zz coefficients of the spherical polynomial
  32207. */
  32208. zz: Vector3;
  32209. /**
  32210. * The xy coefficients of the spherical polynomial
  32211. */
  32212. xy: Vector3;
  32213. /**
  32214. * The yz coefficients of the spherical polynomial
  32215. */
  32216. yz: Vector3;
  32217. /**
  32218. * The zx coefficients of the spherical polynomial
  32219. */
  32220. zx: Vector3;
  32221. /**
  32222. * Adds an ambient color to the spherical polynomial
  32223. * @param color the color to add
  32224. */
  32225. addAmbient(color: Color3): void;
  32226. /**
  32227. * Scales the spherical polynomial by the given amount
  32228. * @param scale the amount to scale
  32229. */
  32230. scaleInPlace(scale: number): void;
  32231. /**
  32232. * Gets the spherical polynomial from harmonics
  32233. * @param harmonics the spherical harmonics
  32234. * @returns the spherical polynomial
  32235. */
  32236. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32237. /**
  32238. * Constructs a spherical polynomial from an array.
  32239. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32240. * @returns the spherical polynomial
  32241. */
  32242. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32243. }
  32244. }
  32245. declare module BABYLON {
  32246. /**
  32247. * Defines the source of the internal texture
  32248. */
  32249. export enum InternalTextureSource {
  32250. /**
  32251. * The source of the texture data is unknown
  32252. */
  32253. Unknown = 0,
  32254. /**
  32255. * Texture data comes from an URL
  32256. */
  32257. Url = 1,
  32258. /**
  32259. * Texture data is only used for temporary storage
  32260. */
  32261. Temp = 2,
  32262. /**
  32263. * Texture data comes from raw data (ArrayBuffer)
  32264. */
  32265. Raw = 3,
  32266. /**
  32267. * Texture content is dynamic (video or dynamic texture)
  32268. */
  32269. Dynamic = 4,
  32270. /**
  32271. * Texture content is generated by rendering to it
  32272. */
  32273. RenderTarget = 5,
  32274. /**
  32275. * Texture content is part of a multi render target process
  32276. */
  32277. MultiRenderTarget = 6,
  32278. /**
  32279. * Texture data comes from a cube data file
  32280. */
  32281. Cube = 7,
  32282. /**
  32283. * Texture data comes from a raw cube data
  32284. */
  32285. CubeRaw = 8,
  32286. /**
  32287. * Texture data come from a prefiltered cube data file
  32288. */
  32289. CubePrefiltered = 9,
  32290. /**
  32291. * Texture content is raw 3D data
  32292. */
  32293. Raw3D = 10,
  32294. /**
  32295. * Texture content is raw 2D array data
  32296. */
  32297. Raw2DArray = 11,
  32298. /**
  32299. * Texture content is a depth texture
  32300. */
  32301. Depth = 12,
  32302. /**
  32303. * Texture data comes from a raw cube data encoded with RGBD
  32304. */
  32305. CubeRawRGBD = 13
  32306. }
  32307. /**
  32308. * Class used to store data associated with WebGL texture data for the engine
  32309. * This class should not be used directly
  32310. */
  32311. export class InternalTexture {
  32312. /** @hidden */
  32313. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32314. /**
  32315. * Defines if the texture is ready
  32316. */
  32317. isReady: boolean;
  32318. /**
  32319. * Defines if the texture is a cube texture
  32320. */
  32321. isCube: boolean;
  32322. /**
  32323. * Defines if the texture contains 3D data
  32324. */
  32325. is3D: boolean;
  32326. /**
  32327. * Defines if the texture contains 2D array data
  32328. */
  32329. is2DArray: boolean;
  32330. /**
  32331. * Defines if the texture contains multiview data
  32332. */
  32333. isMultiview: boolean;
  32334. /**
  32335. * Gets the URL used to load this texture
  32336. */
  32337. url: string;
  32338. /**
  32339. * Gets the sampling mode of the texture
  32340. */
  32341. samplingMode: number;
  32342. /**
  32343. * Gets a boolean indicating if the texture needs mipmaps generation
  32344. */
  32345. generateMipMaps: boolean;
  32346. /**
  32347. * Gets the number of samples used by the texture (WebGL2+ only)
  32348. */
  32349. samples: number;
  32350. /**
  32351. * Gets the type of the texture (int, float...)
  32352. */
  32353. type: number;
  32354. /**
  32355. * Gets the format of the texture (RGB, RGBA...)
  32356. */
  32357. format: number;
  32358. /**
  32359. * Observable called when the texture is loaded
  32360. */
  32361. onLoadedObservable: Observable<InternalTexture>;
  32362. /**
  32363. * Gets the width of the texture
  32364. */
  32365. width: number;
  32366. /**
  32367. * Gets the height of the texture
  32368. */
  32369. height: number;
  32370. /**
  32371. * Gets the depth of the texture
  32372. */
  32373. depth: number;
  32374. /**
  32375. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32376. */
  32377. baseWidth: number;
  32378. /**
  32379. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32380. */
  32381. baseHeight: number;
  32382. /**
  32383. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32384. */
  32385. baseDepth: number;
  32386. /**
  32387. * Gets a boolean indicating if the texture is inverted on Y axis
  32388. */
  32389. invertY: boolean;
  32390. /** @hidden */
  32391. _invertVScale: boolean;
  32392. /** @hidden */
  32393. _associatedChannel: number;
  32394. /** @hidden */
  32395. _source: InternalTextureSource;
  32396. /** @hidden */
  32397. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32398. /** @hidden */
  32399. _bufferView: Nullable<ArrayBufferView>;
  32400. /** @hidden */
  32401. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32402. /** @hidden */
  32403. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32404. /** @hidden */
  32405. _size: number;
  32406. /** @hidden */
  32407. _extension: string;
  32408. /** @hidden */
  32409. _files: Nullable<string[]>;
  32410. /** @hidden */
  32411. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32412. /** @hidden */
  32413. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32414. /** @hidden */
  32415. _framebuffer: Nullable<WebGLFramebuffer>;
  32416. /** @hidden */
  32417. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32418. /** @hidden */
  32419. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32420. /** @hidden */
  32421. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32422. /** @hidden */
  32423. _attachments: Nullable<number[]>;
  32424. /** @hidden */
  32425. _cachedCoordinatesMode: Nullable<number>;
  32426. /** @hidden */
  32427. _cachedWrapU: Nullable<number>;
  32428. /** @hidden */
  32429. _cachedWrapV: Nullable<number>;
  32430. /** @hidden */
  32431. _cachedWrapR: Nullable<number>;
  32432. /** @hidden */
  32433. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32434. /** @hidden */
  32435. _isDisabled: boolean;
  32436. /** @hidden */
  32437. _compression: Nullable<string>;
  32438. /** @hidden */
  32439. _generateStencilBuffer: boolean;
  32440. /** @hidden */
  32441. _generateDepthBuffer: boolean;
  32442. /** @hidden */
  32443. _comparisonFunction: number;
  32444. /** @hidden */
  32445. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32446. /** @hidden */
  32447. _lodGenerationScale: number;
  32448. /** @hidden */
  32449. _lodGenerationOffset: number;
  32450. /** @hidden */
  32451. _depthStencilTexture: Nullable<InternalTexture>;
  32452. /** @hidden */
  32453. _colorTextureArray: Nullable<WebGLTexture>;
  32454. /** @hidden */
  32455. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32456. /** @hidden */
  32457. _lodTextureHigh: Nullable<BaseTexture>;
  32458. /** @hidden */
  32459. _lodTextureMid: Nullable<BaseTexture>;
  32460. /** @hidden */
  32461. _lodTextureLow: Nullable<BaseTexture>;
  32462. /** @hidden */
  32463. _isRGBD: boolean;
  32464. /** @hidden */
  32465. _linearSpecularLOD: boolean;
  32466. /** @hidden */
  32467. _irradianceTexture: Nullable<BaseTexture>;
  32468. /** @hidden */
  32469. _webGLTexture: Nullable<WebGLTexture>;
  32470. /** @hidden */
  32471. _references: number;
  32472. private _engine;
  32473. /**
  32474. * Gets the Engine the texture belongs to.
  32475. * @returns The babylon engine
  32476. */
  32477. getEngine(): ThinEngine;
  32478. /**
  32479. * Gets the data source type of the texture
  32480. */
  32481. get source(): InternalTextureSource;
  32482. /**
  32483. * Creates a new InternalTexture
  32484. * @param engine defines the engine to use
  32485. * @param source defines the type of data that will be used
  32486. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32487. */
  32488. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32489. /**
  32490. * Increments the number of references (ie. the number of Texture that point to it)
  32491. */
  32492. incrementReferences(): void;
  32493. /**
  32494. * Change the size of the texture (not the size of the content)
  32495. * @param width defines the new width
  32496. * @param height defines the new height
  32497. * @param depth defines the new depth (1 by default)
  32498. */
  32499. updateSize(width: int, height: int, depth?: int): void;
  32500. /** @hidden */
  32501. _rebuild(): void;
  32502. /** @hidden */
  32503. _swapAndDie(target: InternalTexture): void;
  32504. /**
  32505. * Dispose the current allocated resources
  32506. */
  32507. dispose(): void;
  32508. }
  32509. }
  32510. declare module BABYLON {
  32511. /**
  32512. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32514. */
  32515. export class Analyser {
  32516. /**
  32517. * Gets or sets the smoothing
  32518. * @ignorenaming
  32519. */
  32520. SMOOTHING: number;
  32521. /**
  32522. * Gets or sets the FFT table size
  32523. * @ignorenaming
  32524. */
  32525. FFT_SIZE: number;
  32526. /**
  32527. * Gets or sets the bar graph amplitude
  32528. * @ignorenaming
  32529. */
  32530. BARGRAPHAMPLITUDE: number;
  32531. /**
  32532. * Gets or sets the position of the debug canvas
  32533. * @ignorenaming
  32534. */
  32535. DEBUGCANVASPOS: {
  32536. x: number;
  32537. y: number;
  32538. };
  32539. /**
  32540. * Gets or sets the debug canvas size
  32541. * @ignorenaming
  32542. */
  32543. DEBUGCANVASSIZE: {
  32544. width: number;
  32545. height: number;
  32546. };
  32547. private _byteFreqs;
  32548. private _byteTime;
  32549. private _floatFreqs;
  32550. private _webAudioAnalyser;
  32551. private _debugCanvas;
  32552. private _debugCanvasContext;
  32553. private _scene;
  32554. private _registerFunc;
  32555. private _audioEngine;
  32556. /**
  32557. * Creates a new analyser
  32558. * @param scene defines hosting scene
  32559. */
  32560. constructor(scene: Scene);
  32561. /**
  32562. * Get the number of data values you will have to play with for the visualization
  32563. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32564. * @returns a number
  32565. */
  32566. getFrequencyBinCount(): number;
  32567. /**
  32568. * Gets the current frequency data as a byte array
  32569. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32570. * @returns a Uint8Array
  32571. */
  32572. getByteFrequencyData(): Uint8Array;
  32573. /**
  32574. * Gets the current waveform as a byte array
  32575. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32576. * @returns a Uint8Array
  32577. */
  32578. getByteTimeDomainData(): Uint8Array;
  32579. /**
  32580. * Gets the current frequency data as a float array
  32581. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32582. * @returns a Float32Array
  32583. */
  32584. getFloatFrequencyData(): Float32Array;
  32585. /**
  32586. * Renders the debug canvas
  32587. */
  32588. drawDebugCanvas(): void;
  32589. /**
  32590. * Stops rendering the debug canvas and removes it
  32591. */
  32592. stopDebugCanvas(): void;
  32593. /**
  32594. * Connects two audio nodes
  32595. * @param inputAudioNode defines first node to connect
  32596. * @param outputAudioNode defines second node to connect
  32597. */
  32598. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32599. /**
  32600. * Releases all associated resources
  32601. */
  32602. dispose(): void;
  32603. }
  32604. }
  32605. declare module BABYLON {
  32606. /**
  32607. * This represents an audio engine and it is responsible
  32608. * to play, synchronize and analyse sounds throughout the application.
  32609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32610. */
  32611. export interface IAudioEngine extends IDisposable {
  32612. /**
  32613. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32614. */
  32615. readonly canUseWebAudio: boolean;
  32616. /**
  32617. * Gets the current AudioContext if available.
  32618. */
  32619. readonly audioContext: Nullable<AudioContext>;
  32620. /**
  32621. * The master gain node defines the global audio volume of your audio engine.
  32622. */
  32623. readonly masterGain: GainNode;
  32624. /**
  32625. * Gets whether or not mp3 are supported by your browser.
  32626. */
  32627. readonly isMP3supported: boolean;
  32628. /**
  32629. * Gets whether or not ogg are supported by your browser.
  32630. */
  32631. readonly isOGGsupported: boolean;
  32632. /**
  32633. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32634. * @ignoreNaming
  32635. */
  32636. WarnedWebAudioUnsupported: boolean;
  32637. /**
  32638. * Defines if the audio engine relies on a custom unlocked button.
  32639. * In this case, the embedded button will not be displayed.
  32640. */
  32641. useCustomUnlockedButton: boolean;
  32642. /**
  32643. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32644. */
  32645. readonly unlocked: boolean;
  32646. /**
  32647. * Event raised when audio has been unlocked on the browser.
  32648. */
  32649. onAudioUnlockedObservable: Observable<AudioEngine>;
  32650. /**
  32651. * Event raised when audio has been locked on the browser.
  32652. */
  32653. onAudioLockedObservable: Observable<AudioEngine>;
  32654. /**
  32655. * Flags the audio engine in Locked state.
  32656. * This happens due to new browser policies preventing audio to autoplay.
  32657. */
  32658. lock(): void;
  32659. /**
  32660. * Unlocks the audio engine once a user action has been done on the dom.
  32661. * This is helpful to resume play once browser policies have been satisfied.
  32662. */
  32663. unlock(): void;
  32664. /**
  32665. * Gets the global volume sets on the master gain.
  32666. * @returns the global volume if set or -1 otherwise
  32667. */
  32668. getGlobalVolume(): number;
  32669. /**
  32670. * Sets the global volume of your experience (sets on the master gain).
  32671. * @param newVolume Defines the new global volume of the application
  32672. */
  32673. setGlobalVolume(newVolume: number): void;
  32674. /**
  32675. * Connect the audio engine to an audio analyser allowing some amazing
  32676. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32678. * @param analyser The analyser to connect to the engine
  32679. */
  32680. connectToAnalyser(analyser: Analyser): void;
  32681. }
  32682. /**
  32683. * This represents the default audio engine used in babylon.
  32684. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32686. */
  32687. export class AudioEngine implements IAudioEngine {
  32688. private _audioContext;
  32689. private _audioContextInitialized;
  32690. private _muteButton;
  32691. private _hostElement;
  32692. /**
  32693. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32694. */
  32695. canUseWebAudio: boolean;
  32696. /**
  32697. * The master gain node defines the global audio volume of your audio engine.
  32698. */
  32699. masterGain: GainNode;
  32700. /**
  32701. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32702. * @ignoreNaming
  32703. */
  32704. WarnedWebAudioUnsupported: boolean;
  32705. /**
  32706. * Gets whether or not mp3 are supported by your browser.
  32707. */
  32708. isMP3supported: boolean;
  32709. /**
  32710. * Gets whether or not ogg are supported by your browser.
  32711. */
  32712. isOGGsupported: boolean;
  32713. /**
  32714. * Gets whether audio has been unlocked on the device.
  32715. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32716. * a user interaction has happened.
  32717. */
  32718. unlocked: boolean;
  32719. /**
  32720. * Defines if the audio engine relies on a custom unlocked button.
  32721. * In this case, the embedded button will not be displayed.
  32722. */
  32723. useCustomUnlockedButton: boolean;
  32724. /**
  32725. * Event raised when audio has been unlocked on the browser.
  32726. */
  32727. onAudioUnlockedObservable: Observable<AudioEngine>;
  32728. /**
  32729. * Event raised when audio has been locked on the browser.
  32730. */
  32731. onAudioLockedObservable: Observable<AudioEngine>;
  32732. /**
  32733. * Gets the current AudioContext if available.
  32734. */
  32735. get audioContext(): Nullable<AudioContext>;
  32736. private _connectedAnalyser;
  32737. /**
  32738. * Instantiates a new audio engine.
  32739. *
  32740. * There should be only one per page as some browsers restrict the number
  32741. * of audio contexts you can create.
  32742. * @param hostElement defines the host element where to display the mute icon if necessary
  32743. */
  32744. constructor(hostElement?: Nullable<HTMLElement>);
  32745. /**
  32746. * Flags the audio engine in Locked state.
  32747. * This happens due to new browser policies preventing audio to autoplay.
  32748. */
  32749. lock(): void;
  32750. /**
  32751. * Unlocks the audio engine once a user action has been done on the dom.
  32752. * This is helpful to resume play once browser policies have been satisfied.
  32753. */
  32754. unlock(): void;
  32755. private _resumeAudioContext;
  32756. private _initializeAudioContext;
  32757. private _tryToRun;
  32758. private _triggerRunningState;
  32759. private _triggerSuspendedState;
  32760. private _displayMuteButton;
  32761. private _moveButtonToTopLeft;
  32762. private _onResize;
  32763. private _hideMuteButton;
  32764. /**
  32765. * Destroy and release the resources associated with the audio ccontext.
  32766. */
  32767. dispose(): void;
  32768. /**
  32769. * Gets the global volume sets on the master gain.
  32770. * @returns the global volume if set or -1 otherwise
  32771. */
  32772. getGlobalVolume(): number;
  32773. /**
  32774. * Sets the global volume of your experience (sets on the master gain).
  32775. * @param newVolume Defines the new global volume of the application
  32776. */
  32777. setGlobalVolume(newVolume: number): void;
  32778. /**
  32779. * Connect the audio engine to an audio analyser allowing some amazing
  32780. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32782. * @param analyser The analyser to connect to the engine
  32783. */
  32784. connectToAnalyser(analyser: Analyser): void;
  32785. }
  32786. }
  32787. declare module BABYLON {
  32788. /**
  32789. * Interface used to present a loading screen while loading a scene
  32790. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32791. */
  32792. export interface ILoadingScreen {
  32793. /**
  32794. * Function called to display the loading screen
  32795. */
  32796. displayLoadingUI: () => void;
  32797. /**
  32798. * Function called to hide the loading screen
  32799. */
  32800. hideLoadingUI: () => void;
  32801. /**
  32802. * Gets or sets the color to use for the background
  32803. */
  32804. loadingUIBackgroundColor: string;
  32805. /**
  32806. * Gets or sets the text to display while loading
  32807. */
  32808. loadingUIText: string;
  32809. }
  32810. /**
  32811. * Class used for the default loading screen
  32812. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32813. */
  32814. export class DefaultLoadingScreen implements ILoadingScreen {
  32815. private _renderingCanvas;
  32816. private _loadingText;
  32817. private _loadingDivBackgroundColor;
  32818. private _loadingDiv;
  32819. private _loadingTextDiv;
  32820. /** Gets or sets the logo url to use for the default loading screen */
  32821. static DefaultLogoUrl: string;
  32822. /** Gets or sets the spinner url to use for the default loading screen */
  32823. static DefaultSpinnerUrl: string;
  32824. /**
  32825. * Creates a new default loading screen
  32826. * @param _renderingCanvas defines the canvas used to render the scene
  32827. * @param _loadingText defines the default text to display
  32828. * @param _loadingDivBackgroundColor defines the default background color
  32829. */
  32830. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32831. /**
  32832. * Function called to display the loading screen
  32833. */
  32834. displayLoadingUI(): void;
  32835. /**
  32836. * Function called to hide the loading screen
  32837. */
  32838. hideLoadingUI(): void;
  32839. /**
  32840. * Gets or sets the text to display while loading
  32841. */
  32842. set loadingUIText(text: string);
  32843. get loadingUIText(): string;
  32844. /**
  32845. * Gets or sets the color to use for the background
  32846. */
  32847. get loadingUIBackgroundColor(): string;
  32848. set loadingUIBackgroundColor(color: string);
  32849. private _resizeLoadingUI;
  32850. }
  32851. }
  32852. declare module BABYLON {
  32853. /**
  32854. * Interface for any object that can request an animation frame
  32855. */
  32856. export interface ICustomAnimationFrameRequester {
  32857. /**
  32858. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32859. */
  32860. renderFunction?: Function;
  32861. /**
  32862. * Called to request the next frame to render to
  32863. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32864. */
  32865. requestAnimationFrame: Function;
  32866. /**
  32867. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32868. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32869. */
  32870. requestID?: number;
  32871. }
  32872. }
  32873. declare module BABYLON {
  32874. /**
  32875. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32876. */
  32877. export class PerformanceMonitor {
  32878. private _enabled;
  32879. private _rollingFrameTime;
  32880. private _lastFrameTimeMs;
  32881. /**
  32882. * constructor
  32883. * @param frameSampleSize The number of samples required to saturate the sliding window
  32884. */
  32885. constructor(frameSampleSize?: number);
  32886. /**
  32887. * Samples current frame
  32888. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32889. */
  32890. sampleFrame(timeMs?: number): void;
  32891. /**
  32892. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32893. */
  32894. get averageFrameTime(): number;
  32895. /**
  32896. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32897. */
  32898. get averageFrameTimeVariance(): number;
  32899. /**
  32900. * Returns the frame time of the most recent frame
  32901. */
  32902. get instantaneousFrameTime(): number;
  32903. /**
  32904. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32905. */
  32906. get averageFPS(): number;
  32907. /**
  32908. * Returns the average framerate in frames per second using the most recent frame time
  32909. */
  32910. get instantaneousFPS(): number;
  32911. /**
  32912. * Returns true if enough samples have been taken to completely fill the sliding window
  32913. */
  32914. get isSaturated(): boolean;
  32915. /**
  32916. * Enables contributions to the sliding window sample set
  32917. */
  32918. enable(): void;
  32919. /**
  32920. * Disables contributions to the sliding window sample set
  32921. * Samples will not be interpolated over the disabled period
  32922. */
  32923. disable(): void;
  32924. /**
  32925. * Returns true if sampling is enabled
  32926. */
  32927. get isEnabled(): boolean;
  32928. /**
  32929. * Resets performance monitor
  32930. */
  32931. reset(): void;
  32932. }
  32933. /**
  32934. * RollingAverage
  32935. *
  32936. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32937. */
  32938. export class RollingAverage {
  32939. /**
  32940. * Current average
  32941. */
  32942. average: number;
  32943. /**
  32944. * Current variance
  32945. */
  32946. variance: number;
  32947. protected _samples: Array<number>;
  32948. protected _sampleCount: number;
  32949. protected _pos: number;
  32950. protected _m2: number;
  32951. /**
  32952. * constructor
  32953. * @param length The number of samples required to saturate the sliding window
  32954. */
  32955. constructor(length: number);
  32956. /**
  32957. * Adds a sample to the sample set
  32958. * @param v The sample value
  32959. */
  32960. add(v: number): void;
  32961. /**
  32962. * Returns previously added values or null if outside of history or outside the sliding window domain
  32963. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32964. * @return Value previously recorded with add() or null if outside of range
  32965. */
  32966. history(i: number): number;
  32967. /**
  32968. * Returns true if enough samples have been taken to completely fill the sliding window
  32969. * @return true if sample-set saturated
  32970. */
  32971. isSaturated(): boolean;
  32972. /**
  32973. * Resets the rolling average (equivalent to 0 samples taken so far)
  32974. */
  32975. reset(): void;
  32976. /**
  32977. * Wraps a value around the sample range boundaries
  32978. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32979. * @return Wrapped position in sample range
  32980. */
  32981. protected _wrapPosition(i: number): number;
  32982. }
  32983. }
  32984. declare module BABYLON {
  32985. /**
  32986. * This class is used to track a performance counter which is number based.
  32987. * The user has access to many properties which give statistics of different nature.
  32988. *
  32989. * The implementer can track two kinds of Performance Counter: time and count.
  32990. * 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.
  32991. * 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.
  32992. */
  32993. export class PerfCounter {
  32994. /**
  32995. * Gets or sets a global boolean to turn on and off all the counters
  32996. */
  32997. static Enabled: boolean;
  32998. /**
  32999. * Returns the smallest value ever
  33000. */
  33001. get min(): number;
  33002. /**
  33003. * Returns the biggest value ever
  33004. */
  33005. get max(): number;
  33006. /**
  33007. * Returns the average value since the performance counter is running
  33008. */
  33009. get average(): number;
  33010. /**
  33011. * Returns the average value of the last second the counter was monitored
  33012. */
  33013. get lastSecAverage(): number;
  33014. /**
  33015. * Returns the current value
  33016. */
  33017. get current(): number;
  33018. /**
  33019. * Gets the accumulated total
  33020. */
  33021. get total(): number;
  33022. /**
  33023. * Gets the total value count
  33024. */
  33025. get count(): number;
  33026. /**
  33027. * Creates a new counter
  33028. */
  33029. constructor();
  33030. /**
  33031. * Call this method to start monitoring a new frame.
  33032. * 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.
  33033. */
  33034. fetchNewFrame(): void;
  33035. /**
  33036. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33037. * @param newCount the count value to add to the monitored count
  33038. * @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.
  33039. */
  33040. addCount(newCount: number, fetchResult: boolean): void;
  33041. /**
  33042. * Start monitoring this performance counter
  33043. */
  33044. beginMonitoring(): void;
  33045. /**
  33046. * Compute the time lapsed since the previous beginMonitoring() call.
  33047. * @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
  33048. */
  33049. endMonitoring(newFrame?: boolean): void;
  33050. private _fetchResult;
  33051. private _startMonitoringTime;
  33052. private _min;
  33053. private _max;
  33054. private _average;
  33055. private _current;
  33056. private _totalValueCount;
  33057. private _totalAccumulated;
  33058. private _lastSecAverage;
  33059. private _lastSecAccumulated;
  33060. private _lastSecTime;
  33061. private _lastSecValueCount;
  33062. }
  33063. }
  33064. declare module BABYLON {
  33065. interface ThinEngine {
  33066. /**
  33067. * Sets alpha constants used by some alpha blending modes
  33068. * @param r defines the red component
  33069. * @param g defines the green component
  33070. * @param b defines the blue component
  33071. * @param a defines the alpha component
  33072. */
  33073. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33074. /**
  33075. * Sets the current alpha mode
  33076. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33077. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33078. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33079. */
  33080. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33081. /**
  33082. * Gets the current alpha mode
  33083. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33084. * @returns the current alpha mode
  33085. */
  33086. getAlphaMode(): number;
  33087. /**
  33088. * Sets the current alpha equation
  33089. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33090. */
  33091. setAlphaEquation(equation: number): void;
  33092. /**
  33093. * Gets the current alpha equation.
  33094. * @returns the current alpha equation
  33095. */
  33096. getAlphaEquation(): number;
  33097. }
  33098. }
  33099. declare module BABYLON {
  33100. /**
  33101. * Defines the interface used by display changed events
  33102. */
  33103. export interface IDisplayChangedEventArgs {
  33104. /** Gets the vrDisplay object (if any) */
  33105. vrDisplay: Nullable<any>;
  33106. /** Gets a boolean indicating if webVR is supported */
  33107. vrSupported: boolean;
  33108. }
  33109. /**
  33110. * Defines the interface used by objects containing a viewport (like a camera)
  33111. */
  33112. interface IViewportOwnerLike {
  33113. /**
  33114. * Gets or sets the viewport
  33115. */
  33116. viewport: IViewportLike;
  33117. }
  33118. /**
  33119. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33120. */
  33121. export class Engine extends ThinEngine {
  33122. /** Defines that alpha blending is disabled */
  33123. static readonly ALPHA_DISABLE: number;
  33124. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33125. static readonly ALPHA_ADD: number;
  33126. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33127. static readonly ALPHA_COMBINE: number;
  33128. /** Defines that alpha blending to DEST - SRC * DEST */
  33129. static readonly ALPHA_SUBTRACT: number;
  33130. /** Defines that alpha blending to SRC * DEST */
  33131. static readonly ALPHA_MULTIPLY: number;
  33132. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33133. static readonly ALPHA_MAXIMIZED: number;
  33134. /** Defines that alpha blending to SRC + DEST */
  33135. static readonly ALPHA_ONEONE: number;
  33136. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33137. static readonly ALPHA_PREMULTIPLIED: number;
  33138. /**
  33139. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33140. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33141. */
  33142. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33143. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33144. static readonly ALPHA_INTERPOLATE: number;
  33145. /**
  33146. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33147. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33148. */
  33149. static readonly ALPHA_SCREENMODE: number;
  33150. /** Defines that the ressource is not delayed*/
  33151. static readonly DELAYLOADSTATE_NONE: number;
  33152. /** Defines that the ressource was successfully delay loaded */
  33153. static readonly DELAYLOADSTATE_LOADED: number;
  33154. /** Defines that the ressource is currently delay loading */
  33155. static readonly DELAYLOADSTATE_LOADING: number;
  33156. /** Defines that the ressource is delayed and has not started loading */
  33157. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33158. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33159. static readonly NEVER: number;
  33160. /** 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 */
  33161. static readonly ALWAYS: number;
  33162. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33163. static readonly LESS: number;
  33164. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33165. static readonly EQUAL: number;
  33166. /** 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 */
  33167. static readonly LEQUAL: number;
  33168. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33169. static readonly GREATER: number;
  33170. /** 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 */
  33171. static readonly GEQUAL: number;
  33172. /** 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 */
  33173. static readonly NOTEQUAL: number;
  33174. /** Passed to stencilOperation to specify that stencil value must be kept */
  33175. static readonly KEEP: number;
  33176. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33177. static readonly REPLACE: number;
  33178. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33179. static readonly INCR: number;
  33180. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33181. static readonly DECR: number;
  33182. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33183. static readonly INVERT: number;
  33184. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33185. static readonly INCR_WRAP: number;
  33186. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33187. static readonly DECR_WRAP: number;
  33188. /** Texture is not repeating outside of 0..1 UVs */
  33189. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33190. /** Texture is repeating outside of 0..1 UVs */
  33191. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33192. /** Texture is repeating and mirrored */
  33193. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33194. /** ALPHA */
  33195. static readonly TEXTUREFORMAT_ALPHA: number;
  33196. /** LUMINANCE */
  33197. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33198. /** LUMINANCE_ALPHA */
  33199. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33200. /** RGB */
  33201. static readonly TEXTUREFORMAT_RGB: number;
  33202. /** RGBA */
  33203. static readonly TEXTUREFORMAT_RGBA: number;
  33204. /** RED */
  33205. static readonly TEXTUREFORMAT_RED: number;
  33206. /** RED (2nd reference) */
  33207. static readonly TEXTUREFORMAT_R: number;
  33208. /** RG */
  33209. static readonly TEXTUREFORMAT_RG: number;
  33210. /** RED_INTEGER */
  33211. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33212. /** RED_INTEGER (2nd reference) */
  33213. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33214. /** RG_INTEGER */
  33215. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33216. /** RGB_INTEGER */
  33217. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33218. /** RGBA_INTEGER */
  33219. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33220. /** UNSIGNED_BYTE */
  33221. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33222. /** UNSIGNED_BYTE (2nd reference) */
  33223. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33224. /** FLOAT */
  33225. static readonly TEXTURETYPE_FLOAT: number;
  33226. /** HALF_FLOAT */
  33227. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33228. /** BYTE */
  33229. static readonly TEXTURETYPE_BYTE: number;
  33230. /** SHORT */
  33231. static readonly TEXTURETYPE_SHORT: number;
  33232. /** UNSIGNED_SHORT */
  33233. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33234. /** INT */
  33235. static readonly TEXTURETYPE_INT: number;
  33236. /** UNSIGNED_INT */
  33237. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33238. /** UNSIGNED_SHORT_4_4_4_4 */
  33239. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33240. /** UNSIGNED_SHORT_5_5_5_1 */
  33241. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33242. /** UNSIGNED_SHORT_5_6_5 */
  33243. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33244. /** UNSIGNED_INT_2_10_10_10_REV */
  33245. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33246. /** UNSIGNED_INT_24_8 */
  33247. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33248. /** UNSIGNED_INT_10F_11F_11F_REV */
  33249. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33250. /** UNSIGNED_INT_5_9_9_9_REV */
  33251. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33252. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33253. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33254. /** nearest is mag = nearest and min = nearest and mip = linear */
  33255. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33256. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33257. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33258. /** Trilinear is mag = linear and min = linear and mip = linear */
  33259. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33260. /** nearest is mag = nearest and min = nearest and mip = linear */
  33261. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33262. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33263. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33264. /** Trilinear is mag = linear and min = linear and mip = linear */
  33265. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33266. /** mag = nearest and min = nearest and mip = nearest */
  33267. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33268. /** mag = nearest and min = linear and mip = nearest */
  33269. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33270. /** mag = nearest and min = linear and mip = linear */
  33271. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33272. /** mag = nearest and min = linear and mip = none */
  33273. static readonly TEXTURE_NEAREST_LINEAR: number;
  33274. /** mag = nearest and min = nearest and mip = none */
  33275. static readonly TEXTURE_NEAREST_NEAREST: number;
  33276. /** mag = linear and min = nearest and mip = nearest */
  33277. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33278. /** mag = linear and min = nearest and mip = linear */
  33279. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33280. /** mag = linear and min = linear and mip = none */
  33281. static readonly TEXTURE_LINEAR_LINEAR: number;
  33282. /** mag = linear and min = nearest and mip = none */
  33283. static readonly TEXTURE_LINEAR_NEAREST: number;
  33284. /** Explicit coordinates mode */
  33285. static readonly TEXTURE_EXPLICIT_MODE: number;
  33286. /** Spherical coordinates mode */
  33287. static readonly TEXTURE_SPHERICAL_MODE: number;
  33288. /** Planar coordinates mode */
  33289. static readonly TEXTURE_PLANAR_MODE: number;
  33290. /** Cubic coordinates mode */
  33291. static readonly TEXTURE_CUBIC_MODE: number;
  33292. /** Projection coordinates mode */
  33293. static readonly TEXTURE_PROJECTION_MODE: number;
  33294. /** Skybox coordinates mode */
  33295. static readonly TEXTURE_SKYBOX_MODE: number;
  33296. /** Inverse Cubic coordinates mode */
  33297. static readonly TEXTURE_INVCUBIC_MODE: number;
  33298. /** Equirectangular coordinates mode */
  33299. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33300. /** Equirectangular Fixed coordinates mode */
  33301. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33302. /** Equirectangular Fixed Mirrored coordinates mode */
  33303. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33304. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33305. static readonly SCALEMODE_FLOOR: number;
  33306. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33307. static readonly SCALEMODE_NEAREST: number;
  33308. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33309. static readonly SCALEMODE_CEILING: number;
  33310. /**
  33311. * Returns the current npm package of the sdk
  33312. */
  33313. static get NpmPackage(): string;
  33314. /**
  33315. * Returns the current version of the framework
  33316. */
  33317. static get Version(): string;
  33318. /** Gets the list of created engines */
  33319. static get Instances(): Engine[];
  33320. /**
  33321. * Gets the latest created engine
  33322. */
  33323. static get LastCreatedEngine(): Nullable<Engine>;
  33324. /**
  33325. * Gets the latest created scene
  33326. */
  33327. static get LastCreatedScene(): Nullable<Scene>;
  33328. /**
  33329. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33330. * @param flag defines which part of the materials must be marked as dirty
  33331. * @param predicate defines a predicate used to filter which materials should be affected
  33332. */
  33333. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33334. /**
  33335. * Method called to create the default loading screen.
  33336. * This can be overriden in your own app.
  33337. * @param canvas The rendering canvas element
  33338. * @returns The loading screen
  33339. */
  33340. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33341. /**
  33342. * Method called to create the default rescale post process on each engine.
  33343. */
  33344. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33345. /**
  33346. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33347. **/
  33348. enableOfflineSupport: boolean;
  33349. /**
  33350. * 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)
  33351. **/
  33352. disableManifestCheck: boolean;
  33353. /**
  33354. * Gets the list of created scenes
  33355. */
  33356. scenes: Scene[];
  33357. /**
  33358. * Event raised when a new scene is created
  33359. */
  33360. onNewSceneAddedObservable: Observable<Scene>;
  33361. /**
  33362. * Gets the list of created postprocesses
  33363. */
  33364. postProcesses: PostProcess[];
  33365. /**
  33366. * Gets a boolean indicating if the pointer is currently locked
  33367. */
  33368. isPointerLock: boolean;
  33369. /**
  33370. * Observable event triggered each time the rendering canvas is resized
  33371. */
  33372. onResizeObservable: Observable<Engine>;
  33373. /**
  33374. * Observable event triggered each time the canvas loses focus
  33375. */
  33376. onCanvasBlurObservable: Observable<Engine>;
  33377. /**
  33378. * Observable event triggered each time the canvas gains focus
  33379. */
  33380. onCanvasFocusObservable: Observable<Engine>;
  33381. /**
  33382. * Observable event triggered each time the canvas receives pointerout event
  33383. */
  33384. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33385. /**
  33386. * Observable raised when the engine begins a new frame
  33387. */
  33388. onBeginFrameObservable: Observable<Engine>;
  33389. /**
  33390. * If set, will be used to request the next animation frame for the render loop
  33391. */
  33392. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33393. /**
  33394. * Observable raised when the engine ends the current frame
  33395. */
  33396. onEndFrameObservable: Observable<Engine>;
  33397. /**
  33398. * Observable raised when the engine is about to compile a shader
  33399. */
  33400. onBeforeShaderCompilationObservable: Observable<Engine>;
  33401. /**
  33402. * Observable raised when the engine has jsut compiled a shader
  33403. */
  33404. onAfterShaderCompilationObservable: Observable<Engine>;
  33405. /**
  33406. * Gets the audio engine
  33407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33408. * @ignorenaming
  33409. */
  33410. static audioEngine: IAudioEngine;
  33411. /**
  33412. * Default AudioEngine factory responsible of creating the Audio Engine.
  33413. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33414. */
  33415. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33416. /**
  33417. * Default offline support factory responsible of creating a tool used to store data locally.
  33418. * By default, this will create a Database object if the workload has been embedded.
  33419. */
  33420. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33421. private _loadingScreen;
  33422. private _pointerLockRequested;
  33423. private _dummyFramebuffer;
  33424. private _rescalePostProcess;
  33425. private _deterministicLockstep;
  33426. private _lockstepMaxSteps;
  33427. private _timeStep;
  33428. protected get _supportsHardwareTextureRescaling(): boolean;
  33429. private _fps;
  33430. private _deltaTime;
  33431. /** @hidden */
  33432. _drawCalls: PerfCounter;
  33433. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  33434. canvasTabIndex: number;
  33435. /**
  33436. * Turn this value on if you want to pause FPS computation when in background
  33437. */
  33438. disablePerformanceMonitorInBackground: boolean;
  33439. private _performanceMonitor;
  33440. /**
  33441. * Gets the performance monitor attached to this engine
  33442. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33443. */
  33444. get performanceMonitor(): PerformanceMonitor;
  33445. private _onFocus;
  33446. private _onBlur;
  33447. private _onCanvasPointerOut;
  33448. private _onCanvasBlur;
  33449. private _onCanvasFocus;
  33450. private _onFullscreenChange;
  33451. private _onPointerLockChange;
  33452. /**
  33453. * Gets the HTML element used to attach event listeners
  33454. * @returns a HTML element
  33455. */
  33456. getInputElement(): Nullable<HTMLElement>;
  33457. /**
  33458. * Creates a new engine
  33459. * @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
  33460. * @param antialias defines enable antialiasing (default: false)
  33461. * @param options defines further options to be sent to the getContext() function
  33462. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33463. */
  33464. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33465. /**
  33466. * Gets current aspect ratio
  33467. * @param viewportOwner defines the camera to use to get the aspect ratio
  33468. * @param useScreen defines if screen size must be used (or the current render target if any)
  33469. * @returns a number defining the aspect ratio
  33470. */
  33471. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33472. /**
  33473. * Gets current screen aspect ratio
  33474. * @returns a number defining the aspect ratio
  33475. */
  33476. getScreenAspectRatio(): number;
  33477. /**
  33478. * Gets the client rect of the HTML canvas attached with the current webGL context
  33479. * @returns a client rectanglee
  33480. */
  33481. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33482. /**
  33483. * Gets the client rect of the HTML element used for events
  33484. * @returns a client rectanglee
  33485. */
  33486. getInputElementClientRect(): Nullable<ClientRect>;
  33487. /**
  33488. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33489. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33490. * @returns true if engine is in deterministic lock step mode
  33491. */
  33492. isDeterministicLockStep(): boolean;
  33493. /**
  33494. * Gets the max steps when engine is running in deterministic lock step
  33495. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33496. * @returns the max steps
  33497. */
  33498. getLockstepMaxSteps(): number;
  33499. /**
  33500. * Returns the time in ms between steps when using deterministic lock step.
  33501. * @returns time step in (ms)
  33502. */
  33503. getTimeStep(): number;
  33504. /**
  33505. * Force the mipmap generation for the given render target texture
  33506. * @param texture defines the render target texture to use
  33507. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33508. */
  33509. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33510. /** States */
  33511. /**
  33512. * Set various states to the webGL context
  33513. * @param culling defines backface culling state
  33514. * @param zOffset defines the value to apply to zOffset (0 by default)
  33515. * @param force defines if states must be applied even if cache is up to date
  33516. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33517. */
  33518. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33519. /**
  33520. * Set the z offset to apply to current rendering
  33521. * @param value defines the offset to apply
  33522. */
  33523. setZOffset(value: number): void;
  33524. /**
  33525. * Gets the current value of the zOffset
  33526. * @returns the current zOffset state
  33527. */
  33528. getZOffset(): number;
  33529. /**
  33530. * Enable or disable depth buffering
  33531. * @param enable defines the state to set
  33532. */
  33533. setDepthBuffer(enable: boolean): void;
  33534. /**
  33535. * Gets a boolean indicating if depth writing is enabled
  33536. * @returns the current depth writing state
  33537. */
  33538. getDepthWrite(): boolean;
  33539. /**
  33540. * Enable or disable depth writing
  33541. * @param enable defines the state to set
  33542. */
  33543. setDepthWrite(enable: boolean): void;
  33544. /**
  33545. * Gets a boolean indicating if stencil buffer is enabled
  33546. * @returns the current stencil buffer state
  33547. */
  33548. getStencilBuffer(): boolean;
  33549. /**
  33550. * Enable or disable the stencil buffer
  33551. * @param enable defines if the stencil buffer must be enabled or disabled
  33552. */
  33553. setStencilBuffer(enable: boolean): void;
  33554. /**
  33555. * Gets the current stencil mask
  33556. * @returns a number defining the new stencil mask to use
  33557. */
  33558. getStencilMask(): number;
  33559. /**
  33560. * Sets the current stencil mask
  33561. * @param mask defines the new stencil mask to use
  33562. */
  33563. setStencilMask(mask: number): void;
  33564. /**
  33565. * Gets the current stencil function
  33566. * @returns a number defining the stencil function to use
  33567. */
  33568. getStencilFunction(): number;
  33569. /**
  33570. * Gets the current stencil reference value
  33571. * @returns a number defining the stencil reference value to use
  33572. */
  33573. getStencilFunctionReference(): number;
  33574. /**
  33575. * Gets the current stencil mask
  33576. * @returns a number defining the stencil mask to use
  33577. */
  33578. getStencilFunctionMask(): number;
  33579. /**
  33580. * Sets the current stencil function
  33581. * @param stencilFunc defines the new stencil function to use
  33582. */
  33583. setStencilFunction(stencilFunc: number): void;
  33584. /**
  33585. * Sets the current stencil reference
  33586. * @param reference defines the new stencil reference to use
  33587. */
  33588. setStencilFunctionReference(reference: number): void;
  33589. /**
  33590. * Sets the current stencil mask
  33591. * @param mask defines the new stencil mask to use
  33592. */
  33593. setStencilFunctionMask(mask: number): void;
  33594. /**
  33595. * Gets the current stencil operation when stencil fails
  33596. * @returns a number defining stencil operation to use when stencil fails
  33597. */
  33598. getStencilOperationFail(): number;
  33599. /**
  33600. * Gets the current stencil operation when depth fails
  33601. * @returns a number defining stencil operation to use when depth fails
  33602. */
  33603. getStencilOperationDepthFail(): number;
  33604. /**
  33605. * Gets the current stencil operation when stencil passes
  33606. * @returns a number defining stencil operation to use when stencil passes
  33607. */
  33608. getStencilOperationPass(): number;
  33609. /**
  33610. * Sets the stencil operation to use when stencil fails
  33611. * @param operation defines the stencil operation to use when stencil fails
  33612. */
  33613. setStencilOperationFail(operation: number): void;
  33614. /**
  33615. * Sets the stencil operation to use when depth fails
  33616. * @param operation defines the stencil operation to use when depth fails
  33617. */
  33618. setStencilOperationDepthFail(operation: number): void;
  33619. /**
  33620. * Sets the stencil operation to use when stencil passes
  33621. * @param operation defines the stencil operation to use when stencil passes
  33622. */
  33623. setStencilOperationPass(operation: number): void;
  33624. /**
  33625. * Sets a boolean indicating if the dithering state is enabled or disabled
  33626. * @param value defines the dithering state
  33627. */
  33628. setDitheringState(value: boolean): void;
  33629. /**
  33630. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33631. * @param value defines the rasterizer state
  33632. */
  33633. setRasterizerState(value: boolean): void;
  33634. /**
  33635. * Gets the current depth function
  33636. * @returns a number defining the depth function
  33637. */
  33638. getDepthFunction(): Nullable<number>;
  33639. /**
  33640. * Sets the current depth function
  33641. * @param depthFunc defines the function to use
  33642. */
  33643. setDepthFunction(depthFunc: number): void;
  33644. /**
  33645. * Sets the current depth function to GREATER
  33646. */
  33647. setDepthFunctionToGreater(): void;
  33648. /**
  33649. * Sets the current depth function to GEQUAL
  33650. */
  33651. setDepthFunctionToGreaterOrEqual(): void;
  33652. /**
  33653. * Sets the current depth function to LESS
  33654. */
  33655. setDepthFunctionToLess(): void;
  33656. /**
  33657. * Sets the current depth function to LEQUAL
  33658. */
  33659. setDepthFunctionToLessOrEqual(): void;
  33660. private _cachedStencilBuffer;
  33661. private _cachedStencilFunction;
  33662. private _cachedStencilMask;
  33663. private _cachedStencilOperationPass;
  33664. private _cachedStencilOperationFail;
  33665. private _cachedStencilOperationDepthFail;
  33666. private _cachedStencilReference;
  33667. /**
  33668. * Caches the the state of the stencil buffer
  33669. */
  33670. cacheStencilState(): void;
  33671. /**
  33672. * Restores the state of the stencil buffer
  33673. */
  33674. restoreStencilState(): void;
  33675. /**
  33676. * Directly set the WebGL Viewport
  33677. * @param x defines the x coordinate of the viewport (in screen space)
  33678. * @param y defines the y coordinate of the viewport (in screen space)
  33679. * @param width defines the width of the viewport (in screen space)
  33680. * @param height defines the height of the viewport (in screen space)
  33681. * @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
  33682. */
  33683. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33684. /**
  33685. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33686. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33687. * @param y defines the y-coordinate of the corner of the clear rectangle
  33688. * @param width defines the width of the clear rectangle
  33689. * @param height defines the height of the clear rectangle
  33690. * @param clearColor defines the clear color
  33691. */
  33692. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33693. /**
  33694. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33695. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33696. * @param y defines the y-coordinate of the corner of the clear rectangle
  33697. * @param width defines the width of the clear rectangle
  33698. * @param height defines the height of the clear rectangle
  33699. */
  33700. enableScissor(x: number, y: number, width: number, height: number): void;
  33701. /**
  33702. * Disable previously set scissor test rectangle
  33703. */
  33704. disableScissor(): void;
  33705. protected _reportDrawCall(): void;
  33706. /**
  33707. * Initializes a webVR display and starts listening to display change events
  33708. * The onVRDisplayChangedObservable will be notified upon these changes
  33709. * @returns The onVRDisplayChangedObservable
  33710. */
  33711. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33712. /** @hidden */
  33713. _prepareVRComponent(): void;
  33714. /** @hidden */
  33715. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33716. /** @hidden */
  33717. _submitVRFrame(): void;
  33718. /**
  33719. * Call this function to leave webVR mode
  33720. * Will do nothing if webVR is not supported or if there is no webVR device
  33721. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33722. */
  33723. disableVR(): void;
  33724. /**
  33725. * Gets a boolean indicating that the system is in VR mode and is presenting
  33726. * @returns true if VR mode is engaged
  33727. */
  33728. isVRPresenting(): boolean;
  33729. /** @hidden */
  33730. _requestVRFrame(): void;
  33731. /** @hidden */
  33732. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33733. /**
  33734. * Gets the source code of the vertex shader associated with a specific webGL program
  33735. * @param program defines the program to use
  33736. * @returns a string containing the source code of the vertex shader associated with the program
  33737. */
  33738. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33739. /**
  33740. * Gets the source code of the fragment shader associated with a specific webGL program
  33741. * @param program defines the program to use
  33742. * @returns a string containing the source code of the fragment shader associated with the program
  33743. */
  33744. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33745. /**
  33746. * Sets a depth stencil texture from a render target to the according uniform.
  33747. * @param channel The texture channel
  33748. * @param uniform The uniform to set
  33749. * @param texture The render target texture containing the depth stencil texture to apply
  33750. */
  33751. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33752. /**
  33753. * Sets a texture to the webGL context from a postprocess
  33754. * @param channel defines the channel to use
  33755. * @param postProcess defines the source postprocess
  33756. */
  33757. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33758. /**
  33759. * Binds the output of the passed in post process to the texture channel specified
  33760. * @param channel The channel the texture should be bound to
  33761. * @param postProcess The post process which's output should be bound
  33762. */
  33763. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33764. /** @hidden */
  33765. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33766. protected _rebuildBuffers(): void;
  33767. /** @hidden */
  33768. _renderFrame(): void;
  33769. _renderLoop(): void;
  33770. /** @hidden */
  33771. _renderViews(): boolean;
  33772. /**
  33773. * Toggle full screen mode
  33774. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33775. */
  33776. switchFullscreen(requestPointerLock: boolean): void;
  33777. /**
  33778. * Enters full screen mode
  33779. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33780. */
  33781. enterFullscreen(requestPointerLock: boolean): void;
  33782. /**
  33783. * Exits full screen mode
  33784. */
  33785. exitFullscreen(): void;
  33786. /**
  33787. * Enters Pointerlock mode
  33788. */
  33789. enterPointerlock(): void;
  33790. /**
  33791. * Exits Pointerlock mode
  33792. */
  33793. exitPointerlock(): void;
  33794. /**
  33795. * Begin a new frame
  33796. */
  33797. beginFrame(): void;
  33798. /**
  33799. * Enf the current frame
  33800. */
  33801. endFrame(): void;
  33802. resize(): void;
  33803. /**
  33804. * Force a specific size of the canvas
  33805. * @param width defines the new canvas' width
  33806. * @param height defines the new canvas' height
  33807. */
  33808. setSize(width: number, height: number): void;
  33809. /**
  33810. * Updates a dynamic vertex buffer.
  33811. * @param vertexBuffer the vertex buffer to update
  33812. * @param data the data used to update the vertex buffer
  33813. * @param byteOffset the byte offset of the data
  33814. * @param byteLength the byte length of the data
  33815. */
  33816. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33817. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33818. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33819. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33820. _releaseTexture(texture: InternalTexture): void;
  33821. /**
  33822. * @hidden
  33823. * Rescales a texture
  33824. * @param source input texutre
  33825. * @param destination destination texture
  33826. * @param scene scene to use to render the resize
  33827. * @param internalFormat format to use when resizing
  33828. * @param onComplete callback to be called when resize has completed
  33829. */
  33830. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33831. /**
  33832. * Gets the current framerate
  33833. * @returns a number representing the framerate
  33834. */
  33835. getFps(): number;
  33836. /**
  33837. * Gets the time spent between current and previous frame
  33838. * @returns a number representing the delta time in ms
  33839. */
  33840. getDeltaTime(): number;
  33841. private _measureFps;
  33842. /** @hidden */
  33843. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33844. /**
  33845. * Update a dynamic index buffer
  33846. * @param indexBuffer defines the target index buffer
  33847. * @param indices defines the data to update
  33848. * @param offset defines the offset in the target index buffer where update should start
  33849. */
  33850. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33851. /**
  33852. * Updates the sample count of a render target texture
  33853. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33854. * @param texture defines the texture to update
  33855. * @param samples defines the sample count to set
  33856. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33857. */
  33858. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33859. /**
  33860. * Updates a depth texture Comparison Mode and Function.
  33861. * If the comparison Function is equal to 0, the mode will be set to none.
  33862. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33863. * @param texture The texture to set the comparison function for
  33864. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33865. */
  33866. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33867. /**
  33868. * Creates a webGL buffer to use with instanciation
  33869. * @param capacity defines the size of the buffer
  33870. * @returns the webGL buffer
  33871. */
  33872. createInstancesBuffer(capacity: number): DataBuffer;
  33873. /**
  33874. * Delete a webGL buffer used with instanciation
  33875. * @param buffer defines the webGL buffer to delete
  33876. */
  33877. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33878. private _clientWaitAsync;
  33879. /** @hidden */
  33880. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  33881. /** @hidden */
  33882. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33883. dispose(): void;
  33884. private _disableTouchAction;
  33885. /**
  33886. * Display the loading screen
  33887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33888. */
  33889. displayLoadingUI(): void;
  33890. /**
  33891. * Hide the loading screen
  33892. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33893. */
  33894. hideLoadingUI(): void;
  33895. /**
  33896. * Gets the current loading screen object
  33897. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33898. */
  33899. get loadingScreen(): ILoadingScreen;
  33900. /**
  33901. * Sets the current loading screen object
  33902. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33903. */
  33904. set loadingScreen(loadingScreen: ILoadingScreen);
  33905. /**
  33906. * Sets the current loading screen text
  33907. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33908. */
  33909. set loadingUIText(text: string);
  33910. /**
  33911. * Sets the current loading screen background color
  33912. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33913. */
  33914. set loadingUIBackgroundColor(color: string);
  33915. /** Pointerlock and fullscreen */
  33916. /**
  33917. * Ask the browser to promote the current element to pointerlock mode
  33918. * @param element defines the DOM element to promote
  33919. */
  33920. static _RequestPointerlock(element: HTMLElement): void;
  33921. /**
  33922. * Asks the browser to exit pointerlock mode
  33923. */
  33924. static _ExitPointerlock(): void;
  33925. /**
  33926. * Ask the browser to promote the current element to fullscreen rendering mode
  33927. * @param element defines the DOM element to promote
  33928. */
  33929. static _RequestFullscreen(element: HTMLElement): void;
  33930. /**
  33931. * Asks the browser to exit fullscreen mode
  33932. */
  33933. static _ExitFullscreen(): void;
  33934. }
  33935. }
  33936. declare module BABYLON {
  33937. /**
  33938. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33939. * during the life time of the application.
  33940. */
  33941. export class EngineStore {
  33942. /** Gets the list of created engines */
  33943. static Instances: Engine[];
  33944. /** @hidden */
  33945. static _LastCreatedScene: Nullable<Scene>;
  33946. /**
  33947. * Gets the latest created engine
  33948. */
  33949. static get LastCreatedEngine(): Nullable<Engine>;
  33950. /**
  33951. * Gets the latest created scene
  33952. */
  33953. static get LastCreatedScene(): Nullable<Scene>;
  33954. /**
  33955. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33956. * @ignorenaming
  33957. */
  33958. static UseFallbackTexture: boolean;
  33959. /**
  33960. * Texture content used if a texture cannot loaded
  33961. * @ignorenaming
  33962. */
  33963. static FallbackTexture: string;
  33964. }
  33965. }
  33966. declare module BABYLON {
  33967. /**
  33968. * Helper class that provides a small promise polyfill
  33969. */
  33970. export class PromisePolyfill {
  33971. /**
  33972. * Static function used to check if the polyfill is required
  33973. * If this is the case then the function will inject the polyfill to window.Promise
  33974. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33975. */
  33976. static Apply(force?: boolean): void;
  33977. }
  33978. }
  33979. declare module BABYLON {
  33980. /**
  33981. * Interface for screenshot methods with describe argument called `size` as object with options
  33982. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33983. */
  33984. export interface IScreenshotSize {
  33985. /**
  33986. * number in pixels for canvas height
  33987. */
  33988. height?: number;
  33989. /**
  33990. * multiplier allowing render at a higher or lower resolution
  33991. * If value is defined then height and width will be ignored and taken from camera
  33992. */
  33993. precision?: number;
  33994. /**
  33995. * number in pixels for canvas width
  33996. */
  33997. width?: number;
  33998. }
  33999. }
  34000. declare module BABYLON {
  34001. interface IColor4Like {
  34002. r: float;
  34003. g: float;
  34004. b: float;
  34005. a: float;
  34006. }
  34007. /**
  34008. * Class containing a set of static utilities functions
  34009. */
  34010. export class Tools {
  34011. /**
  34012. * Gets or sets the base URL to use to load assets
  34013. */
  34014. static get BaseUrl(): string;
  34015. static set BaseUrl(value: string);
  34016. /**
  34017. * Enable/Disable Custom HTTP Request Headers globally.
  34018. * default = false
  34019. * @see CustomRequestHeaders
  34020. */
  34021. static UseCustomRequestHeaders: boolean;
  34022. /**
  34023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34024. * i.e. when loading files, where the server/service expects an Authorization header
  34025. */
  34026. static CustomRequestHeaders: {
  34027. [key: string]: string;
  34028. };
  34029. /**
  34030. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34031. */
  34032. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34033. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34034. /**
  34035. * Default behaviour for cors in the application.
  34036. * It can be a string if the expected behavior is identical in the entire app.
  34037. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34038. */
  34039. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34040. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34041. /**
  34042. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34043. * @ignorenaming
  34044. */
  34045. static get UseFallbackTexture(): boolean;
  34046. static set UseFallbackTexture(value: boolean);
  34047. /**
  34048. * Use this object to register external classes like custom textures or material
  34049. * to allow the laoders to instantiate them
  34050. */
  34051. static get RegisteredExternalClasses(): {
  34052. [key: string]: Object;
  34053. };
  34054. static set RegisteredExternalClasses(classes: {
  34055. [key: string]: Object;
  34056. });
  34057. /**
  34058. * Texture content used if a texture cannot loaded
  34059. * @ignorenaming
  34060. */
  34061. static get fallbackTexture(): string;
  34062. static set fallbackTexture(value: string);
  34063. /**
  34064. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34065. * @param u defines the coordinate on X axis
  34066. * @param v defines the coordinate on Y axis
  34067. * @param width defines the width of the source data
  34068. * @param height defines the height of the source data
  34069. * @param pixels defines the source byte array
  34070. * @param color defines the output color
  34071. */
  34072. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34073. /**
  34074. * Interpolates between a and b via alpha
  34075. * @param a The lower value (returned when alpha = 0)
  34076. * @param b The upper value (returned when alpha = 1)
  34077. * @param alpha The interpolation-factor
  34078. * @return The mixed value
  34079. */
  34080. static Mix(a: number, b: number, alpha: number): number;
  34081. /**
  34082. * Tries to instantiate a new object from a given class name
  34083. * @param className defines the class name to instantiate
  34084. * @returns the new object or null if the system was not able to do the instantiation
  34085. */
  34086. static Instantiate(className: string): any;
  34087. /**
  34088. * Provides a slice function that will work even on IE
  34089. * @param data defines the array to slice
  34090. * @param start defines the start of the data (optional)
  34091. * @param end defines the end of the data (optional)
  34092. * @returns the new sliced array
  34093. */
  34094. static Slice<T>(data: T, start?: number, end?: number): T;
  34095. /**
  34096. * Polyfill for setImmediate
  34097. * @param action defines the action to execute after the current execution block
  34098. */
  34099. static SetImmediate(action: () => void): void;
  34100. /**
  34101. * Function indicating if a number is an exponent of 2
  34102. * @param value defines the value to test
  34103. * @returns true if the value is an exponent of 2
  34104. */
  34105. static IsExponentOfTwo(value: number): boolean;
  34106. private static _tmpFloatArray;
  34107. /**
  34108. * Returns the nearest 32-bit single precision float representation of a Number
  34109. * @param value A Number. If the parameter is of a different type, it will get converted
  34110. * to a number or to NaN if it cannot be converted
  34111. * @returns number
  34112. */
  34113. static FloatRound(value: number): number;
  34114. /**
  34115. * Extracts the filename from a path
  34116. * @param path defines the path to use
  34117. * @returns the filename
  34118. */
  34119. static GetFilename(path: string): string;
  34120. /**
  34121. * Extracts the "folder" part of a path (everything before the filename).
  34122. * @param uri The URI to extract the info from
  34123. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34124. * @returns The "folder" part of the path
  34125. */
  34126. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34127. /**
  34128. * Extracts text content from a DOM element hierarchy
  34129. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34130. */
  34131. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34132. /**
  34133. * Convert an angle in radians to degrees
  34134. * @param angle defines the angle to convert
  34135. * @returns the angle in degrees
  34136. */
  34137. static ToDegrees(angle: number): number;
  34138. /**
  34139. * Convert an angle in degrees to radians
  34140. * @param angle defines the angle to convert
  34141. * @returns the angle in radians
  34142. */
  34143. static ToRadians(angle: number): number;
  34144. /**
  34145. * Returns an array if obj is not an array
  34146. * @param obj defines the object to evaluate as an array
  34147. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34148. * @returns either obj directly if obj is an array or a new array containing obj
  34149. */
  34150. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34151. /**
  34152. * Gets the pointer prefix to use
  34153. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34154. */
  34155. static GetPointerPrefix(): string;
  34156. /**
  34157. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34158. * @param url define the url we are trying
  34159. * @param element define the dom element where to configure the cors policy
  34160. */
  34161. static SetCorsBehavior(url: string | string[], element: {
  34162. crossOrigin: string | null;
  34163. }): void;
  34164. /**
  34165. * Removes unwanted characters from an url
  34166. * @param url defines the url to clean
  34167. * @returns the cleaned url
  34168. */
  34169. static CleanUrl(url: string): string;
  34170. /**
  34171. * Gets or sets a function used to pre-process url before using them to load assets
  34172. */
  34173. static get PreprocessUrl(): (url: string) => string;
  34174. static set PreprocessUrl(processor: (url: string) => string);
  34175. /**
  34176. * Loads an image as an HTMLImageElement.
  34177. * @param input url string, ArrayBuffer, or Blob to load
  34178. * @param onLoad callback called when the image successfully loads
  34179. * @param onError callback called when the image fails to load
  34180. * @param offlineProvider offline provider for caching
  34181. * @param mimeType optional mime type
  34182. * @returns the HTMLImageElement of the loaded image
  34183. */
  34184. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34185. /**
  34186. * Loads a file from a url
  34187. * @param url url string, ArrayBuffer, or Blob to load
  34188. * @param onSuccess callback called when the file successfully loads
  34189. * @param onProgress callback called while file is loading (if the server supports this mode)
  34190. * @param offlineProvider defines the offline provider for caching
  34191. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34192. * @param onError callback called when the file fails to load
  34193. * @returns a file request object
  34194. */
  34195. 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;
  34196. /**
  34197. * Loads a file from a url
  34198. * @param url the file url to load
  34199. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34200. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34201. */
  34202. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34203. /**
  34204. * Load a script (identified by an url). When the url returns, the
  34205. * content of this file is added into a new script element, attached to the DOM (body element)
  34206. * @param scriptUrl defines the url of the script to laod
  34207. * @param onSuccess defines the callback called when the script is loaded
  34208. * @param onError defines the callback to call if an error occurs
  34209. * @param scriptId defines the id of the script element
  34210. */
  34211. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34212. /**
  34213. * Load an asynchronous script (identified by an url). When the url returns, the
  34214. * content of this file is added into a new script element, attached to the DOM (body element)
  34215. * @param scriptUrl defines the url of the script to laod
  34216. * @param scriptId defines the id of the script element
  34217. * @returns a promise request object
  34218. */
  34219. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34220. /**
  34221. * Loads a file from a blob
  34222. * @param fileToLoad defines the blob to use
  34223. * @param callback defines the callback to call when data is loaded
  34224. * @param progressCallback defines the callback to call during loading process
  34225. * @returns a file request object
  34226. */
  34227. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34228. /**
  34229. * Reads a file from a File object
  34230. * @param file defines the file to load
  34231. * @param onSuccess defines the callback to call when data is loaded
  34232. * @param onProgress defines the callback to call during loading process
  34233. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34234. * @param onError defines the callback to call when an error occurs
  34235. * @returns a file request object
  34236. */
  34237. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34238. /**
  34239. * Creates a data url from a given string content
  34240. * @param content defines the content to convert
  34241. * @returns the new data url link
  34242. */
  34243. static FileAsURL(content: string): string;
  34244. /**
  34245. * Format the given number to a specific decimal format
  34246. * @param value defines the number to format
  34247. * @param decimals defines the number of decimals to use
  34248. * @returns the formatted string
  34249. */
  34250. static Format(value: number, decimals?: number): string;
  34251. /**
  34252. * Tries to copy an object by duplicating every property
  34253. * @param source defines the source object
  34254. * @param destination defines the target object
  34255. * @param doNotCopyList defines a list of properties to avoid
  34256. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34257. */
  34258. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34259. /**
  34260. * Gets a boolean indicating if the given object has no own property
  34261. * @param obj defines the object to test
  34262. * @returns true if object has no own property
  34263. */
  34264. static IsEmpty(obj: any): boolean;
  34265. /**
  34266. * Function used to register events at window level
  34267. * @param windowElement defines the Window object to use
  34268. * @param events defines the events to register
  34269. */
  34270. static RegisterTopRootEvents(windowElement: Window, events: {
  34271. name: string;
  34272. handler: Nullable<(e: FocusEvent) => any>;
  34273. }[]): void;
  34274. /**
  34275. * Function used to unregister events from window level
  34276. * @param windowElement defines the Window object to use
  34277. * @param events defines the events to unregister
  34278. */
  34279. static UnregisterTopRootEvents(windowElement: Window, events: {
  34280. name: string;
  34281. handler: Nullable<(e: FocusEvent) => any>;
  34282. }[]): void;
  34283. /**
  34284. * @ignore
  34285. */
  34286. static _ScreenshotCanvas: HTMLCanvasElement;
  34287. /**
  34288. * Dumps the current bound framebuffer
  34289. * @param width defines the rendering width
  34290. * @param height defines the rendering height
  34291. * @param engine defines the hosting engine
  34292. * @param successCallback defines the callback triggered once the data are available
  34293. * @param mimeType defines the mime type of the result
  34294. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34295. */
  34296. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34297. /**
  34298. * Converts the canvas data to blob.
  34299. * This acts as a polyfill for browsers not supporting the to blob function.
  34300. * @param canvas Defines the canvas to extract the data from
  34301. * @param successCallback Defines the callback triggered once the data are available
  34302. * @param mimeType Defines the mime type of the result
  34303. */
  34304. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34305. /**
  34306. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34307. * @param successCallback defines the callback triggered once the data are available
  34308. * @param mimeType defines the mime type of the result
  34309. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34310. */
  34311. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34312. /**
  34313. * Downloads a blob in the browser
  34314. * @param blob defines the blob to download
  34315. * @param fileName defines the name of the downloaded file
  34316. */
  34317. static Download(blob: Blob, fileName: string): void;
  34318. /**
  34319. * Captures a screenshot of the current rendering
  34320. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34321. * @param engine defines the rendering engine
  34322. * @param camera defines the source camera
  34323. * @param size This parameter can be set to a single number or to an object with the
  34324. * following (optional) properties: precision, width, height. If a single number is passed,
  34325. * it will be used for both width and height. If an object is passed, the screenshot size
  34326. * will be derived from the parameters. The precision property is a multiplier allowing
  34327. * rendering at a higher or lower resolution
  34328. * @param successCallback defines the callback receives a single parameter which contains the
  34329. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34330. * src parameter of an <img> to display it
  34331. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34332. * Check your browser for supported MIME types
  34333. */
  34334. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34335. /**
  34336. * Captures a screenshot of the current rendering
  34337. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34338. * @param engine defines the rendering engine
  34339. * @param camera defines the source camera
  34340. * @param size This parameter can be set to a single number or to an object with the
  34341. * following (optional) properties: precision, width, height. If a single number is passed,
  34342. * it will be used for both width and height. If an object is passed, the screenshot size
  34343. * will be derived from the parameters. The precision property is a multiplier allowing
  34344. * rendering at a higher or lower resolution
  34345. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34346. * Check your browser for supported MIME types
  34347. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34348. * to the src parameter of an <img> to display it
  34349. */
  34350. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34351. /**
  34352. * Generates an image screenshot from the specified camera.
  34353. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34354. * @param engine The engine to use for rendering
  34355. * @param camera The camera to use for rendering
  34356. * @param size This parameter can be set to a single number or to an object with the
  34357. * following (optional) properties: precision, width, height. If a single number is passed,
  34358. * it will be used for both width and height. If an object is passed, the screenshot size
  34359. * will be derived from the parameters. The precision property is a multiplier allowing
  34360. * rendering at a higher or lower resolution
  34361. * @param successCallback The callback receives a single parameter which contains the
  34362. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34363. * src parameter of an <img> to display it
  34364. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34365. * Check your browser for supported MIME types
  34366. * @param samples Texture samples (default: 1)
  34367. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34368. * @param fileName A name for for the downloaded file.
  34369. */
  34370. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34371. /**
  34372. * Generates an image screenshot from the specified camera.
  34373. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34374. * @param engine The engine to use for rendering
  34375. * @param camera The camera to use for rendering
  34376. * @param size This parameter can be set to a single number or to an object with the
  34377. * following (optional) properties: precision, width, height. If a single number is passed,
  34378. * it will be used for both width and height. If an object is passed, the screenshot size
  34379. * will be derived from the parameters. The precision property is a multiplier allowing
  34380. * rendering at a higher or lower resolution
  34381. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34382. * Check your browser for supported MIME types
  34383. * @param samples Texture samples (default: 1)
  34384. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34385. * @param fileName A name for for the downloaded file.
  34386. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34387. * to the src parameter of an <img> to display it
  34388. */
  34389. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34390. /**
  34391. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34392. * Be aware Math.random() could cause collisions, but:
  34393. * "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"
  34394. * @returns a pseudo random id
  34395. */
  34396. static RandomId(): string;
  34397. /**
  34398. * Test if the given uri is a base64 string
  34399. * @param uri The uri to test
  34400. * @return True if the uri is a base64 string or false otherwise
  34401. */
  34402. static IsBase64(uri: string): boolean;
  34403. /**
  34404. * Decode the given base64 uri.
  34405. * @param uri The uri to decode
  34406. * @return The decoded base64 data.
  34407. */
  34408. static DecodeBase64(uri: string): ArrayBuffer;
  34409. /**
  34410. * Gets the absolute url.
  34411. * @param url the input url
  34412. * @return the absolute url
  34413. */
  34414. static GetAbsoluteUrl(url: string): string;
  34415. /**
  34416. * No log
  34417. */
  34418. static readonly NoneLogLevel: number;
  34419. /**
  34420. * Only message logs
  34421. */
  34422. static readonly MessageLogLevel: number;
  34423. /**
  34424. * Only warning logs
  34425. */
  34426. static readonly WarningLogLevel: number;
  34427. /**
  34428. * Only error logs
  34429. */
  34430. static readonly ErrorLogLevel: number;
  34431. /**
  34432. * All logs
  34433. */
  34434. static readonly AllLogLevel: number;
  34435. /**
  34436. * Gets a value indicating the number of loading errors
  34437. * @ignorenaming
  34438. */
  34439. static get errorsCount(): number;
  34440. /**
  34441. * Callback called when a new log is added
  34442. */
  34443. static OnNewCacheEntry: (entry: string) => void;
  34444. /**
  34445. * Log a message to the console
  34446. * @param message defines the message to log
  34447. */
  34448. static Log(message: string): void;
  34449. /**
  34450. * Write a warning message to the console
  34451. * @param message defines the message to log
  34452. */
  34453. static Warn(message: string): void;
  34454. /**
  34455. * Write an error message to the console
  34456. * @param message defines the message to log
  34457. */
  34458. static Error(message: string): void;
  34459. /**
  34460. * Gets current log cache (list of logs)
  34461. */
  34462. static get LogCache(): string;
  34463. /**
  34464. * Clears the log cache
  34465. */
  34466. static ClearLogCache(): void;
  34467. /**
  34468. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34469. */
  34470. static set LogLevels(level: number);
  34471. /**
  34472. * Checks if the window object exists
  34473. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34474. */
  34475. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34476. /**
  34477. * No performance log
  34478. */
  34479. static readonly PerformanceNoneLogLevel: number;
  34480. /**
  34481. * Use user marks to log performance
  34482. */
  34483. static readonly PerformanceUserMarkLogLevel: number;
  34484. /**
  34485. * Log performance to the console
  34486. */
  34487. static readonly PerformanceConsoleLogLevel: number;
  34488. private static _performance;
  34489. /**
  34490. * Sets the current performance log level
  34491. */
  34492. static set PerformanceLogLevel(level: number);
  34493. private static _StartPerformanceCounterDisabled;
  34494. private static _EndPerformanceCounterDisabled;
  34495. private static _StartUserMark;
  34496. private static _EndUserMark;
  34497. private static _StartPerformanceConsole;
  34498. private static _EndPerformanceConsole;
  34499. /**
  34500. * Starts a performance counter
  34501. */
  34502. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34503. /**
  34504. * Ends a specific performance coutner
  34505. */
  34506. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34507. /**
  34508. * Gets either window.performance.now() if supported or Date.now() else
  34509. */
  34510. static get Now(): number;
  34511. /**
  34512. * This method will return the name of the class used to create the instance of the given object.
  34513. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34514. * @param object the object to get the class name from
  34515. * @param isType defines if the object is actually a type
  34516. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34517. */
  34518. static GetClassName(object: any, isType?: boolean): string;
  34519. /**
  34520. * Gets the first element of an array satisfying a given predicate
  34521. * @param array defines the array to browse
  34522. * @param predicate defines the predicate to use
  34523. * @returns null if not found or the element
  34524. */
  34525. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34526. /**
  34527. * This method will return the name of the full name of the class, including its owning module (if any).
  34528. * 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).
  34529. * @param object the object to get the class name from
  34530. * @param isType defines if the object is actually a type
  34531. * @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.
  34532. * @ignorenaming
  34533. */
  34534. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34535. /**
  34536. * Returns a promise that resolves after the given amount of time.
  34537. * @param delay Number of milliseconds to delay
  34538. * @returns Promise that resolves after the given amount of time
  34539. */
  34540. static DelayAsync(delay: number): Promise<void>;
  34541. /**
  34542. * Utility function to detect if the current user agent is Safari
  34543. * @returns whether or not the current user agent is safari
  34544. */
  34545. static IsSafari(): boolean;
  34546. }
  34547. /**
  34548. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34549. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34550. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34551. * @param name The name of the class, case should be preserved
  34552. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34553. */
  34554. export function className(name: string, module?: string): (target: Object) => void;
  34555. /**
  34556. * An implementation of a loop for asynchronous functions.
  34557. */
  34558. export class AsyncLoop {
  34559. /**
  34560. * Defines the number of iterations for the loop
  34561. */
  34562. iterations: number;
  34563. /**
  34564. * Defines the current index of the loop.
  34565. */
  34566. index: number;
  34567. private _done;
  34568. private _fn;
  34569. private _successCallback;
  34570. /**
  34571. * Constructor.
  34572. * @param iterations the number of iterations.
  34573. * @param func the function to run each iteration
  34574. * @param successCallback the callback that will be called upon succesful execution
  34575. * @param offset starting offset.
  34576. */
  34577. constructor(
  34578. /**
  34579. * Defines the number of iterations for the loop
  34580. */
  34581. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34582. /**
  34583. * Execute the next iteration. Must be called after the last iteration was finished.
  34584. */
  34585. executeNext(): void;
  34586. /**
  34587. * Break the loop and run the success callback.
  34588. */
  34589. breakLoop(): void;
  34590. /**
  34591. * Create and run an async loop.
  34592. * @param iterations the number of iterations.
  34593. * @param fn the function to run each iteration
  34594. * @param successCallback the callback that will be called upon succesful execution
  34595. * @param offset starting offset.
  34596. * @returns the created async loop object
  34597. */
  34598. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34599. /**
  34600. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34601. * @param iterations total number of iterations
  34602. * @param syncedIterations number of synchronous iterations in each async iteration.
  34603. * @param fn the function to call each iteration.
  34604. * @param callback a success call back that will be called when iterating stops.
  34605. * @param breakFunction a break condition (optional)
  34606. * @param timeout timeout settings for the setTimeout function. default - 0.
  34607. * @returns the created async loop object
  34608. */
  34609. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34610. }
  34611. }
  34612. declare module BABYLON {
  34613. /**
  34614. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34615. * The underlying implementation relies on an associative array to ensure the best performances.
  34616. * The value can be anything including 'null' but except 'undefined'
  34617. */
  34618. export class StringDictionary<T> {
  34619. /**
  34620. * This will clear this dictionary and copy the content from the 'source' one.
  34621. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34622. * @param source the dictionary to take the content from and copy to this dictionary
  34623. */
  34624. copyFrom(source: StringDictionary<T>): void;
  34625. /**
  34626. * Get a value based from its key
  34627. * @param key the given key to get the matching value from
  34628. * @return the value if found, otherwise undefined is returned
  34629. */
  34630. get(key: string): T | undefined;
  34631. /**
  34632. * Get a value from its key or add it if it doesn't exist.
  34633. * This method will ensure you that a given key/data will be present in the dictionary.
  34634. * @param key the given key to get the matching value from
  34635. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34636. * The factory will only be invoked if there's no data for the given key.
  34637. * @return the value corresponding to the key.
  34638. */
  34639. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34640. /**
  34641. * Get a value from its key if present in the dictionary otherwise add it
  34642. * @param key the key to get the value from
  34643. * @param val if there's no such key/value pair in the dictionary add it with this value
  34644. * @return the value corresponding to the key
  34645. */
  34646. getOrAdd(key: string, val: T): T;
  34647. /**
  34648. * Check if there's a given key in the dictionary
  34649. * @param key the key to check for
  34650. * @return true if the key is present, false otherwise
  34651. */
  34652. contains(key: string): boolean;
  34653. /**
  34654. * Add a new key and its corresponding value
  34655. * @param key the key to add
  34656. * @param value the value corresponding to the key
  34657. * @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
  34658. */
  34659. add(key: string, value: T): boolean;
  34660. /**
  34661. * Update a specific value associated to a key
  34662. * @param key defines the key to use
  34663. * @param value defines the value to store
  34664. * @returns true if the value was updated (or false if the key was not found)
  34665. */
  34666. set(key: string, value: T): boolean;
  34667. /**
  34668. * Get the element of the given key and remove it from the dictionary
  34669. * @param key defines the key to search
  34670. * @returns the value associated with the key or null if not found
  34671. */
  34672. getAndRemove(key: string): Nullable<T>;
  34673. /**
  34674. * Remove a key/value from the dictionary.
  34675. * @param key the key to remove
  34676. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34677. */
  34678. remove(key: string): boolean;
  34679. /**
  34680. * Clear the whole content of the dictionary
  34681. */
  34682. clear(): void;
  34683. /**
  34684. * Gets the current count
  34685. */
  34686. get count(): number;
  34687. /**
  34688. * Execute a callback on each key/val of the dictionary.
  34689. * Note that you can remove any element in this dictionary in the callback implementation
  34690. * @param callback the callback to execute on a given key/value pair
  34691. */
  34692. forEach(callback: (key: string, val: T) => void): void;
  34693. /**
  34694. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34695. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34696. * Note that you can remove any element in this dictionary in the callback implementation
  34697. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34698. * @returns the first item
  34699. */
  34700. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34701. private _count;
  34702. private _data;
  34703. }
  34704. }
  34705. declare module BABYLON {
  34706. /** @hidden */
  34707. export interface ICollisionCoordinator {
  34708. createCollider(): Collider;
  34709. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34710. init(scene: Scene): void;
  34711. }
  34712. /** @hidden */
  34713. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34714. private _scene;
  34715. private _scaledPosition;
  34716. private _scaledVelocity;
  34717. private _finalPosition;
  34718. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34719. createCollider(): Collider;
  34720. init(scene: Scene): void;
  34721. private _collideWithWorld;
  34722. }
  34723. }
  34724. declare module BABYLON {
  34725. /**
  34726. * Class used to manage all inputs for the scene.
  34727. */
  34728. export class InputManager {
  34729. /** The distance in pixel that you have to move to prevent some events */
  34730. static DragMovementThreshold: number;
  34731. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34732. static LongPressDelay: number;
  34733. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34734. static DoubleClickDelay: number;
  34735. /** If you need to check double click without raising a single click at first click, enable this flag */
  34736. static ExclusiveDoubleClickMode: boolean;
  34737. private _wheelEventName;
  34738. private _onPointerMove;
  34739. private _onPointerDown;
  34740. private _onPointerUp;
  34741. private _initClickEvent;
  34742. private _initActionManager;
  34743. private _delayedSimpleClick;
  34744. private _delayedSimpleClickTimeout;
  34745. private _previousDelayedSimpleClickTimeout;
  34746. private _meshPickProceed;
  34747. private _previousButtonPressed;
  34748. private _currentPickResult;
  34749. private _previousPickResult;
  34750. private _totalPointersPressed;
  34751. private _doubleClickOccured;
  34752. private _pointerOverMesh;
  34753. private _pickedDownMesh;
  34754. private _pickedUpMesh;
  34755. private _pointerX;
  34756. private _pointerY;
  34757. private _unTranslatedPointerX;
  34758. private _unTranslatedPointerY;
  34759. private _startingPointerPosition;
  34760. private _previousStartingPointerPosition;
  34761. private _startingPointerTime;
  34762. private _previousStartingPointerTime;
  34763. private _pointerCaptures;
  34764. private _onKeyDown;
  34765. private _onKeyUp;
  34766. private _onCanvasFocusObserver;
  34767. private _onCanvasBlurObserver;
  34768. private _scene;
  34769. /**
  34770. * Creates a new InputManager
  34771. * @param scene defines the hosting scene
  34772. */
  34773. constructor(scene: Scene);
  34774. /**
  34775. * Gets the mesh that is currently under the pointer
  34776. */
  34777. get meshUnderPointer(): Nullable<AbstractMesh>;
  34778. /**
  34779. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34780. */
  34781. get unTranslatedPointer(): Vector2;
  34782. /**
  34783. * Gets or sets the current on-screen X position of the pointer
  34784. */
  34785. get pointerX(): number;
  34786. set pointerX(value: number);
  34787. /**
  34788. * Gets or sets the current on-screen Y position of the pointer
  34789. */
  34790. get pointerY(): number;
  34791. set pointerY(value: number);
  34792. private _updatePointerPosition;
  34793. private _processPointerMove;
  34794. private _setRayOnPointerInfo;
  34795. private _checkPrePointerObservable;
  34796. /**
  34797. * Use this method to simulate a pointer move on a mesh
  34798. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34799. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34800. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34801. */
  34802. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34803. /**
  34804. * Use this method to simulate a pointer down on a mesh
  34805. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34806. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34807. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34808. */
  34809. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34810. private _processPointerDown;
  34811. /** @hidden */
  34812. _isPointerSwiping(): boolean;
  34813. /**
  34814. * Use this method to simulate a pointer up on a mesh
  34815. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34816. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34817. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34818. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34819. */
  34820. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34821. private _processPointerUp;
  34822. /**
  34823. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34824. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34825. * @returns true if the pointer was captured
  34826. */
  34827. isPointerCaptured(pointerId?: number): boolean;
  34828. /**
  34829. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34830. * @param attachUp defines if you want to attach events to pointerup
  34831. * @param attachDown defines if you want to attach events to pointerdown
  34832. * @param attachMove defines if you want to attach events to pointermove
  34833. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34834. */
  34835. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34836. /**
  34837. * Detaches all event handlers
  34838. */
  34839. detachControl(): void;
  34840. /**
  34841. * Force the value of meshUnderPointer
  34842. * @param mesh defines the mesh to use
  34843. */
  34844. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34845. /**
  34846. * Gets the mesh under the pointer
  34847. * @returns a Mesh or null if no mesh is under the pointer
  34848. */
  34849. getPointerOverMesh(): Nullable<AbstractMesh>;
  34850. }
  34851. }
  34852. declare module BABYLON {
  34853. /**
  34854. * Helper class used to generate session unique ID
  34855. */
  34856. export class UniqueIdGenerator {
  34857. private static _UniqueIdCounter;
  34858. /**
  34859. * Gets an unique (relatively to the current scene) Id
  34860. */
  34861. static get UniqueId(): number;
  34862. }
  34863. }
  34864. declare module BABYLON {
  34865. /**
  34866. * This class defines the direct association between an animation and a target
  34867. */
  34868. export class TargetedAnimation {
  34869. /**
  34870. * Animation to perform
  34871. */
  34872. animation: Animation;
  34873. /**
  34874. * Target to animate
  34875. */
  34876. target: any;
  34877. /**
  34878. * Serialize the object
  34879. * @returns the JSON object representing the current entity
  34880. */
  34881. serialize(): any;
  34882. }
  34883. /**
  34884. * Use this class to create coordinated animations on multiple targets
  34885. */
  34886. export class AnimationGroup implements IDisposable {
  34887. /** The name of the animation group */
  34888. name: string;
  34889. private _scene;
  34890. private _targetedAnimations;
  34891. private _animatables;
  34892. private _from;
  34893. private _to;
  34894. private _isStarted;
  34895. private _isPaused;
  34896. private _speedRatio;
  34897. private _loopAnimation;
  34898. /**
  34899. * Gets or sets the unique id of the node
  34900. */
  34901. uniqueId: number;
  34902. /**
  34903. * This observable will notify when one animation have ended
  34904. */
  34905. onAnimationEndObservable: Observable<TargetedAnimation>;
  34906. /**
  34907. * Observer raised when one animation loops
  34908. */
  34909. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34910. /**
  34911. * Observer raised when all animations have looped
  34912. */
  34913. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34914. /**
  34915. * This observable will notify when all animations have ended.
  34916. */
  34917. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34918. /**
  34919. * This observable will notify when all animations have paused.
  34920. */
  34921. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34922. /**
  34923. * This observable will notify when all animations are playing.
  34924. */
  34925. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34926. /**
  34927. * Gets the first frame
  34928. */
  34929. get from(): number;
  34930. /**
  34931. * Gets the last frame
  34932. */
  34933. get to(): number;
  34934. /**
  34935. * Define if the animations are started
  34936. */
  34937. get isStarted(): boolean;
  34938. /**
  34939. * Gets a value indicating that the current group is playing
  34940. */
  34941. get isPlaying(): boolean;
  34942. /**
  34943. * Gets or sets the speed ratio to use for all animations
  34944. */
  34945. get speedRatio(): number;
  34946. /**
  34947. * Gets or sets the speed ratio to use for all animations
  34948. */
  34949. set speedRatio(value: number);
  34950. /**
  34951. * Gets or sets if all animations should loop or not
  34952. */
  34953. get loopAnimation(): boolean;
  34954. set loopAnimation(value: boolean);
  34955. /**
  34956. * Gets the targeted animations for this animation group
  34957. */
  34958. get targetedAnimations(): Array<TargetedAnimation>;
  34959. /**
  34960. * returning the list of animatables controlled by this animation group.
  34961. */
  34962. get animatables(): Array<Animatable>;
  34963. /**
  34964. * Instantiates a new Animation Group.
  34965. * This helps managing several animations at once.
  34966. * @see http://doc.babylonjs.com/how_to/group
  34967. * @param name Defines the name of the group
  34968. * @param scene Defines the scene the group belongs to
  34969. */
  34970. constructor(
  34971. /** The name of the animation group */
  34972. name: string, scene?: Nullable<Scene>);
  34973. /**
  34974. * Add an animation (with its target) in the group
  34975. * @param animation defines the animation we want to add
  34976. * @param target defines the target of the animation
  34977. * @returns the TargetedAnimation object
  34978. */
  34979. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34980. /**
  34981. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34982. * It can add constant keys at begin or end
  34983. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34984. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34985. * @returns the animation group
  34986. */
  34987. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34988. private _animationLoopCount;
  34989. private _animationLoopFlags;
  34990. private _processLoop;
  34991. /**
  34992. * Start all animations on given targets
  34993. * @param loop defines if animations must loop
  34994. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34995. * @param from defines the from key (optional)
  34996. * @param to defines the to key (optional)
  34997. * @returns the current animation group
  34998. */
  34999. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35000. /**
  35001. * Pause all animations
  35002. * @returns the animation group
  35003. */
  35004. pause(): AnimationGroup;
  35005. /**
  35006. * Play all animations to initial state
  35007. * This function will start() the animations if they were not started or will restart() them if they were paused
  35008. * @param loop defines if animations must loop
  35009. * @returns the animation group
  35010. */
  35011. play(loop?: boolean): AnimationGroup;
  35012. /**
  35013. * Reset all animations to initial state
  35014. * @returns the animation group
  35015. */
  35016. reset(): AnimationGroup;
  35017. /**
  35018. * Restart animations from key 0
  35019. * @returns the animation group
  35020. */
  35021. restart(): AnimationGroup;
  35022. /**
  35023. * Stop all animations
  35024. * @returns the animation group
  35025. */
  35026. stop(): AnimationGroup;
  35027. /**
  35028. * Set animation weight for all animatables
  35029. * @param weight defines the weight to use
  35030. * @return the animationGroup
  35031. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35032. */
  35033. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35034. /**
  35035. * Synchronize and normalize all animatables with a source animatable
  35036. * @param root defines the root animatable to synchronize with
  35037. * @return the animationGroup
  35038. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35039. */
  35040. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35041. /**
  35042. * Goes to a specific frame in this animation group
  35043. * @param frame the frame number to go to
  35044. * @return the animationGroup
  35045. */
  35046. goToFrame(frame: number): AnimationGroup;
  35047. /**
  35048. * Dispose all associated resources
  35049. */
  35050. dispose(): void;
  35051. private _checkAnimationGroupEnded;
  35052. /**
  35053. * Clone the current animation group and returns a copy
  35054. * @param newName defines the name of the new group
  35055. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35056. * @returns the new aniamtion group
  35057. */
  35058. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35059. /**
  35060. * Serializes the animationGroup to an object
  35061. * @returns Serialized object
  35062. */
  35063. serialize(): any;
  35064. /**
  35065. * Returns a new AnimationGroup object parsed from the source provided.
  35066. * @param parsedAnimationGroup defines the source
  35067. * @param scene defines the scene that will receive the animationGroup
  35068. * @returns a new AnimationGroup
  35069. */
  35070. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35071. /**
  35072. * Returns the string "AnimationGroup"
  35073. * @returns "AnimationGroup"
  35074. */
  35075. getClassName(): string;
  35076. /**
  35077. * Creates a detailled string about the object
  35078. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35079. * @returns a string representing the object
  35080. */
  35081. toString(fullDetails?: boolean): string;
  35082. }
  35083. }
  35084. declare module BABYLON {
  35085. /**
  35086. * Define an interface for all classes that will hold resources
  35087. */
  35088. export interface IDisposable {
  35089. /**
  35090. * Releases all held resources
  35091. */
  35092. dispose(): void;
  35093. }
  35094. /** Interface defining initialization parameters for Scene class */
  35095. export interface SceneOptions {
  35096. /**
  35097. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35098. * It will improve performance when the number of geometries becomes important.
  35099. */
  35100. useGeometryUniqueIdsMap?: boolean;
  35101. /**
  35102. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35103. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35104. */
  35105. useMaterialMeshMap?: boolean;
  35106. /**
  35107. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35108. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35109. */
  35110. useClonedMeshMap?: boolean;
  35111. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35112. virtual?: boolean;
  35113. }
  35114. /**
  35115. * Represents a scene to be rendered by the engine.
  35116. * @see http://doc.babylonjs.com/features/scene
  35117. */
  35118. export class Scene extends AbstractScene implements IAnimatable {
  35119. /** The fog is deactivated */
  35120. static readonly FOGMODE_NONE: number;
  35121. /** The fog density is following an exponential function */
  35122. static readonly FOGMODE_EXP: number;
  35123. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35124. static readonly FOGMODE_EXP2: number;
  35125. /** The fog density is following a linear function. */
  35126. static readonly FOGMODE_LINEAR: number;
  35127. /**
  35128. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35129. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35130. */
  35131. static MinDeltaTime: number;
  35132. /**
  35133. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35134. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35135. */
  35136. static MaxDeltaTime: number;
  35137. /**
  35138. * Factory used to create the default material.
  35139. * @param name The name of the material to create
  35140. * @param scene The scene to create the material for
  35141. * @returns The default material
  35142. */
  35143. static DefaultMaterialFactory(scene: Scene): Material;
  35144. /**
  35145. * Factory used to create the a collision coordinator.
  35146. * @returns The collision coordinator
  35147. */
  35148. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35149. /** @hidden */
  35150. _inputManager: InputManager;
  35151. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35152. cameraToUseForPointers: Nullable<Camera>;
  35153. /** @hidden */
  35154. readonly _isScene: boolean;
  35155. /** @hidden */
  35156. _blockEntityCollection: boolean;
  35157. /**
  35158. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35159. */
  35160. autoClear: boolean;
  35161. /**
  35162. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35163. */
  35164. autoClearDepthAndStencil: boolean;
  35165. /**
  35166. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35167. */
  35168. clearColor: Color4;
  35169. /**
  35170. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35171. */
  35172. ambientColor: Color3;
  35173. /**
  35174. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35175. * It should only be one of the following (if not the default embedded one):
  35176. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35177. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35178. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35179. * The material properties need to be setup according to the type of texture in use.
  35180. */
  35181. environmentBRDFTexture: BaseTexture;
  35182. /** @hidden */
  35183. protected _environmentTexture: Nullable<BaseTexture>;
  35184. /**
  35185. * Texture used in all pbr material as the reflection texture.
  35186. * As in the majority of the scene they are the same (exception for multi room and so on),
  35187. * this is easier to reference from here than from all the materials.
  35188. */
  35189. get environmentTexture(): Nullable<BaseTexture>;
  35190. /**
  35191. * Texture used in all pbr material as the reflection texture.
  35192. * As in the majority of the scene they are the same (exception for multi room and so on),
  35193. * this is easier to set here than in all the materials.
  35194. */
  35195. set environmentTexture(value: Nullable<BaseTexture>);
  35196. /** @hidden */
  35197. protected _environmentIntensity: number;
  35198. /**
  35199. * Intensity of the environment in all pbr material.
  35200. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35201. * As in the majority of the scene they are the same (exception for multi room and so on),
  35202. * this is easier to reference from here than from all the materials.
  35203. */
  35204. get environmentIntensity(): number;
  35205. /**
  35206. * Intensity of the environment in all pbr material.
  35207. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35208. * As in the majority of the scene they are the same (exception for multi room and so on),
  35209. * this is easier to set here than in all the materials.
  35210. */
  35211. set environmentIntensity(value: number);
  35212. /** @hidden */
  35213. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35214. /**
  35215. * Default image processing configuration used either in the rendering
  35216. * Forward main pass or through the imageProcessingPostProcess if present.
  35217. * As in the majority of the scene they are the same (exception for multi camera),
  35218. * this is easier to reference from here than from all the materials and post process.
  35219. *
  35220. * No setter as we it is a shared configuration, you can set the values instead.
  35221. */
  35222. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35223. private _forceWireframe;
  35224. /**
  35225. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35226. */
  35227. set forceWireframe(value: boolean);
  35228. get forceWireframe(): boolean;
  35229. private _skipFrustumClipping;
  35230. /**
  35231. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35232. */
  35233. set skipFrustumClipping(value: boolean);
  35234. get skipFrustumClipping(): boolean;
  35235. private _forcePointsCloud;
  35236. /**
  35237. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35238. */
  35239. set forcePointsCloud(value: boolean);
  35240. get forcePointsCloud(): boolean;
  35241. /**
  35242. * Gets or sets the active clipplane 1
  35243. */
  35244. clipPlane: Nullable<Plane>;
  35245. /**
  35246. * Gets or sets the active clipplane 2
  35247. */
  35248. clipPlane2: Nullable<Plane>;
  35249. /**
  35250. * Gets or sets the active clipplane 3
  35251. */
  35252. clipPlane3: Nullable<Plane>;
  35253. /**
  35254. * Gets or sets the active clipplane 4
  35255. */
  35256. clipPlane4: Nullable<Plane>;
  35257. /**
  35258. * Gets or sets the active clipplane 5
  35259. */
  35260. clipPlane5: Nullable<Plane>;
  35261. /**
  35262. * Gets or sets the active clipplane 6
  35263. */
  35264. clipPlane6: Nullable<Plane>;
  35265. /**
  35266. * Gets or sets a boolean indicating if animations are enabled
  35267. */
  35268. animationsEnabled: boolean;
  35269. private _animationPropertiesOverride;
  35270. /**
  35271. * Gets or sets the animation properties override
  35272. */
  35273. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35274. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35275. /**
  35276. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35277. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35278. */
  35279. useConstantAnimationDeltaTime: boolean;
  35280. /**
  35281. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35282. * Please note that it requires to run a ray cast through the scene on every frame
  35283. */
  35284. constantlyUpdateMeshUnderPointer: boolean;
  35285. /**
  35286. * Defines the HTML cursor to use when hovering over interactive elements
  35287. */
  35288. hoverCursor: string;
  35289. /**
  35290. * Defines the HTML default cursor to use (empty by default)
  35291. */
  35292. defaultCursor: string;
  35293. /**
  35294. * Defines whether cursors are handled by the scene.
  35295. */
  35296. doNotHandleCursors: boolean;
  35297. /**
  35298. * This is used to call preventDefault() on pointer down
  35299. * in order to block unwanted artifacts like system double clicks
  35300. */
  35301. preventDefaultOnPointerDown: boolean;
  35302. /**
  35303. * This is used to call preventDefault() on pointer up
  35304. * in order to block unwanted artifacts like system double clicks
  35305. */
  35306. preventDefaultOnPointerUp: boolean;
  35307. /**
  35308. * Gets or sets user defined metadata
  35309. */
  35310. metadata: any;
  35311. /**
  35312. * For internal use only. Please do not use.
  35313. */
  35314. reservedDataStore: any;
  35315. /**
  35316. * Gets the name of the plugin used to load this scene (null by default)
  35317. */
  35318. loadingPluginName: string;
  35319. /**
  35320. * Use this array to add regular expressions used to disable offline support for specific urls
  35321. */
  35322. disableOfflineSupportExceptionRules: RegExp[];
  35323. /**
  35324. * An event triggered when the scene is disposed.
  35325. */
  35326. onDisposeObservable: Observable<Scene>;
  35327. private _onDisposeObserver;
  35328. /** Sets a function to be executed when this scene is disposed. */
  35329. set onDispose(callback: () => void);
  35330. /**
  35331. * An event triggered before rendering the scene (right after animations and physics)
  35332. */
  35333. onBeforeRenderObservable: Observable<Scene>;
  35334. private _onBeforeRenderObserver;
  35335. /** Sets a function to be executed before rendering this scene */
  35336. set beforeRender(callback: Nullable<() => void>);
  35337. /**
  35338. * An event triggered after rendering the scene
  35339. */
  35340. onAfterRenderObservable: Observable<Scene>;
  35341. /**
  35342. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35343. */
  35344. onAfterRenderCameraObservable: Observable<Camera>;
  35345. private _onAfterRenderObserver;
  35346. /** Sets a function to be executed after rendering this scene */
  35347. set afterRender(callback: Nullable<() => void>);
  35348. /**
  35349. * An event triggered before animating the scene
  35350. */
  35351. onBeforeAnimationsObservable: Observable<Scene>;
  35352. /**
  35353. * An event triggered after animations processing
  35354. */
  35355. onAfterAnimationsObservable: Observable<Scene>;
  35356. /**
  35357. * An event triggered before draw calls are ready to be sent
  35358. */
  35359. onBeforeDrawPhaseObservable: Observable<Scene>;
  35360. /**
  35361. * An event triggered after draw calls have been sent
  35362. */
  35363. onAfterDrawPhaseObservable: Observable<Scene>;
  35364. /**
  35365. * An event triggered when the scene is ready
  35366. */
  35367. onReadyObservable: Observable<Scene>;
  35368. /**
  35369. * An event triggered before rendering a camera
  35370. */
  35371. onBeforeCameraRenderObservable: Observable<Camera>;
  35372. private _onBeforeCameraRenderObserver;
  35373. /** Sets a function to be executed before rendering a camera*/
  35374. set beforeCameraRender(callback: () => void);
  35375. /**
  35376. * An event triggered after rendering a camera
  35377. */
  35378. onAfterCameraRenderObservable: Observable<Camera>;
  35379. private _onAfterCameraRenderObserver;
  35380. /** Sets a function to be executed after rendering a camera*/
  35381. set afterCameraRender(callback: () => void);
  35382. /**
  35383. * An event triggered when active meshes evaluation is about to start
  35384. */
  35385. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35386. /**
  35387. * An event triggered when active meshes evaluation is done
  35388. */
  35389. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35390. /**
  35391. * An event triggered when particles rendering is about to start
  35392. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35393. */
  35394. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35395. /**
  35396. * An event triggered when particles rendering is done
  35397. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35398. */
  35399. onAfterParticlesRenderingObservable: Observable<Scene>;
  35400. /**
  35401. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35402. */
  35403. onDataLoadedObservable: Observable<Scene>;
  35404. /**
  35405. * An event triggered when a camera is created
  35406. */
  35407. onNewCameraAddedObservable: Observable<Camera>;
  35408. /**
  35409. * An event triggered when a camera is removed
  35410. */
  35411. onCameraRemovedObservable: Observable<Camera>;
  35412. /**
  35413. * An event triggered when a light is created
  35414. */
  35415. onNewLightAddedObservable: Observable<Light>;
  35416. /**
  35417. * An event triggered when a light is removed
  35418. */
  35419. onLightRemovedObservable: Observable<Light>;
  35420. /**
  35421. * An event triggered when a geometry is created
  35422. */
  35423. onNewGeometryAddedObservable: Observable<Geometry>;
  35424. /**
  35425. * An event triggered when a geometry is removed
  35426. */
  35427. onGeometryRemovedObservable: Observable<Geometry>;
  35428. /**
  35429. * An event triggered when a transform node is created
  35430. */
  35431. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35432. /**
  35433. * An event triggered when a transform node is removed
  35434. */
  35435. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35436. /**
  35437. * An event triggered when a mesh is created
  35438. */
  35439. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35440. /**
  35441. * An event triggered when a mesh is removed
  35442. */
  35443. onMeshRemovedObservable: Observable<AbstractMesh>;
  35444. /**
  35445. * An event triggered when a skeleton is created
  35446. */
  35447. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35448. /**
  35449. * An event triggered when a skeleton is removed
  35450. */
  35451. onSkeletonRemovedObservable: Observable<Skeleton>;
  35452. /**
  35453. * An event triggered when a material is created
  35454. */
  35455. onNewMaterialAddedObservable: Observable<Material>;
  35456. /**
  35457. * An event triggered when a material is removed
  35458. */
  35459. onMaterialRemovedObservable: Observable<Material>;
  35460. /**
  35461. * An event triggered when a texture is created
  35462. */
  35463. onNewTextureAddedObservable: Observable<BaseTexture>;
  35464. /**
  35465. * An event triggered when a texture is removed
  35466. */
  35467. onTextureRemovedObservable: Observable<BaseTexture>;
  35468. /**
  35469. * An event triggered when render targets are about to be rendered
  35470. * Can happen multiple times per frame.
  35471. */
  35472. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35473. /**
  35474. * An event triggered when render targets were rendered.
  35475. * Can happen multiple times per frame.
  35476. */
  35477. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35478. /**
  35479. * An event triggered before calculating deterministic simulation step
  35480. */
  35481. onBeforeStepObservable: Observable<Scene>;
  35482. /**
  35483. * An event triggered after calculating deterministic simulation step
  35484. */
  35485. onAfterStepObservable: Observable<Scene>;
  35486. /**
  35487. * An event triggered when the activeCamera property is updated
  35488. */
  35489. onActiveCameraChanged: Observable<Scene>;
  35490. /**
  35491. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35492. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35493. * 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)
  35494. */
  35495. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35496. /**
  35497. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35498. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35499. * 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)
  35500. */
  35501. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35502. /**
  35503. * This Observable will when a mesh has been imported into the scene.
  35504. */
  35505. onMeshImportedObservable: Observable<AbstractMesh>;
  35506. /**
  35507. * This Observable will when an animation file has been imported into the scene.
  35508. */
  35509. onAnimationFileImportedObservable: Observable<Scene>;
  35510. /**
  35511. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35512. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35513. */
  35514. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35515. /** @hidden */
  35516. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35517. /**
  35518. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35519. */
  35520. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35521. /**
  35522. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35523. */
  35524. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35525. /**
  35526. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35527. */
  35528. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35529. /** Callback called when a pointer move is detected */
  35530. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35531. /** Callback called when a pointer down is detected */
  35532. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35533. /** Callback called when a pointer up is detected */
  35534. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35535. /** Callback called when a pointer pick is detected */
  35536. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35537. /**
  35538. * 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).
  35539. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35540. */
  35541. onPrePointerObservable: Observable<PointerInfoPre>;
  35542. /**
  35543. * Observable event triggered each time an input event is received from the rendering canvas
  35544. */
  35545. onPointerObservable: Observable<PointerInfo>;
  35546. /**
  35547. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35548. */
  35549. get unTranslatedPointer(): Vector2;
  35550. /**
  35551. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35552. */
  35553. static get DragMovementThreshold(): number;
  35554. static set DragMovementThreshold(value: number);
  35555. /**
  35556. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35557. */
  35558. static get LongPressDelay(): number;
  35559. static set LongPressDelay(value: number);
  35560. /**
  35561. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35562. */
  35563. static get DoubleClickDelay(): number;
  35564. static set DoubleClickDelay(value: number);
  35565. /** If you need to check double click without raising a single click at first click, enable this flag */
  35566. static get ExclusiveDoubleClickMode(): boolean;
  35567. static set ExclusiveDoubleClickMode(value: boolean);
  35568. /** @hidden */
  35569. _mirroredCameraPosition: Nullable<Vector3>;
  35570. /**
  35571. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35572. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35573. */
  35574. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35575. /**
  35576. * Observable event triggered each time an keyboard event is received from the hosting window
  35577. */
  35578. onKeyboardObservable: Observable<KeyboardInfo>;
  35579. private _useRightHandedSystem;
  35580. /**
  35581. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35582. */
  35583. set useRightHandedSystem(value: boolean);
  35584. get useRightHandedSystem(): boolean;
  35585. private _timeAccumulator;
  35586. private _currentStepId;
  35587. private _currentInternalStep;
  35588. /**
  35589. * Sets the step Id used by deterministic lock step
  35590. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35591. * @param newStepId defines the step Id
  35592. */
  35593. setStepId(newStepId: number): void;
  35594. /**
  35595. * Gets the step Id used by deterministic lock step
  35596. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35597. * @returns the step Id
  35598. */
  35599. getStepId(): number;
  35600. /**
  35601. * Gets the internal step used by deterministic lock step
  35602. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35603. * @returns the internal step
  35604. */
  35605. getInternalStep(): number;
  35606. private _fogEnabled;
  35607. /**
  35608. * Gets or sets a boolean indicating if fog is enabled on this scene
  35609. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35610. * (Default is true)
  35611. */
  35612. set fogEnabled(value: boolean);
  35613. get fogEnabled(): boolean;
  35614. private _fogMode;
  35615. /**
  35616. * Gets or sets the fog mode to use
  35617. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35618. * | mode | value |
  35619. * | --- | --- |
  35620. * | FOGMODE_NONE | 0 |
  35621. * | FOGMODE_EXP | 1 |
  35622. * | FOGMODE_EXP2 | 2 |
  35623. * | FOGMODE_LINEAR | 3 |
  35624. */
  35625. set fogMode(value: number);
  35626. get fogMode(): number;
  35627. /**
  35628. * Gets or sets the fog color to use
  35629. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35630. * (Default is Color3(0.2, 0.2, 0.3))
  35631. */
  35632. fogColor: Color3;
  35633. /**
  35634. * Gets or sets the fog density to use
  35635. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35636. * (Default is 0.1)
  35637. */
  35638. fogDensity: number;
  35639. /**
  35640. * Gets or sets the fog start distance to use
  35641. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35642. * (Default is 0)
  35643. */
  35644. fogStart: number;
  35645. /**
  35646. * Gets or sets the fog end distance to use
  35647. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35648. * (Default is 1000)
  35649. */
  35650. fogEnd: number;
  35651. private _shadowsEnabled;
  35652. /**
  35653. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35654. */
  35655. set shadowsEnabled(value: boolean);
  35656. get shadowsEnabled(): boolean;
  35657. private _lightsEnabled;
  35658. /**
  35659. * Gets or sets a boolean indicating if lights are enabled on this scene
  35660. */
  35661. set lightsEnabled(value: boolean);
  35662. get lightsEnabled(): boolean;
  35663. /** All of the active cameras added to this scene. */
  35664. activeCameras: Camera[];
  35665. /** @hidden */
  35666. _activeCamera: Nullable<Camera>;
  35667. /** Gets or sets the current active camera */
  35668. get activeCamera(): Nullable<Camera>;
  35669. set activeCamera(value: Nullable<Camera>);
  35670. private _defaultMaterial;
  35671. /** The default material used on meshes when no material is affected */
  35672. get defaultMaterial(): Material;
  35673. /** The default material used on meshes when no material is affected */
  35674. set defaultMaterial(value: Material);
  35675. private _texturesEnabled;
  35676. /**
  35677. * Gets or sets a boolean indicating if textures are enabled on this scene
  35678. */
  35679. set texturesEnabled(value: boolean);
  35680. get texturesEnabled(): boolean;
  35681. /**
  35682. * Gets or sets a boolean indicating if particles are enabled on this scene
  35683. */
  35684. particlesEnabled: boolean;
  35685. /**
  35686. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35687. */
  35688. spritesEnabled: boolean;
  35689. private _skeletonsEnabled;
  35690. /**
  35691. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35692. */
  35693. set skeletonsEnabled(value: boolean);
  35694. get skeletonsEnabled(): boolean;
  35695. /**
  35696. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35697. */
  35698. lensFlaresEnabled: boolean;
  35699. /**
  35700. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35701. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35702. */
  35703. collisionsEnabled: boolean;
  35704. private _collisionCoordinator;
  35705. /** @hidden */
  35706. get collisionCoordinator(): ICollisionCoordinator;
  35707. /**
  35708. * Defines the gravity applied to this scene (used only for collisions)
  35709. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35710. */
  35711. gravity: Vector3;
  35712. /**
  35713. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35714. */
  35715. postProcessesEnabled: boolean;
  35716. /**
  35717. * The list of postprocesses added to the scene
  35718. */
  35719. postProcesses: PostProcess[];
  35720. /**
  35721. * Gets the current postprocess manager
  35722. */
  35723. postProcessManager: PostProcessManager;
  35724. /**
  35725. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35726. */
  35727. renderTargetsEnabled: boolean;
  35728. /**
  35729. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35730. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35731. */
  35732. dumpNextRenderTargets: boolean;
  35733. /**
  35734. * The list of user defined render targets added to the scene
  35735. */
  35736. customRenderTargets: RenderTargetTexture[];
  35737. /**
  35738. * Defines if texture loading must be delayed
  35739. * If true, textures will only be loaded when they need to be rendered
  35740. */
  35741. useDelayedTextureLoading: boolean;
  35742. /**
  35743. * Gets the list of meshes imported to the scene through SceneLoader
  35744. */
  35745. importedMeshesFiles: String[];
  35746. /**
  35747. * Gets or sets a boolean indicating if probes are enabled on this scene
  35748. */
  35749. probesEnabled: boolean;
  35750. /**
  35751. * Gets or sets the current offline provider to use to store scene data
  35752. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35753. */
  35754. offlineProvider: IOfflineProvider;
  35755. /**
  35756. * Gets or sets the action manager associated with the scene
  35757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35758. */
  35759. actionManager: AbstractActionManager;
  35760. private _meshesForIntersections;
  35761. /**
  35762. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35763. */
  35764. proceduralTexturesEnabled: boolean;
  35765. private _engine;
  35766. private _totalVertices;
  35767. /** @hidden */
  35768. _activeIndices: PerfCounter;
  35769. /** @hidden */
  35770. _activeParticles: PerfCounter;
  35771. /** @hidden */
  35772. _activeBones: PerfCounter;
  35773. private _animationRatio;
  35774. /** @hidden */
  35775. _animationTimeLast: number;
  35776. /** @hidden */
  35777. _animationTime: number;
  35778. /**
  35779. * Gets or sets a general scale for animation speed
  35780. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35781. */
  35782. animationTimeScale: number;
  35783. /** @hidden */
  35784. _cachedMaterial: Nullable<Material>;
  35785. /** @hidden */
  35786. _cachedEffect: Nullable<Effect>;
  35787. /** @hidden */
  35788. _cachedVisibility: Nullable<number>;
  35789. private _renderId;
  35790. private _frameId;
  35791. private _executeWhenReadyTimeoutId;
  35792. private _intermediateRendering;
  35793. private _viewUpdateFlag;
  35794. private _projectionUpdateFlag;
  35795. /** @hidden */
  35796. _toBeDisposed: Nullable<IDisposable>[];
  35797. private _activeRequests;
  35798. /** @hidden */
  35799. _pendingData: any[];
  35800. private _isDisposed;
  35801. /**
  35802. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35803. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35804. */
  35805. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35806. private _activeMeshes;
  35807. private _processedMaterials;
  35808. private _renderTargets;
  35809. /** @hidden */
  35810. _activeParticleSystems: SmartArray<IParticleSystem>;
  35811. private _activeSkeletons;
  35812. private _softwareSkinnedMeshes;
  35813. private _renderingManager;
  35814. /** @hidden */
  35815. _activeAnimatables: Animatable[];
  35816. private _transformMatrix;
  35817. private _sceneUbo;
  35818. /** @hidden */
  35819. _viewMatrix: Matrix;
  35820. private _projectionMatrix;
  35821. /** @hidden */
  35822. _forcedViewPosition: Nullable<Vector3>;
  35823. /** @hidden */
  35824. _frustumPlanes: Plane[];
  35825. /**
  35826. * Gets the list of frustum planes (built from the active camera)
  35827. */
  35828. get frustumPlanes(): Plane[];
  35829. /**
  35830. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35831. * This is useful if there are more lights that the maximum simulteanous authorized
  35832. */
  35833. requireLightSorting: boolean;
  35834. /** @hidden */
  35835. readonly useMaterialMeshMap: boolean;
  35836. /** @hidden */
  35837. readonly useClonedMeshMap: boolean;
  35838. private _externalData;
  35839. private _uid;
  35840. /**
  35841. * @hidden
  35842. * Backing store of defined scene components.
  35843. */
  35844. _components: ISceneComponent[];
  35845. /**
  35846. * @hidden
  35847. * Backing store of defined scene components.
  35848. */
  35849. _serializableComponents: ISceneSerializableComponent[];
  35850. /**
  35851. * List of components to register on the next registration step.
  35852. */
  35853. private _transientComponents;
  35854. /**
  35855. * Registers the transient components if needed.
  35856. */
  35857. private _registerTransientComponents;
  35858. /**
  35859. * @hidden
  35860. * Add a component to the scene.
  35861. * Note that the ccomponent could be registered on th next frame if this is called after
  35862. * the register component stage.
  35863. * @param component Defines the component to add to the scene
  35864. */
  35865. _addComponent(component: ISceneComponent): void;
  35866. /**
  35867. * @hidden
  35868. * Gets a component from the scene.
  35869. * @param name defines the name of the component to retrieve
  35870. * @returns the component or null if not present
  35871. */
  35872. _getComponent(name: string): Nullable<ISceneComponent>;
  35873. /**
  35874. * @hidden
  35875. * Defines the actions happening before camera updates.
  35876. */
  35877. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35878. /**
  35879. * @hidden
  35880. * Defines the actions happening before clear the canvas.
  35881. */
  35882. _beforeClearStage: Stage<SimpleStageAction>;
  35883. /**
  35884. * @hidden
  35885. * Defines the actions when collecting render targets for the frame.
  35886. */
  35887. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35888. /**
  35889. * @hidden
  35890. * Defines the actions happening for one camera in the frame.
  35891. */
  35892. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35893. /**
  35894. * @hidden
  35895. * Defines the actions happening during the per mesh ready checks.
  35896. */
  35897. _isReadyForMeshStage: Stage<MeshStageAction>;
  35898. /**
  35899. * @hidden
  35900. * Defines the actions happening before evaluate active mesh checks.
  35901. */
  35902. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35903. /**
  35904. * @hidden
  35905. * Defines the actions happening during the evaluate sub mesh checks.
  35906. */
  35907. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35908. /**
  35909. * @hidden
  35910. * Defines the actions happening during the active mesh stage.
  35911. */
  35912. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35913. /**
  35914. * @hidden
  35915. * Defines the actions happening during the per camera render target step.
  35916. */
  35917. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35918. /**
  35919. * @hidden
  35920. * Defines the actions happening just before the active camera is drawing.
  35921. */
  35922. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35923. /**
  35924. * @hidden
  35925. * Defines the actions happening just before a render target is drawing.
  35926. */
  35927. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35928. /**
  35929. * @hidden
  35930. * Defines the actions happening just before a rendering group is drawing.
  35931. */
  35932. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35933. /**
  35934. * @hidden
  35935. * Defines the actions happening just before a mesh is drawing.
  35936. */
  35937. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35938. /**
  35939. * @hidden
  35940. * Defines the actions happening just after a mesh has been drawn.
  35941. */
  35942. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35943. /**
  35944. * @hidden
  35945. * Defines the actions happening just after a rendering group has been drawn.
  35946. */
  35947. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35948. /**
  35949. * @hidden
  35950. * Defines the actions happening just after the active camera has been drawn.
  35951. */
  35952. _afterCameraDrawStage: Stage<CameraStageAction>;
  35953. /**
  35954. * @hidden
  35955. * Defines the actions happening just after a render target has been drawn.
  35956. */
  35957. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35958. /**
  35959. * @hidden
  35960. * Defines the actions happening just after rendering all cameras and computing intersections.
  35961. */
  35962. _afterRenderStage: Stage<SimpleStageAction>;
  35963. /**
  35964. * @hidden
  35965. * Defines the actions happening when a pointer move event happens.
  35966. */
  35967. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35968. /**
  35969. * @hidden
  35970. * Defines the actions happening when a pointer down event happens.
  35971. */
  35972. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35973. /**
  35974. * @hidden
  35975. * Defines the actions happening when a pointer up event happens.
  35976. */
  35977. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35978. /**
  35979. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35980. */
  35981. private geometriesByUniqueId;
  35982. /**
  35983. * Creates a new Scene
  35984. * @param engine defines the engine to use to render this scene
  35985. * @param options defines the scene options
  35986. */
  35987. constructor(engine: Engine, options?: SceneOptions);
  35988. /**
  35989. * Gets a string idenfifying the name of the class
  35990. * @returns "Scene" string
  35991. */
  35992. getClassName(): string;
  35993. private _defaultMeshCandidates;
  35994. /**
  35995. * @hidden
  35996. */
  35997. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35998. private _defaultSubMeshCandidates;
  35999. /**
  36000. * @hidden
  36001. */
  36002. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36003. /**
  36004. * Sets the default candidate providers for the scene.
  36005. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36006. * and getCollidingSubMeshCandidates to their default function
  36007. */
  36008. setDefaultCandidateProviders(): void;
  36009. /**
  36010. * Gets the mesh that is currently under the pointer
  36011. */
  36012. get meshUnderPointer(): Nullable<AbstractMesh>;
  36013. /**
  36014. * Gets or sets the current on-screen X position of the pointer
  36015. */
  36016. get pointerX(): number;
  36017. set pointerX(value: number);
  36018. /**
  36019. * Gets or sets the current on-screen Y position of the pointer
  36020. */
  36021. get pointerY(): number;
  36022. set pointerY(value: number);
  36023. /**
  36024. * Gets the cached material (ie. the latest rendered one)
  36025. * @returns the cached material
  36026. */
  36027. getCachedMaterial(): Nullable<Material>;
  36028. /**
  36029. * Gets the cached effect (ie. the latest rendered one)
  36030. * @returns the cached effect
  36031. */
  36032. getCachedEffect(): Nullable<Effect>;
  36033. /**
  36034. * Gets the cached visibility state (ie. the latest rendered one)
  36035. * @returns the cached visibility state
  36036. */
  36037. getCachedVisibility(): Nullable<number>;
  36038. /**
  36039. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36040. * @param material defines the current material
  36041. * @param effect defines the current effect
  36042. * @param visibility defines the current visibility state
  36043. * @returns true if one parameter is not cached
  36044. */
  36045. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36046. /**
  36047. * Gets the engine associated with the scene
  36048. * @returns an Engine
  36049. */
  36050. getEngine(): Engine;
  36051. /**
  36052. * Gets the total number of vertices rendered per frame
  36053. * @returns the total number of vertices rendered per frame
  36054. */
  36055. getTotalVertices(): number;
  36056. /**
  36057. * Gets the performance counter for total vertices
  36058. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36059. */
  36060. get totalVerticesPerfCounter(): PerfCounter;
  36061. /**
  36062. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36063. * @returns the total number of active indices rendered per frame
  36064. */
  36065. getActiveIndices(): number;
  36066. /**
  36067. * Gets the performance counter for active indices
  36068. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36069. */
  36070. get totalActiveIndicesPerfCounter(): PerfCounter;
  36071. /**
  36072. * Gets the total number of active particles rendered per frame
  36073. * @returns the total number of active particles rendered per frame
  36074. */
  36075. getActiveParticles(): number;
  36076. /**
  36077. * Gets the performance counter for active particles
  36078. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36079. */
  36080. get activeParticlesPerfCounter(): PerfCounter;
  36081. /**
  36082. * Gets the total number of active bones rendered per frame
  36083. * @returns the total number of active bones rendered per frame
  36084. */
  36085. getActiveBones(): number;
  36086. /**
  36087. * Gets the performance counter for active bones
  36088. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36089. */
  36090. get activeBonesPerfCounter(): PerfCounter;
  36091. /**
  36092. * Gets the array of active meshes
  36093. * @returns an array of AbstractMesh
  36094. */
  36095. getActiveMeshes(): SmartArray<AbstractMesh>;
  36096. /**
  36097. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36098. * @returns a number
  36099. */
  36100. getAnimationRatio(): number;
  36101. /**
  36102. * Gets an unique Id for the current render phase
  36103. * @returns a number
  36104. */
  36105. getRenderId(): number;
  36106. /**
  36107. * Gets an unique Id for the current frame
  36108. * @returns a number
  36109. */
  36110. getFrameId(): number;
  36111. /** Call this function if you want to manually increment the render Id*/
  36112. incrementRenderId(): void;
  36113. private _createUbo;
  36114. /**
  36115. * Use this method to simulate a pointer move on a mesh
  36116. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36117. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36118. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36119. * @returns the current scene
  36120. */
  36121. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36122. /**
  36123. * Use this method to simulate a pointer down on a mesh
  36124. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36125. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36126. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36127. * @returns the current scene
  36128. */
  36129. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36130. /**
  36131. * Use this method to simulate a pointer up on a mesh
  36132. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36133. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36134. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36135. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36136. * @returns the current scene
  36137. */
  36138. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36139. /**
  36140. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36141. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36142. * @returns true if the pointer was captured
  36143. */
  36144. isPointerCaptured(pointerId?: number): boolean;
  36145. /**
  36146. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36147. * @param attachUp defines if you want to attach events to pointerup
  36148. * @param attachDown defines if you want to attach events to pointerdown
  36149. * @param attachMove defines if you want to attach events to pointermove
  36150. */
  36151. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36152. /** Detaches all event handlers*/
  36153. detachControl(): void;
  36154. /**
  36155. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36156. * Delay loaded resources are not taking in account
  36157. * @return true if all required resources are ready
  36158. */
  36159. isReady(): boolean;
  36160. /** Resets all cached information relative to material (including effect and visibility) */
  36161. resetCachedMaterial(): void;
  36162. /**
  36163. * Registers a function to be called before every frame render
  36164. * @param func defines the function to register
  36165. */
  36166. registerBeforeRender(func: () => void): void;
  36167. /**
  36168. * Unregisters a function called before every frame render
  36169. * @param func defines the function to unregister
  36170. */
  36171. unregisterBeforeRender(func: () => void): void;
  36172. /**
  36173. * Registers a function to be called after every frame render
  36174. * @param func defines the function to register
  36175. */
  36176. registerAfterRender(func: () => void): void;
  36177. /**
  36178. * Unregisters a function called after every frame render
  36179. * @param func defines the function to unregister
  36180. */
  36181. unregisterAfterRender(func: () => void): void;
  36182. private _executeOnceBeforeRender;
  36183. /**
  36184. * The provided function will run before render once and will be disposed afterwards.
  36185. * A timeout delay can be provided so that the function will be executed in N ms.
  36186. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36187. * @param func The function to be executed.
  36188. * @param timeout optional delay in ms
  36189. */
  36190. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36191. /** @hidden */
  36192. _addPendingData(data: any): void;
  36193. /** @hidden */
  36194. _removePendingData(data: any): void;
  36195. /**
  36196. * Returns the number of items waiting to be loaded
  36197. * @returns the number of items waiting to be loaded
  36198. */
  36199. getWaitingItemsCount(): number;
  36200. /**
  36201. * Returns a boolean indicating if the scene is still loading data
  36202. */
  36203. get isLoading(): boolean;
  36204. /**
  36205. * Registers a function to be executed when the scene is ready
  36206. * @param {Function} func - the function to be executed
  36207. */
  36208. executeWhenReady(func: () => void): void;
  36209. /**
  36210. * Returns a promise that resolves when the scene is ready
  36211. * @returns A promise that resolves when the scene is ready
  36212. */
  36213. whenReadyAsync(): Promise<void>;
  36214. /** @hidden */
  36215. _checkIsReady(): void;
  36216. /**
  36217. * Gets all animatable attached to the scene
  36218. */
  36219. get animatables(): Animatable[];
  36220. /**
  36221. * Resets the last animation time frame.
  36222. * Useful to override when animations start running when loading a scene for the first time.
  36223. */
  36224. resetLastAnimationTimeFrame(): void;
  36225. /**
  36226. * Gets the current view matrix
  36227. * @returns a Matrix
  36228. */
  36229. getViewMatrix(): Matrix;
  36230. /**
  36231. * Gets the current projection matrix
  36232. * @returns a Matrix
  36233. */
  36234. getProjectionMatrix(): Matrix;
  36235. /**
  36236. * Gets the current transform matrix
  36237. * @returns a Matrix made of View * Projection
  36238. */
  36239. getTransformMatrix(): Matrix;
  36240. /**
  36241. * Sets the current transform matrix
  36242. * @param viewL defines the View matrix to use
  36243. * @param projectionL defines the Projection matrix to use
  36244. * @param viewR defines the right View matrix to use (if provided)
  36245. * @param projectionR defines the right Projection matrix to use (if provided)
  36246. */
  36247. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36248. /**
  36249. * Gets the uniform buffer used to store scene data
  36250. * @returns a UniformBuffer
  36251. */
  36252. getSceneUniformBuffer(): UniformBuffer;
  36253. /**
  36254. * Gets an unique (relatively to the current scene) Id
  36255. * @returns an unique number for the scene
  36256. */
  36257. getUniqueId(): number;
  36258. /**
  36259. * Add a mesh to the list of scene's meshes
  36260. * @param newMesh defines the mesh to add
  36261. * @param recursive if all child meshes should also be added to the scene
  36262. */
  36263. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36264. /**
  36265. * Remove a mesh for the list of scene's meshes
  36266. * @param toRemove defines the mesh to remove
  36267. * @param recursive if all child meshes should also be removed from the scene
  36268. * @returns the index where the mesh was in the mesh list
  36269. */
  36270. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36271. /**
  36272. * Add a transform node to the list of scene's transform nodes
  36273. * @param newTransformNode defines the transform node to add
  36274. */
  36275. addTransformNode(newTransformNode: TransformNode): void;
  36276. /**
  36277. * Remove a transform node for the list of scene's transform nodes
  36278. * @param toRemove defines the transform node to remove
  36279. * @returns the index where the transform node was in the transform node list
  36280. */
  36281. removeTransformNode(toRemove: TransformNode): number;
  36282. /**
  36283. * Remove a skeleton for the list of scene's skeletons
  36284. * @param toRemove defines the skeleton to remove
  36285. * @returns the index where the skeleton was in the skeleton list
  36286. */
  36287. removeSkeleton(toRemove: Skeleton): number;
  36288. /**
  36289. * Remove a morph target for the list of scene's morph targets
  36290. * @param toRemove defines the morph target to remove
  36291. * @returns the index where the morph target was in the morph target list
  36292. */
  36293. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36294. /**
  36295. * Remove a light for the list of scene's lights
  36296. * @param toRemove defines the light to remove
  36297. * @returns the index where the light was in the light list
  36298. */
  36299. removeLight(toRemove: Light): number;
  36300. /**
  36301. * Remove a camera for the list of scene's cameras
  36302. * @param toRemove defines the camera to remove
  36303. * @returns the index where the camera was in the camera list
  36304. */
  36305. removeCamera(toRemove: Camera): number;
  36306. /**
  36307. * Remove a particle system for the list of scene's particle systems
  36308. * @param toRemove defines the particle system to remove
  36309. * @returns the index where the particle system was in the particle system list
  36310. */
  36311. removeParticleSystem(toRemove: IParticleSystem): number;
  36312. /**
  36313. * Remove a animation for the list of scene's animations
  36314. * @param toRemove defines the animation to remove
  36315. * @returns the index where the animation was in the animation list
  36316. */
  36317. removeAnimation(toRemove: Animation): number;
  36318. /**
  36319. * Will stop the animation of the given target
  36320. * @param target - the target
  36321. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36322. * @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)
  36323. */
  36324. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36325. /**
  36326. * Removes the given animation group from this scene.
  36327. * @param toRemove The animation group to remove
  36328. * @returns The index of the removed animation group
  36329. */
  36330. removeAnimationGroup(toRemove: AnimationGroup): number;
  36331. /**
  36332. * Removes the given multi-material from this scene.
  36333. * @param toRemove The multi-material to remove
  36334. * @returns The index of the removed multi-material
  36335. */
  36336. removeMultiMaterial(toRemove: MultiMaterial): number;
  36337. /**
  36338. * Removes the given material from this scene.
  36339. * @param toRemove The material to remove
  36340. * @returns The index of the removed material
  36341. */
  36342. removeMaterial(toRemove: Material): number;
  36343. /**
  36344. * Removes the given action manager from this scene.
  36345. * @param toRemove The action manager to remove
  36346. * @returns The index of the removed action manager
  36347. */
  36348. removeActionManager(toRemove: AbstractActionManager): number;
  36349. /**
  36350. * Removes the given texture from this scene.
  36351. * @param toRemove The texture to remove
  36352. * @returns The index of the removed texture
  36353. */
  36354. removeTexture(toRemove: BaseTexture): number;
  36355. /**
  36356. * Adds the given light to this scene
  36357. * @param newLight The light to add
  36358. */
  36359. addLight(newLight: Light): void;
  36360. /**
  36361. * Sorts the list list based on light priorities
  36362. */
  36363. sortLightsByPriority(): void;
  36364. /**
  36365. * Adds the given camera to this scene
  36366. * @param newCamera The camera to add
  36367. */
  36368. addCamera(newCamera: Camera): void;
  36369. /**
  36370. * Adds the given skeleton to this scene
  36371. * @param newSkeleton The skeleton to add
  36372. */
  36373. addSkeleton(newSkeleton: Skeleton): void;
  36374. /**
  36375. * Adds the given particle system to this scene
  36376. * @param newParticleSystem The particle system to add
  36377. */
  36378. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36379. /**
  36380. * Adds the given animation to this scene
  36381. * @param newAnimation The animation to add
  36382. */
  36383. addAnimation(newAnimation: Animation): void;
  36384. /**
  36385. * Adds the given animation group to this scene.
  36386. * @param newAnimationGroup The animation group to add
  36387. */
  36388. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36389. /**
  36390. * Adds the given multi-material to this scene
  36391. * @param newMultiMaterial The multi-material to add
  36392. */
  36393. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36394. /**
  36395. * Adds the given material to this scene
  36396. * @param newMaterial The material to add
  36397. */
  36398. addMaterial(newMaterial: Material): void;
  36399. /**
  36400. * Adds the given morph target to this scene
  36401. * @param newMorphTargetManager The morph target to add
  36402. */
  36403. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36404. /**
  36405. * Adds the given geometry to this scene
  36406. * @param newGeometry The geometry to add
  36407. */
  36408. addGeometry(newGeometry: Geometry): void;
  36409. /**
  36410. * Adds the given action manager to this scene
  36411. * @param newActionManager The action manager to add
  36412. */
  36413. addActionManager(newActionManager: AbstractActionManager): void;
  36414. /**
  36415. * Adds the given texture to this scene.
  36416. * @param newTexture The texture to add
  36417. */
  36418. addTexture(newTexture: BaseTexture): void;
  36419. /**
  36420. * Switch active camera
  36421. * @param newCamera defines the new active camera
  36422. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36423. */
  36424. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36425. /**
  36426. * sets the active camera of the scene using its ID
  36427. * @param id defines the camera's ID
  36428. * @return the new active camera or null if none found.
  36429. */
  36430. setActiveCameraByID(id: string): Nullable<Camera>;
  36431. /**
  36432. * sets the active camera of the scene using its name
  36433. * @param name defines the camera's name
  36434. * @returns the new active camera or null if none found.
  36435. */
  36436. setActiveCameraByName(name: string): Nullable<Camera>;
  36437. /**
  36438. * get an animation group using its name
  36439. * @param name defines the material's name
  36440. * @return the animation group or null if none found.
  36441. */
  36442. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36443. /**
  36444. * Get a material using its unique id
  36445. * @param uniqueId defines the material's unique id
  36446. * @return the material or null if none found.
  36447. */
  36448. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36449. /**
  36450. * get a material using its id
  36451. * @param id defines the material's ID
  36452. * @return the material or null if none found.
  36453. */
  36454. getMaterialByID(id: string): Nullable<Material>;
  36455. /**
  36456. * Gets a the last added material using a given id
  36457. * @param id defines the material's ID
  36458. * @return the last material with the given id or null if none found.
  36459. */
  36460. getLastMaterialByID(id: string): Nullable<Material>;
  36461. /**
  36462. * Gets a material using its name
  36463. * @param name defines the material's name
  36464. * @return the material or null if none found.
  36465. */
  36466. getMaterialByName(name: string): Nullable<Material>;
  36467. /**
  36468. * Get a texture using its unique id
  36469. * @param uniqueId defines the texture's unique id
  36470. * @return the texture or null if none found.
  36471. */
  36472. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36473. /**
  36474. * Gets a camera using its id
  36475. * @param id defines the id to look for
  36476. * @returns the camera or null if not found
  36477. */
  36478. getCameraByID(id: string): Nullable<Camera>;
  36479. /**
  36480. * Gets a camera using its unique id
  36481. * @param uniqueId defines the unique id to look for
  36482. * @returns the camera or null if not found
  36483. */
  36484. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36485. /**
  36486. * Gets a camera using its name
  36487. * @param name defines the camera's name
  36488. * @return the camera or null if none found.
  36489. */
  36490. getCameraByName(name: string): Nullable<Camera>;
  36491. /**
  36492. * Gets a bone using its id
  36493. * @param id defines the bone's id
  36494. * @return the bone or null if not found
  36495. */
  36496. getBoneByID(id: string): Nullable<Bone>;
  36497. /**
  36498. * Gets a bone using its id
  36499. * @param name defines the bone's name
  36500. * @return the bone or null if not found
  36501. */
  36502. getBoneByName(name: string): Nullable<Bone>;
  36503. /**
  36504. * Gets a light node using its name
  36505. * @param name defines the the light's name
  36506. * @return the light or null if none found.
  36507. */
  36508. getLightByName(name: string): Nullable<Light>;
  36509. /**
  36510. * Gets a light node using its id
  36511. * @param id defines the light's id
  36512. * @return the light or null if none found.
  36513. */
  36514. getLightByID(id: string): Nullable<Light>;
  36515. /**
  36516. * Gets a light node using its scene-generated unique ID
  36517. * @param uniqueId defines the light's unique id
  36518. * @return the light or null if none found.
  36519. */
  36520. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36521. /**
  36522. * Gets a particle system by id
  36523. * @param id defines the particle system id
  36524. * @return the corresponding system or null if none found
  36525. */
  36526. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36527. /**
  36528. * Gets a geometry using its ID
  36529. * @param id defines the geometry's id
  36530. * @return the geometry or null if none found.
  36531. */
  36532. getGeometryByID(id: string): Nullable<Geometry>;
  36533. private _getGeometryByUniqueID;
  36534. /**
  36535. * Add a new geometry to this scene
  36536. * @param geometry defines the geometry to be added to the scene.
  36537. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36538. * @return a boolean defining if the geometry was added or not
  36539. */
  36540. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36541. /**
  36542. * Removes an existing geometry
  36543. * @param geometry defines the geometry to be removed from the scene
  36544. * @return a boolean defining if the geometry was removed or not
  36545. */
  36546. removeGeometry(geometry: Geometry): boolean;
  36547. /**
  36548. * Gets the list of geometries attached to the scene
  36549. * @returns an array of Geometry
  36550. */
  36551. getGeometries(): Geometry[];
  36552. /**
  36553. * Gets the first added mesh found of a given ID
  36554. * @param id defines the id to search for
  36555. * @return the mesh found or null if not found at all
  36556. */
  36557. getMeshByID(id: string): Nullable<AbstractMesh>;
  36558. /**
  36559. * Gets a list of meshes using their id
  36560. * @param id defines the id to search for
  36561. * @returns a list of meshes
  36562. */
  36563. getMeshesByID(id: string): Array<AbstractMesh>;
  36564. /**
  36565. * Gets the first added transform node found of a given ID
  36566. * @param id defines the id to search for
  36567. * @return the found transform node or null if not found at all.
  36568. */
  36569. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36570. /**
  36571. * Gets a transform node with its auto-generated unique id
  36572. * @param uniqueId efines the unique id to search for
  36573. * @return the found transform node or null if not found at all.
  36574. */
  36575. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36576. /**
  36577. * Gets a list of transform nodes using their id
  36578. * @param id defines the id to search for
  36579. * @returns a list of transform nodes
  36580. */
  36581. getTransformNodesByID(id: string): Array<TransformNode>;
  36582. /**
  36583. * Gets a mesh with its auto-generated unique id
  36584. * @param uniqueId defines the unique id to search for
  36585. * @return the found mesh or null if not found at all.
  36586. */
  36587. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36588. /**
  36589. * Gets a the last added mesh using a given id
  36590. * @param id defines the id to search for
  36591. * @return the found mesh or null if not found at all.
  36592. */
  36593. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36594. /**
  36595. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36596. * @param id defines the id to search for
  36597. * @return the found node or null if not found at all
  36598. */
  36599. getLastEntryByID(id: string): Nullable<Node>;
  36600. /**
  36601. * Gets a node (Mesh, Camera, Light) using a given id
  36602. * @param id defines the id to search for
  36603. * @return the found node or null if not found at all
  36604. */
  36605. getNodeByID(id: string): Nullable<Node>;
  36606. /**
  36607. * Gets a node (Mesh, Camera, Light) using a given name
  36608. * @param name defines the name to search for
  36609. * @return the found node or null if not found at all.
  36610. */
  36611. getNodeByName(name: string): Nullable<Node>;
  36612. /**
  36613. * Gets a mesh using a given name
  36614. * @param name defines the name to search for
  36615. * @return the found mesh or null if not found at all.
  36616. */
  36617. getMeshByName(name: string): Nullable<AbstractMesh>;
  36618. /**
  36619. * Gets a transform node using a given name
  36620. * @param name defines the name to search for
  36621. * @return the found transform node or null if not found at all.
  36622. */
  36623. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36624. /**
  36625. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36626. * @param id defines the id to search for
  36627. * @return the found skeleton or null if not found at all.
  36628. */
  36629. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36630. /**
  36631. * Gets a skeleton using a given auto generated unique id
  36632. * @param uniqueId defines the unique id to search for
  36633. * @return the found skeleton or null if not found at all.
  36634. */
  36635. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36636. /**
  36637. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36638. * @param id defines the id to search for
  36639. * @return the found skeleton or null if not found at all.
  36640. */
  36641. getSkeletonById(id: string): Nullable<Skeleton>;
  36642. /**
  36643. * Gets a skeleton using a given name
  36644. * @param name defines the name to search for
  36645. * @return the found skeleton or null if not found at all.
  36646. */
  36647. getSkeletonByName(name: string): Nullable<Skeleton>;
  36648. /**
  36649. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36650. * @param id defines the id to search for
  36651. * @return the found morph target manager or null if not found at all.
  36652. */
  36653. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36654. /**
  36655. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36656. * @param id defines the id to search for
  36657. * @return the found morph target or null if not found at all.
  36658. */
  36659. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36660. /**
  36661. * Gets a boolean indicating if the given mesh is active
  36662. * @param mesh defines the mesh to look for
  36663. * @returns true if the mesh is in the active list
  36664. */
  36665. isActiveMesh(mesh: AbstractMesh): boolean;
  36666. /**
  36667. * Return a unique id as a string which can serve as an identifier for the scene
  36668. */
  36669. get uid(): string;
  36670. /**
  36671. * Add an externaly attached data from its key.
  36672. * This method call will fail and return false, if such key already exists.
  36673. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36674. * @param key the unique key that identifies the data
  36675. * @param data the data object to associate to the key for this Engine instance
  36676. * @return true if no such key were already present and the data was added successfully, false otherwise
  36677. */
  36678. addExternalData<T>(key: string, data: T): boolean;
  36679. /**
  36680. * Get an externaly attached data from its key
  36681. * @param key the unique key that identifies the data
  36682. * @return the associated data, if present (can be null), or undefined if not present
  36683. */
  36684. getExternalData<T>(key: string): Nullable<T>;
  36685. /**
  36686. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36687. * @param key the unique key that identifies the data
  36688. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36689. * @return the associated data, can be null if the factory returned null.
  36690. */
  36691. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36692. /**
  36693. * Remove an externaly attached data from the Engine instance
  36694. * @param key the unique key that identifies the data
  36695. * @return true if the data was successfully removed, false if it doesn't exist
  36696. */
  36697. removeExternalData(key: string): boolean;
  36698. private _evaluateSubMesh;
  36699. /**
  36700. * Clear the processed materials smart array preventing retention point in material dispose.
  36701. */
  36702. freeProcessedMaterials(): void;
  36703. private _preventFreeActiveMeshesAndRenderingGroups;
  36704. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36705. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36706. * when disposing several meshes in a row or a hierarchy of meshes.
  36707. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36708. */
  36709. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36710. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36711. /**
  36712. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36713. */
  36714. freeActiveMeshes(): void;
  36715. /**
  36716. * Clear the info related to rendering groups preventing retention points during dispose.
  36717. */
  36718. freeRenderingGroups(): void;
  36719. /** @hidden */
  36720. _isInIntermediateRendering(): boolean;
  36721. /**
  36722. * Lambda returning the list of potentially active meshes.
  36723. */
  36724. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36725. /**
  36726. * Lambda returning the list of potentially active sub meshes.
  36727. */
  36728. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36729. /**
  36730. * Lambda returning the list of potentially intersecting sub meshes.
  36731. */
  36732. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36733. /**
  36734. * Lambda returning the list of potentially colliding sub meshes.
  36735. */
  36736. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36737. private _activeMeshesFrozen;
  36738. private _skipEvaluateActiveMeshesCompletely;
  36739. /**
  36740. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36741. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36742. * @returns the current scene
  36743. */
  36744. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36745. /**
  36746. * Use this function to restart evaluating active meshes on every frame
  36747. * @returns the current scene
  36748. */
  36749. unfreezeActiveMeshes(): Scene;
  36750. private _evaluateActiveMeshes;
  36751. private _activeMesh;
  36752. /**
  36753. * Update the transform matrix to update from the current active camera
  36754. * @param force defines a boolean used to force the update even if cache is up to date
  36755. */
  36756. updateTransformMatrix(force?: boolean): void;
  36757. private _bindFrameBuffer;
  36758. /** @hidden */
  36759. _allowPostProcessClearColor: boolean;
  36760. /** @hidden */
  36761. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36762. private _processSubCameras;
  36763. private _checkIntersections;
  36764. /** @hidden */
  36765. _advancePhysicsEngineStep(step: number): void;
  36766. /**
  36767. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36768. */
  36769. getDeterministicFrameTime: () => number;
  36770. /** @hidden */
  36771. _animate(): void;
  36772. /** Execute all animations (for a frame) */
  36773. animate(): void;
  36774. /**
  36775. * Render the scene
  36776. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36777. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36778. */
  36779. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36780. /**
  36781. * Freeze all materials
  36782. * A frozen material will not be updatable but should be faster to render
  36783. */
  36784. freezeMaterials(): void;
  36785. /**
  36786. * Unfreeze all materials
  36787. * A frozen material will not be updatable but should be faster to render
  36788. */
  36789. unfreezeMaterials(): void;
  36790. /**
  36791. * Releases all held ressources
  36792. */
  36793. dispose(): void;
  36794. /**
  36795. * Gets if the scene is already disposed
  36796. */
  36797. get isDisposed(): boolean;
  36798. /**
  36799. * Call this function to reduce memory footprint of the scene.
  36800. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36801. */
  36802. clearCachedVertexData(): void;
  36803. /**
  36804. * This function will remove the local cached buffer data from texture.
  36805. * It will save memory but will prevent the texture from being rebuilt
  36806. */
  36807. cleanCachedTextureBuffer(): void;
  36808. /**
  36809. * Get the world extend vectors with an optional filter
  36810. *
  36811. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36812. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36813. */
  36814. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36815. min: Vector3;
  36816. max: Vector3;
  36817. };
  36818. /**
  36819. * Creates a ray that can be used to pick in the scene
  36820. * @param x defines the x coordinate of the origin (on-screen)
  36821. * @param y defines the y coordinate of the origin (on-screen)
  36822. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36823. * @param camera defines the camera to use for the picking
  36824. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36825. * @returns a Ray
  36826. */
  36827. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36828. /**
  36829. * Creates a ray that can be used to pick in the scene
  36830. * @param x defines the x coordinate of the origin (on-screen)
  36831. * @param y defines the y coordinate of the origin (on-screen)
  36832. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36833. * @param result defines the ray where to store the picking ray
  36834. * @param camera defines the camera to use for the picking
  36835. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36836. * @returns the current scene
  36837. */
  36838. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36839. /**
  36840. * Creates a ray that can be used to pick in the scene
  36841. * @param x defines the x coordinate of the origin (on-screen)
  36842. * @param y defines the y coordinate of the origin (on-screen)
  36843. * @param camera defines the camera to use for the picking
  36844. * @returns a Ray
  36845. */
  36846. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36847. /**
  36848. * Creates a ray that can be used to pick in the scene
  36849. * @param x defines the x coordinate of the origin (on-screen)
  36850. * @param y defines the y coordinate of the origin (on-screen)
  36851. * @param result defines the ray where to store the picking ray
  36852. * @param camera defines the camera to use for the picking
  36853. * @returns the current scene
  36854. */
  36855. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36856. /** Launch a ray to try to pick a mesh in the scene
  36857. * @param x position on screen
  36858. * @param y position on screen
  36859. * @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
  36860. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36861. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36862. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36863. * @returns a PickingInfo
  36864. */
  36865. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36866. /** Use the given ray to pick a mesh in the scene
  36867. * @param ray The ray to use to pick meshes
  36868. * @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
  36869. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36870. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36871. * @returns a PickingInfo
  36872. */
  36873. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36874. /**
  36875. * Launch a ray to try to pick a mesh in the scene
  36876. * @param x X position on screen
  36877. * @param y Y position on screen
  36878. * @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
  36879. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36880. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36881. * @returns an array of PickingInfo
  36882. */
  36883. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36884. /**
  36885. * Launch a ray to try to pick a mesh in the scene
  36886. * @param ray Ray to use
  36887. * @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
  36888. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36889. * @returns an array of PickingInfo
  36890. */
  36891. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36892. /**
  36893. * Force the value of meshUnderPointer
  36894. * @param mesh defines the mesh to use
  36895. */
  36896. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36897. /**
  36898. * Gets the mesh under the pointer
  36899. * @returns a Mesh or null if no mesh is under the pointer
  36900. */
  36901. getPointerOverMesh(): Nullable<AbstractMesh>;
  36902. /** @hidden */
  36903. _rebuildGeometries(): void;
  36904. /** @hidden */
  36905. _rebuildTextures(): void;
  36906. private _getByTags;
  36907. /**
  36908. * Get a list of meshes by tags
  36909. * @param tagsQuery defines the tags query to use
  36910. * @param forEach defines a predicate used to filter results
  36911. * @returns an array of Mesh
  36912. */
  36913. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36914. /**
  36915. * Get a list of cameras by tags
  36916. * @param tagsQuery defines the tags query to use
  36917. * @param forEach defines a predicate used to filter results
  36918. * @returns an array of Camera
  36919. */
  36920. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36921. /**
  36922. * Get a list of lights by tags
  36923. * @param tagsQuery defines the tags query to use
  36924. * @param forEach defines a predicate used to filter results
  36925. * @returns an array of Light
  36926. */
  36927. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36928. /**
  36929. * Get a list of materials by tags
  36930. * @param tagsQuery defines the tags query to use
  36931. * @param forEach defines a predicate used to filter results
  36932. * @returns an array of Material
  36933. */
  36934. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36935. /**
  36936. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36937. * This allowed control for front to back rendering or reversly depending of the special needs.
  36938. *
  36939. * @param renderingGroupId The rendering group id corresponding to its index
  36940. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36941. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36942. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36943. */
  36944. 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;
  36945. /**
  36946. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36947. *
  36948. * @param renderingGroupId The rendering group id corresponding to its index
  36949. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36950. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36951. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36952. */
  36953. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36954. /**
  36955. * Gets the current auto clear configuration for one rendering group of the rendering
  36956. * manager.
  36957. * @param index the rendering group index to get the information for
  36958. * @returns The auto clear setup for the requested rendering group
  36959. */
  36960. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36961. private _blockMaterialDirtyMechanism;
  36962. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36963. get blockMaterialDirtyMechanism(): boolean;
  36964. set blockMaterialDirtyMechanism(value: boolean);
  36965. /**
  36966. * Will flag all materials as dirty to trigger new shader compilation
  36967. * @param flag defines the flag used to specify which material part must be marked as dirty
  36968. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36969. */
  36970. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36971. /** @hidden */
  36972. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  36973. /** @hidden */
  36974. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36975. /** @hidden */
  36976. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  36977. /** @hidden */
  36978. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36979. /** @hidden */
  36980. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36981. /** @hidden */
  36982. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36983. }
  36984. }
  36985. declare module BABYLON {
  36986. /**
  36987. * Set of assets to keep when moving a scene into an asset container.
  36988. */
  36989. export class KeepAssets extends AbstractScene {
  36990. }
  36991. /**
  36992. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36993. */
  36994. export class InstantiatedEntries {
  36995. /**
  36996. * List of new root nodes (eg. nodes with no parent)
  36997. */
  36998. rootNodes: TransformNode[];
  36999. /**
  37000. * List of new skeletons
  37001. */
  37002. skeletons: Skeleton[];
  37003. /**
  37004. * List of new animation groups
  37005. */
  37006. animationGroups: AnimationGroup[];
  37007. }
  37008. /**
  37009. * Container with a set of assets that can be added or removed from a scene.
  37010. */
  37011. export class AssetContainer extends AbstractScene {
  37012. private _wasAddedToScene;
  37013. /**
  37014. * The scene the AssetContainer belongs to.
  37015. */
  37016. scene: Scene;
  37017. /**
  37018. * Instantiates an AssetContainer.
  37019. * @param scene The scene the AssetContainer belongs to.
  37020. */
  37021. constructor(scene: Scene);
  37022. /**
  37023. * Instantiate or clone all meshes and add the new ones to the scene.
  37024. * Skeletons and animation groups will all be cloned
  37025. * @param nameFunction defines an optional function used to get new names for clones
  37026. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37027. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37028. */
  37029. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37030. /**
  37031. * Adds all the assets from the container to the scene.
  37032. */
  37033. addAllToScene(): void;
  37034. /**
  37035. * Removes all the assets in the container from the scene
  37036. */
  37037. removeAllFromScene(): void;
  37038. /**
  37039. * Disposes all the assets in the container
  37040. */
  37041. dispose(): void;
  37042. private _moveAssets;
  37043. /**
  37044. * Removes all the assets contained in the scene and adds them to the container.
  37045. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37046. */
  37047. moveAllFromScene(keepAssets?: KeepAssets): void;
  37048. /**
  37049. * 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.
  37050. * @returns the root mesh
  37051. */
  37052. createRootMesh(): Mesh;
  37053. /**
  37054. * Merge animations from this asset container into a scene
  37055. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37056. * @param animatables set of animatables to retarget to a node from the scene
  37057. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37058. */
  37059. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37060. }
  37061. }
  37062. declare module BABYLON {
  37063. /**
  37064. * Defines how the parser contract is defined.
  37065. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37066. */
  37067. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37068. /**
  37069. * Defines how the individual parser contract is defined.
  37070. * These parser can parse an individual asset
  37071. */
  37072. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37073. /**
  37074. * Base class of the scene acting as a container for the different elements composing a scene.
  37075. * This class is dynamically extended by the different components of the scene increasing
  37076. * flexibility and reducing coupling
  37077. */
  37078. export abstract class AbstractScene {
  37079. /**
  37080. * Stores the list of available parsers in the application.
  37081. */
  37082. private static _BabylonFileParsers;
  37083. /**
  37084. * Stores the list of available individual parsers in the application.
  37085. */
  37086. private static _IndividualBabylonFileParsers;
  37087. /**
  37088. * Adds a parser in the list of available ones
  37089. * @param name Defines the name of the parser
  37090. * @param parser Defines the parser to add
  37091. */
  37092. static AddParser(name: string, parser: BabylonFileParser): void;
  37093. /**
  37094. * Gets a general parser from the list of avaialble ones
  37095. * @param name Defines the name of the parser
  37096. * @returns the requested parser or null
  37097. */
  37098. static GetParser(name: string): Nullable<BabylonFileParser>;
  37099. /**
  37100. * Adds n individual parser in the list of available ones
  37101. * @param name Defines the name of the parser
  37102. * @param parser Defines the parser to add
  37103. */
  37104. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37105. /**
  37106. * Gets an individual parser from the list of avaialble ones
  37107. * @param name Defines the name of the parser
  37108. * @returns the requested parser or null
  37109. */
  37110. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37111. /**
  37112. * Parser json data and populate both a scene and its associated container object
  37113. * @param jsonData Defines the data to parse
  37114. * @param scene Defines the scene to parse the data for
  37115. * @param container Defines the container attached to the parsing sequence
  37116. * @param rootUrl Defines the root url of the data
  37117. */
  37118. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37119. /**
  37120. * Gets the list of root nodes (ie. nodes with no parent)
  37121. */
  37122. rootNodes: Node[];
  37123. /** All of the cameras added to this scene
  37124. * @see http://doc.babylonjs.com/babylon101/cameras
  37125. */
  37126. cameras: Camera[];
  37127. /**
  37128. * All of the lights added to this scene
  37129. * @see http://doc.babylonjs.com/babylon101/lights
  37130. */
  37131. lights: Light[];
  37132. /**
  37133. * All of the (abstract) meshes added to this scene
  37134. */
  37135. meshes: AbstractMesh[];
  37136. /**
  37137. * The list of skeletons added to the scene
  37138. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37139. */
  37140. skeletons: Skeleton[];
  37141. /**
  37142. * All of the particle systems added to this scene
  37143. * @see http://doc.babylonjs.com/babylon101/particles
  37144. */
  37145. particleSystems: IParticleSystem[];
  37146. /**
  37147. * Gets a list of Animations associated with the scene
  37148. */
  37149. animations: Animation[];
  37150. /**
  37151. * All of the animation groups added to this scene
  37152. * @see http://doc.babylonjs.com/how_to/group
  37153. */
  37154. animationGroups: AnimationGroup[];
  37155. /**
  37156. * All of the multi-materials added to this scene
  37157. * @see http://doc.babylonjs.com/how_to/multi_materials
  37158. */
  37159. multiMaterials: MultiMaterial[];
  37160. /**
  37161. * All of the materials added to this scene
  37162. * In the context of a Scene, it is not supposed to be modified manually.
  37163. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37164. * Note also that the order of the Material within the array is not significant and might change.
  37165. * @see http://doc.babylonjs.com/babylon101/materials
  37166. */
  37167. materials: Material[];
  37168. /**
  37169. * The list of morph target managers added to the scene
  37170. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37171. */
  37172. morphTargetManagers: MorphTargetManager[];
  37173. /**
  37174. * The list of geometries used in the scene.
  37175. */
  37176. geometries: Geometry[];
  37177. /**
  37178. * All of the tranform nodes added to this scene
  37179. * In the context of a Scene, it is not supposed to be modified manually.
  37180. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37181. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37182. * @see http://doc.babylonjs.com/how_to/transformnode
  37183. */
  37184. transformNodes: TransformNode[];
  37185. /**
  37186. * ActionManagers available on the scene.
  37187. */
  37188. actionManagers: AbstractActionManager[];
  37189. /**
  37190. * Textures to keep.
  37191. */
  37192. textures: BaseTexture[];
  37193. /**
  37194. * Environment texture for the scene
  37195. */
  37196. environmentTexture: Nullable<BaseTexture>;
  37197. /**
  37198. * @returns all meshes, lights, cameras, transformNodes and bones
  37199. */
  37200. getNodes(): Array<Node>;
  37201. }
  37202. }
  37203. declare module BABYLON {
  37204. /**
  37205. * Interface used to define options for Sound class
  37206. */
  37207. export interface ISoundOptions {
  37208. /**
  37209. * Does the sound autoplay once loaded.
  37210. */
  37211. autoplay?: boolean;
  37212. /**
  37213. * Does the sound loop after it finishes playing once.
  37214. */
  37215. loop?: boolean;
  37216. /**
  37217. * Sound's volume
  37218. */
  37219. volume?: number;
  37220. /**
  37221. * Is it a spatial sound?
  37222. */
  37223. spatialSound?: boolean;
  37224. /**
  37225. * Maximum distance to hear that sound
  37226. */
  37227. maxDistance?: number;
  37228. /**
  37229. * Uses user defined attenuation function
  37230. */
  37231. useCustomAttenuation?: boolean;
  37232. /**
  37233. * Define the roll off factor of spatial sounds.
  37234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37235. */
  37236. rolloffFactor?: number;
  37237. /**
  37238. * Define the reference distance the sound should be heard perfectly.
  37239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37240. */
  37241. refDistance?: number;
  37242. /**
  37243. * Define the distance attenuation model the sound will follow.
  37244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37245. */
  37246. distanceModel?: string;
  37247. /**
  37248. * Defines the playback speed (1 by default)
  37249. */
  37250. playbackRate?: number;
  37251. /**
  37252. * Defines if the sound is from a streaming source
  37253. */
  37254. streaming?: boolean;
  37255. /**
  37256. * Defines an optional length (in seconds) inside the sound file
  37257. */
  37258. length?: number;
  37259. /**
  37260. * Defines an optional offset (in seconds) inside the sound file
  37261. */
  37262. offset?: number;
  37263. /**
  37264. * If true, URLs will not be required to state the audio file codec to use.
  37265. */
  37266. skipCodecCheck?: boolean;
  37267. }
  37268. /**
  37269. * Defines a sound that can be played in the application.
  37270. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37272. */
  37273. export class Sound {
  37274. /**
  37275. * The name of the sound in the scene.
  37276. */
  37277. name: string;
  37278. /**
  37279. * Does the sound autoplay once loaded.
  37280. */
  37281. autoplay: boolean;
  37282. /**
  37283. * Does the sound loop after it finishes playing once.
  37284. */
  37285. loop: boolean;
  37286. /**
  37287. * Does the sound use a custom attenuation curve to simulate the falloff
  37288. * happening when the source gets further away from the camera.
  37289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37290. */
  37291. useCustomAttenuation: boolean;
  37292. /**
  37293. * The sound track id this sound belongs to.
  37294. */
  37295. soundTrackId: number;
  37296. /**
  37297. * Is this sound currently played.
  37298. */
  37299. isPlaying: boolean;
  37300. /**
  37301. * Is this sound currently paused.
  37302. */
  37303. isPaused: boolean;
  37304. /**
  37305. * Does this sound enables spatial sound.
  37306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37307. */
  37308. spatialSound: boolean;
  37309. /**
  37310. * Define the reference distance the sound should be heard perfectly.
  37311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37312. */
  37313. refDistance: number;
  37314. /**
  37315. * Define the roll off factor of spatial sounds.
  37316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37317. */
  37318. rolloffFactor: number;
  37319. /**
  37320. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37322. */
  37323. maxDistance: number;
  37324. /**
  37325. * Define the distance attenuation model the sound will follow.
  37326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37327. */
  37328. distanceModel: string;
  37329. /**
  37330. * @hidden
  37331. * Back Compat
  37332. **/
  37333. onended: () => any;
  37334. /**
  37335. * Observable event when the current playing sound finishes.
  37336. */
  37337. onEndedObservable: Observable<Sound>;
  37338. private _panningModel;
  37339. private _playbackRate;
  37340. private _streaming;
  37341. private _startTime;
  37342. private _startOffset;
  37343. private _position;
  37344. /** @hidden */
  37345. _positionInEmitterSpace: boolean;
  37346. private _localDirection;
  37347. private _volume;
  37348. private _isReadyToPlay;
  37349. private _isDirectional;
  37350. private _readyToPlayCallback;
  37351. private _audioBuffer;
  37352. private _soundSource;
  37353. private _streamingSource;
  37354. private _soundPanner;
  37355. private _soundGain;
  37356. private _inputAudioNode;
  37357. private _outputAudioNode;
  37358. private _coneInnerAngle;
  37359. private _coneOuterAngle;
  37360. private _coneOuterGain;
  37361. private _scene;
  37362. private _connectedTransformNode;
  37363. private _customAttenuationFunction;
  37364. private _registerFunc;
  37365. private _isOutputConnected;
  37366. private _htmlAudioElement;
  37367. private _urlType;
  37368. private _length?;
  37369. private _offset?;
  37370. /** @hidden */
  37371. static _SceneComponentInitialization: (scene: Scene) => void;
  37372. /**
  37373. * Create a sound and attach it to a scene
  37374. * @param name Name of your sound
  37375. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37376. * @param scene defines the scene the sound belongs to
  37377. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37378. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37379. */
  37380. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37381. /**
  37382. * Release the sound and its associated resources
  37383. */
  37384. dispose(): void;
  37385. /**
  37386. * Gets if the sounds is ready to be played or not.
  37387. * @returns true if ready, otherwise false
  37388. */
  37389. isReady(): boolean;
  37390. private _soundLoaded;
  37391. /**
  37392. * Sets the data of the sound from an audiobuffer
  37393. * @param audioBuffer The audioBuffer containing the data
  37394. */
  37395. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37396. /**
  37397. * Updates the current sounds options such as maxdistance, loop...
  37398. * @param options A JSON object containing values named as the object properties
  37399. */
  37400. updateOptions(options: ISoundOptions): void;
  37401. private _createSpatialParameters;
  37402. private _updateSpatialParameters;
  37403. /**
  37404. * Switch the panning model to HRTF:
  37405. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37407. */
  37408. switchPanningModelToHRTF(): void;
  37409. /**
  37410. * Switch the panning model to Equal Power:
  37411. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37413. */
  37414. switchPanningModelToEqualPower(): void;
  37415. private _switchPanningModel;
  37416. /**
  37417. * Connect this sound to a sound track audio node like gain...
  37418. * @param soundTrackAudioNode the sound track audio node to connect to
  37419. */
  37420. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37421. /**
  37422. * Transform this sound into a directional source
  37423. * @param coneInnerAngle Size of the inner cone in degree
  37424. * @param coneOuterAngle Size of the outer cone in degree
  37425. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37426. */
  37427. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37428. /**
  37429. * Gets or sets the inner angle for the directional cone.
  37430. */
  37431. get directionalConeInnerAngle(): number;
  37432. /**
  37433. * Gets or sets the inner angle for the directional cone.
  37434. */
  37435. set directionalConeInnerAngle(value: number);
  37436. /**
  37437. * Gets or sets the outer angle for the directional cone.
  37438. */
  37439. get directionalConeOuterAngle(): number;
  37440. /**
  37441. * Gets or sets the outer angle for the directional cone.
  37442. */
  37443. set directionalConeOuterAngle(value: number);
  37444. /**
  37445. * Sets the position of the emitter if spatial sound is enabled
  37446. * @param newPosition Defines the new posisiton
  37447. */
  37448. setPosition(newPosition: Vector3): void;
  37449. /**
  37450. * Sets the local direction of the emitter if spatial sound is enabled
  37451. * @param newLocalDirection Defines the new local direction
  37452. */
  37453. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37454. private _updateDirection;
  37455. /** @hidden */
  37456. updateDistanceFromListener(): void;
  37457. /**
  37458. * Sets a new custom attenuation function for the sound.
  37459. * @param callback Defines the function used for the attenuation
  37460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37461. */
  37462. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37463. /**
  37464. * Play the sound
  37465. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37466. * @param offset (optional) Start the sound at a specific time in seconds
  37467. * @param length (optional) Sound duration (in seconds)
  37468. */
  37469. play(time?: number, offset?: number, length?: number): void;
  37470. private _onended;
  37471. /**
  37472. * Stop the sound
  37473. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37474. */
  37475. stop(time?: number): void;
  37476. /**
  37477. * Put the sound in pause
  37478. */
  37479. pause(): void;
  37480. /**
  37481. * Sets a dedicated volume for this sounds
  37482. * @param newVolume Define the new volume of the sound
  37483. * @param time Define time for gradual change to new volume
  37484. */
  37485. setVolume(newVolume: number, time?: number): void;
  37486. /**
  37487. * Set the sound play back rate
  37488. * @param newPlaybackRate Define the playback rate the sound should be played at
  37489. */
  37490. setPlaybackRate(newPlaybackRate: number): void;
  37491. /**
  37492. * Gets the volume of the sound.
  37493. * @returns the volume of the sound
  37494. */
  37495. getVolume(): number;
  37496. /**
  37497. * Attach the sound to a dedicated mesh
  37498. * @param transformNode The transform node to connect the sound with
  37499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37500. */
  37501. attachToMesh(transformNode: TransformNode): void;
  37502. /**
  37503. * Detach the sound from the previously attached mesh
  37504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37505. */
  37506. detachFromMesh(): void;
  37507. private _onRegisterAfterWorldMatrixUpdate;
  37508. /**
  37509. * Clone the current sound in the scene.
  37510. * @returns the new sound clone
  37511. */
  37512. clone(): Nullable<Sound>;
  37513. /**
  37514. * Gets the current underlying audio buffer containing the data
  37515. * @returns the audio buffer
  37516. */
  37517. getAudioBuffer(): Nullable<AudioBuffer>;
  37518. /**
  37519. * Serializes the Sound in a JSON representation
  37520. * @returns the JSON representation of the sound
  37521. */
  37522. serialize(): any;
  37523. /**
  37524. * Parse a JSON representation of a sound to innstantiate in a given scene
  37525. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37526. * @param scene Define the scene the new parsed sound should be created in
  37527. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37528. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37529. * @returns the newly parsed sound
  37530. */
  37531. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37532. }
  37533. }
  37534. declare module BABYLON {
  37535. /**
  37536. * This defines an action helpful to play a defined sound on a triggered action.
  37537. */
  37538. export class PlaySoundAction extends Action {
  37539. private _sound;
  37540. /**
  37541. * Instantiate the action
  37542. * @param triggerOptions defines the trigger options
  37543. * @param sound defines the sound to play
  37544. * @param condition defines the trigger related conditions
  37545. */
  37546. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37547. /** @hidden */
  37548. _prepare(): void;
  37549. /**
  37550. * Execute the action and play the sound.
  37551. */
  37552. execute(): void;
  37553. /**
  37554. * Serializes the actions and its related information.
  37555. * @param parent defines the object to serialize in
  37556. * @returns the serialized object
  37557. */
  37558. serialize(parent: any): any;
  37559. }
  37560. /**
  37561. * This defines an action helpful to stop a defined sound on a triggered action.
  37562. */
  37563. export class StopSoundAction extends Action {
  37564. private _sound;
  37565. /**
  37566. * Instantiate the action
  37567. * @param triggerOptions defines the trigger options
  37568. * @param sound defines the sound to stop
  37569. * @param condition defines the trigger related conditions
  37570. */
  37571. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37572. /** @hidden */
  37573. _prepare(): void;
  37574. /**
  37575. * Execute the action and stop the sound.
  37576. */
  37577. execute(): void;
  37578. /**
  37579. * Serializes the actions and its related information.
  37580. * @param parent defines the object to serialize in
  37581. * @returns the serialized object
  37582. */
  37583. serialize(parent: any): any;
  37584. }
  37585. }
  37586. declare module BABYLON {
  37587. /**
  37588. * This defines an action responsible to change the value of a property
  37589. * by interpolating between its current value and the newly set one once triggered.
  37590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37591. */
  37592. export class InterpolateValueAction extends Action {
  37593. /**
  37594. * Defines the path of the property where the value should be interpolated
  37595. */
  37596. propertyPath: string;
  37597. /**
  37598. * Defines the target value at the end of the interpolation.
  37599. */
  37600. value: any;
  37601. /**
  37602. * Defines the time it will take for the property to interpolate to the value.
  37603. */
  37604. duration: number;
  37605. /**
  37606. * Defines if the other scene animations should be stopped when the action has been triggered
  37607. */
  37608. stopOtherAnimations?: boolean;
  37609. /**
  37610. * Defines a callback raised once the interpolation animation has been done.
  37611. */
  37612. onInterpolationDone?: () => void;
  37613. /**
  37614. * Observable triggered once the interpolation animation has been done.
  37615. */
  37616. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37617. private _target;
  37618. private _effectiveTarget;
  37619. private _property;
  37620. /**
  37621. * Instantiate the action
  37622. * @param triggerOptions defines the trigger options
  37623. * @param target defines the object containing the value to interpolate
  37624. * @param propertyPath defines the path to the property in the target object
  37625. * @param value defines the target value at the end of the interpolation
  37626. * @param duration deines the time it will take for the property to interpolate to the value.
  37627. * @param condition defines the trigger related conditions
  37628. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37629. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37630. */
  37631. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37632. /** @hidden */
  37633. _prepare(): void;
  37634. /**
  37635. * Execute the action starts the value interpolation.
  37636. */
  37637. execute(): void;
  37638. /**
  37639. * Serializes the actions and its related information.
  37640. * @param parent defines the object to serialize in
  37641. * @returns the serialized object
  37642. */
  37643. serialize(parent: any): any;
  37644. }
  37645. }
  37646. declare module BABYLON {
  37647. /**
  37648. * Options allowed during the creation of a sound track.
  37649. */
  37650. export interface ISoundTrackOptions {
  37651. /**
  37652. * The volume the sound track should take during creation
  37653. */
  37654. volume?: number;
  37655. /**
  37656. * Define if the sound track is the main sound track of the scene
  37657. */
  37658. mainTrack?: boolean;
  37659. }
  37660. /**
  37661. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37662. * It will be also used in a future release to apply effects on a specific track.
  37663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37664. */
  37665. export class SoundTrack {
  37666. /**
  37667. * The unique identifier of the sound track in the scene.
  37668. */
  37669. id: number;
  37670. /**
  37671. * The list of sounds included in the sound track.
  37672. */
  37673. soundCollection: Array<Sound>;
  37674. private _outputAudioNode;
  37675. private _scene;
  37676. private _connectedAnalyser;
  37677. private _options;
  37678. private _isInitialized;
  37679. /**
  37680. * Creates a new sound track.
  37681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37682. * @param scene Define the scene the sound track belongs to
  37683. * @param options
  37684. */
  37685. constructor(scene: Scene, options?: ISoundTrackOptions);
  37686. private _initializeSoundTrackAudioGraph;
  37687. /**
  37688. * Release the sound track and its associated resources
  37689. */
  37690. dispose(): void;
  37691. /**
  37692. * Adds a sound to this sound track
  37693. * @param sound define the cound to add
  37694. * @ignoreNaming
  37695. */
  37696. AddSound(sound: Sound): void;
  37697. /**
  37698. * Removes a sound to this sound track
  37699. * @param sound define the cound to remove
  37700. * @ignoreNaming
  37701. */
  37702. RemoveSound(sound: Sound): void;
  37703. /**
  37704. * Set a global volume for the full sound track.
  37705. * @param newVolume Define the new volume of the sound track
  37706. */
  37707. setVolume(newVolume: number): void;
  37708. /**
  37709. * Switch the panning model to HRTF:
  37710. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37712. */
  37713. switchPanningModelToHRTF(): void;
  37714. /**
  37715. * Switch the panning model to Equal Power:
  37716. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37718. */
  37719. switchPanningModelToEqualPower(): void;
  37720. /**
  37721. * Connect the sound track to an audio analyser allowing some amazing
  37722. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37724. * @param analyser The analyser to connect to the engine
  37725. */
  37726. connectToAnalyser(analyser: Analyser): void;
  37727. }
  37728. }
  37729. declare module BABYLON {
  37730. interface AbstractScene {
  37731. /**
  37732. * The list of sounds used in the scene.
  37733. */
  37734. sounds: Nullable<Array<Sound>>;
  37735. }
  37736. interface Scene {
  37737. /**
  37738. * @hidden
  37739. * Backing field
  37740. */
  37741. _mainSoundTrack: SoundTrack;
  37742. /**
  37743. * The main sound track played by the scene.
  37744. * It cotains your primary collection of sounds.
  37745. */
  37746. mainSoundTrack: SoundTrack;
  37747. /**
  37748. * The list of sound tracks added to the scene
  37749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37750. */
  37751. soundTracks: Nullable<Array<SoundTrack>>;
  37752. /**
  37753. * Gets a sound using a given name
  37754. * @param name defines the name to search for
  37755. * @return the found sound or null if not found at all.
  37756. */
  37757. getSoundByName(name: string): Nullable<Sound>;
  37758. /**
  37759. * Gets or sets if audio support is enabled
  37760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37761. */
  37762. audioEnabled: boolean;
  37763. /**
  37764. * Gets or sets if audio will be output to headphones
  37765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37766. */
  37767. headphone: boolean;
  37768. /**
  37769. * Gets or sets custom audio listener position provider
  37770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37771. */
  37772. audioListenerPositionProvider: Nullable<() => Vector3>;
  37773. /**
  37774. * Gets or sets a refresh rate when using 3D audio positioning
  37775. */
  37776. audioPositioningRefreshRate: number;
  37777. }
  37778. /**
  37779. * Defines the sound scene component responsible to manage any sounds
  37780. * in a given scene.
  37781. */
  37782. export class AudioSceneComponent implements ISceneSerializableComponent {
  37783. /**
  37784. * The component name helpfull to identify the component in the list of scene components.
  37785. */
  37786. readonly name: string;
  37787. /**
  37788. * The scene the component belongs to.
  37789. */
  37790. scene: Scene;
  37791. private _audioEnabled;
  37792. /**
  37793. * Gets whether audio is enabled or not.
  37794. * Please use related enable/disable method to switch state.
  37795. */
  37796. get audioEnabled(): boolean;
  37797. private _headphone;
  37798. /**
  37799. * Gets whether audio is outputing to headphone or not.
  37800. * Please use the according Switch methods to change output.
  37801. */
  37802. get headphone(): boolean;
  37803. /**
  37804. * Gets or sets a refresh rate when using 3D audio positioning
  37805. */
  37806. audioPositioningRefreshRate: number;
  37807. private _audioListenerPositionProvider;
  37808. /**
  37809. * Gets the current audio listener position provider
  37810. */
  37811. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37812. /**
  37813. * Sets a custom listener position for all sounds in the scene
  37814. * By default, this is the position of the first active camera
  37815. */
  37816. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37817. /**
  37818. * Creates a new instance of the component for the given scene
  37819. * @param scene Defines the scene to register the component in
  37820. */
  37821. constructor(scene: Scene);
  37822. /**
  37823. * Registers the component in a given scene
  37824. */
  37825. register(): void;
  37826. /**
  37827. * Rebuilds the elements related to this component in case of
  37828. * context lost for instance.
  37829. */
  37830. rebuild(): void;
  37831. /**
  37832. * Serializes the component data to the specified json object
  37833. * @param serializationObject The object to serialize to
  37834. */
  37835. serialize(serializationObject: any): void;
  37836. /**
  37837. * Adds all the elements from the container to the scene
  37838. * @param container the container holding the elements
  37839. */
  37840. addFromContainer(container: AbstractScene): void;
  37841. /**
  37842. * Removes all the elements in the container from the scene
  37843. * @param container contains the elements to remove
  37844. * @param dispose if the removed element should be disposed (default: false)
  37845. */
  37846. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37847. /**
  37848. * Disposes the component and the associated ressources.
  37849. */
  37850. dispose(): void;
  37851. /**
  37852. * Disables audio in the associated scene.
  37853. */
  37854. disableAudio(): void;
  37855. /**
  37856. * Enables audio in the associated scene.
  37857. */
  37858. enableAudio(): void;
  37859. /**
  37860. * Switch audio to headphone output.
  37861. */
  37862. switchAudioModeForHeadphones(): void;
  37863. /**
  37864. * Switch audio to normal speakers.
  37865. */
  37866. switchAudioModeForNormalSpeakers(): void;
  37867. private _cachedCameraDirection;
  37868. private _cachedCameraPosition;
  37869. private _lastCheck;
  37870. private _afterRender;
  37871. }
  37872. }
  37873. declare module BABYLON {
  37874. /**
  37875. * Wraps one or more Sound objects and selects one with random weight for playback.
  37876. */
  37877. export class WeightedSound {
  37878. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37879. loop: boolean;
  37880. private _coneInnerAngle;
  37881. private _coneOuterAngle;
  37882. private _volume;
  37883. /** A Sound is currently playing. */
  37884. isPlaying: boolean;
  37885. /** A Sound is currently paused. */
  37886. isPaused: boolean;
  37887. private _sounds;
  37888. private _weights;
  37889. private _currentIndex?;
  37890. /**
  37891. * Creates a new WeightedSound from the list of sounds given.
  37892. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37893. * @param sounds Array of Sounds that will be selected from.
  37894. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37895. */
  37896. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37897. /**
  37898. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37899. */
  37900. get directionalConeInnerAngle(): number;
  37901. /**
  37902. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37903. */
  37904. set directionalConeInnerAngle(value: number);
  37905. /**
  37906. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37907. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37908. */
  37909. get directionalConeOuterAngle(): number;
  37910. /**
  37911. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37912. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37913. */
  37914. set directionalConeOuterAngle(value: number);
  37915. /**
  37916. * Playback volume.
  37917. */
  37918. get volume(): number;
  37919. /**
  37920. * Playback volume.
  37921. */
  37922. set volume(value: number);
  37923. private _onended;
  37924. /**
  37925. * Suspend playback
  37926. */
  37927. pause(): void;
  37928. /**
  37929. * Stop playback
  37930. */
  37931. stop(): void;
  37932. /**
  37933. * Start playback.
  37934. * @param startOffset Position the clip head at a specific time in seconds.
  37935. */
  37936. play(startOffset?: number): void;
  37937. }
  37938. }
  37939. declare module BABYLON {
  37940. /**
  37941. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37942. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37943. */
  37944. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37945. /**
  37946. * Gets the name of the behavior.
  37947. */
  37948. get name(): string;
  37949. /**
  37950. * The easing function used by animations
  37951. */
  37952. static EasingFunction: BackEase;
  37953. /**
  37954. * The easing mode used by animations
  37955. */
  37956. static EasingMode: number;
  37957. /**
  37958. * The duration of the animation, in milliseconds
  37959. */
  37960. transitionDuration: number;
  37961. /**
  37962. * Length of the distance animated by the transition when lower radius is reached
  37963. */
  37964. lowerRadiusTransitionRange: number;
  37965. /**
  37966. * Length of the distance animated by the transition when upper radius is reached
  37967. */
  37968. upperRadiusTransitionRange: number;
  37969. private _autoTransitionRange;
  37970. /**
  37971. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37972. */
  37973. get autoTransitionRange(): boolean;
  37974. /**
  37975. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37976. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37977. */
  37978. set autoTransitionRange(value: boolean);
  37979. private _attachedCamera;
  37980. private _onAfterCheckInputsObserver;
  37981. private _onMeshTargetChangedObserver;
  37982. /**
  37983. * Initializes the behavior.
  37984. */
  37985. init(): void;
  37986. /**
  37987. * Attaches the behavior to its arc rotate camera.
  37988. * @param camera Defines the camera to attach the behavior to
  37989. */
  37990. attach(camera: ArcRotateCamera): void;
  37991. /**
  37992. * Detaches the behavior from its current arc rotate camera.
  37993. */
  37994. detach(): void;
  37995. private _radiusIsAnimating;
  37996. private _radiusBounceTransition;
  37997. private _animatables;
  37998. private _cachedWheelPrecision;
  37999. /**
  38000. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38001. * @param radiusLimit The limit to check against.
  38002. * @return Bool to indicate if at limit.
  38003. */
  38004. private _isRadiusAtLimit;
  38005. /**
  38006. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38007. * @param radiusDelta The delta by which to animate to. Can be negative.
  38008. */
  38009. private _applyBoundRadiusAnimation;
  38010. /**
  38011. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38012. */
  38013. protected _clearAnimationLocks(): void;
  38014. /**
  38015. * Stops and removes all animations that have been applied to the camera
  38016. */
  38017. stopAllAnimations(): void;
  38018. }
  38019. }
  38020. declare module BABYLON {
  38021. /**
  38022. * 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.
  38023. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38024. */
  38025. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38026. /**
  38027. * Gets the name of the behavior.
  38028. */
  38029. get name(): string;
  38030. private _mode;
  38031. private _radiusScale;
  38032. private _positionScale;
  38033. private _defaultElevation;
  38034. private _elevationReturnTime;
  38035. private _elevationReturnWaitTime;
  38036. private _zoomStopsAnimation;
  38037. private _framingTime;
  38038. /**
  38039. * The easing function used by animations
  38040. */
  38041. static EasingFunction: ExponentialEase;
  38042. /**
  38043. * The easing mode used by animations
  38044. */
  38045. static EasingMode: number;
  38046. /**
  38047. * Sets the current mode used by the behavior
  38048. */
  38049. set mode(mode: number);
  38050. /**
  38051. * Gets current mode used by the behavior.
  38052. */
  38053. get mode(): number;
  38054. /**
  38055. * Sets the scale applied to the radius (1 by default)
  38056. */
  38057. set radiusScale(radius: number);
  38058. /**
  38059. * Gets the scale applied to the radius
  38060. */
  38061. get radiusScale(): number;
  38062. /**
  38063. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38064. */
  38065. set positionScale(scale: number);
  38066. /**
  38067. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38068. */
  38069. get positionScale(): number;
  38070. /**
  38071. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38072. * behaviour is triggered, in radians.
  38073. */
  38074. set defaultElevation(elevation: number);
  38075. /**
  38076. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38077. * behaviour is triggered, in radians.
  38078. */
  38079. get defaultElevation(): number;
  38080. /**
  38081. * Sets the time (in milliseconds) taken to return to the default beta position.
  38082. * Negative value indicates camera should not return to default.
  38083. */
  38084. set elevationReturnTime(speed: number);
  38085. /**
  38086. * Gets the time (in milliseconds) taken to return to the default beta position.
  38087. * Negative value indicates camera should not return to default.
  38088. */
  38089. get elevationReturnTime(): number;
  38090. /**
  38091. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38092. */
  38093. set elevationReturnWaitTime(time: number);
  38094. /**
  38095. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38096. */
  38097. get elevationReturnWaitTime(): number;
  38098. /**
  38099. * Sets the flag that indicates if user zooming should stop animation.
  38100. */
  38101. set zoomStopsAnimation(flag: boolean);
  38102. /**
  38103. * Gets the flag that indicates if user zooming should stop animation.
  38104. */
  38105. get zoomStopsAnimation(): boolean;
  38106. /**
  38107. * Sets the transition time when framing the mesh, in milliseconds
  38108. */
  38109. set framingTime(time: number);
  38110. /**
  38111. * Gets the transition time when framing the mesh, in milliseconds
  38112. */
  38113. get framingTime(): number;
  38114. /**
  38115. * Define if the behavior should automatically change the configured
  38116. * camera limits and sensibilities.
  38117. */
  38118. autoCorrectCameraLimitsAndSensibility: boolean;
  38119. private _onPrePointerObservableObserver;
  38120. private _onAfterCheckInputsObserver;
  38121. private _onMeshTargetChangedObserver;
  38122. private _attachedCamera;
  38123. private _isPointerDown;
  38124. private _lastInteractionTime;
  38125. /**
  38126. * Initializes the behavior.
  38127. */
  38128. init(): void;
  38129. /**
  38130. * Attaches the behavior to its arc rotate camera.
  38131. * @param camera Defines the camera to attach the behavior to
  38132. */
  38133. attach(camera: ArcRotateCamera): void;
  38134. /**
  38135. * Detaches the behavior from its current arc rotate camera.
  38136. */
  38137. detach(): void;
  38138. private _animatables;
  38139. private _betaIsAnimating;
  38140. private _betaTransition;
  38141. private _radiusTransition;
  38142. private _vectorTransition;
  38143. /**
  38144. * Targets the given mesh and updates zoom level accordingly.
  38145. * @param mesh The mesh to target.
  38146. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38147. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38148. */
  38149. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38150. /**
  38151. * Targets the given mesh with its children and updates zoom level accordingly.
  38152. * @param mesh The mesh to target.
  38153. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38154. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38155. */
  38156. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38157. /**
  38158. * Targets the given meshes with their children and updates zoom level accordingly.
  38159. * @param meshes The mesh to target.
  38160. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38161. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38162. */
  38163. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38164. /**
  38165. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38166. * @param minimumWorld Determines the smaller position of the bounding box extend
  38167. * @param maximumWorld Determines the bigger position of the bounding box extend
  38168. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38169. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38170. */
  38171. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38172. /**
  38173. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38174. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38175. * frustum width.
  38176. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38177. * to fully enclose the mesh in the viewing frustum.
  38178. */
  38179. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38180. /**
  38181. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38182. * is automatically returned to its default position (expected to be above ground plane).
  38183. */
  38184. private _maintainCameraAboveGround;
  38185. /**
  38186. * Returns the frustum slope based on the canvas ratio and camera FOV
  38187. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38188. */
  38189. private _getFrustumSlope;
  38190. /**
  38191. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38192. */
  38193. private _clearAnimationLocks;
  38194. /**
  38195. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38196. */
  38197. private _applyUserInteraction;
  38198. /**
  38199. * Stops and removes all animations that have been applied to the camera
  38200. */
  38201. stopAllAnimations(): void;
  38202. /**
  38203. * Gets a value indicating if the user is moving the camera
  38204. */
  38205. get isUserIsMoving(): boolean;
  38206. /**
  38207. * The camera can move all the way towards the mesh.
  38208. */
  38209. static IgnoreBoundsSizeMode: number;
  38210. /**
  38211. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38212. */
  38213. static FitFrustumSidesMode: number;
  38214. }
  38215. }
  38216. declare module BABYLON {
  38217. /**
  38218. * Base class for Camera Pointer Inputs.
  38219. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38220. * for example usage.
  38221. */
  38222. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38223. /**
  38224. * Defines the camera the input is attached to.
  38225. */
  38226. abstract camera: Camera;
  38227. /**
  38228. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38229. */
  38230. protected _altKey: boolean;
  38231. protected _ctrlKey: boolean;
  38232. protected _metaKey: boolean;
  38233. protected _shiftKey: boolean;
  38234. /**
  38235. * Which mouse buttons were pressed at time of last mouse event.
  38236. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38237. */
  38238. protected _buttonsPressed: number;
  38239. /**
  38240. * Defines the buttons associated with the input to handle camera move.
  38241. */
  38242. buttons: number[];
  38243. /**
  38244. * Attach the input controls to a specific dom element to get the input from.
  38245. * @param element Defines the element the controls should be listened from
  38246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38247. */
  38248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38249. /**
  38250. * Detach the current controls from the specified dom element.
  38251. * @param element Defines the element to stop listening the inputs from
  38252. */
  38253. detachControl(element: Nullable<HTMLElement>): void;
  38254. /**
  38255. * Gets the class name of the current input.
  38256. * @returns the class name
  38257. */
  38258. getClassName(): string;
  38259. /**
  38260. * Get the friendly name associated with the input class.
  38261. * @returns the input friendly name
  38262. */
  38263. getSimpleName(): string;
  38264. /**
  38265. * Called on pointer POINTERDOUBLETAP event.
  38266. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38267. */
  38268. protected onDoubleTap(type: string): void;
  38269. /**
  38270. * Called on pointer POINTERMOVE event if only a single touch is active.
  38271. * Override this method to provide functionality.
  38272. */
  38273. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38274. /**
  38275. * Called on pointer POINTERMOVE event if multiple touches are active.
  38276. * Override this method to provide functionality.
  38277. */
  38278. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38279. /**
  38280. * Called on JS contextmenu event.
  38281. * Override this method to provide functionality.
  38282. */
  38283. protected onContextMenu(evt: PointerEvent): void;
  38284. /**
  38285. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38286. * press.
  38287. * Override this method to provide functionality.
  38288. */
  38289. protected onButtonDown(evt: PointerEvent): void;
  38290. /**
  38291. * Called each time a new POINTERUP event occurs. Ie, for each button
  38292. * release.
  38293. * Override this method to provide functionality.
  38294. */
  38295. protected onButtonUp(evt: PointerEvent): void;
  38296. /**
  38297. * Called when window becomes inactive.
  38298. * Override this method to provide functionality.
  38299. */
  38300. protected onLostFocus(): void;
  38301. private _pointerInput;
  38302. private _observer;
  38303. private _onLostFocus;
  38304. private pointA;
  38305. private pointB;
  38306. }
  38307. }
  38308. declare module BABYLON {
  38309. /**
  38310. * Manage the pointers inputs to control an arc rotate camera.
  38311. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38312. */
  38313. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38314. /**
  38315. * Defines the camera the input is attached to.
  38316. */
  38317. camera: ArcRotateCamera;
  38318. /**
  38319. * Gets the class name of the current input.
  38320. * @returns the class name
  38321. */
  38322. getClassName(): string;
  38323. /**
  38324. * Defines the buttons associated with the input to handle camera move.
  38325. */
  38326. buttons: number[];
  38327. /**
  38328. * Defines the pointer angular sensibility along the X axis or how fast is
  38329. * the camera rotating.
  38330. */
  38331. angularSensibilityX: number;
  38332. /**
  38333. * Defines the pointer angular sensibility along the Y axis or how fast is
  38334. * the camera rotating.
  38335. */
  38336. angularSensibilityY: number;
  38337. /**
  38338. * Defines the pointer pinch precision or how fast is the camera zooming.
  38339. */
  38340. pinchPrecision: number;
  38341. /**
  38342. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38343. * from 0.
  38344. * It defines the percentage of current camera.radius to use as delta when
  38345. * pinch zoom is used.
  38346. */
  38347. pinchDeltaPercentage: number;
  38348. /**
  38349. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38350. * that any object in the plane at the camera's target point will scale
  38351. * perfectly with finger motion.
  38352. * Overrides pinchDeltaPercentage and pinchPrecision.
  38353. */
  38354. useNaturalPinchZoom: boolean;
  38355. /**
  38356. * Defines the pointer panning sensibility or how fast is the camera moving.
  38357. */
  38358. panningSensibility: number;
  38359. /**
  38360. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38361. */
  38362. multiTouchPanning: boolean;
  38363. /**
  38364. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38365. * zoom (pinch) through multitouch.
  38366. */
  38367. multiTouchPanAndZoom: boolean;
  38368. /**
  38369. * Revers pinch action direction.
  38370. */
  38371. pinchInwards: boolean;
  38372. private _isPanClick;
  38373. private _twoFingerActivityCount;
  38374. private _isPinching;
  38375. /**
  38376. * Called on pointer POINTERMOVE event if only a single touch is active.
  38377. */
  38378. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38379. /**
  38380. * Called on pointer POINTERDOUBLETAP event.
  38381. */
  38382. protected onDoubleTap(type: string): void;
  38383. /**
  38384. * Called on pointer POINTERMOVE event if multiple touches are active.
  38385. */
  38386. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38387. /**
  38388. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38389. * press.
  38390. */
  38391. protected onButtonDown(evt: PointerEvent): void;
  38392. /**
  38393. * Called each time a new POINTERUP event occurs. Ie, for each button
  38394. * release.
  38395. */
  38396. protected onButtonUp(evt: PointerEvent): void;
  38397. /**
  38398. * Called when window becomes inactive.
  38399. */
  38400. protected onLostFocus(): void;
  38401. }
  38402. }
  38403. declare module BABYLON {
  38404. /**
  38405. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38407. */
  38408. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38409. /**
  38410. * Defines the camera the input is attached to.
  38411. */
  38412. camera: ArcRotateCamera;
  38413. /**
  38414. * Defines the list of key codes associated with the up action (increase alpha)
  38415. */
  38416. keysUp: number[];
  38417. /**
  38418. * Defines the list of key codes associated with the down action (decrease alpha)
  38419. */
  38420. keysDown: number[];
  38421. /**
  38422. * Defines the list of key codes associated with the left action (increase beta)
  38423. */
  38424. keysLeft: number[];
  38425. /**
  38426. * Defines the list of key codes associated with the right action (decrease beta)
  38427. */
  38428. keysRight: number[];
  38429. /**
  38430. * Defines the list of key codes associated with the reset action.
  38431. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38432. */
  38433. keysReset: number[];
  38434. /**
  38435. * Defines the panning sensibility of the inputs.
  38436. * (How fast is the camera panning)
  38437. */
  38438. panningSensibility: number;
  38439. /**
  38440. * Defines the zooming sensibility of the inputs.
  38441. * (How fast is the camera zooming)
  38442. */
  38443. zoomingSensibility: number;
  38444. /**
  38445. * Defines whether maintaining the alt key down switch the movement mode from
  38446. * orientation to zoom.
  38447. */
  38448. useAltToZoom: boolean;
  38449. /**
  38450. * Rotation speed of the camera
  38451. */
  38452. angularSpeed: number;
  38453. private _keys;
  38454. private _ctrlPressed;
  38455. private _altPressed;
  38456. private _onCanvasBlurObserver;
  38457. private _onKeyboardObserver;
  38458. private _engine;
  38459. private _scene;
  38460. /**
  38461. * Attach the input controls to a specific dom element to get the input from.
  38462. * @param element Defines the element the controls should be listened from
  38463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38464. */
  38465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38466. /**
  38467. * Detach the current controls from the specified dom element.
  38468. * @param element Defines the element to stop listening the inputs from
  38469. */
  38470. detachControl(element: Nullable<HTMLElement>): void;
  38471. /**
  38472. * Update the current camera state depending on the inputs that have been used this frame.
  38473. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38474. */
  38475. checkInputs(): void;
  38476. /**
  38477. * Gets the class name of the current intput.
  38478. * @returns the class name
  38479. */
  38480. getClassName(): string;
  38481. /**
  38482. * Get the friendly name associated with the input class.
  38483. * @returns the input friendly name
  38484. */
  38485. getSimpleName(): string;
  38486. }
  38487. }
  38488. declare module BABYLON {
  38489. /**
  38490. * Manage the mouse wheel inputs to control an arc rotate camera.
  38491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38492. */
  38493. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38494. /**
  38495. * Defines the camera the input is attached to.
  38496. */
  38497. camera: ArcRotateCamera;
  38498. /**
  38499. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38500. */
  38501. wheelPrecision: number;
  38502. /**
  38503. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38504. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38505. */
  38506. wheelDeltaPercentage: number;
  38507. private _wheel;
  38508. private _observer;
  38509. private computeDeltaFromMouseWheelLegacyEvent;
  38510. /**
  38511. * Attach the input controls to a specific dom element to get the input from.
  38512. * @param element Defines the element the controls should be listened from
  38513. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38514. */
  38515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38516. /**
  38517. * Detach the current controls from the specified dom element.
  38518. * @param element Defines the element to stop listening the inputs from
  38519. */
  38520. detachControl(element: Nullable<HTMLElement>): void;
  38521. /**
  38522. * Gets the class name of the current intput.
  38523. * @returns the class name
  38524. */
  38525. getClassName(): string;
  38526. /**
  38527. * Get the friendly name associated with the input class.
  38528. * @returns the input friendly name
  38529. */
  38530. getSimpleName(): string;
  38531. }
  38532. }
  38533. declare module BABYLON {
  38534. /**
  38535. * Default Inputs manager for the ArcRotateCamera.
  38536. * It groups all the default supported inputs for ease of use.
  38537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38538. */
  38539. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38540. /**
  38541. * Instantiates a new ArcRotateCameraInputsManager.
  38542. * @param camera Defines the camera the inputs belong to
  38543. */
  38544. constructor(camera: ArcRotateCamera);
  38545. /**
  38546. * Add mouse wheel input support to the input manager.
  38547. * @returns the current input manager
  38548. */
  38549. addMouseWheel(): ArcRotateCameraInputsManager;
  38550. /**
  38551. * Add pointers input support to the input manager.
  38552. * @returns the current input manager
  38553. */
  38554. addPointers(): ArcRotateCameraInputsManager;
  38555. /**
  38556. * Add keyboard input support to the input manager.
  38557. * @returns the current input manager
  38558. */
  38559. addKeyboard(): ArcRotateCameraInputsManager;
  38560. }
  38561. }
  38562. declare module BABYLON {
  38563. /**
  38564. * This represents an orbital type of camera.
  38565. *
  38566. * 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.
  38567. * 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.
  38568. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38569. */
  38570. export class ArcRotateCamera extends TargetCamera {
  38571. /**
  38572. * Defines the rotation angle of the camera along the longitudinal axis.
  38573. */
  38574. alpha: number;
  38575. /**
  38576. * Defines the rotation angle of the camera along the latitudinal axis.
  38577. */
  38578. beta: number;
  38579. /**
  38580. * Defines the radius of the camera from it s target point.
  38581. */
  38582. radius: number;
  38583. protected _target: Vector3;
  38584. protected _targetHost: Nullable<AbstractMesh>;
  38585. /**
  38586. * Defines the target point of the camera.
  38587. * The camera looks towards it form the radius distance.
  38588. */
  38589. get target(): Vector3;
  38590. set target(value: Vector3);
  38591. /**
  38592. * Define the current local position of the camera in the scene
  38593. */
  38594. get position(): Vector3;
  38595. set position(newPosition: Vector3);
  38596. protected _upVector: Vector3;
  38597. protected _upToYMatrix: Matrix;
  38598. protected _YToUpMatrix: Matrix;
  38599. /**
  38600. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38601. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38602. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38603. */
  38604. set upVector(vec: Vector3);
  38605. get upVector(): Vector3;
  38606. /**
  38607. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38608. */
  38609. setMatUp(): void;
  38610. /**
  38611. * Current inertia value on the longitudinal axis.
  38612. * The bigger this number the longer it will take for the camera to stop.
  38613. */
  38614. inertialAlphaOffset: number;
  38615. /**
  38616. * Current inertia value on the latitudinal axis.
  38617. * The bigger this number the longer it will take for the camera to stop.
  38618. */
  38619. inertialBetaOffset: number;
  38620. /**
  38621. * Current inertia value on the radius axis.
  38622. * The bigger this number the longer it will take for the camera to stop.
  38623. */
  38624. inertialRadiusOffset: number;
  38625. /**
  38626. * Minimum allowed angle on the longitudinal axis.
  38627. * This can help limiting how the Camera is able to move in the scene.
  38628. */
  38629. lowerAlphaLimit: Nullable<number>;
  38630. /**
  38631. * Maximum allowed angle on the longitudinal axis.
  38632. * This can help limiting how the Camera is able to move in the scene.
  38633. */
  38634. upperAlphaLimit: Nullable<number>;
  38635. /**
  38636. * Minimum allowed angle on the latitudinal axis.
  38637. * This can help limiting how the Camera is able to move in the scene.
  38638. */
  38639. lowerBetaLimit: number;
  38640. /**
  38641. * Maximum allowed angle on the latitudinal axis.
  38642. * This can help limiting how the Camera is able to move in the scene.
  38643. */
  38644. upperBetaLimit: number;
  38645. /**
  38646. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38647. * This can help limiting how the Camera is able to move in the scene.
  38648. */
  38649. lowerRadiusLimit: Nullable<number>;
  38650. /**
  38651. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38652. * This can help limiting how the Camera is able to move in the scene.
  38653. */
  38654. upperRadiusLimit: Nullable<number>;
  38655. /**
  38656. * Defines the current inertia value used during panning of the camera along the X axis.
  38657. */
  38658. inertialPanningX: number;
  38659. /**
  38660. * Defines the current inertia value used during panning of the camera along the Y axis.
  38661. */
  38662. inertialPanningY: number;
  38663. /**
  38664. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38665. * Basically if your fingers moves away from more than this distance you will be considered
  38666. * in pinch mode.
  38667. */
  38668. pinchToPanMaxDistance: number;
  38669. /**
  38670. * Defines the maximum distance the camera can pan.
  38671. * This could help keeping the cammera always in your scene.
  38672. */
  38673. panningDistanceLimit: Nullable<number>;
  38674. /**
  38675. * Defines the target of the camera before paning.
  38676. */
  38677. panningOriginTarget: Vector3;
  38678. /**
  38679. * Defines the value of the inertia used during panning.
  38680. * 0 would mean stop inertia and one would mean no decelleration at all.
  38681. */
  38682. panningInertia: number;
  38683. /**
  38684. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38685. */
  38686. get angularSensibilityX(): number;
  38687. set angularSensibilityX(value: number);
  38688. /**
  38689. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38690. */
  38691. get angularSensibilityY(): number;
  38692. set angularSensibilityY(value: number);
  38693. /**
  38694. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38695. */
  38696. get pinchPrecision(): number;
  38697. set pinchPrecision(value: number);
  38698. /**
  38699. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38700. * It will be used instead of pinchDeltaPrecision if different from 0.
  38701. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38702. */
  38703. get pinchDeltaPercentage(): number;
  38704. set pinchDeltaPercentage(value: number);
  38705. /**
  38706. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38707. * and pinch delta percentage.
  38708. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38709. * that any object in the plane at the camera's target point will scale
  38710. * perfectly with finger motion.
  38711. */
  38712. get useNaturalPinchZoom(): boolean;
  38713. set useNaturalPinchZoom(value: boolean);
  38714. /**
  38715. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38716. */
  38717. get panningSensibility(): number;
  38718. set panningSensibility(value: number);
  38719. /**
  38720. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38721. */
  38722. get keysUp(): number[];
  38723. set keysUp(value: number[]);
  38724. /**
  38725. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38726. */
  38727. get keysDown(): number[];
  38728. set keysDown(value: number[]);
  38729. /**
  38730. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38731. */
  38732. get keysLeft(): number[];
  38733. set keysLeft(value: number[]);
  38734. /**
  38735. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38736. */
  38737. get keysRight(): number[];
  38738. set keysRight(value: number[]);
  38739. /**
  38740. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38741. */
  38742. get wheelPrecision(): number;
  38743. set wheelPrecision(value: number);
  38744. /**
  38745. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38746. * It will be used instead of pinchDeltaPrecision if different from 0.
  38747. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38748. */
  38749. get wheelDeltaPercentage(): number;
  38750. set wheelDeltaPercentage(value: number);
  38751. /**
  38752. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38753. */
  38754. zoomOnFactor: number;
  38755. /**
  38756. * Defines a screen offset for the camera position.
  38757. */
  38758. targetScreenOffset: Vector2;
  38759. /**
  38760. * Allows the camera to be completely reversed.
  38761. * If false the camera can not arrive upside down.
  38762. */
  38763. allowUpsideDown: boolean;
  38764. /**
  38765. * Define if double tap/click is used to restore the previously saved state of the camera.
  38766. */
  38767. useInputToRestoreState: boolean;
  38768. /** @hidden */
  38769. _viewMatrix: Matrix;
  38770. /** @hidden */
  38771. _useCtrlForPanning: boolean;
  38772. /** @hidden */
  38773. _panningMouseButton: number;
  38774. /**
  38775. * Defines the input associated to the camera.
  38776. */
  38777. inputs: ArcRotateCameraInputsManager;
  38778. /** @hidden */
  38779. _reset: () => void;
  38780. /**
  38781. * Defines the allowed panning axis.
  38782. */
  38783. panningAxis: Vector3;
  38784. protected _localDirection: Vector3;
  38785. protected _transformedDirection: Vector3;
  38786. private _bouncingBehavior;
  38787. /**
  38788. * Gets the bouncing behavior of the camera if it has been enabled.
  38789. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38790. */
  38791. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38792. /**
  38793. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38794. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38795. */
  38796. get useBouncingBehavior(): boolean;
  38797. set useBouncingBehavior(value: boolean);
  38798. private _framingBehavior;
  38799. /**
  38800. * Gets the framing behavior of the camera if it has been enabled.
  38801. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38802. */
  38803. get framingBehavior(): Nullable<FramingBehavior>;
  38804. /**
  38805. * Defines if the framing behavior of the camera is enabled on the camera.
  38806. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38807. */
  38808. get useFramingBehavior(): boolean;
  38809. set useFramingBehavior(value: boolean);
  38810. private _autoRotationBehavior;
  38811. /**
  38812. * Gets the auto rotation behavior of the camera if it has been enabled.
  38813. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38814. */
  38815. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38816. /**
  38817. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38818. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38819. */
  38820. get useAutoRotationBehavior(): boolean;
  38821. set useAutoRotationBehavior(value: boolean);
  38822. /**
  38823. * Observable triggered when the mesh target has been changed on the camera.
  38824. */
  38825. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38826. /**
  38827. * Event raised when the camera is colliding with a mesh.
  38828. */
  38829. onCollide: (collidedMesh: AbstractMesh) => void;
  38830. /**
  38831. * Defines whether the camera should check collision with the objects oh the scene.
  38832. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38833. */
  38834. checkCollisions: boolean;
  38835. /**
  38836. * Defines the collision radius of the camera.
  38837. * This simulates a sphere around the camera.
  38838. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38839. */
  38840. collisionRadius: Vector3;
  38841. protected _collider: Collider;
  38842. protected _previousPosition: Vector3;
  38843. protected _collisionVelocity: Vector3;
  38844. protected _newPosition: Vector3;
  38845. protected _previousAlpha: number;
  38846. protected _previousBeta: number;
  38847. protected _previousRadius: number;
  38848. protected _collisionTriggered: boolean;
  38849. protected _targetBoundingCenter: Nullable<Vector3>;
  38850. private _computationVector;
  38851. /**
  38852. * Instantiates a new ArcRotateCamera in a given scene
  38853. * @param name Defines the name of the camera
  38854. * @param alpha Defines the camera rotation along the logitudinal axis
  38855. * @param beta Defines the camera rotation along the latitudinal axis
  38856. * @param radius Defines the camera distance from its target
  38857. * @param target Defines the camera target
  38858. * @param scene Defines the scene the camera belongs to
  38859. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38860. */
  38861. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38862. /** @hidden */
  38863. _initCache(): void;
  38864. /** @hidden */
  38865. _updateCache(ignoreParentClass?: boolean): void;
  38866. protected _getTargetPosition(): Vector3;
  38867. private _storedAlpha;
  38868. private _storedBeta;
  38869. private _storedRadius;
  38870. private _storedTarget;
  38871. private _storedTargetScreenOffset;
  38872. /**
  38873. * Stores the current state of the camera (alpha, beta, radius and target)
  38874. * @returns the camera itself
  38875. */
  38876. storeState(): Camera;
  38877. /**
  38878. * @hidden
  38879. * Restored camera state. You must call storeState() first
  38880. */
  38881. _restoreStateValues(): boolean;
  38882. /** @hidden */
  38883. _isSynchronizedViewMatrix(): boolean;
  38884. /**
  38885. * Attached controls to the current camera.
  38886. * @param element Defines the element the controls should be listened from
  38887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38888. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38889. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38890. */
  38891. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38892. /**
  38893. * Detach the current controls from the camera.
  38894. * The camera will stop reacting to inputs.
  38895. * @param element Defines the element to stop listening the inputs from
  38896. */
  38897. detachControl(element: HTMLElement): void;
  38898. /** @hidden */
  38899. _checkInputs(): void;
  38900. protected _checkLimits(): void;
  38901. /**
  38902. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38903. */
  38904. rebuildAnglesAndRadius(): void;
  38905. /**
  38906. * Use a position to define the current camera related information like alpha, beta and radius
  38907. * @param position Defines the position to set the camera at
  38908. */
  38909. setPosition(position: Vector3): void;
  38910. /**
  38911. * Defines the target the camera should look at.
  38912. * This will automatically adapt alpha beta and radius to fit within the new target.
  38913. * @param target Defines the new target as a Vector or a mesh
  38914. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  38915. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38916. */
  38917. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38918. /** @hidden */
  38919. _getViewMatrix(): Matrix;
  38920. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38921. /**
  38922. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38923. * @param meshes Defines the mesh to zoom on
  38924. * @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)
  38925. */
  38926. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38927. /**
  38928. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38929. * The target will be changed but the radius
  38930. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38931. * @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)
  38932. */
  38933. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38934. min: Vector3;
  38935. max: Vector3;
  38936. distance: number;
  38937. }, doNotUpdateMaxZ?: boolean): void;
  38938. /**
  38939. * @override
  38940. * Override Camera.createRigCamera
  38941. */
  38942. createRigCamera(name: string, cameraIndex: number): Camera;
  38943. /**
  38944. * @hidden
  38945. * @override
  38946. * Override Camera._updateRigCameras
  38947. */
  38948. _updateRigCameras(): void;
  38949. /**
  38950. * Destroy the camera and release the current resources hold by it.
  38951. */
  38952. dispose(): void;
  38953. /**
  38954. * Gets the current object class name.
  38955. * @return the class name
  38956. */
  38957. getClassName(): string;
  38958. }
  38959. }
  38960. declare module BABYLON {
  38961. /**
  38962. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38963. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38964. */
  38965. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38966. /**
  38967. * Gets the name of the behavior.
  38968. */
  38969. get name(): string;
  38970. private _zoomStopsAnimation;
  38971. private _idleRotationSpeed;
  38972. private _idleRotationWaitTime;
  38973. private _idleRotationSpinupTime;
  38974. /**
  38975. * Sets the flag that indicates if user zooming should stop animation.
  38976. */
  38977. set zoomStopsAnimation(flag: boolean);
  38978. /**
  38979. * Gets the flag that indicates if user zooming should stop animation.
  38980. */
  38981. get zoomStopsAnimation(): boolean;
  38982. /**
  38983. * Sets the default speed at which the camera rotates around the model.
  38984. */
  38985. set idleRotationSpeed(speed: number);
  38986. /**
  38987. * Gets the default speed at which the camera rotates around the model.
  38988. */
  38989. get idleRotationSpeed(): number;
  38990. /**
  38991. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38992. */
  38993. set idleRotationWaitTime(time: number);
  38994. /**
  38995. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38996. */
  38997. get idleRotationWaitTime(): number;
  38998. /**
  38999. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39000. */
  39001. set idleRotationSpinupTime(time: number);
  39002. /**
  39003. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39004. */
  39005. get idleRotationSpinupTime(): number;
  39006. /**
  39007. * Gets a value indicating if the camera is currently rotating because of this behavior
  39008. */
  39009. get rotationInProgress(): boolean;
  39010. private _onPrePointerObservableObserver;
  39011. private _onAfterCheckInputsObserver;
  39012. private _attachedCamera;
  39013. private _isPointerDown;
  39014. private _lastFrameTime;
  39015. private _lastInteractionTime;
  39016. private _cameraRotationSpeed;
  39017. /**
  39018. * Initializes the behavior.
  39019. */
  39020. init(): void;
  39021. /**
  39022. * Attaches the behavior to its arc rotate camera.
  39023. * @param camera Defines the camera to attach the behavior to
  39024. */
  39025. attach(camera: ArcRotateCamera): void;
  39026. /**
  39027. * Detaches the behavior from its current arc rotate camera.
  39028. */
  39029. detach(): void;
  39030. /**
  39031. * Returns true if user is scrolling.
  39032. * @return true if user is scrolling.
  39033. */
  39034. private _userIsZooming;
  39035. private _lastFrameRadius;
  39036. private _shouldAnimationStopForInteraction;
  39037. /**
  39038. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39039. */
  39040. private _applyUserInteraction;
  39041. private _userIsMoving;
  39042. }
  39043. }
  39044. declare module BABYLON {
  39045. /**
  39046. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39047. */
  39048. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39049. private ui;
  39050. /**
  39051. * The name of the behavior
  39052. */
  39053. name: string;
  39054. /**
  39055. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39056. */
  39057. distanceAwayFromFace: number;
  39058. /**
  39059. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39060. */
  39061. distanceAwayFromBottomOfFace: number;
  39062. private _faceVectors;
  39063. private _target;
  39064. private _scene;
  39065. private _onRenderObserver;
  39066. private _tmpMatrix;
  39067. private _tmpVector;
  39068. /**
  39069. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39070. * @param ui The transform node that should be attched to the mesh
  39071. */
  39072. constructor(ui: TransformNode);
  39073. /**
  39074. * Initializes the behavior
  39075. */
  39076. init(): void;
  39077. private _closestFace;
  39078. private _zeroVector;
  39079. private _lookAtTmpMatrix;
  39080. private _lookAtToRef;
  39081. /**
  39082. * Attaches the AttachToBoxBehavior to the passed in mesh
  39083. * @param target The mesh that the specified node will be attached to
  39084. */
  39085. attach(target: Mesh): void;
  39086. /**
  39087. * Detaches the behavior from the mesh
  39088. */
  39089. detach(): void;
  39090. }
  39091. }
  39092. declare module BABYLON {
  39093. /**
  39094. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39095. */
  39096. export class FadeInOutBehavior implements Behavior<Mesh> {
  39097. /**
  39098. * Time in milliseconds to delay before fading in (Default: 0)
  39099. */
  39100. delay: number;
  39101. /**
  39102. * Time in milliseconds for the mesh to fade in (Default: 300)
  39103. */
  39104. fadeInTime: number;
  39105. private _millisecondsPerFrame;
  39106. private _hovered;
  39107. private _hoverValue;
  39108. private _ownerNode;
  39109. /**
  39110. * Instatiates the FadeInOutBehavior
  39111. */
  39112. constructor();
  39113. /**
  39114. * The name of the behavior
  39115. */
  39116. get name(): string;
  39117. /**
  39118. * Initializes the behavior
  39119. */
  39120. init(): void;
  39121. /**
  39122. * Attaches the fade behavior on the passed in mesh
  39123. * @param ownerNode The mesh that will be faded in/out once attached
  39124. */
  39125. attach(ownerNode: Mesh): void;
  39126. /**
  39127. * Detaches the behavior from the mesh
  39128. */
  39129. detach(): void;
  39130. /**
  39131. * Triggers the mesh to begin fading in or out
  39132. * @param value if the object should fade in or out (true to fade in)
  39133. */
  39134. fadeIn(value: boolean): void;
  39135. private _update;
  39136. private _setAllVisibility;
  39137. }
  39138. }
  39139. declare module BABYLON {
  39140. /**
  39141. * Class containing a set of static utilities functions for managing Pivots
  39142. * @hidden
  39143. */
  39144. export class PivotTools {
  39145. private static _PivotCached;
  39146. private static _OldPivotPoint;
  39147. private static _PivotTranslation;
  39148. private static _PivotTmpVector;
  39149. /** @hidden */
  39150. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39151. /** @hidden */
  39152. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39153. }
  39154. }
  39155. declare module BABYLON {
  39156. /**
  39157. * Class containing static functions to help procedurally build meshes
  39158. */
  39159. export class PlaneBuilder {
  39160. /**
  39161. * Creates a plane mesh
  39162. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39163. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39164. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39166. * * 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
  39167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39168. * @param name defines the name of the mesh
  39169. * @param options defines the options used to create the mesh
  39170. * @param scene defines the hosting scene
  39171. * @returns the plane mesh
  39172. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39173. */
  39174. static CreatePlane(name: string, options: {
  39175. size?: number;
  39176. width?: number;
  39177. height?: number;
  39178. sideOrientation?: number;
  39179. frontUVs?: Vector4;
  39180. backUVs?: Vector4;
  39181. updatable?: boolean;
  39182. sourcePlane?: Plane;
  39183. }, scene?: Nullable<Scene>): Mesh;
  39184. }
  39185. }
  39186. declare module BABYLON {
  39187. /**
  39188. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39189. */
  39190. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39191. private static _AnyMouseID;
  39192. /**
  39193. * Abstract mesh the behavior is set on
  39194. */
  39195. attachedNode: AbstractMesh;
  39196. private _dragPlane;
  39197. private _scene;
  39198. private _pointerObserver;
  39199. private _beforeRenderObserver;
  39200. private static _planeScene;
  39201. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39202. /**
  39203. * 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)
  39204. */
  39205. maxDragAngle: number;
  39206. /**
  39207. * @hidden
  39208. */
  39209. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39210. /**
  39211. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39212. */
  39213. currentDraggingPointerID: number;
  39214. /**
  39215. * The last position where the pointer hit the drag plane in world space
  39216. */
  39217. lastDragPosition: Vector3;
  39218. /**
  39219. * If the behavior is currently in a dragging state
  39220. */
  39221. dragging: boolean;
  39222. /**
  39223. * 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)
  39224. */
  39225. dragDeltaRatio: number;
  39226. /**
  39227. * If the drag plane orientation should be updated during the dragging (Default: true)
  39228. */
  39229. updateDragPlane: boolean;
  39230. private _debugMode;
  39231. private _moving;
  39232. /**
  39233. * Fires each time the attached mesh is dragged with the pointer
  39234. * * delta between last drag position and current drag position in world space
  39235. * * dragDistance along the drag axis
  39236. * * dragPlaneNormal normal of the current drag plane used during the drag
  39237. * * dragPlanePoint in world space where the drag intersects the drag plane
  39238. */
  39239. onDragObservable: Observable<{
  39240. delta: Vector3;
  39241. dragPlanePoint: Vector3;
  39242. dragPlaneNormal: Vector3;
  39243. dragDistance: number;
  39244. pointerId: number;
  39245. }>;
  39246. /**
  39247. * Fires each time a drag begins (eg. mouse down on mesh)
  39248. */
  39249. onDragStartObservable: Observable<{
  39250. dragPlanePoint: Vector3;
  39251. pointerId: number;
  39252. }>;
  39253. /**
  39254. * Fires each time a drag ends (eg. mouse release after drag)
  39255. */
  39256. onDragEndObservable: Observable<{
  39257. dragPlanePoint: Vector3;
  39258. pointerId: number;
  39259. }>;
  39260. /**
  39261. * If the attached mesh should be moved when dragged
  39262. */
  39263. moveAttached: boolean;
  39264. /**
  39265. * If the drag behavior will react to drag events (Default: true)
  39266. */
  39267. enabled: boolean;
  39268. /**
  39269. * If pointer events should start and release the drag (Default: true)
  39270. */
  39271. startAndReleaseDragOnPointerEvents: boolean;
  39272. /**
  39273. * If camera controls should be detached during the drag
  39274. */
  39275. detachCameraControls: boolean;
  39276. /**
  39277. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39278. */
  39279. useObjectOrientationForDragging: boolean;
  39280. private _options;
  39281. /**
  39282. * Gets the options used by the behavior
  39283. */
  39284. get options(): {
  39285. dragAxis?: Vector3;
  39286. dragPlaneNormal?: Vector3;
  39287. };
  39288. /**
  39289. * Sets the options used by the behavior
  39290. */
  39291. set options(options: {
  39292. dragAxis?: Vector3;
  39293. dragPlaneNormal?: Vector3;
  39294. });
  39295. /**
  39296. * Creates a pointer drag behavior that can be attached to a mesh
  39297. * @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)
  39298. */
  39299. constructor(options?: {
  39300. dragAxis?: Vector3;
  39301. dragPlaneNormal?: Vector3;
  39302. });
  39303. /**
  39304. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39305. */
  39306. validateDrag: (targetPosition: Vector3) => boolean;
  39307. /**
  39308. * The name of the behavior
  39309. */
  39310. get name(): string;
  39311. /**
  39312. * Initializes the behavior
  39313. */
  39314. init(): void;
  39315. private _tmpVector;
  39316. private _alternatePickedPoint;
  39317. private _worldDragAxis;
  39318. private _targetPosition;
  39319. private _attachedElement;
  39320. /**
  39321. * Attaches the drag behavior the passed in mesh
  39322. * @param ownerNode The mesh that will be dragged around once attached
  39323. * @param predicate Predicate to use for pick filtering
  39324. */
  39325. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39326. /**
  39327. * Force relase the drag action by code.
  39328. */
  39329. releaseDrag(): void;
  39330. private _startDragRay;
  39331. private _lastPointerRay;
  39332. /**
  39333. * Simulates the start of a pointer drag event on the behavior
  39334. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39335. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39336. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39337. */
  39338. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39339. private _startDrag;
  39340. private _dragDelta;
  39341. private _moveDrag;
  39342. private _pickWithRayOnDragPlane;
  39343. private _pointA;
  39344. private _pointB;
  39345. private _pointC;
  39346. private _lineA;
  39347. private _lineB;
  39348. private _localAxis;
  39349. private _lookAt;
  39350. private _updateDragPlanePosition;
  39351. /**
  39352. * Detaches the behavior from the mesh
  39353. */
  39354. detach(): void;
  39355. }
  39356. }
  39357. declare module BABYLON {
  39358. /**
  39359. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39360. */
  39361. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39362. private _dragBehaviorA;
  39363. private _dragBehaviorB;
  39364. private _startDistance;
  39365. private _initialScale;
  39366. private _targetScale;
  39367. private _ownerNode;
  39368. private _sceneRenderObserver;
  39369. /**
  39370. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39371. */
  39372. constructor();
  39373. /**
  39374. * The name of the behavior
  39375. */
  39376. get name(): string;
  39377. /**
  39378. * Initializes the behavior
  39379. */
  39380. init(): void;
  39381. private _getCurrentDistance;
  39382. /**
  39383. * Attaches the scale behavior the passed in mesh
  39384. * @param ownerNode The mesh that will be scaled around once attached
  39385. */
  39386. attach(ownerNode: Mesh): void;
  39387. /**
  39388. * Detaches the behavior from the mesh
  39389. */
  39390. detach(): void;
  39391. }
  39392. }
  39393. declare module BABYLON {
  39394. /**
  39395. * 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
  39396. */
  39397. export class SixDofDragBehavior implements Behavior<Mesh> {
  39398. private static _virtualScene;
  39399. private _ownerNode;
  39400. private _sceneRenderObserver;
  39401. private _scene;
  39402. private _targetPosition;
  39403. private _virtualOriginMesh;
  39404. private _virtualDragMesh;
  39405. private _pointerObserver;
  39406. private _moving;
  39407. private _startingOrientation;
  39408. /**
  39409. * 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)
  39410. */
  39411. private zDragFactor;
  39412. /**
  39413. * If the object should rotate to face the drag origin
  39414. */
  39415. rotateDraggedObject: boolean;
  39416. /**
  39417. * If the behavior is currently in a dragging state
  39418. */
  39419. dragging: boolean;
  39420. /**
  39421. * 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)
  39422. */
  39423. dragDeltaRatio: number;
  39424. /**
  39425. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39426. */
  39427. currentDraggingPointerID: number;
  39428. /**
  39429. * If camera controls should be detached during the drag
  39430. */
  39431. detachCameraControls: boolean;
  39432. /**
  39433. * Fires each time a drag starts
  39434. */
  39435. onDragStartObservable: Observable<{}>;
  39436. /**
  39437. * Fires each time a drag ends (eg. mouse release after drag)
  39438. */
  39439. onDragEndObservable: Observable<{}>;
  39440. /**
  39441. * 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
  39442. */
  39443. constructor();
  39444. /**
  39445. * The name of the behavior
  39446. */
  39447. get name(): string;
  39448. /**
  39449. * Initializes the behavior
  39450. */
  39451. init(): void;
  39452. /**
  39453. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39454. */
  39455. private get _pointerCamera();
  39456. /**
  39457. * Attaches the scale behavior the passed in mesh
  39458. * @param ownerNode The mesh that will be scaled around once attached
  39459. */
  39460. attach(ownerNode: Mesh): void;
  39461. /**
  39462. * Detaches the behavior from the mesh
  39463. */
  39464. detach(): void;
  39465. }
  39466. }
  39467. declare module BABYLON {
  39468. /**
  39469. * Class used to apply inverse kinematics to bones
  39470. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39471. */
  39472. export class BoneIKController {
  39473. private static _tmpVecs;
  39474. private static _tmpQuat;
  39475. private static _tmpMats;
  39476. /**
  39477. * Gets or sets the target mesh
  39478. */
  39479. targetMesh: AbstractMesh;
  39480. /** Gets or sets the mesh used as pole */
  39481. poleTargetMesh: AbstractMesh;
  39482. /**
  39483. * Gets or sets the bone used as pole
  39484. */
  39485. poleTargetBone: Nullable<Bone>;
  39486. /**
  39487. * Gets or sets the target position
  39488. */
  39489. targetPosition: Vector3;
  39490. /**
  39491. * Gets or sets the pole target position
  39492. */
  39493. poleTargetPosition: Vector3;
  39494. /**
  39495. * Gets or sets the pole target local offset
  39496. */
  39497. poleTargetLocalOffset: Vector3;
  39498. /**
  39499. * Gets or sets the pole angle
  39500. */
  39501. poleAngle: number;
  39502. /**
  39503. * Gets or sets the mesh associated with the controller
  39504. */
  39505. mesh: AbstractMesh;
  39506. /**
  39507. * 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)
  39508. */
  39509. slerpAmount: number;
  39510. private _bone1Quat;
  39511. private _bone1Mat;
  39512. private _bone2Ang;
  39513. private _bone1;
  39514. private _bone2;
  39515. private _bone1Length;
  39516. private _bone2Length;
  39517. private _maxAngle;
  39518. private _maxReach;
  39519. private _rightHandedSystem;
  39520. private _bendAxis;
  39521. private _slerping;
  39522. private _adjustRoll;
  39523. /**
  39524. * Gets or sets maximum allowed angle
  39525. */
  39526. get maxAngle(): number;
  39527. set maxAngle(value: number);
  39528. /**
  39529. * Creates a new BoneIKController
  39530. * @param mesh defines the mesh to control
  39531. * @param bone defines the bone to control
  39532. * @param options defines options to set up the controller
  39533. */
  39534. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39535. targetMesh?: AbstractMesh;
  39536. poleTargetMesh?: AbstractMesh;
  39537. poleTargetBone?: Bone;
  39538. poleTargetLocalOffset?: Vector3;
  39539. poleAngle?: number;
  39540. bendAxis?: Vector3;
  39541. maxAngle?: number;
  39542. slerpAmount?: number;
  39543. });
  39544. private _setMaxAngle;
  39545. /**
  39546. * Force the controller to update the bones
  39547. */
  39548. update(): void;
  39549. }
  39550. }
  39551. declare module BABYLON {
  39552. /**
  39553. * Class used to make a bone look toward a point in space
  39554. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39555. */
  39556. export class BoneLookController {
  39557. private static _tmpVecs;
  39558. private static _tmpQuat;
  39559. private static _tmpMats;
  39560. /**
  39561. * The target Vector3 that the bone will look at
  39562. */
  39563. target: Vector3;
  39564. /**
  39565. * The mesh that the bone is attached to
  39566. */
  39567. mesh: AbstractMesh;
  39568. /**
  39569. * The bone that will be looking to the target
  39570. */
  39571. bone: Bone;
  39572. /**
  39573. * The up axis of the coordinate system that is used when the bone is rotated
  39574. */
  39575. upAxis: Vector3;
  39576. /**
  39577. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39578. */
  39579. upAxisSpace: Space;
  39580. /**
  39581. * Used to make an adjustment to the yaw of the bone
  39582. */
  39583. adjustYaw: number;
  39584. /**
  39585. * Used to make an adjustment to the pitch of the bone
  39586. */
  39587. adjustPitch: number;
  39588. /**
  39589. * Used to make an adjustment to the roll of the bone
  39590. */
  39591. adjustRoll: number;
  39592. /**
  39593. * 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)
  39594. */
  39595. slerpAmount: number;
  39596. private _minYaw;
  39597. private _maxYaw;
  39598. private _minPitch;
  39599. private _maxPitch;
  39600. private _minYawSin;
  39601. private _minYawCos;
  39602. private _maxYawSin;
  39603. private _maxYawCos;
  39604. private _midYawConstraint;
  39605. private _minPitchTan;
  39606. private _maxPitchTan;
  39607. private _boneQuat;
  39608. private _slerping;
  39609. private _transformYawPitch;
  39610. private _transformYawPitchInv;
  39611. private _firstFrameSkipped;
  39612. private _yawRange;
  39613. private _fowardAxis;
  39614. /**
  39615. * Gets or sets the minimum yaw angle that the bone can look to
  39616. */
  39617. get minYaw(): number;
  39618. set minYaw(value: number);
  39619. /**
  39620. * Gets or sets the maximum yaw angle that the bone can look to
  39621. */
  39622. get maxYaw(): number;
  39623. set maxYaw(value: number);
  39624. /**
  39625. * Gets or sets the minimum pitch angle that the bone can look to
  39626. */
  39627. get minPitch(): number;
  39628. set minPitch(value: number);
  39629. /**
  39630. * Gets or sets the maximum pitch angle that the bone can look to
  39631. */
  39632. get maxPitch(): number;
  39633. set maxPitch(value: number);
  39634. /**
  39635. * Create a BoneLookController
  39636. * @param mesh the mesh that the bone belongs to
  39637. * @param bone the bone that will be looking to the target
  39638. * @param target the target Vector3 to look at
  39639. * @param options optional settings:
  39640. * * maxYaw: the maximum angle the bone will yaw to
  39641. * * minYaw: the minimum angle the bone will yaw to
  39642. * * maxPitch: the maximum angle the bone will pitch to
  39643. * * minPitch: the minimum angle the bone will yaw to
  39644. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39645. * * upAxis: the up axis of the coordinate system
  39646. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39647. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39648. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39649. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39650. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39651. * * adjustRoll: used to make an adjustment to the roll of the bone
  39652. **/
  39653. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39654. maxYaw?: number;
  39655. minYaw?: number;
  39656. maxPitch?: number;
  39657. minPitch?: number;
  39658. slerpAmount?: number;
  39659. upAxis?: Vector3;
  39660. upAxisSpace?: Space;
  39661. yawAxis?: Vector3;
  39662. pitchAxis?: Vector3;
  39663. adjustYaw?: number;
  39664. adjustPitch?: number;
  39665. adjustRoll?: number;
  39666. });
  39667. /**
  39668. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39669. */
  39670. update(): void;
  39671. private _getAngleDiff;
  39672. private _getAngleBetween;
  39673. private _isAngleBetween;
  39674. }
  39675. }
  39676. declare module BABYLON {
  39677. /**
  39678. * Manage the gamepad inputs to control an arc rotate camera.
  39679. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39680. */
  39681. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39682. /**
  39683. * Defines the camera the input is attached to.
  39684. */
  39685. camera: ArcRotateCamera;
  39686. /**
  39687. * Defines the gamepad the input is gathering event from.
  39688. */
  39689. gamepad: Nullable<Gamepad>;
  39690. /**
  39691. * Defines the gamepad rotation sensiblity.
  39692. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39693. */
  39694. gamepadRotationSensibility: number;
  39695. /**
  39696. * Defines the gamepad move sensiblity.
  39697. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39698. */
  39699. gamepadMoveSensibility: number;
  39700. private _yAxisScale;
  39701. /**
  39702. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39703. */
  39704. get invertYAxis(): boolean;
  39705. set invertYAxis(value: boolean);
  39706. private _onGamepadConnectedObserver;
  39707. private _onGamepadDisconnectedObserver;
  39708. /**
  39709. * Attach the input controls to a specific dom element to get the input from.
  39710. * @param element Defines the element the controls should be listened from
  39711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39712. */
  39713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39714. /**
  39715. * Detach the current controls from the specified dom element.
  39716. * @param element Defines the element to stop listening the inputs from
  39717. */
  39718. detachControl(element: Nullable<HTMLElement>): void;
  39719. /**
  39720. * Update the current camera state depending on the inputs that have been used this frame.
  39721. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39722. */
  39723. checkInputs(): void;
  39724. /**
  39725. * Gets the class name of the current intput.
  39726. * @returns the class name
  39727. */
  39728. getClassName(): string;
  39729. /**
  39730. * Get the friendly name associated with the input class.
  39731. * @returns the input friendly name
  39732. */
  39733. getSimpleName(): string;
  39734. }
  39735. }
  39736. declare module BABYLON {
  39737. interface ArcRotateCameraInputsManager {
  39738. /**
  39739. * Add orientation input support to the input manager.
  39740. * @returns the current input manager
  39741. */
  39742. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39743. }
  39744. /**
  39745. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39747. */
  39748. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39749. /**
  39750. * Defines the camera the input is attached to.
  39751. */
  39752. camera: ArcRotateCamera;
  39753. /**
  39754. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39755. */
  39756. alphaCorrection: number;
  39757. /**
  39758. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39759. */
  39760. gammaCorrection: number;
  39761. private _alpha;
  39762. private _gamma;
  39763. private _dirty;
  39764. private _deviceOrientationHandler;
  39765. /**
  39766. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39767. */
  39768. constructor();
  39769. /**
  39770. * Attach the input controls to a specific dom element to get the input from.
  39771. * @param element Defines the element the controls should be listened from
  39772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39773. */
  39774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39775. /** @hidden */
  39776. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39777. /**
  39778. * Update the current camera state depending on the inputs that have been used this frame.
  39779. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39780. */
  39781. checkInputs(): void;
  39782. /**
  39783. * Detach the current controls from the specified dom element.
  39784. * @param element Defines the element to stop listening the inputs from
  39785. */
  39786. detachControl(element: Nullable<HTMLElement>): void;
  39787. /**
  39788. * Gets the class name of the current intput.
  39789. * @returns the class name
  39790. */
  39791. getClassName(): string;
  39792. /**
  39793. * Get the friendly name associated with the input class.
  39794. * @returns the input friendly name
  39795. */
  39796. getSimpleName(): string;
  39797. }
  39798. }
  39799. declare module BABYLON {
  39800. /**
  39801. * Listen to mouse events to control the camera.
  39802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39803. */
  39804. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39805. /**
  39806. * Defines the camera the input is attached to.
  39807. */
  39808. camera: FlyCamera;
  39809. /**
  39810. * Defines if touch is enabled. (Default is true.)
  39811. */
  39812. touchEnabled: boolean;
  39813. /**
  39814. * Defines the buttons associated with the input to handle camera rotation.
  39815. */
  39816. buttons: number[];
  39817. /**
  39818. * Assign buttons for Yaw control.
  39819. */
  39820. buttonsYaw: number[];
  39821. /**
  39822. * Assign buttons for Pitch control.
  39823. */
  39824. buttonsPitch: number[];
  39825. /**
  39826. * Assign buttons for Roll control.
  39827. */
  39828. buttonsRoll: number[];
  39829. /**
  39830. * Detect if any button is being pressed while mouse is moved.
  39831. * -1 = Mouse locked.
  39832. * 0 = Left button.
  39833. * 1 = Middle Button.
  39834. * 2 = Right Button.
  39835. */
  39836. activeButton: number;
  39837. /**
  39838. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39839. * Higher values reduce its sensitivity.
  39840. */
  39841. angularSensibility: number;
  39842. private _mousemoveCallback;
  39843. private _observer;
  39844. private _rollObserver;
  39845. private previousPosition;
  39846. private noPreventDefault;
  39847. private element;
  39848. /**
  39849. * Listen to mouse events to control the camera.
  39850. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39851. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39852. */
  39853. constructor(touchEnabled?: boolean);
  39854. /**
  39855. * Attach the mouse control to the HTML DOM element.
  39856. * @param element Defines the element that listens to the input events.
  39857. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39858. */
  39859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39860. /**
  39861. * Detach the current controls from the specified dom element.
  39862. * @param element Defines the element to stop listening the inputs from
  39863. */
  39864. detachControl(element: Nullable<HTMLElement>): void;
  39865. /**
  39866. * Gets the class name of the current input.
  39867. * @returns the class name.
  39868. */
  39869. getClassName(): string;
  39870. /**
  39871. * Get the friendly name associated with the input class.
  39872. * @returns the input's friendly name.
  39873. */
  39874. getSimpleName(): string;
  39875. private _pointerInput;
  39876. private _onMouseMove;
  39877. /**
  39878. * Rotate camera by mouse offset.
  39879. */
  39880. private rotateCamera;
  39881. }
  39882. }
  39883. declare module BABYLON {
  39884. /**
  39885. * Default Inputs manager for the FlyCamera.
  39886. * It groups all the default supported inputs for ease of use.
  39887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39888. */
  39889. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39890. /**
  39891. * Instantiates a new FlyCameraInputsManager.
  39892. * @param camera Defines the camera the inputs belong to.
  39893. */
  39894. constructor(camera: FlyCamera);
  39895. /**
  39896. * Add keyboard input support to the input manager.
  39897. * @returns the new FlyCameraKeyboardMoveInput().
  39898. */
  39899. addKeyboard(): FlyCameraInputsManager;
  39900. /**
  39901. * Add mouse input support to the input manager.
  39902. * @param touchEnabled Enable touch screen support.
  39903. * @returns the new FlyCameraMouseInput().
  39904. */
  39905. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39906. }
  39907. }
  39908. declare module BABYLON {
  39909. /**
  39910. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39911. * such as in a 3D Space Shooter or a Flight Simulator.
  39912. */
  39913. export class FlyCamera extends TargetCamera {
  39914. /**
  39915. * Define the collision ellipsoid of the camera.
  39916. * This is helpful for simulating a camera body, like a player's body.
  39917. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39918. */
  39919. ellipsoid: Vector3;
  39920. /**
  39921. * Define an offset for the position of the ellipsoid around the camera.
  39922. * This can be helpful if the camera is attached away from the player's body center,
  39923. * such as at its head.
  39924. */
  39925. ellipsoidOffset: Vector3;
  39926. /**
  39927. * Enable or disable collisions of the camera with the rest of the scene objects.
  39928. */
  39929. checkCollisions: boolean;
  39930. /**
  39931. * Enable or disable gravity on the camera.
  39932. */
  39933. applyGravity: boolean;
  39934. /**
  39935. * Define the current direction the camera is moving to.
  39936. */
  39937. cameraDirection: Vector3;
  39938. /**
  39939. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39940. * This overrides and empties cameraRotation.
  39941. */
  39942. rotationQuaternion: Quaternion;
  39943. /**
  39944. * Track Roll to maintain the wanted Rolling when looking around.
  39945. */
  39946. _trackRoll: number;
  39947. /**
  39948. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39949. */
  39950. rollCorrect: number;
  39951. /**
  39952. * Mimic a banked turn, Rolling the camera when Yawing.
  39953. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39954. */
  39955. bankedTurn: boolean;
  39956. /**
  39957. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39958. */
  39959. bankedTurnLimit: number;
  39960. /**
  39961. * Value of 0 disables the banked Roll.
  39962. * Value of 1 is equal to the Yaw angle in radians.
  39963. */
  39964. bankedTurnMultiplier: number;
  39965. /**
  39966. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39967. */
  39968. inputs: FlyCameraInputsManager;
  39969. /**
  39970. * Gets the input sensibility for mouse input.
  39971. * Higher values reduce sensitivity.
  39972. */
  39973. get angularSensibility(): number;
  39974. /**
  39975. * Sets the input sensibility for a mouse input.
  39976. * Higher values reduce sensitivity.
  39977. */
  39978. set angularSensibility(value: number);
  39979. /**
  39980. * Get the keys for camera movement forward.
  39981. */
  39982. get keysForward(): number[];
  39983. /**
  39984. * Set the keys for camera movement forward.
  39985. */
  39986. set keysForward(value: number[]);
  39987. /**
  39988. * Get the keys for camera movement backward.
  39989. */
  39990. get keysBackward(): number[];
  39991. set keysBackward(value: number[]);
  39992. /**
  39993. * Get the keys for camera movement up.
  39994. */
  39995. get keysUp(): number[];
  39996. /**
  39997. * Set the keys for camera movement up.
  39998. */
  39999. set keysUp(value: number[]);
  40000. /**
  40001. * Get the keys for camera movement down.
  40002. */
  40003. get keysDown(): number[];
  40004. /**
  40005. * Set the keys for camera movement down.
  40006. */
  40007. set keysDown(value: number[]);
  40008. /**
  40009. * Get the keys for camera movement left.
  40010. */
  40011. get keysLeft(): number[];
  40012. /**
  40013. * Set the keys for camera movement left.
  40014. */
  40015. set keysLeft(value: number[]);
  40016. /**
  40017. * Set the keys for camera movement right.
  40018. */
  40019. get keysRight(): number[];
  40020. /**
  40021. * Set the keys for camera movement right.
  40022. */
  40023. set keysRight(value: number[]);
  40024. /**
  40025. * Event raised when the camera collides with a mesh in the scene.
  40026. */
  40027. onCollide: (collidedMesh: AbstractMesh) => void;
  40028. private _collider;
  40029. private _needMoveForGravity;
  40030. private _oldPosition;
  40031. private _diffPosition;
  40032. private _newPosition;
  40033. /** @hidden */
  40034. _localDirection: Vector3;
  40035. /** @hidden */
  40036. _transformedDirection: Vector3;
  40037. /**
  40038. * Instantiates a FlyCamera.
  40039. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40040. * such as in a 3D Space Shooter or a Flight Simulator.
  40041. * @param name Define the name of the camera in the scene.
  40042. * @param position Define the starting position of the camera in the scene.
  40043. * @param scene Define the scene the camera belongs to.
  40044. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40045. */
  40046. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40047. /**
  40048. * Attach a control to the HTML DOM element.
  40049. * @param element Defines the element that listens to the input events.
  40050. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40051. */
  40052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40053. /**
  40054. * Detach a control from the HTML DOM element.
  40055. * The camera will stop reacting to that input.
  40056. * @param element Defines the element that listens to the input events.
  40057. */
  40058. detachControl(element: HTMLElement): void;
  40059. private _collisionMask;
  40060. /**
  40061. * Get the mask that the camera ignores in collision events.
  40062. */
  40063. get collisionMask(): number;
  40064. /**
  40065. * Set the mask that the camera ignores in collision events.
  40066. */
  40067. set collisionMask(mask: number);
  40068. /** @hidden */
  40069. _collideWithWorld(displacement: Vector3): void;
  40070. /** @hidden */
  40071. private _onCollisionPositionChange;
  40072. /** @hidden */
  40073. _checkInputs(): void;
  40074. /** @hidden */
  40075. _decideIfNeedsToMove(): boolean;
  40076. /** @hidden */
  40077. _updatePosition(): void;
  40078. /**
  40079. * Restore the Roll to its target value at the rate specified.
  40080. * @param rate - Higher means slower restoring.
  40081. * @hidden
  40082. */
  40083. restoreRoll(rate: number): void;
  40084. /**
  40085. * Destroy the camera and release the current resources held by it.
  40086. */
  40087. dispose(): void;
  40088. /**
  40089. * Get the current object class name.
  40090. * @returns the class name.
  40091. */
  40092. getClassName(): string;
  40093. }
  40094. }
  40095. declare module BABYLON {
  40096. /**
  40097. * Listen to keyboard events to control the camera.
  40098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40099. */
  40100. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40101. /**
  40102. * Defines the camera the input is attached to.
  40103. */
  40104. camera: FlyCamera;
  40105. /**
  40106. * The list of keyboard keys used to control the forward move of the camera.
  40107. */
  40108. keysForward: number[];
  40109. /**
  40110. * The list of keyboard keys used to control the backward move of the camera.
  40111. */
  40112. keysBackward: number[];
  40113. /**
  40114. * The list of keyboard keys used to control the forward move of the camera.
  40115. */
  40116. keysUp: number[];
  40117. /**
  40118. * The list of keyboard keys used to control the backward move of the camera.
  40119. */
  40120. keysDown: number[];
  40121. /**
  40122. * The list of keyboard keys used to control the right strafe move of the camera.
  40123. */
  40124. keysRight: number[];
  40125. /**
  40126. * The list of keyboard keys used to control the left strafe move of the camera.
  40127. */
  40128. keysLeft: number[];
  40129. private _keys;
  40130. private _onCanvasBlurObserver;
  40131. private _onKeyboardObserver;
  40132. private _engine;
  40133. private _scene;
  40134. /**
  40135. * Attach the input controls to a specific dom element to get the input from.
  40136. * @param element Defines the element the controls should be listened from
  40137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40138. */
  40139. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40140. /**
  40141. * Detach the current controls from the specified dom element.
  40142. * @param element Defines the element to stop listening the inputs from
  40143. */
  40144. detachControl(element: Nullable<HTMLElement>): void;
  40145. /**
  40146. * Gets the class name of the current intput.
  40147. * @returns the class name
  40148. */
  40149. getClassName(): string;
  40150. /** @hidden */
  40151. _onLostFocus(e: FocusEvent): void;
  40152. /**
  40153. * Get the friendly name associated with the input class.
  40154. * @returns the input friendly name
  40155. */
  40156. getSimpleName(): string;
  40157. /**
  40158. * Update the current camera state depending on the inputs that have been used this frame.
  40159. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40160. */
  40161. checkInputs(): void;
  40162. }
  40163. }
  40164. declare module BABYLON {
  40165. /**
  40166. * Manage the mouse wheel inputs to control a follow camera.
  40167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40168. */
  40169. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40170. /**
  40171. * Defines the camera the input is attached to.
  40172. */
  40173. camera: FollowCamera;
  40174. /**
  40175. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40176. */
  40177. axisControlRadius: boolean;
  40178. /**
  40179. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40180. */
  40181. axisControlHeight: boolean;
  40182. /**
  40183. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40184. */
  40185. axisControlRotation: boolean;
  40186. /**
  40187. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40188. * relation to mouseWheel events.
  40189. */
  40190. wheelPrecision: number;
  40191. /**
  40192. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40193. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40194. */
  40195. wheelDeltaPercentage: number;
  40196. private _wheel;
  40197. private _observer;
  40198. /**
  40199. * Attach the input controls to a specific dom element to get the input from.
  40200. * @param element Defines the element the controls should be listened from
  40201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40202. */
  40203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40204. /**
  40205. * Detach the current controls from the specified dom element.
  40206. * @param element Defines the element to stop listening the inputs from
  40207. */
  40208. detachControl(element: Nullable<HTMLElement>): void;
  40209. /**
  40210. * Gets the class name of the current intput.
  40211. * @returns the class name
  40212. */
  40213. getClassName(): string;
  40214. /**
  40215. * Get the friendly name associated with the input class.
  40216. * @returns the input friendly name
  40217. */
  40218. getSimpleName(): string;
  40219. }
  40220. }
  40221. declare module BABYLON {
  40222. /**
  40223. * Manage the pointers inputs to control an follow camera.
  40224. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40225. */
  40226. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40227. /**
  40228. * Defines the camera the input is attached to.
  40229. */
  40230. camera: FollowCamera;
  40231. /**
  40232. * Gets the class name of the current input.
  40233. * @returns the class name
  40234. */
  40235. getClassName(): string;
  40236. /**
  40237. * Defines the pointer angular sensibility along the X axis or how fast is
  40238. * the camera rotating.
  40239. * A negative number will reverse the axis direction.
  40240. */
  40241. angularSensibilityX: number;
  40242. /**
  40243. * Defines the pointer angular sensibility along the Y axis or how fast is
  40244. * the camera rotating.
  40245. * A negative number will reverse the axis direction.
  40246. */
  40247. angularSensibilityY: number;
  40248. /**
  40249. * Defines the pointer pinch precision or how fast is the camera zooming.
  40250. * A negative number will reverse the axis direction.
  40251. */
  40252. pinchPrecision: number;
  40253. /**
  40254. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40255. * from 0.
  40256. * It defines the percentage of current camera.radius to use as delta when
  40257. * pinch zoom is used.
  40258. */
  40259. pinchDeltaPercentage: number;
  40260. /**
  40261. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40262. */
  40263. axisXControlRadius: boolean;
  40264. /**
  40265. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40266. */
  40267. axisXControlHeight: boolean;
  40268. /**
  40269. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40270. */
  40271. axisXControlRotation: boolean;
  40272. /**
  40273. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40274. */
  40275. axisYControlRadius: boolean;
  40276. /**
  40277. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40278. */
  40279. axisYControlHeight: boolean;
  40280. /**
  40281. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40282. */
  40283. axisYControlRotation: boolean;
  40284. /**
  40285. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40286. */
  40287. axisPinchControlRadius: boolean;
  40288. /**
  40289. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40290. */
  40291. axisPinchControlHeight: boolean;
  40292. /**
  40293. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40294. */
  40295. axisPinchControlRotation: boolean;
  40296. /**
  40297. * Log error messages if basic misconfiguration has occurred.
  40298. */
  40299. warningEnable: boolean;
  40300. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40301. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40302. private _warningCounter;
  40303. private _warning;
  40304. }
  40305. }
  40306. declare module BABYLON {
  40307. /**
  40308. * Default Inputs manager for the FollowCamera.
  40309. * It groups all the default supported inputs for ease of use.
  40310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40311. */
  40312. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40313. /**
  40314. * Instantiates a new FollowCameraInputsManager.
  40315. * @param camera Defines the camera the inputs belong to
  40316. */
  40317. constructor(camera: FollowCamera);
  40318. /**
  40319. * Add keyboard input support to the input manager.
  40320. * @returns the current input manager
  40321. */
  40322. addKeyboard(): FollowCameraInputsManager;
  40323. /**
  40324. * Add mouse wheel input support to the input manager.
  40325. * @returns the current input manager
  40326. */
  40327. addMouseWheel(): FollowCameraInputsManager;
  40328. /**
  40329. * Add pointers input support to the input manager.
  40330. * @returns the current input manager
  40331. */
  40332. addPointers(): FollowCameraInputsManager;
  40333. /**
  40334. * Add orientation input support to the input manager.
  40335. * @returns the current input manager
  40336. */
  40337. addVRDeviceOrientation(): FollowCameraInputsManager;
  40338. }
  40339. }
  40340. declare module BABYLON {
  40341. /**
  40342. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40343. * an arc rotate version arcFollowCamera are available.
  40344. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40345. */
  40346. export class FollowCamera extends TargetCamera {
  40347. /**
  40348. * Distance the follow camera should follow an object at
  40349. */
  40350. radius: number;
  40351. /**
  40352. * Minimum allowed distance of the camera to the axis of rotation
  40353. * (The camera can not get closer).
  40354. * This can help limiting how the Camera is able to move in the scene.
  40355. */
  40356. lowerRadiusLimit: Nullable<number>;
  40357. /**
  40358. * Maximum allowed distance of the camera to the axis of rotation
  40359. * (The camera can not get further).
  40360. * This can help limiting how the Camera is able to move in the scene.
  40361. */
  40362. upperRadiusLimit: Nullable<number>;
  40363. /**
  40364. * Define a rotation offset between the camera and the object it follows
  40365. */
  40366. rotationOffset: number;
  40367. /**
  40368. * Minimum allowed angle to camera position relative to target object.
  40369. * This can help limiting how the Camera is able to move in the scene.
  40370. */
  40371. lowerRotationOffsetLimit: Nullable<number>;
  40372. /**
  40373. * Maximum allowed angle to camera position relative to target object.
  40374. * This can help limiting how the Camera is able to move in the scene.
  40375. */
  40376. upperRotationOffsetLimit: Nullable<number>;
  40377. /**
  40378. * Define a height offset between the camera and the object it follows.
  40379. * It can help following an object from the top (like a car chaing a plane)
  40380. */
  40381. heightOffset: number;
  40382. /**
  40383. * Minimum allowed height of camera position relative to target object.
  40384. * This can help limiting how the Camera is able to move in the scene.
  40385. */
  40386. lowerHeightOffsetLimit: Nullable<number>;
  40387. /**
  40388. * Maximum allowed height of camera position relative to target object.
  40389. * This can help limiting how the Camera is able to move in the scene.
  40390. */
  40391. upperHeightOffsetLimit: Nullable<number>;
  40392. /**
  40393. * Define how fast the camera can accelerate to follow it s target.
  40394. */
  40395. cameraAcceleration: number;
  40396. /**
  40397. * Define the speed limit of the camera following an object.
  40398. */
  40399. maxCameraSpeed: number;
  40400. /**
  40401. * Define the target of the camera.
  40402. */
  40403. lockedTarget: Nullable<AbstractMesh>;
  40404. /**
  40405. * Defines the input associated with the camera.
  40406. */
  40407. inputs: FollowCameraInputsManager;
  40408. /**
  40409. * Instantiates the follow camera.
  40410. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40411. * @param name Define the name of the camera in the scene
  40412. * @param position Define the position of the camera
  40413. * @param scene Define the scene the camera belong to
  40414. * @param lockedTarget Define the target of the camera
  40415. */
  40416. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40417. private _follow;
  40418. /**
  40419. * Attached controls to the current camera.
  40420. * @param element Defines the element the controls should be listened from
  40421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40422. */
  40423. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40424. /**
  40425. * Detach the current controls from the camera.
  40426. * The camera will stop reacting to inputs.
  40427. * @param element Defines the element to stop listening the inputs from
  40428. */
  40429. detachControl(element: HTMLElement): void;
  40430. /** @hidden */
  40431. _checkInputs(): void;
  40432. private _checkLimits;
  40433. /**
  40434. * Gets the camera class name.
  40435. * @returns the class name
  40436. */
  40437. getClassName(): string;
  40438. }
  40439. /**
  40440. * Arc Rotate version of the follow camera.
  40441. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40442. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40443. */
  40444. export class ArcFollowCamera extends TargetCamera {
  40445. /** The longitudinal angle of the camera */
  40446. alpha: number;
  40447. /** The latitudinal angle of the camera */
  40448. beta: number;
  40449. /** The radius of the camera from its target */
  40450. radius: number;
  40451. /** Define the camera target (the messh it should follow) */
  40452. target: Nullable<AbstractMesh>;
  40453. private _cartesianCoordinates;
  40454. /**
  40455. * Instantiates a new ArcFollowCamera
  40456. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40457. * @param name Define the name of the camera
  40458. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40459. * @param beta Define the rotation angle of the camera around the elevation axis
  40460. * @param radius Define the radius of the camera from its target point
  40461. * @param target Define the target of the camera
  40462. * @param scene Define the scene the camera belongs to
  40463. */
  40464. constructor(name: string,
  40465. /** The longitudinal angle of the camera */
  40466. alpha: number,
  40467. /** The latitudinal angle of the camera */
  40468. beta: number,
  40469. /** The radius of the camera from its target */
  40470. radius: number,
  40471. /** Define the camera target (the messh it should follow) */
  40472. target: Nullable<AbstractMesh>, scene: Scene);
  40473. private _follow;
  40474. /** @hidden */
  40475. _checkInputs(): void;
  40476. /**
  40477. * Returns the class name of the object.
  40478. * It is mostly used internally for serialization purposes.
  40479. */
  40480. getClassName(): string;
  40481. }
  40482. }
  40483. declare module BABYLON {
  40484. /**
  40485. * Manage the keyboard inputs to control the movement of a follow camera.
  40486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40487. */
  40488. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40489. /**
  40490. * Defines the camera the input is attached to.
  40491. */
  40492. camera: FollowCamera;
  40493. /**
  40494. * Defines the list of key codes associated with the up action (increase heightOffset)
  40495. */
  40496. keysHeightOffsetIncr: number[];
  40497. /**
  40498. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40499. */
  40500. keysHeightOffsetDecr: number[];
  40501. /**
  40502. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40503. */
  40504. keysHeightOffsetModifierAlt: boolean;
  40505. /**
  40506. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40507. */
  40508. keysHeightOffsetModifierCtrl: boolean;
  40509. /**
  40510. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40511. */
  40512. keysHeightOffsetModifierShift: boolean;
  40513. /**
  40514. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40515. */
  40516. keysRotationOffsetIncr: number[];
  40517. /**
  40518. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40519. */
  40520. keysRotationOffsetDecr: number[];
  40521. /**
  40522. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40523. */
  40524. keysRotationOffsetModifierAlt: boolean;
  40525. /**
  40526. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40527. */
  40528. keysRotationOffsetModifierCtrl: boolean;
  40529. /**
  40530. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40531. */
  40532. keysRotationOffsetModifierShift: boolean;
  40533. /**
  40534. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40535. */
  40536. keysRadiusIncr: number[];
  40537. /**
  40538. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40539. */
  40540. keysRadiusDecr: number[];
  40541. /**
  40542. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40543. */
  40544. keysRadiusModifierAlt: boolean;
  40545. /**
  40546. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40547. */
  40548. keysRadiusModifierCtrl: boolean;
  40549. /**
  40550. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40551. */
  40552. keysRadiusModifierShift: boolean;
  40553. /**
  40554. * Defines the rate of change of heightOffset.
  40555. */
  40556. heightSensibility: number;
  40557. /**
  40558. * Defines the rate of change of rotationOffset.
  40559. */
  40560. rotationSensibility: number;
  40561. /**
  40562. * Defines the rate of change of radius.
  40563. */
  40564. radiusSensibility: number;
  40565. private _keys;
  40566. private _ctrlPressed;
  40567. private _altPressed;
  40568. private _shiftPressed;
  40569. private _onCanvasBlurObserver;
  40570. private _onKeyboardObserver;
  40571. private _engine;
  40572. private _scene;
  40573. /**
  40574. * Attach the input controls to a specific dom element to get the input from.
  40575. * @param element Defines the element the controls should be listened from
  40576. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40577. */
  40578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40579. /**
  40580. * Detach the current controls from the specified dom element.
  40581. * @param element Defines the element to stop listening the inputs from
  40582. */
  40583. detachControl(element: Nullable<HTMLElement>): void;
  40584. /**
  40585. * Update the current camera state depending on the inputs that have been used this frame.
  40586. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40587. */
  40588. checkInputs(): void;
  40589. /**
  40590. * Gets the class name of the current input.
  40591. * @returns the class name
  40592. */
  40593. getClassName(): string;
  40594. /**
  40595. * Get the friendly name associated with the input class.
  40596. * @returns the input friendly name
  40597. */
  40598. getSimpleName(): string;
  40599. /**
  40600. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40601. * allow modification of the heightOffset value.
  40602. */
  40603. private _modifierHeightOffset;
  40604. /**
  40605. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40606. * allow modification of the rotationOffset value.
  40607. */
  40608. private _modifierRotationOffset;
  40609. /**
  40610. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40611. * allow modification of the radius value.
  40612. */
  40613. private _modifierRadius;
  40614. }
  40615. }
  40616. declare module BABYLON {
  40617. interface FreeCameraInputsManager {
  40618. /**
  40619. * @hidden
  40620. */
  40621. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40622. /**
  40623. * Add orientation input support to the input manager.
  40624. * @returns the current input manager
  40625. */
  40626. addDeviceOrientation(): FreeCameraInputsManager;
  40627. }
  40628. /**
  40629. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40630. * Screen rotation is taken into account.
  40631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40632. */
  40633. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40634. private _camera;
  40635. private _screenOrientationAngle;
  40636. private _constantTranform;
  40637. private _screenQuaternion;
  40638. private _alpha;
  40639. private _beta;
  40640. private _gamma;
  40641. /**
  40642. * Can be used to detect if a device orientation sensor is available on a device
  40643. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40644. * @returns a promise that will resolve on orientation change
  40645. */
  40646. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40647. /**
  40648. * @hidden
  40649. */
  40650. _onDeviceOrientationChangedObservable: Observable<void>;
  40651. /**
  40652. * Instantiates a new input
  40653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40654. */
  40655. constructor();
  40656. /**
  40657. * Define the camera controlled by the input.
  40658. */
  40659. get camera(): FreeCamera;
  40660. set camera(camera: FreeCamera);
  40661. /**
  40662. * Attach the input controls to a specific dom element to get the input from.
  40663. * @param element Defines the element the controls should be listened from
  40664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40665. */
  40666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40667. private _orientationChanged;
  40668. private _deviceOrientation;
  40669. /**
  40670. * Detach the current controls from the specified dom element.
  40671. * @param element Defines the element to stop listening the inputs from
  40672. */
  40673. detachControl(element: Nullable<HTMLElement>): void;
  40674. /**
  40675. * Update the current camera state depending on the inputs that have been used this frame.
  40676. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40677. */
  40678. checkInputs(): void;
  40679. /**
  40680. * Gets the class name of the current intput.
  40681. * @returns the class name
  40682. */
  40683. getClassName(): string;
  40684. /**
  40685. * Get the friendly name associated with the input class.
  40686. * @returns the input friendly name
  40687. */
  40688. getSimpleName(): string;
  40689. }
  40690. }
  40691. declare module BABYLON {
  40692. /**
  40693. * Manage the gamepad inputs to control a free camera.
  40694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40695. */
  40696. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40697. /**
  40698. * Define the camera the input is attached to.
  40699. */
  40700. camera: FreeCamera;
  40701. /**
  40702. * Define the Gamepad controlling the input
  40703. */
  40704. gamepad: Nullable<Gamepad>;
  40705. /**
  40706. * Defines the gamepad rotation sensiblity.
  40707. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40708. */
  40709. gamepadAngularSensibility: number;
  40710. /**
  40711. * Defines the gamepad move sensiblity.
  40712. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40713. */
  40714. gamepadMoveSensibility: number;
  40715. private _yAxisScale;
  40716. /**
  40717. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40718. */
  40719. get invertYAxis(): boolean;
  40720. set invertYAxis(value: boolean);
  40721. private _onGamepadConnectedObserver;
  40722. private _onGamepadDisconnectedObserver;
  40723. private _cameraTransform;
  40724. private _deltaTransform;
  40725. private _vector3;
  40726. private _vector2;
  40727. /**
  40728. * Attach the input controls to a specific dom element to get the input from.
  40729. * @param element Defines the element the controls should be listened from
  40730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40731. */
  40732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40733. /**
  40734. * Detach the current controls from the specified dom element.
  40735. * @param element Defines the element to stop listening the inputs from
  40736. */
  40737. detachControl(element: Nullable<HTMLElement>): void;
  40738. /**
  40739. * Update the current camera state depending on the inputs that have been used this frame.
  40740. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40741. */
  40742. checkInputs(): void;
  40743. /**
  40744. * Gets the class name of the current intput.
  40745. * @returns the class name
  40746. */
  40747. getClassName(): string;
  40748. /**
  40749. * Get the friendly name associated with the input class.
  40750. * @returns the input friendly name
  40751. */
  40752. getSimpleName(): string;
  40753. }
  40754. }
  40755. declare module BABYLON {
  40756. /**
  40757. * Defines the potential axis of a Joystick
  40758. */
  40759. export enum JoystickAxis {
  40760. /** X axis */
  40761. X = 0,
  40762. /** Y axis */
  40763. Y = 1,
  40764. /** Z axis */
  40765. Z = 2
  40766. }
  40767. /**
  40768. * Class used to define virtual joystick (used in touch mode)
  40769. */
  40770. export class VirtualJoystick {
  40771. /**
  40772. * Gets or sets a boolean indicating that left and right values must be inverted
  40773. */
  40774. reverseLeftRight: boolean;
  40775. /**
  40776. * Gets or sets a boolean indicating that up and down values must be inverted
  40777. */
  40778. reverseUpDown: boolean;
  40779. /**
  40780. * Gets the offset value for the position (ie. the change of the position value)
  40781. */
  40782. deltaPosition: Vector3;
  40783. /**
  40784. * Gets a boolean indicating if the virtual joystick was pressed
  40785. */
  40786. pressed: boolean;
  40787. /**
  40788. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40789. */
  40790. static Canvas: Nullable<HTMLCanvasElement>;
  40791. private static _globalJoystickIndex;
  40792. private static vjCanvasContext;
  40793. private static vjCanvasWidth;
  40794. private static vjCanvasHeight;
  40795. private static halfWidth;
  40796. private _action;
  40797. private _axisTargetedByLeftAndRight;
  40798. private _axisTargetedByUpAndDown;
  40799. private _joystickSensibility;
  40800. private _inversedSensibility;
  40801. private _joystickPointerID;
  40802. private _joystickColor;
  40803. private _joystickPointerPos;
  40804. private _joystickPreviousPointerPos;
  40805. private _joystickPointerStartPos;
  40806. private _deltaJoystickVector;
  40807. private _leftJoystick;
  40808. private _touches;
  40809. private _onPointerDownHandlerRef;
  40810. private _onPointerMoveHandlerRef;
  40811. private _onPointerUpHandlerRef;
  40812. private _onResize;
  40813. /**
  40814. * Creates a new virtual joystick
  40815. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40816. */
  40817. constructor(leftJoystick?: boolean);
  40818. /**
  40819. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40820. * @param newJoystickSensibility defines the new sensibility
  40821. */
  40822. setJoystickSensibility(newJoystickSensibility: number): void;
  40823. private _onPointerDown;
  40824. private _onPointerMove;
  40825. private _onPointerUp;
  40826. /**
  40827. * Change the color of the virtual joystick
  40828. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40829. */
  40830. setJoystickColor(newColor: string): void;
  40831. /**
  40832. * Defines a callback to call when the joystick is touched
  40833. * @param action defines the callback
  40834. */
  40835. setActionOnTouch(action: () => any): void;
  40836. /**
  40837. * Defines which axis you'd like to control for left & right
  40838. * @param axis defines the axis to use
  40839. */
  40840. setAxisForLeftRight(axis: JoystickAxis): void;
  40841. /**
  40842. * Defines which axis you'd like to control for up & down
  40843. * @param axis defines the axis to use
  40844. */
  40845. setAxisForUpDown(axis: JoystickAxis): void;
  40846. private _drawVirtualJoystick;
  40847. /**
  40848. * Release internal HTML canvas
  40849. */
  40850. releaseCanvas(): void;
  40851. }
  40852. }
  40853. declare module BABYLON {
  40854. interface FreeCameraInputsManager {
  40855. /**
  40856. * Add virtual joystick input support to the input manager.
  40857. * @returns the current input manager
  40858. */
  40859. addVirtualJoystick(): FreeCameraInputsManager;
  40860. }
  40861. /**
  40862. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40863. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40864. */
  40865. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40866. /**
  40867. * Defines the camera the input is attached to.
  40868. */
  40869. camera: FreeCamera;
  40870. private _leftjoystick;
  40871. private _rightjoystick;
  40872. /**
  40873. * Gets the left stick of the virtual joystick.
  40874. * @returns The virtual Joystick
  40875. */
  40876. getLeftJoystick(): VirtualJoystick;
  40877. /**
  40878. * Gets the right stick of the virtual joystick.
  40879. * @returns The virtual Joystick
  40880. */
  40881. getRightJoystick(): VirtualJoystick;
  40882. /**
  40883. * Update the current camera state depending on the inputs that have been used this frame.
  40884. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40885. */
  40886. checkInputs(): void;
  40887. /**
  40888. * Attach the input controls to a specific dom element to get the input from.
  40889. * @param element Defines the element the controls should be listened from
  40890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40891. */
  40892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40893. /**
  40894. * Detach the current controls from the specified dom element.
  40895. * @param element Defines the element to stop listening the inputs from
  40896. */
  40897. detachControl(element: Nullable<HTMLElement>): void;
  40898. /**
  40899. * Gets the class name of the current intput.
  40900. * @returns the class name
  40901. */
  40902. getClassName(): string;
  40903. /**
  40904. * Get the friendly name associated with the input class.
  40905. * @returns the input friendly name
  40906. */
  40907. getSimpleName(): string;
  40908. }
  40909. }
  40910. declare module BABYLON {
  40911. /**
  40912. * This represents a FPS type of camera controlled by touch.
  40913. * This is like a universal camera minus the Gamepad controls.
  40914. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40915. */
  40916. export class TouchCamera extends FreeCamera {
  40917. /**
  40918. * Defines the touch sensibility for rotation.
  40919. * The higher the faster.
  40920. */
  40921. get touchAngularSensibility(): number;
  40922. set touchAngularSensibility(value: number);
  40923. /**
  40924. * Defines the touch sensibility for move.
  40925. * The higher the faster.
  40926. */
  40927. get touchMoveSensibility(): number;
  40928. set touchMoveSensibility(value: number);
  40929. /**
  40930. * Instantiates a new touch camera.
  40931. * This represents a FPS type of camera controlled by touch.
  40932. * This is like a universal camera minus the Gamepad controls.
  40933. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40934. * @param name Define the name of the camera in the scene
  40935. * @param position Define the start position of the camera in the scene
  40936. * @param scene Define the scene the camera belongs to
  40937. */
  40938. constructor(name: string, position: Vector3, scene: Scene);
  40939. /**
  40940. * Gets the current object class name.
  40941. * @return the class name
  40942. */
  40943. getClassName(): string;
  40944. /** @hidden */
  40945. _setupInputs(): void;
  40946. }
  40947. }
  40948. declare module BABYLON {
  40949. /**
  40950. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40951. * being tilted forward or back and left or right.
  40952. */
  40953. export class DeviceOrientationCamera extends FreeCamera {
  40954. private _initialQuaternion;
  40955. private _quaternionCache;
  40956. private _tmpDragQuaternion;
  40957. private _disablePointerInputWhenUsingDeviceOrientation;
  40958. /**
  40959. * Creates a new device orientation camera
  40960. * @param name The name of the camera
  40961. * @param position The start position camera
  40962. * @param scene The scene the camera belongs to
  40963. */
  40964. constructor(name: string, position: Vector3, scene: Scene);
  40965. /**
  40966. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40967. */
  40968. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40969. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40970. private _dragFactor;
  40971. /**
  40972. * Enabled turning on the y axis when the orientation sensor is active
  40973. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40974. */
  40975. enableHorizontalDragging(dragFactor?: number): void;
  40976. /**
  40977. * Gets the current instance class name ("DeviceOrientationCamera").
  40978. * This helps avoiding instanceof at run time.
  40979. * @returns the class name
  40980. */
  40981. getClassName(): string;
  40982. /**
  40983. * @hidden
  40984. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40985. */
  40986. _checkInputs(): void;
  40987. /**
  40988. * Reset the camera to its default orientation on the specified axis only.
  40989. * @param axis The axis to reset
  40990. */
  40991. resetToCurrentRotation(axis?: Axis): void;
  40992. }
  40993. }
  40994. declare module BABYLON {
  40995. /**
  40996. * Defines supported buttons for XBox360 compatible gamepads
  40997. */
  40998. export enum Xbox360Button {
  40999. /** A */
  41000. A = 0,
  41001. /** B */
  41002. B = 1,
  41003. /** X */
  41004. X = 2,
  41005. /** Y */
  41006. Y = 3,
  41007. /** Left button */
  41008. LB = 4,
  41009. /** Right button */
  41010. RB = 5,
  41011. /** Back */
  41012. Back = 8,
  41013. /** Start */
  41014. Start = 9,
  41015. /** Left stick */
  41016. LeftStick = 10,
  41017. /** Right stick */
  41018. RightStick = 11
  41019. }
  41020. /** Defines values for XBox360 DPad */
  41021. export enum Xbox360Dpad {
  41022. /** Up */
  41023. Up = 12,
  41024. /** Down */
  41025. Down = 13,
  41026. /** Left */
  41027. Left = 14,
  41028. /** Right */
  41029. Right = 15
  41030. }
  41031. /**
  41032. * Defines a XBox360 gamepad
  41033. */
  41034. export class Xbox360Pad extends Gamepad {
  41035. private _leftTrigger;
  41036. private _rightTrigger;
  41037. private _onlefttriggerchanged;
  41038. private _onrighttriggerchanged;
  41039. private _onbuttondown;
  41040. private _onbuttonup;
  41041. private _ondpaddown;
  41042. private _ondpadup;
  41043. /** Observable raised when a button is pressed */
  41044. onButtonDownObservable: Observable<Xbox360Button>;
  41045. /** Observable raised when a button is released */
  41046. onButtonUpObservable: Observable<Xbox360Button>;
  41047. /** Observable raised when a pad is pressed */
  41048. onPadDownObservable: Observable<Xbox360Dpad>;
  41049. /** Observable raised when a pad is released */
  41050. onPadUpObservable: Observable<Xbox360Dpad>;
  41051. private _buttonA;
  41052. private _buttonB;
  41053. private _buttonX;
  41054. private _buttonY;
  41055. private _buttonBack;
  41056. private _buttonStart;
  41057. private _buttonLB;
  41058. private _buttonRB;
  41059. private _buttonLeftStick;
  41060. private _buttonRightStick;
  41061. private _dPadUp;
  41062. private _dPadDown;
  41063. private _dPadLeft;
  41064. private _dPadRight;
  41065. private _isXboxOnePad;
  41066. /**
  41067. * Creates a new XBox360 gamepad object
  41068. * @param id defines the id of this gamepad
  41069. * @param index defines its index
  41070. * @param gamepad defines the internal HTML gamepad object
  41071. * @param xboxOne defines if it is a XBox One gamepad
  41072. */
  41073. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41074. /**
  41075. * Defines the callback to call when left trigger is pressed
  41076. * @param callback defines the callback to use
  41077. */
  41078. onlefttriggerchanged(callback: (value: number) => void): void;
  41079. /**
  41080. * Defines the callback to call when right trigger is pressed
  41081. * @param callback defines the callback to use
  41082. */
  41083. onrighttriggerchanged(callback: (value: number) => void): void;
  41084. /**
  41085. * Gets the left trigger value
  41086. */
  41087. get leftTrigger(): number;
  41088. /**
  41089. * Sets the left trigger value
  41090. */
  41091. set leftTrigger(newValue: number);
  41092. /**
  41093. * Gets the right trigger value
  41094. */
  41095. get rightTrigger(): number;
  41096. /**
  41097. * Sets the right trigger value
  41098. */
  41099. set rightTrigger(newValue: number);
  41100. /**
  41101. * Defines the callback to call when a button is pressed
  41102. * @param callback defines the callback to use
  41103. */
  41104. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41105. /**
  41106. * Defines the callback to call when a button is released
  41107. * @param callback defines the callback to use
  41108. */
  41109. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41110. /**
  41111. * Defines the callback to call when a pad is pressed
  41112. * @param callback defines the callback to use
  41113. */
  41114. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41115. /**
  41116. * Defines the callback to call when a pad is released
  41117. * @param callback defines the callback to use
  41118. */
  41119. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41120. private _setButtonValue;
  41121. private _setDPadValue;
  41122. /**
  41123. * Gets the value of the `A` button
  41124. */
  41125. get buttonA(): number;
  41126. /**
  41127. * Sets the value of the `A` button
  41128. */
  41129. set buttonA(value: number);
  41130. /**
  41131. * Gets the value of the `B` button
  41132. */
  41133. get buttonB(): number;
  41134. /**
  41135. * Sets the value of the `B` button
  41136. */
  41137. set buttonB(value: number);
  41138. /**
  41139. * Gets the value of the `X` button
  41140. */
  41141. get buttonX(): number;
  41142. /**
  41143. * Sets the value of the `X` button
  41144. */
  41145. set buttonX(value: number);
  41146. /**
  41147. * Gets the value of the `Y` button
  41148. */
  41149. get buttonY(): number;
  41150. /**
  41151. * Sets the value of the `Y` button
  41152. */
  41153. set buttonY(value: number);
  41154. /**
  41155. * Gets the value of the `Start` button
  41156. */
  41157. get buttonStart(): number;
  41158. /**
  41159. * Sets the value of the `Start` button
  41160. */
  41161. set buttonStart(value: number);
  41162. /**
  41163. * Gets the value of the `Back` button
  41164. */
  41165. get buttonBack(): number;
  41166. /**
  41167. * Sets the value of the `Back` button
  41168. */
  41169. set buttonBack(value: number);
  41170. /**
  41171. * Gets the value of the `Left` button
  41172. */
  41173. get buttonLB(): number;
  41174. /**
  41175. * Sets the value of the `Left` button
  41176. */
  41177. set buttonLB(value: number);
  41178. /**
  41179. * Gets the value of the `Right` button
  41180. */
  41181. get buttonRB(): number;
  41182. /**
  41183. * Sets the value of the `Right` button
  41184. */
  41185. set buttonRB(value: number);
  41186. /**
  41187. * Gets the value of the Left joystick
  41188. */
  41189. get buttonLeftStick(): number;
  41190. /**
  41191. * Sets the value of the Left joystick
  41192. */
  41193. set buttonLeftStick(value: number);
  41194. /**
  41195. * Gets the value of the Right joystick
  41196. */
  41197. get buttonRightStick(): number;
  41198. /**
  41199. * Sets the value of the Right joystick
  41200. */
  41201. set buttonRightStick(value: number);
  41202. /**
  41203. * Gets the value of D-pad up
  41204. */
  41205. get dPadUp(): number;
  41206. /**
  41207. * Sets the value of D-pad up
  41208. */
  41209. set dPadUp(value: number);
  41210. /**
  41211. * Gets the value of D-pad down
  41212. */
  41213. get dPadDown(): number;
  41214. /**
  41215. * Sets the value of D-pad down
  41216. */
  41217. set dPadDown(value: number);
  41218. /**
  41219. * Gets the value of D-pad left
  41220. */
  41221. get dPadLeft(): number;
  41222. /**
  41223. * Sets the value of D-pad left
  41224. */
  41225. set dPadLeft(value: number);
  41226. /**
  41227. * Gets the value of D-pad right
  41228. */
  41229. get dPadRight(): number;
  41230. /**
  41231. * Sets the value of D-pad right
  41232. */
  41233. set dPadRight(value: number);
  41234. /**
  41235. * Force the gamepad to synchronize with device values
  41236. */
  41237. update(): void;
  41238. /**
  41239. * Disposes the gamepad
  41240. */
  41241. dispose(): void;
  41242. }
  41243. }
  41244. declare module BABYLON {
  41245. /**
  41246. * Defines supported buttons for DualShock compatible gamepads
  41247. */
  41248. export enum DualShockButton {
  41249. /** Cross */
  41250. Cross = 0,
  41251. /** Circle */
  41252. Circle = 1,
  41253. /** Square */
  41254. Square = 2,
  41255. /** Triangle */
  41256. Triangle = 3,
  41257. /** L1 */
  41258. L1 = 4,
  41259. /** R1 */
  41260. R1 = 5,
  41261. /** Share */
  41262. Share = 8,
  41263. /** Options */
  41264. Options = 9,
  41265. /** Left stick */
  41266. LeftStick = 10,
  41267. /** Right stick */
  41268. RightStick = 11
  41269. }
  41270. /** Defines values for DualShock DPad */
  41271. export enum DualShockDpad {
  41272. /** Up */
  41273. Up = 12,
  41274. /** Down */
  41275. Down = 13,
  41276. /** Left */
  41277. Left = 14,
  41278. /** Right */
  41279. Right = 15
  41280. }
  41281. /**
  41282. * Defines a DualShock gamepad
  41283. */
  41284. export class DualShockPad extends Gamepad {
  41285. private _leftTrigger;
  41286. private _rightTrigger;
  41287. private _onlefttriggerchanged;
  41288. private _onrighttriggerchanged;
  41289. private _onbuttondown;
  41290. private _onbuttonup;
  41291. private _ondpaddown;
  41292. private _ondpadup;
  41293. /** Observable raised when a button is pressed */
  41294. onButtonDownObservable: Observable<DualShockButton>;
  41295. /** Observable raised when a button is released */
  41296. onButtonUpObservable: Observable<DualShockButton>;
  41297. /** Observable raised when a pad is pressed */
  41298. onPadDownObservable: Observable<DualShockDpad>;
  41299. /** Observable raised when a pad is released */
  41300. onPadUpObservable: Observable<DualShockDpad>;
  41301. private _buttonCross;
  41302. private _buttonCircle;
  41303. private _buttonSquare;
  41304. private _buttonTriangle;
  41305. private _buttonShare;
  41306. private _buttonOptions;
  41307. private _buttonL1;
  41308. private _buttonR1;
  41309. private _buttonLeftStick;
  41310. private _buttonRightStick;
  41311. private _dPadUp;
  41312. private _dPadDown;
  41313. private _dPadLeft;
  41314. private _dPadRight;
  41315. /**
  41316. * Creates a new DualShock gamepad object
  41317. * @param id defines the id of this gamepad
  41318. * @param index defines its index
  41319. * @param gamepad defines the internal HTML gamepad object
  41320. */
  41321. constructor(id: string, index: number, gamepad: any);
  41322. /**
  41323. * Defines the callback to call when left trigger is pressed
  41324. * @param callback defines the callback to use
  41325. */
  41326. onlefttriggerchanged(callback: (value: number) => void): void;
  41327. /**
  41328. * Defines the callback to call when right trigger is pressed
  41329. * @param callback defines the callback to use
  41330. */
  41331. onrighttriggerchanged(callback: (value: number) => void): void;
  41332. /**
  41333. * Gets the left trigger value
  41334. */
  41335. get leftTrigger(): number;
  41336. /**
  41337. * Sets the left trigger value
  41338. */
  41339. set leftTrigger(newValue: number);
  41340. /**
  41341. * Gets the right trigger value
  41342. */
  41343. get rightTrigger(): number;
  41344. /**
  41345. * Sets the right trigger value
  41346. */
  41347. set rightTrigger(newValue: number);
  41348. /**
  41349. * Defines the callback to call when a button is pressed
  41350. * @param callback defines the callback to use
  41351. */
  41352. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41353. /**
  41354. * Defines the callback to call when a button is released
  41355. * @param callback defines the callback to use
  41356. */
  41357. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41358. /**
  41359. * Defines the callback to call when a pad is pressed
  41360. * @param callback defines the callback to use
  41361. */
  41362. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41363. /**
  41364. * Defines the callback to call when a pad is released
  41365. * @param callback defines the callback to use
  41366. */
  41367. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41368. private _setButtonValue;
  41369. private _setDPadValue;
  41370. /**
  41371. * Gets the value of the `Cross` button
  41372. */
  41373. get buttonCross(): number;
  41374. /**
  41375. * Sets the value of the `Cross` button
  41376. */
  41377. set buttonCross(value: number);
  41378. /**
  41379. * Gets the value of the `Circle` button
  41380. */
  41381. get buttonCircle(): number;
  41382. /**
  41383. * Sets the value of the `Circle` button
  41384. */
  41385. set buttonCircle(value: number);
  41386. /**
  41387. * Gets the value of the `Square` button
  41388. */
  41389. get buttonSquare(): number;
  41390. /**
  41391. * Sets the value of the `Square` button
  41392. */
  41393. set buttonSquare(value: number);
  41394. /**
  41395. * Gets the value of the `Triangle` button
  41396. */
  41397. get buttonTriangle(): number;
  41398. /**
  41399. * Sets the value of the `Triangle` button
  41400. */
  41401. set buttonTriangle(value: number);
  41402. /**
  41403. * Gets the value of the `Options` button
  41404. */
  41405. get buttonOptions(): number;
  41406. /**
  41407. * Sets the value of the `Options` button
  41408. */
  41409. set buttonOptions(value: number);
  41410. /**
  41411. * Gets the value of the `Share` button
  41412. */
  41413. get buttonShare(): number;
  41414. /**
  41415. * Sets the value of the `Share` button
  41416. */
  41417. set buttonShare(value: number);
  41418. /**
  41419. * Gets the value of the `L1` button
  41420. */
  41421. get buttonL1(): number;
  41422. /**
  41423. * Sets the value of the `L1` button
  41424. */
  41425. set buttonL1(value: number);
  41426. /**
  41427. * Gets the value of the `R1` button
  41428. */
  41429. get buttonR1(): number;
  41430. /**
  41431. * Sets the value of the `R1` button
  41432. */
  41433. set buttonR1(value: number);
  41434. /**
  41435. * Gets the value of the Left joystick
  41436. */
  41437. get buttonLeftStick(): number;
  41438. /**
  41439. * Sets the value of the Left joystick
  41440. */
  41441. set buttonLeftStick(value: number);
  41442. /**
  41443. * Gets the value of the Right joystick
  41444. */
  41445. get buttonRightStick(): number;
  41446. /**
  41447. * Sets the value of the Right joystick
  41448. */
  41449. set buttonRightStick(value: number);
  41450. /**
  41451. * Gets the value of D-pad up
  41452. */
  41453. get dPadUp(): number;
  41454. /**
  41455. * Sets the value of D-pad up
  41456. */
  41457. set dPadUp(value: number);
  41458. /**
  41459. * Gets the value of D-pad down
  41460. */
  41461. get dPadDown(): number;
  41462. /**
  41463. * Sets the value of D-pad down
  41464. */
  41465. set dPadDown(value: number);
  41466. /**
  41467. * Gets the value of D-pad left
  41468. */
  41469. get dPadLeft(): number;
  41470. /**
  41471. * Sets the value of D-pad left
  41472. */
  41473. set dPadLeft(value: number);
  41474. /**
  41475. * Gets the value of D-pad right
  41476. */
  41477. get dPadRight(): number;
  41478. /**
  41479. * Sets the value of D-pad right
  41480. */
  41481. set dPadRight(value: number);
  41482. /**
  41483. * Force the gamepad to synchronize with device values
  41484. */
  41485. update(): void;
  41486. /**
  41487. * Disposes the gamepad
  41488. */
  41489. dispose(): void;
  41490. }
  41491. }
  41492. declare module BABYLON {
  41493. /**
  41494. * Manager for handling gamepads
  41495. */
  41496. export class GamepadManager {
  41497. private _scene?;
  41498. private _babylonGamepads;
  41499. private _oneGamepadConnected;
  41500. /** @hidden */
  41501. _isMonitoring: boolean;
  41502. private _gamepadEventSupported;
  41503. private _gamepadSupport?;
  41504. /**
  41505. * observable to be triggered when the gamepad controller has been connected
  41506. */
  41507. onGamepadConnectedObservable: Observable<Gamepad>;
  41508. /**
  41509. * observable to be triggered when the gamepad controller has been disconnected
  41510. */
  41511. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41512. private _onGamepadConnectedEvent;
  41513. private _onGamepadDisconnectedEvent;
  41514. /**
  41515. * Initializes the gamepad manager
  41516. * @param _scene BabylonJS scene
  41517. */
  41518. constructor(_scene?: Scene | undefined);
  41519. /**
  41520. * The gamepads in the game pad manager
  41521. */
  41522. get gamepads(): Gamepad[];
  41523. /**
  41524. * Get the gamepad controllers based on type
  41525. * @param type The type of gamepad controller
  41526. * @returns Nullable gamepad
  41527. */
  41528. getGamepadByType(type?: number): Nullable<Gamepad>;
  41529. /**
  41530. * Disposes the gamepad manager
  41531. */
  41532. dispose(): void;
  41533. private _addNewGamepad;
  41534. private _startMonitoringGamepads;
  41535. private _stopMonitoringGamepads;
  41536. /** @hidden */
  41537. _checkGamepadsStatus(): void;
  41538. private _updateGamepadObjects;
  41539. }
  41540. }
  41541. declare module BABYLON {
  41542. interface Scene {
  41543. /** @hidden */
  41544. _gamepadManager: Nullable<GamepadManager>;
  41545. /**
  41546. * Gets the gamepad manager associated with the scene
  41547. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41548. */
  41549. gamepadManager: GamepadManager;
  41550. }
  41551. /**
  41552. * Interface representing a free camera inputs manager
  41553. */
  41554. interface FreeCameraInputsManager {
  41555. /**
  41556. * Adds gamepad input support to the FreeCameraInputsManager.
  41557. * @returns the FreeCameraInputsManager
  41558. */
  41559. addGamepad(): FreeCameraInputsManager;
  41560. }
  41561. /**
  41562. * Interface representing an arc rotate camera inputs manager
  41563. */
  41564. interface ArcRotateCameraInputsManager {
  41565. /**
  41566. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41567. * @returns the camera inputs manager
  41568. */
  41569. addGamepad(): ArcRotateCameraInputsManager;
  41570. }
  41571. /**
  41572. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41573. */
  41574. export class GamepadSystemSceneComponent implements ISceneComponent {
  41575. /**
  41576. * The component name helpfull to identify the component in the list of scene components.
  41577. */
  41578. readonly name: string;
  41579. /**
  41580. * The scene the component belongs to.
  41581. */
  41582. scene: Scene;
  41583. /**
  41584. * Creates a new instance of the component for the given scene
  41585. * @param scene Defines the scene to register the component in
  41586. */
  41587. constructor(scene: Scene);
  41588. /**
  41589. * Registers the component in a given scene
  41590. */
  41591. register(): void;
  41592. /**
  41593. * Rebuilds the elements related to this component in case of
  41594. * context lost for instance.
  41595. */
  41596. rebuild(): void;
  41597. /**
  41598. * Disposes the component and the associated ressources
  41599. */
  41600. dispose(): void;
  41601. private _beforeCameraUpdate;
  41602. }
  41603. }
  41604. declare module BABYLON {
  41605. /**
  41606. * 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,
  41607. * which still works and will still be found in many Playgrounds.
  41608. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41609. */
  41610. export class UniversalCamera extends TouchCamera {
  41611. /**
  41612. * Defines the gamepad rotation sensiblity.
  41613. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41614. */
  41615. get gamepadAngularSensibility(): number;
  41616. set gamepadAngularSensibility(value: number);
  41617. /**
  41618. * Defines the gamepad move sensiblity.
  41619. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41620. */
  41621. get gamepadMoveSensibility(): number;
  41622. set gamepadMoveSensibility(value: number);
  41623. /**
  41624. * 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,
  41625. * which still works and will still be found in many Playgrounds.
  41626. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41627. * @param name Define the name of the camera in the scene
  41628. * @param position Define the start position of the camera in the scene
  41629. * @param scene Define the scene the camera belongs to
  41630. */
  41631. constructor(name: string, position: Vector3, scene: Scene);
  41632. /**
  41633. * Gets the current object class name.
  41634. * @return the class name
  41635. */
  41636. getClassName(): string;
  41637. }
  41638. }
  41639. declare module BABYLON {
  41640. /**
  41641. * This represents a FPS type of camera. This is only here for back compat purpose.
  41642. * Please use the UniversalCamera instead as both are identical.
  41643. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41644. */
  41645. export class GamepadCamera extends UniversalCamera {
  41646. /**
  41647. * Instantiates a new Gamepad Camera
  41648. * This represents a FPS type of camera. This is only here for back compat purpose.
  41649. * Please use the UniversalCamera instead as both are identical.
  41650. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41651. * @param name Define the name of the camera in the scene
  41652. * @param position Define the start position of the camera in the scene
  41653. * @param scene Define the scene the camera belongs to
  41654. */
  41655. constructor(name: string, position: Vector3, scene: Scene);
  41656. /**
  41657. * Gets the current object class name.
  41658. * @return the class name
  41659. */
  41660. getClassName(): string;
  41661. }
  41662. }
  41663. declare module BABYLON {
  41664. /** @hidden */
  41665. export var passPixelShader: {
  41666. name: string;
  41667. shader: string;
  41668. };
  41669. }
  41670. declare module BABYLON {
  41671. /** @hidden */
  41672. export var passCubePixelShader: {
  41673. name: string;
  41674. shader: string;
  41675. };
  41676. }
  41677. declare module BABYLON {
  41678. /**
  41679. * PassPostProcess which produces an output the same as it's input
  41680. */
  41681. export class PassPostProcess extends PostProcess {
  41682. /**
  41683. * Creates the PassPostProcess
  41684. * @param name The name of the effect.
  41685. * @param options The required width/height ratio to downsize to before computing the render pass.
  41686. * @param camera The camera to apply the render pass to.
  41687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41688. * @param engine The engine which the post process will be applied. (default: current engine)
  41689. * @param reusable If the post process can be reused on the same frame. (default: false)
  41690. * @param textureType The type of texture to be used when performing the post processing.
  41691. * @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)
  41692. */
  41693. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41694. }
  41695. /**
  41696. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41697. */
  41698. export class PassCubePostProcess extends PostProcess {
  41699. private _face;
  41700. /**
  41701. * Gets or sets the cube face to display.
  41702. * * 0 is +X
  41703. * * 1 is -X
  41704. * * 2 is +Y
  41705. * * 3 is -Y
  41706. * * 4 is +Z
  41707. * * 5 is -Z
  41708. */
  41709. get face(): number;
  41710. set face(value: number);
  41711. /**
  41712. * Creates the PassCubePostProcess
  41713. * @param name The name of the effect.
  41714. * @param options The required width/height ratio to downsize to before computing the render pass.
  41715. * @param camera The camera to apply the render pass to.
  41716. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41717. * @param engine The engine which the post process will be applied. (default: current engine)
  41718. * @param reusable If the post process can be reused on the same frame. (default: false)
  41719. * @param textureType The type of texture to be used when performing the post processing.
  41720. * @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)
  41721. */
  41722. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41723. }
  41724. }
  41725. declare module BABYLON {
  41726. /** @hidden */
  41727. export var anaglyphPixelShader: {
  41728. name: string;
  41729. shader: string;
  41730. };
  41731. }
  41732. declare module BABYLON {
  41733. /**
  41734. * Postprocess used to generate anaglyphic rendering
  41735. */
  41736. export class AnaglyphPostProcess extends PostProcess {
  41737. private _passedProcess;
  41738. /**
  41739. * Creates a new AnaglyphPostProcess
  41740. * @param name defines postprocess name
  41741. * @param options defines creation options or target ratio scale
  41742. * @param rigCameras defines cameras using this postprocess
  41743. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41744. * @param engine defines hosting engine
  41745. * @param reusable defines if the postprocess will be reused multiple times per frame
  41746. */
  41747. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41748. }
  41749. }
  41750. declare module BABYLON {
  41751. /**
  41752. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41753. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41754. */
  41755. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41756. /**
  41757. * Creates a new AnaglyphArcRotateCamera
  41758. * @param name defines camera name
  41759. * @param alpha defines alpha angle (in radians)
  41760. * @param beta defines beta angle (in radians)
  41761. * @param radius defines radius
  41762. * @param target defines camera target
  41763. * @param interaxialDistance defines distance between each color axis
  41764. * @param scene defines the hosting scene
  41765. */
  41766. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41767. /**
  41768. * Gets camera class name
  41769. * @returns AnaglyphArcRotateCamera
  41770. */
  41771. getClassName(): string;
  41772. }
  41773. }
  41774. declare module BABYLON {
  41775. /**
  41776. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41777. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41778. */
  41779. export class AnaglyphFreeCamera extends FreeCamera {
  41780. /**
  41781. * Creates a new AnaglyphFreeCamera
  41782. * @param name defines camera name
  41783. * @param position defines initial position
  41784. * @param interaxialDistance defines distance between each color axis
  41785. * @param scene defines the hosting scene
  41786. */
  41787. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41788. /**
  41789. * Gets camera class name
  41790. * @returns AnaglyphFreeCamera
  41791. */
  41792. getClassName(): string;
  41793. }
  41794. }
  41795. declare module BABYLON {
  41796. /**
  41797. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41798. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41799. */
  41800. export class AnaglyphGamepadCamera extends GamepadCamera {
  41801. /**
  41802. * Creates a new AnaglyphGamepadCamera
  41803. * @param name defines camera name
  41804. * @param position defines initial position
  41805. * @param interaxialDistance defines distance between each color axis
  41806. * @param scene defines the hosting scene
  41807. */
  41808. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41809. /**
  41810. * Gets camera class name
  41811. * @returns AnaglyphGamepadCamera
  41812. */
  41813. getClassName(): string;
  41814. }
  41815. }
  41816. declare module BABYLON {
  41817. /**
  41818. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41819. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41820. */
  41821. export class AnaglyphUniversalCamera extends UniversalCamera {
  41822. /**
  41823. * Creates a new AnaglyphUniversalCamera
  41824. * @param name defines camera name
  41825. * @param position defines initial position
  41826. * @param interaxialDistance defines distance between each color axis
  41827. * @param scene defines the hosting scene
  41828. */
  41829. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41830. /**
  41831. * Gets camera class name
  41832. * @returns AnaglyphUniversalCamera
  41833. */
  41834. getClassName(): string;
  41835. }
  41836. }
  41837. declare module BABYLON {
  41838. /** @hidden */
  41839. export var stereoscopicInterlacePixelShader: {
  41840. name: string;
  41841. shader: string;
  41842. };
  41843. }
  41844. declare module BABYLON {
  41845. /**
  41846. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41847. */
  41848. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41849. private _stepSize;
  41850. private _passedProcess;
  41851. /**
  41852. * Initializes a StereoscopicInterlacePostProcessI
  41853. * @param name The name of the effect.
  41854. * @param rigCameras The rig cameras to be appled to the post process
  41855. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41856. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41858. * @param engine The engine which the post process will be applied. (default: current engine)
  41859. * @param reusable If the post process can be reused on the same frame. (default: false)
  41860. */
  41861. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41862. }
  41863. /**
  41864. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41865. */
  41866. export class StereoscopicInterlacePostProcess extends PostProcess {
  41867. private _stepSize;
  41868. private _passedProcess;
  41869. /**
  41870. * Initializes a StereoscopicInterlacePostProcess
  41871. * @param name The name of the effect.
  41872. * @param rigCameras The rig cameras to be appled to the post process
  41873. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41875. * @param engine The engine which the post process will be applied. (default: current engine)
  41876. * @param reusable If the post process can be reused on the same frame. (default: false)
  41877. */
  41878. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41879. }
  41880. }
  41881. declare module BABYLON {
  41882. /**
  41883. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41884. * @see http://doc.babylonjs.com/features/cameras
  41885. */
  41886. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41887. /**
  41888. * Creates a new StereoscopicArcRotateCamera
  41889. * @param name defines camera name
  41890. * @param alpha defines alpha angle (in radians)
  41891. * @param beta defines beta angle (in radians)
  41892. * @param radius defines radius
  41893. * @param target defines camera target
  41894. * @param interaxialDistance defines distance between each color axis
  41895. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41896. * @param scene defines the hosting scene
  41897. */
  41898. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41899. /**
  41900. * Gets camera class name
  41901. * @returns StereoscopicArcRotateCamera
  41902. */
  41903. getClassName(): string;
  41904. }
  41905. }
  41906. declare module BABYLON {
  41907. /**
  41908. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41909. * @see http://doc.babylonjs.com/features/cameras
  41910. */
  41911. export class StereoscopicFreeCamera extends FreeCamera {
  41912. /**
  41913. * Creates a new StereoscopicFreeCamera
  41914. * @param name defines camera name
  41915. * @param position defines initial position
  41916. * @param interaxialDistance defines distance between each color axis
  41917. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41918. * @param scene defines the hosting scene
  41919. */
  41920. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41921. /**
  41922. * Gets camera class name
  41923. * @returns StereoscopicFreeCamera
  41924. */
  41925. getClassName(): string;
  41926. }
  41927. }
  41928. declare module BABYLON {
  41929. /**
  41930. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41931. * @see http://doc.babylonjs.com/features/cameras
  41932. */
  41933. export class StereoscopicGamepadCamera extends GamepadCamera {
  41934. /**
  41935. * Creates a new StereoscopicGamepadCamera
  41936. * @param name defines camera name
  41937. * @param position defines initial position
  41938. * @param interaxialDistance defines distance between each color axis
  41939. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41940. * @param scene defines the hosting scene
  41941. */
  41942. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41943. /**
  41944. * Gets camera class name
  41945. * @returns StereoscopicGamepadCamera
  41946. */
  41947. getClassName(): string;
  41948. }
  41949. }
  41950. declare module BABYLON {
  41951. /**
  41952. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41953. * @see http://doc.babylonjs.com/features/cameras
  41954. */
  41955. export class StereoscopicUniversalCamera extends UniversalCamera {
  41956. /**
  41957. * Creates a new StereoscopicUniversalCamera
  41958. * @param name defines camera name
  41959. * @param position defines initial position
  41960. * @param interaxialDistance defines distance between each color axis
  41961. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41962. * @param scene defines the hosting scene
  41963. */
  41964. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41965. /**
  41966. * Gets camera class name
  41967. * @returns StereoscopicUniversalCamera
  41968. */
  41969. getClassName(): string;
  41970. }
  41971. }
  41972. declare module BABYLON {
  41973. /**
  41974. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41975. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41976. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41977. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41978. */
  41979. export class VirtualJoysticksCamera extends FreeCamera {
  41980. /**
  41981. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41982. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41983. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41984. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41985. * @param name Define the name of the camera in the scene
  41986. * @param position Define the start position of the camera in the scene
  41987. * @param scene Define the scene the camera belongs to
  41988. */
  41989. constructor(name: string, position: Vector3, scene: Scene);
  41990. /**
  41991. * Gets the current object class name.
  41992. * @return the class name
  41993. */
  41994. getClassName(): string;
  41995. }
  41996. }
  41997. declare module BABYLON {
  41998. /**
  41999. * This represents all the required metrics to create a VR camera.
  42000. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42001. */
  42002. export class VRCameraMetrics {
  42003. /**
  42004. * Define the horizontal resolution off the screen.
  42005. */
  42006. hResolution: number;
  42007. /**
  42008. * Define the vertical resolution off the screen.
  42009. */
  42010. vResolution: number;
  42011. /**
  42012. * Define the horizontal screen size.
  42013. */
  42014. hScreenSize: number;
  42015. /**
  42016. * Define the vertical screen size.
  42017. */
  42018. vScreenSize: number;
  42019. /**
  42020. * Define the vertical screen center position.
  42021. */
  42022. vScreenCenter: number;
  42023. /**
  42024. * Define the distance of the eyes to the screen.
  42025. */
  42026. eyeToScreenDistance: number;
  42027. /**
  42028. * Define the distance between both lenses
  42029. */
  42030. lensSeparationDistance: number;
  42031. /**
  42032. * Define the distance between both viewer's eyes.
  42033. */
  42034. interpupillaryDistance: number;
  42035. /**
  42036. * Define the distortion factor of the VR postprocess.
  42037. * Please, touch with care.
  42038. */
  42039. distortionK: number[];
  42040. /**
  42041. * Define the chromatic aberration correction factors for the VR post process.
  42042. */
  42043. chromaAbCorrection: number[];
  42044. /**
  42045. * Define the scale factor of the post process.
  42046. * The smaller the better but the slower.
  42047. */
  42048. postProcessScaleFactor: number;
  42049. /**
  42050. * Define an offset for the lens center.
  42051. */
  42052. lensCenterOffset: number;
  42053. /**
  42054. * Define if the current vr camera should compensate the distortion of the lense or not.
  42055. */
  42056. compensateDistortion: boolean;
  42057. /**
  42058. * Defines if multiview should be enabled when rendering (Default: false)
  42059. */
  42060. multiviewEnabled: boolean;
  42061. /**
  42062. * Gets the rendering aspect ratio based on the provided resolutions.
  42063. */
  42064. get aspectRatio(): number;
  42065. /**
  42066. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42067. */
  42068. get aspectRatioFov(): number;
  42069. /**
  42070. * @hidden
  42071. */
  42072. get leftHMatrix(): Matrix;
  42073. /**
  42074. * @hidden
  42075. */
  42076. get rightHMatrix(): Matrix;
  42077. /**
  42078. * @hidden
  42079. */
  42080. get leftPreViewMatrix(): Matrix;
  42081. /**
  42082. * @hidden
  42083. */
  42084. get rightPreViewMatrix(): Matrix;
  42085. /**
  42086. * Get the default VRMetrics based on the most generic setup.
  42087. * @returns the default vr metrics
  42088. */
  42089. static GetDefault(): VRCameraMetrics;
  42090. }
  42091. }
  42092. declare module BABYLON {
  42093. /** @hidden */
  42094. export var vrDistortionCorrectionPixelShader: {
  42095. name: string;
  42096. shader: string;
  42097. };
  42098. }
  42099. declare module BABYLON {
  42100. /**
  42101. * VRDistortionCorrectionPostProcess used for mobile VR
  42102. */
  42103. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42104. private _isRightEye;
  42105. private _distortionFactors;
  42106. private _postProcessScaleFactor;
  42107. private _lensCenterOffset;
  42108. private _scaleIn;
  42109. private _scaleFactor;
  42110. private _lensCenter;
  42111. /**
  42112. * Initializes the VRDistortionCorrectionPostProcess
  42113. * @param name The name of the effect.
  42114. * @param camera The camera to apply the render pass to.
  42115. * @param isRightEye If this is for the right eye distortion
  42116. * @param vrMetrics All the required metrics for the VR camera
  42117. */
  42118. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42119. }
  42120. }
  42121. declare module BABYLON {
  42122. /**
  42123. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42124. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42125. */
  42126. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42127. /**
  42128. * Creates a new VRDeviceOrientationArcRotateCamera
  42129. * @param name defines camera name
  42130. * @param alpha defines the camera rotation along the logitudinal axis
  42131. * @param beta defines the camera rotation along the latitudinal axis
  42132. * @param radius defines the camera distance from its target
  42133. * @param target defines the camera target
  42134. * @param scene defines the scene the camera belongs to
  42135. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42136. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42137. */
  42138. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42139. /**
  42140. * Gets camera class name
  42141. * @returns VRDeviceOrientationArcRotateCamera
  42142. */
  42143. getClassName(): string;
  42144. }
  42145. }
  42146. declare module BABYLON {
  42147. /**
  42148. * Camera used to simulate VR rendering (based on FreeCamera)
  42149. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42150. */
  42151. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42152. /**
  42153. * Creates a new VRDeviceOrientationFreeCamera
  42154. * @param name defines camera name
  42155. * @param position defines the start position of the camera
  42156. * @param scene defines the scene the camera belongs to
  42157. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42158. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42159. */
  42160. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42161. /**
  42162. * Gets camera class name
  42163. * @returns VRDeviceOrientationFreeCamera
  42164. */
  42165. getClassName(): string;
  42166. }
  42167. }
  42168. declare module BABYLON {
  42169. /**
  42170. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42171. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42172. */
  42173. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42174. /**
  42175. * Creates a new VRDeviceOrientationGamepadCamera
  42176. * @param name defines camera name
  42177. * @param position defines the start position of the camera
  42178. * @param scene defines the scene the camera belongs to
  42179. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42180. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42181. */
  42182. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42183. /**
  42184. * Gets camera class name
  42185. * @returns VRDeviceOrientationGamepadCamera
  42186. */
  42187. getClassName(): string;
  42188. }
  42189. }
  42190. declare module BABYLON {
  42191. /** @hidden */
  42192. export var imageProcessingPixelShader: {
  42193. name: string;
  42194. shader: string;
  42195. };
  42196. }
  42197. declare module BABYLON {
  42198. /**
  42199. * ImageProcessingPostProcess
  42200. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42201. */
  42202. export class ImageProcessingPostProcess extends PostProcess {
  42203. /**
  42204. * Default configuration related to image processing available in the PBR Material.
  42205. */
  42206. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42207. /**
  42208. * Gets the image processing configuration used either in this material.
  42209. */
  42210. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42211. /**
  42212. * Sets the Default image processing configuration used either in the this material.
  42213. *
  42214. * If sets to null, the scene one is in use.
  42215. */
  42216. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42217. /**
  42218. * Keep track of the image processing observer to allow dispose and replace.
  42219. */
  42220. private _imageProcessingObserver;
  42221. /**
  42222. * Attaches a new image processing configuration to the PBR Material.
  42223. * @param configuration
  42224. */
  42225. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42226. /**
  42227. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42228. */
  42229. get colorCurves(): Nullable<ColorCurves>;
  42230. /**
  42231. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42232. */
  42233. set colorCurves(value: Nullable<ColorCurves>);
  42234. /**
  42235. * Gets wether the color curves effect is enabled.
  42236. */
  42237. get colorCurvesEnabled(): boolean;
  42238. /**
  42239. * Sets wether the color curves effect is enabled.
  42240. */
  42241. set colorCurvesEnabled(value: boolean);
  42242. /**
  42243. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42244. */
  42245. get colorGradingTexture(): Nullable<BaseTexture>;
  42246. /**
  42247. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42248. */
  42249. set colorGradingTexture(value: Nullable<BaseTexture>);
  42250. /**
  42251. * Gets wether the color grading effect is enabled.
  42252. */
  42253. get colorGradingEnabled(): boolean;
  42254. /**
  42255. * Gets wether the color grading effect is enabled.
  42256. */
  42257. set colorGradingEnabled(value: boolean);
  42258. /**
  42259. * Gets exposure used in the effect.
  42260. */
  42261. get exposure(): number;
  42262. /**
  42263. * Sets exposure used in the effect.
  42264. */
  42265. set exposure(value: number);
  42266. /**
  42267. * Gets wether tonemapping is enabled or not.
  42268. */
  42269. get toneMappingEnabled(): boolean;
  42270. /**
  42271. * Sets wether tonemapping is enabled or not
  42272. */
  42273. set toneMappingEnabled(value: boolean);
  42274. /**
  42275. * Gets the type of tone mapping effect.
  42276. */
  42277. get toneMappingType(): number;
  42278. /**
  42279. * Sets the type of tone mapping effect.
  42280. */
  42281. set toneMappingType(value: number);
  42282. /**
  42283. * Gets contrast used in the effect.
  42284. */
  42285. get contrast(): number;
  42286. /**
  42287. * Sets contrast used in the effect.
  42288. */
  42289. set contrast(value: number);
  42290. /**
  42291. * Gets Vignette stretch size.
  42292. */
  42293. get vignetteStretch(): number;
  42294. /**
  42295. * Sets Vignette stretch size.
  42296. */
  42297. set vignetteStretch(value: number);
  42298. /**
  42299. * Gets Vignette centre X Offset.
  42300. */
  42301. get vignetteCentreX(): number;
  42302. /**
  42303. * Sets Vignette centre X Offset.
  42304. */
  42305. set vignetteCentreX(value: number);
  42306. /**
  42307. * Gets Vignette centre Y Offset.
  42308. */
  42309. get vignetteCentreY(): number;
  42310. /**
  42311. * Sets Vignette centre Y Offset.
  42312. */
  42313. set vignetteCentreY(value: number);
  42314. /**
  42315. * Gets Vignette weight or intensity of the vignette effect.
  42316. */
  42317. get vignetteWeight(): number;
  42318. /**
  42319. * Sets Vignette weight or intensity of the vignette effect.
  42320. */
  42321. set vignetteWeight(value: number);
  42322. /**
  42323. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42324. * if vignetteEnabled is set to true.
  42325. */
  42326. get vignetteColor(): Color4;
  42327. /**
  42328. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42329. * if vignetteEnabled is set to true.
  42330. */
  42331. set vignetteColor(value: Color4);
  42332. /**
  42333. * Gets Camera field of view used by the Vignette effect.
  42334. */
  42335. get vignetteCameraFov(): number;
  42336. /**
  42337. * Sets Camera field of view used by the Vignette effect.
  42338. */
  42339. set vignetteCameraFov(value: number);
  42340. /**
  42341. * Gets the vignette blend mode allowing different kind of effect.
  42342. */
  42343. get vignetteBlendMode(): number;
  42344. /**
  42345. * Sets the vignette blend mode allowing different kind of effect.
  42346. */
  42347. set vignetteBlendMode(value: number);
  42348. /**
  42349. * Gets wether the vignette effect is enabled.
  42350. */
  42351. get vignetteEnabled(): boolean;
  42352. /**
  42353. * Sets wether the vignette effect is enabled.
  42354. */
  42355. set vignetteEnabled(value: boolean);
  42356. private _fromLinearSpace;
  42357. /**
  42358. * Gets wether the input of the processing is in Gamma or Linear Space.
  42359. */
  42360. get fromLinearSpace(): boolean;
  42361. /**
  42362. * Sets wether the input of the processing is in Gamma or Linear Space.
  42363. */
  42364. set fromLinearSpace(value: boolean);
  42365. /**
  42366. * Defines cache preventing GC.
  42367. */
  42368. private _defines;
  42369. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42370. /**
  42371. * "ImageProcessingPostProcess"
  42372. * @returns "ImageProcessingPostProcess"
  42373. */
  42374. getClassName(): string;
  42375. protected _updateParameters(): void;
  42376. dispose(camera?: Camera): void;
  42377. }
  42378. }
  42379. declare module BABYLON {
  42380. /**
  42381. * Class containing static functions to help procedurally build meshes
  42382. */
  42383. export class GroundBuilder {
  42384. /**
  42385. * Creates a ground mesh
  42386. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42387. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42389. * @param name defines the name of the mesh
  42390. * @param options defines the options used to create the mesh
  42391. * @param scene defines the hosting scene
  42392. * @returns the ground mesh
  42393. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42394. */
  42395. static CreateGround(name: string, options: {
  42396. width?: number;
  42397. height?: number;
  42398. subdivisions?: number;
  42399. subdivisionsX?: number;
  42400. subdivisionsY?: number;
  42401. updatable?: boolean;
  42402. }, scene: any): Mesh;
  42403. /**
  42404. * Creates a tiled ground mesh
  42405. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42406. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42407. * * 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
  42408. * * 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
  42409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42410. * @param name defines the name of the mesh
  42411. * @param options defines the options used to create the mesh
  42412. * @param scene defines the hosting scene
  42413. * @returns the tiled ground mesh
  42414. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42415. */
  42416. static CreateTiledGround(name: string, options: {
  42417. xmin: number;
  42418. zmin: number;
  42419. xmax: number;
  42420. zmax: number;
  42421. subdivisions?: {
  42422. w: number;
  42423. h: number;
  42424. };
  42425. precision?: {
  42426. w: number;
  42427. h: number;
  42428. };
  42429. updatable?: boolean;
  42430. }, scene?: Nullable<Scene>): Mesh;
  42431. /**
  42432. * Creates a ground mesh from a height map
  42433. * * The parameter `url` sets the URL of the height map image resource.
  42434. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42435. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42436. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42437. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42438. * * 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.
  42439. * * 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).
  42440. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42442. * @param name defines the name of the mesh
  42443. * @param url defines the url to the height map
  42444. * @param options defines the options used to create the mesh
  42445. * @param scene defines the hosting scene
  42446. * @returns the ground mesh
  42447. * @see https://doc.babylonjs.com/babylon101/height_map
  42448. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42449. */
  42450. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42451. width?: number;
  42452. height?: number;
  42453. subdivisions?: number;
  42454. minHeight?: number;
  42455. maxHeight?: number;
  42456. colorFilter?: Color3;
  42457. alphaFilter?: number;
  42458. updatable?: boolean;
  42459. onReady?: (mesh: GroundMesh) => void;
  42460. }, scene?: Nullable<Scene>): GroundMesh;
  42461. }
  42462. }
  42463. declare module BABYLON {
  42464. /**
  42465. * Class containing static functions to help procedurally build meshes
  42466. */
  42467. export class TorusBuilder {
  42468. /**
  42469. * Creates a torus mesh
  42470. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42471. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42472. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42474. * * 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
  42475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42476. * @param name defines the name of the mesh
  42477. * @param options defines the options used to create the mesh
  42478. * @param scene defines the hosting scene
  42479. * @returns the torus mesh
  42480. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42481. */
  42482. static CreateTorus(name: string, options: {
  42483. diameter?: number;
  42484. thickness?: number;
  42485. tessellation?: number;
  42486. updatable?: boolean;
  42487. sideOrientation?: number;
  42488. frontUVs?: Vector4;
  42489. backUVs?: Vector4;
  42490. }, scene: any): Mesh;
  42491. }
  42492. }
  42493. declare module BABYLON {
  42494. /**
  42495. * Class containing static functions to help procedurally build meshes
  42496. */
  42497. export class CylinderBuilder {
  42498. /**
  42499. * Creates a cylinder or a cone mesh
  42500. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42501. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42502. * * 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.
  42503. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42504. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42505. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42506. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42507. * * 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).
  42508. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42509. * * 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).
  42510. * * 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
  42511. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42512. * * 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
  42513. * * 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.
  42514. * * If `enclose` is false, a ring surface is one element.
  42515. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42516. * * 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
  42517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42518. * * 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
  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 cylinder mesh
  42524. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42525. */
  42526. static CreateCylinder(name: string, options: {
  42527. height?: number;
  42528. diameterTop?: number;
  42529. diameterBottom?: number;
  42530. diameter?: number;
  42531. tessellation?: number;
  42532. subdivisions?: number;
  42533. arc?: number;
  42534. faceColors?: Color4[];
  42535. faceUV?: Vector4[];
  42536. updatable?: boolean;
  42537. hasRings?: boolean;
  42538. enclose?: boolean;
  42539. cap?: number;
  42540. sideOrientation?: number;
  42541. frontUVs?: Vector4;
  42542. backUVs?: Vector4;
  42543. }, scene: any): Mesh;
  42544. }
  42545. }
  42546. declare module BABYLON {
  42547. /**
  42548. * States of the webXR experience
  42549. */
  42550. export enum WebXRState {
  42551. /**
  42552. * Transitioning to being in XR mode
  42553. */
  42554. ENTERING_XR = 0,
  42555. /**
  42556. * Transitioning to non XR mode
  42557. */
  42558. EXITING_XR = 1,
  42559. /**
  42560. * In XR mode and presenting
  42561. */
  42562. IN_XR = 2,
  42563. /**
  42564. * Not entered XR mode
  42565. */
  42566. NOT_IN_XR = 3
  42567. }
  42568. /**
  42569. * Abstraction of the XR render target
  42570. */
  42571. export interface WebXRRenderTarget extends IDisposable {
  42572. /**
  42573. * xrpresent context of the canvas which can be used to display/mirror xr content
  42574. */
  42575. canvasContext: WebGLRenderingContext;
  42576. /**
  42577. * xr layer for the canvas
  42578. */
  42579. xrLayer: Nullable<XRWebGLLayer>;
  42580. /**
  42581. * Initializes the xr layer for the session
  42582. * @param xrSession xr session
  42583. * @returns a promise that will resolve once the XR Layer has been created
  42584. */
  42585. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42586. }
  42587. }
  42588. declare module BABYLON {
  42589. /**
  42590. * COnfiguration object for WebXR output canvas
  42591. */
  42592. export class WebXRManagedOutputCanvasOptions {
  42593. /**
  42594. * An optional canvas in case you wish to create it yourself and provide it here.
  42595. * If not provided, a new canvas will be created
  42596. */
  42597. canvasElement?: HTMLCanvasElement;
  42598. /**
  42599. * Options for this XR Layer output
  42600. */
  42601. canvasOptions?: XRWebGLLayerOptions;
  42602. /**
  42603. * CSS styling for a newly created canvas (if not provided)
  42604. */
  42605. newCanvasCssStyle?: string;
  42606. /**
  42607. * Get the default values of the configuration object
  42608. * @returns default values of this configuration object
  42609. */
  42610. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42611. }
  42612. /**
  42613. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42614. */
  42615. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42616. private _options;
  42617. private _canvas;
  42618. private _engine;
  42619. /**
  42620. * Rendering context of the canvas which can be used to display/mirror xr content
  42621. */
  42622. canvasContext: WebGLRenderingContext;
  42623. /**
  42624. * xr layer for the canvas
  42625. */
  42626. xrLayer: Nullable<XRWebGLLayer>;
  42627. /**
  42628. * Initializes the canvas to be added/removed upon entering/exiting xr
  42629. * @param _xrSessionManager The XR Session manager
  42630. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42631. */
  42632. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42633. /**
  42634. * Disposes of the object
  42635. */
  42636. dispose(): void;
  42637. /**
  42638. * Initializes the xr layer for the session
  42639. * @param xrSession xr session
  42640. * @returns a promise that will resolve once the XR Layer has been created
  42641. */
  42642. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42643. private _addCanvas;
  42644. private _removeCanvas;
  42645. private _setManagedOutputCanvas;
  42646. }
  42647. }
  42648. declare module BABYLON {
  42649. /**
  42650. * Manages an XRSession to work with Babylon's engine
  42651. * @see https://doc.babylonjs.com/how_to/webxr
  42652. */
  42653. export class WebXRSessionManager implements IDisposable {
  42654. /** The scene which the session should be created for */
  42655. scene: Scene;
  42656. private _referenceSpace;
  42657. private _rttProvider;
  42658. private _sessionEnded;
  42659. private _xrNavigator;
  42660. private baseLayer;
  42661. /**
  42662. * The base reference space from which the session started. good if you want to reset your
  42663. * reference space
  42664. */
  42665. baseReferenceSpace: XRReferenceSpace;
  42666. /**
  42667. * Current XR frame
  42668. */
  42669. currentFrame: Nullable<XRFrame>;
  42670. /** WebXR timestamp updated every frame */
  42671. currentTimestamp: number;
  42672. /**
  42673. * Used just in case of a failure to initialize an immersive session.
  42674. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42675. */
  42676. defaultHeightCompensation: number;
  42677. /**
  42678. * Fires every time a new xrFrame arrives which can be used to update the camera
  42679. */
  42680. onXRFrameObservable: Observable<XRFrame>;
  42681. /**
  42682. * Fires when the reference space changed
  42683. */
  42684. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42685. /**
  42686. * Fires when the xr session is ended either by the device or manually done
  42687. */
  42688. onXRSessionEnded: Observable<any>;
  42689. /**
  42690. * Fires when the xr session is ended either by the device or manually done
  42691. */
  42692. onXRSessionInit: Observable<XRSession>;
  42693. /**
  42694. * Underlying xr session
  42695. */
  42696. session: XRSession;
  42697. /**
  42698. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42699. * or get the offset the player is currently at.
  42700. */
  42701. viewerReferenceSpace: XRReferenceSpace;
  42702. /**
  42703. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42704. * @param scene The scene which the session should be created for
  42705. */
  42706. constructor(
  42707. /** The scene which the session should be created for */
  42708. scene: Scene);
  42709. /**
  42710. * The current reference space used in this session. This reference space can constantly change!
  42711. * It is mainly used to offset the camera's position.
  42712. */
  42713. get referenceSpace(): XRReferenceSpace;
  42714. /**
  42715. * Set a new reference space and triggers the observable
  42716. */
  42717. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42718. /**
  42719. * Disposes of the session manager
  42720. */
  42721. dispose(): void;
  42722. /**
  42723. * Stops the xrSession and restores the render loop
  42724. * @returns Promise which resolves after it exits XR
  42725. */
  42726. exitXRAsync(): Promise<void>;
  42727. /**
  42728. * Gets the correct render target texture to be rendered this frame for this eye
  42729. * @param eye the eye for which to get the render target
  42730. * @returns the render target for the specified eye
  42731. */
  42732. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42733. /**
  42734. * Creates a WebXRRenderTarget object for the XR session
  42735. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42736. * @param options optional options to provide when creating a new render target
  42737. * @returns a WebXR render target to which the session can render
  42738. */
  42739. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42740. /**
  42741. * Initializes the manager
  42742. * After initialization enterXR can be called to start an XR session
  42743. * @returns Promise which resolves after it is initialized
  42744. */
  42745. initializeAsync(): Promise<void>;
  42746. /**
  42747. * Initializes an xr session
  42748. * @param xrSessionMode mode to initialize
  42749. * @param xrSessionInit defines optional and required values to pass to the session builder
  42750. * @returns a promise which will resolve once the session has been initialized
  42751. */
  42752. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42753. /**
  42754. * Checks if a session would be supported for the creation options specified
  42755. * @param sessionMode session mode to check if supported eg. immersive-vr
  42756. * @returns A Promise that resolves to true if supported and false if not
  42757. */
  42758. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42759. /**
  42760. * Resets the reference space to the one started the session
  42761. */
  42762. resetReferenceSpace(): void;
  42763. /**
  42764. * Starts rendering to the xr layer
  42765. */
  42766. runXRRenderLoop(): void;
  42767. /**
  42768. * Sets the reference space on the xr session
  42769. * @param referenceSpaceType space to set
  42770. * @returns a promise that will resolve once the reference space has been set
  42771. */
  42772. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42773. /**
  42774. * Updates the render state of the session
  42775. * @param state state to set
  42776. * @returns a promise that resolves once the render state has been updated
  42777. */
  42778. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42779. /**
  42780. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42781. * @param sessionMode defines the session to test
  42782. * @returns a promise with boolean as final value
  42783. */
  42784. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42785. private _createRenderTargetTexture;
  42786. }
  42787. }
  42788. declare module BABYLON {
  42789. /**
  42790. * WebXR Camera which holds the views for the xrSession
  42791. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42792. */
  42793. export class WebXRCamera extends FreeCamera {
  42794. private _xrSessionManager;
  42795. private _firstFrame;
  42796. private _referenceQuaternion;
  42797. private _referencedPosition;
  42798. private _xrInvPositionCache;
  42799. private _xrInvQuaternionCache;
  42800. /**
  42801. * Should position compensation execute on first frame.
  42802. * This is used when copying the position from a native (non XR) camera
  42803. */
  42804. compensateOnFirstFrame: boolean;
  42805. /**
  42806. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42807. * @param name the name of the camera
  42808. * @param scene the scene to add the camera to
  42809. * @param _xrSessionManager a constructed xr session manager
  42810. */
  42811. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42812. /**
  42813. * Return the user's height, unrelated to the current ground.
  42814. * This will be the y position of this camera, when ground level is 0.
  42815. */
  42816. get realWorldHeight(): number;
  42817. /** @hidden */
  42818. _updateForDualEyeDebugging(): void;
  42819. /**
  42820. * Sets this camera's transformation based on a non-vr camera
  42821. * @param otherCamera the non-vr camera to copy the transformation from
  42822. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42823. */
  42824. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42825. /**
  42826. * Gets the current instance class name ("WebXRCamera").
  42827. * @returns the class name
  42828. */
  42829. getClassName(): string;
  42830. private _updateFromXRSession;
  42831. private _updateNumberOfRigCameras;
  42832. private _updateReferenceSpace;
  42833. private _updateReferenceSpaceOffset;
  42834. }
  42835. }
  42836. declare module BABYLON {
  42837. /**
  42838. * Defining the interface required for a (webxr) feature
  42839. */
  42840. export interface IWebXRFeature extends IDisposable {
  42841. /**
  42842. * Is this feature attached
  42843. */
  42844. attached: boolean;
  42845. /**
  42846. * Should auto-attach be disabled?
  42847. */
  42848. disableAutoAttach: boolean;
  42849. /**
  42850. * Attach the feature to the session
  42851. * Will usually be called by the features manager
  42852. *
  42853. * @param force should attachment be forced (even when already attached)
  42854. * @returns true if successful.
  42855. */
  42856. attach(force?: boolean): boolean;
  42857. /**
  42858. * Detach the feature from the session
  42859. * Will usually be called by the features manager
  42860. *
  42861. * @returns true if successful.
  42862. */
  42863. detach(): boolean;
  42864. }
  42865. /**
  42866. * A list of the currently available features without referencing them
  42867. */
  42868. export class WebXRFeatureName {
  42869. /**
  42870. * The name of the anchor system feature
  42871. */
  42872. static ANCHOR_SYSTEM: string;
  42873. /**
  42874. * The name of the background remover feature
  42875. */
  42876. static BACKGROUND_REMOVER: string;
  42877. /**
  42878. * The name of the hit test feature
  42879. */
  42880. static HIT_TEST: string;
  42881. /**
  42882. * physics impostors for xr controllers feature
  42883. */
  42884. static PHYSICS_CONTROLLERS: string;
  42885. /**
  42886. * The name of the plane detection feature
  42887. */
  42888. static PLANE_DETECTION: string;
  42889. /**
  42890. * The name of the pointer selection feature
  42891. */
  42892. static POINTER_SELECTION: string;
  42893. /**
  42894. * The name of the teleportation feature
  42895. */
  42896. static TELEPORTATION: string;
  42897. }
  42898. /**
  42899. * Defining the constructor of a feature. Used to register the modules.
  42900. */
  42901. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42902. /**
  42903. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42904. * It is mainly used in AR sessions.
  42905. *
  42906. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42907. */
  42908. export class WebXRFeaturesManager implements IDisposable {
  42909. private _xrSessionManager;
  42910. private static readonly _AvailableFeatures;
  42911. private _features;
  42912. /**
  42913. * constructs a new features manages.
  42914. *
  42915. * @param _xrSessionManager an instance of WebXRSessionManager
  42916. */
  42917. constructor(_xrSessionManager: WebXRSessionManager);
  42918. /**
  42919. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42920. * Mainly used internally.
  42921. *
  42922. * @param featureName the name of the feature to register
  42923. * @param constructorFunction the function used to construct the module
  42924. * @param version the (babylon) version of the module
  42925. * @param stable is that a stable version of this module
  42926. */
  42927. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42928. /**
  42929. * Returns a constructor of a specific feature.
  42930. *
  42931. * @param featureName the name of the feature to construct
  42932. * @param version the version of the feature to load
  42933. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42934. * @param options optional options provided to the module.
  42935. * @returns a function that, when called, will return a new instance of this feature
  42936. */
  42937. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42938. /**
  42939. * Can be used to return the list of features currently registered
  42940. *
  42941. * @returns an Array of available features
  42942. */
  42943. static GetAvailableFeatures(): string[];
  42944. /**
  42945. * Gets the versions available for a specific feature
  42946. * @param featureName the name of the feature
  42947. * @returns an array with the available versions
  42948. */
  42949. static GetAvailableVersions(featureName: string): string[];
  42950. /**
  42951. * Return the latest unstable version of this feature
  42952. * @param featureName the name of the feature to search
  42953. * @returns the version number. if not found will return -1
  42954. */
  42955. static GetLatestVersionOfFeature(featureName: string): number;
  42956. /**
  42957. * Return the latest stable version of this feature
  42958. * @param featureName the name of the feature to search
  42959. * @returns the version number. if not found will return -1
  42960. */
  42961. static GetStableVersionOfFeature(featureName: string): number;
  42962. /**
  42963. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42964. * Can be used during a session to start a feature
  42965. * @param featureName the name of feature to attach
  42966. */
  42967. attachFeature(featureName: string): void;
  42968. /**
  42969. * Can be used inside a session or when the session ends to detach a specific feature
  42970. * @param featureName the name of the feature to detach
  42971. */
  42972. detachFeature(featureName: string): void;
  42973. /**
  42974. * Used to disable an already-enabled feature
  42975. * The feature will be disposed and will be recreated once enabled.
  42976. * @param featureName the feature to disable
  42977. * @returns true if disable was successful
  42978. */
  42979. disableFeature(featureName: string | {
  42980. Name: string;
  42981. }): boolean;
  42982. /**
  42983. * dispose this features manager
  42984. */
  42985. dispose(): void;
  42986. /**
  42987. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  42988. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  42989. *
  42990. * @param featureName the name of the feature to load or the class of the feature
  42991. * @param version optional version to load. if not provided the latest version will be enabled
  42992. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42993. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42994. * @returns a new constructed feature or throws an error if feature not found.
  42995. */
  42996. enableFeature(featureName: string | {
  42997. Name: string;
  42998. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42999. /**
  43000. * get the implementation of an enabled feature.
  43001. * @param featureName the name of the feature to load
  43002. * @returns the feature class, if found
  43003. */
  43004. getEnabledFeature(featureName: string): IWebXRFeature;
  43005. /**
  43006. * Get the list of enabled features
  43007. * @returns an array of enabled features
  43008. */
  43009. getEnabledFeatures(): string[];
  43010. }
  43011. }
  43012. declare module BABYLON {
  43013. /**
  43014. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43015. * @see https://doc.babylonjs.com/how_to/webxr
  43016. */
  43017. export class WebXRExperienceHelper implements IDisposable {
  43018. private scene;
  43019. private _nonVRCamera;
  43020. private _originalSceneAutoClear;
  43021. private _supported;
  43022. /**
  43023. * Camera used to render xr content
  43024. */
  43025. camera: WebXRCamera;
  43026. /** A features manager for this xr session */
  43027. featuresManager: WebXRFeaturesManager;
  43028. /**
  43029. * Observers registered here will be triggered after the camera's initial transformation is set
  43030. * This can be used to set a different ground level or an extra rotation.
  43031. *
  43032. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43033. * to the position set after this observable is done executing.
  43034. */
  43035. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43036. /**
  43037. * Fires when the state of the experience helper has changed
  43038. */
  43039. onStateChangedObservable: Observable<WebXRState>;
  43040. /** Session manager used to keep track of xr session */
  43041. sessionManager: WebXRSessionManager;
  43042. /**
  43043. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43044. */
  43045. state: WebXRState;
  43046. /**
  43047. * Creates a WebXRExperienceHelper
  43048. * @param scene The scene the helper should be created in
  43049. */
  43050. private constructor();
  43051. /**
  43052. * Creates the experience helper
  43053. * @param scene the scene to attach the experience helper to
  43054. * @returns a promise for the experience helper
  43055. */
  43056. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43057. /**
  43058. * Disposes of the experience helper
  43059. */
  43060. dispose(): void;
  43061. /**
  43062. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43063. * @param sessionMode options for the XR session
  43064. * @param referenceSpaceType frame of reference of the XR session
  43065. * @param renderTarget the output canvas that will be used to enter XR mode
  43066. * @returns promise that resolves after xr mode has entered
  43067. */
  43068. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43069. /**
  43070. * Exits XR mode and returns the scene to its original state
  43071. * @returns promise that resolves after xr mode has exited
  43072. */
  43073. exitXRAsync(): Promise<void>;
  43074. private _nonXRToXRCamera;
  43075. private _setState;
  43076. }
  43077. }
  43078. declare module BABYLON {
  43079. /**
  43080. * X-Y values for axes in WebXR
  43081. */
  43082. export interface IWebXRMotionControllerAxesValue {
  43083. /**
  43084. * The value of the x axis
  43085. */
  43086. x: number;
  43087. /**
  43088. * The value of the y-axis
  43089. */
  43090. y: number;
  43091. }
  43092. /**
  43093. * changed / previous values for the values of this component
  43094. */
  43095. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43096. /**
  43097. * current (this frame) value
  43098. */
  43099. current: T;
  43100. /**
  43101. * previous (last change) value
  43102. */
  43103. previous: T;
  43104. }
  43105. /**
  43106. * Represents changes in the component between current frame and last values recorded
  43107. */
  43108. export interface IWebXRMotionControllerComponentChanges {
  43109. /**
  43110. * will be populated with previous and current values if axes changed
  43111. */
  43112. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43113. /**
  43114. * will be populated with previous and current values if pressed changed
  43115. */
  43116. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43117. /**
  43118. * will be populated with previous and current values if touched changed
  43119. */
  43120. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43121. /**
  43122. * will be populated with previous and current values if value changed
  43123. */
  43124. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43125. }
  43126. /**
  43127. * This class represents a single component (for example button or thumbstick) of a motion controller
  43128. */
  43129. export class WebXRControllerComponent implements IDisposable {
  43130. /**
  43131. * the id of this component
  43132. */
  43133. id: string;
  43134. /**
  43135. * the type of the component
  43136. */
  43137. type: MotionControllerComponentType;
  43138. private _buttonIndex;
  43139. private _axesIndices;
  43140. private _axes;
  43141. private _changes;
  43142. private _currentValue;
  43143. private _hasChanges;
  43144. private _pressed;
  43145. private _touched;
  43146. /**
  43147. * button component type
  43148. */
  43149. static BUTTON_TYPE: MotionControllerComponentType;
  43150. /**
  43151. * squeeze component type
  43152. */
  43153. static SQUEEZE_TYPE: MotionControllerComponentType;
  43154. /**
  43155. * Thumbstick component type
  43156. */
  43157. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43158. /**
  43159. * Touchpad component type
  43160. */
  43161. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43162. /**
  43163. * trigger component type
  43164. */
  43165. static TRIGGER_TYPE: MotionControllerComponentType;
  43166. /**
  43167. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43168. * the axes data changes
  43169. */
  43170. onAxisValueChangedObservable: Observable<{
  43171. x: number;
  43172. y: number;
  43173. }>;
  43174. /**
  43175. * Observers registered here will be triggered when the state of a button changes
  43176. * State change is either pressed / touched / value
  43177. */
  43178. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43179. /**
  43180. * Creates a new component for a motion controller.
  43181. * It is created by the motion controller itself
  43182. *
  43183. * @param id the id of this component
  43184. * @param type the type of the component
  43185. * @param _buttonIndex index in the buttons array of the gamepad
  43186. * @param _axesIndices indices of the values in the axes array of the gamepad
  43187. */
  43188. constructor(
  43189. /**
  43190. * the id of this component
  43191. */
  43192. id: string,
  43193. /**
  43194. * the type of the component
  43195. */
  43196. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43197. /**
  43198. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43199. */
  43200. get axes(): IWebXRMotionControllerAxesValue;
  43201. /**
  43202. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43203. */
  43204. get changes(): IWebXRMotionControllerComponentChanges;
  43205. /**
  43206. * Return whether or not the component changed the last frame
  43207. */
  43208. get hasChanges(): boolean;
  43209. /**
  43210. * is the button currently pressed
  43211. */
  43212. get pressed(): boolean;
  43213. /**
  43214. * is the button currently touched
  43215. */
  43216. get touched(): boolean;
  43217. /**
  43218. * Get the current value of this component
  43219. */
  43220. get value(): number;
  43221. /**
  43222. * Dispose this component
  43223. */
  43224. dispose(): void;
  43225. /**
  43226. * Are there axes correlating to this component
  43227. * @return true is axes data is available
  43228. */
  43229. isAxes(): boolean;
  43230. /**
  43231. * Is this component a button (hence - pressable)
  43232. * @returns true if can be pressed
  43233. */
  43234. isButton(): boolean;
  43235. /**
  43236. * update this component using the gamepad object it is in. Called on every frame
  43237. * @param nativeController the native gamepad controller object
  43238. */
  43239. update(nativeController: IMinimalMotionControllerObject): void;
  43240. }
  43241. }
  43242. declare module BABYLON {
  43243. /**
  43244. * Class used to represent data loading progression
  43245. */
  43246. export class SceneLoaderProgressEvent {
  43247. /** defines if data length to load can be evaluated */
  43248. readonly lengthComputable: boolean;
  43249. /** defines the loaded data length */
  43250. readonly loaded: number;
  43251. /** defines the data length to load */
  43252. readonly total: number;
  43253. /**
  43254. * Create a new progress event
  43255. * @param lengthComputable defines if data length to load can be evaluated
  43256. * @param loaded defines the loaded data length
  43257. * @param total defines the data length to load
  43258. */
  43259. constructor(
  43260. /** defines if data length to load can be evaluated */
  43261. lengthComputable: boolean,
  43262. /** defines the loaded data length */
  43263. loaded: number,
  43264. /** defines the data length to load */
  43265. total: number);
  43266. /**
  43267. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43268. * @param event defines the source event
  43269. * @returns a new SceneLoaderProgressEvent
  43270. */
  43271. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43272. }
  43273. /**
  43274. * Interface used by SceneLoader plugins to define supported file extensions
  43275. */
  43276. export interface ISceneLoaderPluginExtensions {
  43277. /**
  43278. * Defines the list of supported extensions
  43279. */
  43280. [extension: string]: {
  43281. isBinary: boolean;
  43282. };
  43283. }
  43284. /**
  43285. * Interface used by SceneLoader plugin factory
  43286. */
  43287. export interface ISceneLoaderPluginFactory {
  43288. /**
  43289. * Defines the name of the factory
  43290. */
  43291. name: string;
  43292. /**
  43293. * Function called to create a new plugin
  43294. * @return the new plugin
  43295. */
  43296. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43297. /**
  43298. * The callback that returns true if the data can be directly loaded.
  43299. * @param data string containing the file data
  43300. * @returns if the data can be loaded directly
  43301. */
  43302. canDirectLoad?(data: string): boolean;
  43303. }
  43304. /**
  43305. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43306. */
  43307. export interface ISceneLoaderPluginBase {
  43308. /**
  43309. * The friendly name of this plugin.
  43310. */
  43311. name: string;
  43312. /**
  43313. * The file extensions supported by this plugin.
  43314. */
  43315. extensions: string | ISceneLoaderPluginExtensions;
  43316. /**
  43317. * The callback called when loading from a url.
  43318. * @param scene scene loading this url
  43319. * @param url url to load
  43320. * @param onSuccess callback called when the file successfully loads
  43321. * @param onProgress callback called while file is loading (if the server supports this mode)
  43322. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43323. * @param onError callback called when the file fails to load
  43324. * @returns a file request object
  43325. */
  43326. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43327. /**
  43328. * The callback called when loading from a file object.
  43329. * @param scene scene loading this file
  43330. * @param file defines the file to load
  43331. * @param onSuccess defines the callback to call when data is loaded
  43332. * @param onProgress defines the callback to call during loading process
  43333. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43334. * @param onError defines the callback to call when an error occurs
  43335. * @returns a file request object
  43336. */
  43337. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43338. /**
  43339. * The callback that returns true if the data can be directly loaded.
  43340. * @param data string containing the file data
  43341. * @returns if the data can be loaded directly
  43342. */
  43343. canDirectLoad?(data: string): boolean;
  43344. /**
  43345. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43346. * @param scene scene loading this data
  43347. * @param data string containing the data
  43348. * @returns data to pass to the plugin
  43349. */
  43350. directLoad?(scene: Scene, data: string): any;
  43351. /**
  43352. * The callback that allows custom handling of the root url based on the response url.
  43353. * @param rootUrl the original root url
  43354. * @param responseURL the response url if available
  43355. * @returns the new root url
  43356. */
  43357. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43358. }
  43359. /**
  43360. * Interface used to define a SceneLoader plugin
  43361. */
  43362. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43363. /**
  43364. * Import meshes into a scene.
  43365. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43366. * @param scene The scene to import into
  43367. * @param data The data to import
  43368. * @param rootUrl The root url for scene and resources
  43369. * @param meshes The meshes array to import into
  43370. * @param particleSystems The particle systems array to import into
  43371. * @param skeletons The skeletons array to import into
  43372. * @param onError The callback when import fails
  43373. * @returns True if successful or false otherwise
  43374. */
  43375. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43376. /**
  43377. * Load into a scene.
  43378. * @param scene The scene to load into
  43379. * @param data The data to import
  43380. * @param rootUrl The root url for scene and resources
  43381. * @param onError The callback when import fails
  43382. * @returns True if successful or false otherwise
  43383. */
  43384. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43385. /**
  43386. * Load into an asset container.
  43387. * @param scene The scene to load into
  43388. * @param data The data to import
  43389. * @param rootUrl The root url for scene and resources
  43390. * @param onError The callback when import fails
  43391. * @returns The loaded asset container
  43392. */
  43393. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43394. }
  43395. /**
  43396. * Interface used to define an async SceneLoader plugin
  43397. */
  43398. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43399. /**
  43400. * Import meshes into a scene.
  43401. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43402. * @param scene The scene to import into
  43403. * @param data The data to import
  43404. * @param rootUrl The root url for scene and resources
  43405. * @param onProgress The callback when the load progresses
  43406. * @param fileName Defines the name of the file to load
  43407. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43408. */
  43409. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43410. meshes: AbstractMesh[];
  43411. particleSystems: IParticleSystem[];
  43412. skeletons: Skeleton[];
  43413. animationGroups: AnimationGroup[];
  43414. }>;
  43415. /**
  43416. * Load into a scene.
  43417. * @param scene The scene to load into
  43418. * @param data The data to import
  43419. * @param rootUrl The root url for scene and resources
  43420. * @param onProgress The callback when the load progresses
  43421. * @param fileName Defines the name of the file to load
  43422. * @returns Nothing
  43423. */
  43424. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43425. /**
  43426. * Load into an asset container.
  43427. * @param scene The scene to load into
  43428. * @param data The data to import
  43429. * @param rootUrl The root url for scene and resources
  43430. * @param onProgress The callback when the load progresses
  43431. * @param fileName Defines the name of the file to load
  43432. * @returns The loaded asset container
  43433. */
  43434. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43435. }
  43436. /**
  43437. * Mode that determines how to handle old animation groups before loading new ones.
  43438. */
  43439. export enum SceneLoaderAnimationGroupLoadingMode {
  43440. /**
  43441. * Reset all old animations to initial state then dispose them.
  43442. */
  43443. Clean = 0,
  43444. /**
  43445. * Stop all old animations.
  43446. */
  43447. Stop = 1,
  43448. /**
  43449. * Restart old animations from first frame.
  43450. */
  43451. Sync = 2,
  43452. /**
  43453. * Old animations remains untouched.
  43454. */
  43455. NoSync = 3
  43456. }
  43457. /**
  43458. * Class used to load scene from various file formats using registered plugins
  43459. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43460. */
  43461. export class SceneLoader {
  43462. /**
  43463. * No logging while loading
  43464. */
  43465. static readonly NO_LOGGING: number;
  43466. /**
  43467. * Minimal logging while loading
  43468. */
  43469. static readonly MINIMAL_LOGGING: number;
  43470. /**
  43471. * Summary logging while loading
  43472. */
  43473. static readonly SUMMARY_LOGGING: number;
  43474. /**
  43475. * Detailled logging while loading
  43476. */
  43477. static readonly DETAILED_LOGGING: number;
  43478. /**
  43479. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43480. */
  43481. static get ForceFullSceneLoadingForIncremental(): boolean;
  43482. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43483. /**
  43484. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43485. */
  43486. static get ShowLoadingScreen(): boolean;
  43487. static set ShowLoadingScreen(value: boolean);
  43488. /**
  43489. * Defines the current logging level (while loading the scene)
  43490. * @ignorenaming
  43491. */
  43492. static get loggingLevel(): number;
  43493. static set loggingLevel(value: number);
  43494. /**
  43495. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43496. */
  43497. static get CleanBoneMatrixWeights(): boolean;
  43498. static set CleanBoneMatrixWeights(value: boolean);
  43499. /**
  43500. * Event raised when a plugin is used to load a scene
  43501. */
  43502. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43503. private static _registeredPlugins;
  43504. private static _getDefaultPlugin;
  43505. private static _getPluginForExtension;
  43506. private static _getPluginForDirectLoad;
  43507. private static _getPluginForFilename;
  43508. private static _getDirectLoad;
  43509. private static _loadData;
  43510. private static _getFileInfo;
  43511. /**
  43512. * Gets a plugin that can load the given extension
  43513. * @param extension defines the extension to load
  43514. * @returns a plugin or null if none works
  43515. */
  43516. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43517. /**
  43518. * Gets a boolean indicating that the given extension can be loaded
  43519. * @param extension defines the extension to load
  43520. * @returns true if the extension is supported
  43521. */
  43522. static IsPluginForExtensionAvailable(extension: string): boolean;
  43523. /**
  43524. * Adds a new plugin to the list of registered plugins
  43525. * @param plugin defines the plugin to add
  43526. */
  43527. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43528. /**
  43529. * Import meshes into a scene
  43530. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43531. * @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)
  43532. * @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)
  43533. * @param scene the instance of BABYLON.Scene to append to
  43534. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43535. * @param onProgress a callback with a progress event for each file being loaded
  43536. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43537. * @param pluginExtension the extension used to determine the plugin
  43538. * @returns The loaded plugin
  43539. */
  43540. 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>;
  43541. /**
  43542. * Import meshes into a scene
  43543. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43544. * @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)
  43545. * @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)
  43546. * @param scene the instance of BABYLON.Scene to append to
  43547. * @param onProgress a callback with a progress event for each file being loaded
  43548. * @param pluginExtension the extension used to determine the plugin
  43549. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43550. */
  43551. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43552. meshes: AbstractMesh[];
  43553. particleSystems: IParticleSystem[];
  43554. skeletons: Skeleton[];
  43555. animationGroups: AnimationGroup[];
  43556. }>;
  43557. /**
  43558. * Load a scene
  43559. * @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)
  43560. * @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)
  43561. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43562. * @param onSuccess a callback with the scene when import succeeds
  43563. * @param onProgress a callback with a progress event for each file being loaded
  43564. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43565. * @param pluginExtension the extension used to determine the plugin
  43566. * @returns The loaded plugin
  43567. */
  43568. 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>;
  43569. /**
  43570. * Load a scene
  43571. * @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)
  43572. * @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)
  43573. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43574. * @param onProgress a callback with a progress event for each file being loaded
  43575. * @param pluginExtension the extension used to determine the plugin
  43576. * @returns The loaded scene
  43577. */
  43578. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43579. /**
  43580. * Append a scene
  43581. * @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)
  43582. * @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)
  43583. * @param scene is the instance of BABYLON.Scene to append to
  43584. * @param onSuccess a callback with the scene when import succeeds
  43585. * @param onProgress a callback with a progress event for each file being loaded
  43586. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43587. * @param pluginExtension the extension used to determine the plugin
  43588. * @returns The loaded plugin
  43589. */
  43590. 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>;
  43591. /**
  43592. * Append a scene
  43593. * @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)
  43594. * @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)
  43595. * @param scene is the instance of BABYLON.Scene to append to
  43596. * @param onProgress a callback with a progress event for each file being loaded
  43597. * @param pluginExtension the extension used to determine the plugin
  43598. * @returns The given scene
  43599. */
  43600. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43601. /**
  43602. * Load a scene into an asset container
  43603. * @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)
  43604. * @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)
  43605. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43606. * @param onSuccess a callback with the scene when import succeeds
  43607. * @param onProgress a callback with a progress event for each file being loaded
  43608. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43609. * @param pluginExtension the extension used to determine the plugin
  43610. * @returns The loaded plugin
  43611. */
  43612. 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>;
  43613. /**
  43614. * Load a scene into an asset container
  43615. * @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)
  43616. * @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)
  43617. * @param scene is the instance of Scene to append to
  43618. * @param onProgress a callback with a progress event for each file being loaded
  43619. * @param pluginExtension the extension used to determine the plugin
  43620. * @returns The loaded asset container
  43621. */
  43622. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43623. /**
  43624. * Import animations from a file into a scene
  43625. * @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)
  43626. * @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)
  43627. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43628. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43629. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43630. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43631. * @param onSuccess a callback with the scene when import succeeds
  43632. * @param onProgress a callback with a progress event for each file being loaded
  43633. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43634. */
  43635. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  43636. /**
  43637. * Import animations from a file into a scene
  43638. * @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)
  43639. * @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)
  43640. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43641. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43642. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43643. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43644. * @param onSuccess a callback with the scene when import succeeds
  43645. * @param onProgress a callback with a progress event for each file being loaded
  43646. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43647. * @returns the updated scene with imported animations
  43648. */
  43649. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  43650. }
  43651. }
  43652. declare module BABYLON {
  43653. /**
  43654. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43655. */
  43656. export type MotionControllerHandness = "none" | "left" | "right";
  43657. /**
  43658. * The type of components available in motion controllers.
  43659. * This is not the name of the component.
  43660. */
  43661. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43662. /**
  43663. * The state of a controller component
  43664. */
  43665. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43666. /**
  43667. * The schema of motion controller layout.
  43668. * No object will be initialized using this interface
  43669. * This is used just to define the profile.
  43670. */
  43671. export interface IMotionControllerLayout {
  43672. /**
  43673. * Path to load the assets. Usually relative to the base path
  43674. */
  43675. assetPath: string;
  43676. /**
  43677. * Available components (unsorted)
  43678. */
  43679. components: {
  43680. /**
  43681. * A map of component Ids
  43682. */
  43683. [componentId: string]: {
  43684. /**
  43685. * The type of input the component outputs
  43686. */
  43687. type: MotionControllerComponentType;
  43688. /**
  43689. * The indices of this component in the gamepad object
  43690. */
  43691. gamepadIndices: {
  43692. /**
  43693. * Index of button
  43694. */
  43695. button?: number;
  43696. /**
  43697. * If available, index of x-axis
  43698. */
  43699. xAxis?: number;
  43700. /**
  43701. * If available, index of y-axis
  43702. */
  43703. yAxis?: number;
  43704. };
  43705. /**
  43706. * The mesh's root node name
  43707. */
  43708. rootNodeName: string;
  43709. /**
  43710. * Animation definitions for this model
  43711. */
  43712. visualResponses: {
  43713. [stateKey: string]: {
  43714. /**
  43715. * What property will be animated
  43716. */
  43717. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43718. /**
  43719. * What states influence this visual response
  43720. */
  43721. states: MotionControllerComponentStateType[];
  43722. /**
  43723. * Type of animation - movement or visibility
  43724. */
  43725. valueNodeProperty: "transform" | "visibility";
  43726. /**
  43727. * Base node name to move. Its position will be calculated according to the min and max nodes
  43728. */
  43729. valueNodeName?: string;
  43730. /**
  43731. * Minimum movement node
  43732. */
  43733. minNodeName?: string;
  43734. /**
  43735. * Max movement node
  43736. */
  43737. maxNodeName?: string;
  43738. };
  43739. };
  43740. /**
  43741. * If touch enabled, what is the name of node to display user feedback
  43742. */
  43743. touchPointNodeName?: string;
  43744. };
  43745. };
  43746. /**
  43747. * Is it xr standard mapping or not
  43748. */
  43749. gamepadMapping: "" | "xr-standard";
  43750. /**
  43751. * Base root node of this entire model
  43752. */
  43753. rootNodeName: string;
  43754. /**
  43755. * Defines the main button component id
  43756. */
  43757. selectComponentId: string;
  43758. }
  43759. /**
  43760. * A definition for the layout map in the input profile
  43761. */
  43762. export interface IMotionControllerLayoutMap {
  43763. /**
  43764. * Layouts with handness type as a key
  43765. */
  43766. [handness: string]: IMotionControllerLayout;
  43767. }
  43768. /**
  43769. * The XR Input profile schema
  43770. * Profiles can be found here:
  43771. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43772. */
  43773. export interface IMotionControllerProfile {
  43774. /**
  43775. * fallback profiles for this profileId
  43776. */
  43777. fallbackProfileIds: string[];
  43778. /**
  43779. * The layout map, with handness as key
  43780. */
  43781. layouts: IMotionControllerLayoutMap;
  43782. /**
  43783. * The id of this profile
  43784. * correlates to the profile(s) in the xrInput.profiles array
  43785. */
  43786. profileId: string;
  43787. }
  43788. /**
  43789. * A helper-interface for the 3 meshes needed for controller button animation
  43790. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43791. */
  43792. export interface IMotionControllerButtonMeshMap {
  43793. /**
  43794. * the mesh that defines the pressed value mesh position.
  43795. * This is used to find the max-position of this button
  43796. */
  43797. pressedMesh: AbstractMesh;
  43798. /**
  43799. * the mesh that defines the unpressed value mesh position.
  43800. * This is used to find the min (or initial) position of this button
  43801. */
  43802. unpressedMesh: AbstractMesh;
  43803. /**
  43804. * The mesh that will be changed when value changes
  43805. */
  43806. valueMesh: AbstractMesh;
  43807. }
  43808. /**
  43809. * A helper-interface for the 3 meshes needed for controller axis animation.
  43810. * This will be expanded when touchpad animations are fully supported
  43811. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43812. */
  43813. export interface IMotionControllerMeshMap {
  43814. /**
  43815. * the mesh that defines the maximum value mesh position.
  43816. */
  43817. maxMesh?: AbstractMesh;
  43818. /**
  43819. * the mesh that defines the minimum value mesh position.
  43820. */
  43821. minMesh?: AbstractMesh;
  43822. /**
  43823. * The mesh that will be changed when axis value changes
  43824. */
  43825. valueMesh: AbstractMesh;
  43826. }
  43827. /**
  43828. * The elements needed for change-detection of the gamepad objects in motion controllers
  43829. */
  43830. export interface IMinimalMotionControllerObject {
  43831. /**
  43832. * Available axes of this controller
  43833. */
  43834. axes: number[];
  43835. /**
  43836. * An array of available buttons
  43837. */
  43838. buttons: Array<{
  43839. /**
  43840. * Value of the button/trigger
  43841. */
  43842. value: number;
  43843. /**
  43844. * If the button/trigger is currently touched
  43845. */
  43846. touched: boolean;
  43847. /**
  43848. * If the button/trigger is currently pressed
  43849. */
  43850. pressed: boolean;
  43851. }>;
  43852. }
  43853. /**
  43854. * An Abstract Motion controller
  43855. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43856. * Each component has an observable to check for changes in value and state
  43857. */
  43858. export abstract class WebXRAbstractMotionController implements IDisposable {
  43859. protected scene: Scene;
  43860. protected layout: IMotionControllerLayout;
  43861. /**
  43862. * The gamepad object correlating to this controller
  43863. */
  43864. gamepadObject: IMinimalMotionControllerObject;
  43865. /**
  43866. * handness (left/right/none) of this controller
  43867. */
  43868. handness: MotionControllerHandness;
  43869. private _initComponent;
  43870. private _modelReady;
  43871. /**
  43872. * A map of components (WebXRControllerComponent) in this motion controller
  43873. * Components have a ComponentType and can also have both button and axis definitions
  43874. */
  43875. readonly components: {
  43876. [id: string]: WebXRControllerComponent;
  43877. };
  43878. /**
  43879. * Disable the model's animation. Can be set at any time.
  43880. */
  43881. disableAnimation: boolean;
  43882. /**
  43883. * Observers registered here will be triggered when the model of this controller is done loading
  43884. */
  43885. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43886. /**
  43887. * The profile id of this motion controller
  43888. */
  43889. abstract profileId: string;
  43890. /**
  43891. * The root mesh of the model. It is null if the model was not yet initialized
  43892. */
  43893. rootMesh: Nullable<AbstractMesh>;
  43894. /**
  43895. * constructs a new abstract motion controller
  43896. * @param scene the scene to which the model of the controller will be added
  43897. * @param layout The profile layout to load
  43898. * @param gamepadObject The gamepad object correlating to this controller
  43899. * @param handness handness (left/right/none) of this controller
  43900. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43901. */
  43902. constructor(scene: Scene, layout: IMotionControllerLayout,
  43903. /**
  43904. * The gamepad object correlating to this controller
  43905. */
  43906. gamepadObject: IMinimalMotionControllerObject,
  43907. /**
  43908. * handness (left/right/none) of this controller
  43909. */
  43910. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43911. /**
  43912. * Dispose this controller, the model mesh and all its components
  43913. */
  43914. dispose(): void;
  43915. /**
  43916. * Returns all components of specific type
  43917. * @param type the type to search for
  43918. * @return an array of components with this type
  43919. */
  43920. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43921. /**
  43922. * get a component based an its component id as defined in layout.components
  43923. * @param id the id of the component
  43924. * @returns the component correlates to the id or undefined if not found
  43925. */
  43926. getComponent(id: string): WebXRControllerComponent;
  43927. /**
  43928. * Get the list of components available in this motion controller
  43929. * @returns an array of strings correlating to available components
  43930. */
  43931. getComponentIds(): string[];
  43932. /**
  43933. * Get the first component of specific type
  43934. * @param type type of component to find
  43935. * @return a controller component or null if not found
  43936. */
  43937. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43938. /**
  43939. * Get the main (Select) component of this controller as defined in the layout
  43940. * @returns the main component of this controller
  43941. */
  43942. getMainComponent(): WebXRControllerComponent;
  43943. /**
  43944. * Loads the model correlating to this controller
  43945. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43946. * @returns A promise fulfilled with the result of the model loading
  43947. */
  43948. loadModel(): Promise<boolean>;
  43949. /**
  43950. * Update this model using the current XRFrame
  43951. * @param xrFrame the current xr frame to use and update the model
  43952. */
  43953. updateFromXRFrame(xrFrame: XRFrame): void;
  43954. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43955. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43956. /**
  43957. * Moves the axis on the controller mesh based on its current state
  43958. * @param axis the index of the axis
  43959. * @param axisValue the value of the axis which determines the meshes new position
  43960. * @hidden
  43961. */
  43962. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43963. /**
  43964. * Update the model itself with the current frame data
  43965. * @param xrFrame the frame to use for updating the model mesh
  43966. */
  43967. protected updateModel(xrFrame: XRFrame): void;
  43968. /**
  43969. * Get the filename and path for this controller's model
  43970. * @returns a map of filename and path
  43971. */
  43972. protected abstract _getFilenameAndPath(): {
  43973. filename: string;
  43974. path: string;
  43975. };
  43976. /**
  43977. * This function is called before the mesh is loaded. It checks for loading constraints.
  43978. * For example, this function can check if the GLB loader is available
  43979. * If this function returns false, the generic controller will be loaded instead
  43980. * @returns Is the client ready to load the mesh
  43981. */
  43982. protected abstract _getModelLoadingConstraints(): boolean;
  43983. /**
  43984. * This function will be called after the model was successfully loaded and can be used
  43985. * for mesh transformations before it is available for the user
  43986. * @param meshes the loaded meshes
  43987. */
  43988. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43989. /**
  43990. * Set the root mesh for this controller. Important for the WebXR controller class
  43991. * @param meshes the loaded meshes
  43992. */
  43993. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43994. /**
  43995. * A function executed each frame that updates the mesh (if needed)
  43996. * @param xrFrame the current xrFrame
  43997. */
  43998. protected abstract _updateModel(xrFrame: XRFrame): void;
  43999. private _getGenericFilenameAndPath;
  44000. private _getGenericParentMesh;
  44001. }
  44002. }
  44003. declare module BABYLON {
  44004. /**
  44005. * A generic trigger-only motion controller for WebXR
  44006. */
  44007. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44008. /**
  44009. * Static version of the profile id of this controller
  44010. */
  44011. static ProfileId: string;
  44012. profileId: string;
  44013. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44014. protected _getFilenameAndPath(): {
  44015. filename: string;
  44016. path: string;
  44017. };
  44018. protected _getModelLoadingConstraints(): boolean;
  44019. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44020. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44021. protected _updateModel(): void;
  44022. }
  44023. }
  44024. declare module BABYLON {
  44025. /**
  44026. * Class containing static functions to help procedurally build meshes
  44027. */
  44028. export class SphereBuilder {
  44029. /**
  44030. * Creates a sphere mesh
  44031. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44032. * * 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`)
  44033. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44034. * * 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
  44035. * * 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)
  44036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44037. * * 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
  44038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44039. * @param name defines the name of the mesh
  44040. * @param options defines the options used to create the mesh
  44041. * @param scene defines the hosting scene
  44042. * @returns the sphere mesh
  44043. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44044. */
  44045. static CreateSphere(name: string, options: {
  44046. segments?: number;
  44047. diameter?: number;
  44048. diameterX?: number;
  44049. diameterY?: number;
  44050. diameterZ?: number;
  44051. arc?: number;
  44052. slice?: number;
  44053. sideOrientation?: number;
  44054. frontUVs?: Vector4;
  44055. backUVs?: Vector4;
  44056. updatable?: boolean;
  44057. }, scene?: Nullable<Scene>): Mesh;
  44058. }
  44059. }
  44060. declare module BABYLON {
  44061. /**
  44062. * A profiled motion controller has its profile loaded from an online repository.
  44063. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44064. */
  44065. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44066. private _repositoryUrl;
  44067. private _buttonMeshMapping;
  44068. private _touchDots;
  44069. /**
  44070. * The profile ID of this controller. Will be populated when the controller initializes.
  44071. */
  44072. profileId: string;
  44073. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44074. dispose(): void;
  44075. protected _getFilenameAndPath(): {
  44076. filename: string;
  44077. path: string;
  44078. };
  44079. protected _getModelLoadingConstraints(): boolean;
  44080. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44081. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44082. protected _updateModel(_xrFrame: XRFrame): void;
  44083. }
  44084. }
  44085. declare module BABYLON {
  44086. /**
  44087. * A construction function type to create a new controller based on an xrInput object
  44088. */
  44089. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44090. /**
  44091. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44092. *
  44093. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44094. * it should be replaced with auto-loaded controllers.
  44095. *
  44096. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44097. */
  44098. export class WebXRMotionControllerManager {
  44099. private static _AvailableControllers;
  44100. private static _Fallbacks;
  44101. private static _ProfileLoadingPromises;
  44102. private static _ProfilesList;
  44103. /**
  44104. * The base URL of the online controller repository. Can be changed at any time.
  44105. */
  44106. static BaseRepositoryUrl: string;
  44107. /**
  44108. * Which repository gets priority - local or online
  44109. */
  44110. static PrioritizeOnlineRepository: boolean;
  44111. /**
  44112. * Use the online repository, or use only locally-defined controllers
  44113. */
  44114. static UseOnlineRepository: boolean;
  44115. /**
  44116. * Clear the cache used for profile loading and reload when requested again
  44117. */
  44118. static ClearProfilesCache(): void;
  44119. /**
  44120. * Register the default fallbacks.
  44121. * This function is called automatically when this file is imported.
  44122. */
  44123. static DefaultFallbacks(): void;
  44124. /**
  44125. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44126. * @param profileId the profile to which a fallback needs to be found
  44127. * @return an array with corresponding fallback profiles
  44128. */
  44129. static FindFallbackWithProfileId(profileId: string): string[];
  44130. /**
  44131. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44132. * The order of search:
  44133. *
  44134. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44135. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44136. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44137. * 4) return the generic trigger controller if none were found
  44138. *
  44139. * @param xrInput the xrInput to which a new controller is initialized
  44140. * @param scene the scene to which the model will be added
  44141. * @param forceProfile force a certain profile for this controller
  44142. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44143. */
  44144. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44145. /**
  44146. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44147. *
  44148. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44149. *
  44150. * @param type the profile type to register
  44151. * @param constructFunction the function to be called when loading this profile
  44152. */
  44153. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44154. /**
  44155. * Register a fallback to a specific profile.
  44156. * @param profileId the profileId that will receive the fallbacks
  44157. * @param fallbacks A list of fallback profiles
  44158. */
  44159. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44160. /**
  44161. * Will update the list of profiles available in the repository
  44162. * @return a promise that resolves to a map of profiles available online
  44163. */
  44164. static UpdateProfilesList(): Promise<{
  44165. [profile: string]: string;
  44166. }>;
  44167. private static _LoadProfileFromRepository;
  44168. private static _LoadProfilesFromAvailableControllers;
  44169. }
  44170. }
  44171. declare module BABYLON {
  44172. /**
  44173. * Configuration options for the WebXR controller creation
  44174. */
  44175. export interface IWebXRControllerOptions {
  44176. /**
  44177. * Should the controller mesh be animated when a user interacts with it
  44178. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44179. */
  44180. disableMotionControllerAnimation?: boolean;
  44181. /**
  44182. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44183. */
  44184. doNotLoadControllerMesh?: boolean;
  44185. /**
  44186. * Force a specific controller type for this controller.
  44187. * This can be used when creating your own profile or when testing different controllers
  44188. */
  44189. forceControllerProfile?: string;
  44190. }
  44191. /**
  44192. * Represents an XR controller
  44193. */
  44194. export class WebXRInputSource {
  44195. private _scene;
  44196. /** The underlying input source for the controller */
  44197. inputSource: XRInputSource;
  44198. private _options;
  44199. private _tmpQuaternion;
  44200. private _tmpVector;
  44201. private _uniqueId;
  44202. /**
  44203. * 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
  44204. */
  44205. grip?: AbstractMesh;
  44206. /**
  44207. * If available, this is the gamepad object related to this controller.
  44208. * Using this object it is possible to get click events and trackpad changes of the
  44209. * webxr controller that is currently being used.
  44210. */
  44211. motionController?: WebXRAbstractMotionController;
  44212. /**
  44213. * Event that fires when the controller is removed/disposed.
  44214. * The object provided as event data is this controller, after associated assets were disposed.
  44215. * uniqueId is still available.
  44216. */
  44217. onDisposeObservable: Observable<WebXRInputSource>;
  44218. /**
  44219. * Will be triggered when the mesh associated with the motion controller is done loading.
  44220. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44221. * A shortened version of controller -> motion controller -> on mesh loaded.
  44222. */
  44223. onMeshLoadedObservable: Observable<AbstractMesh>;
  44224. /**
  44225. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44226. */
  44227. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44228. /**
  44229. * Pointer which can be used to select objects or attach a visible laser to
  44230. */
  44231. pointer: AbstractMesh;
  44232. /**
  44233. * Creates the controller
  44234. * @see https://doc.babylonjs.com/how_to/webxr
  44235. * @param _scene the scene which the controller should be associated to
  44236. * @param inputSource the underlying input source for the controller
  44237. * @param _options options for this controller creation
  44238. */
  44239. constructor(_scene: Scene,
  44240. /** The underlying input source for the controller */
  44241. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44242. /**
  44243. * Get this controllers unique id
  44244. */
  44245. get uniqueId(): string;
  44246. /**
  44247. * Disposes of the object
  44248. */
  44249. dispose(): void;
  44250. /**
  44251. * Gets a world space ray coming from the pointer or grip
  44252. * @param result the resulting ray
  44253. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44254. */
  44255. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44256. /**
  44257. * Updates the controller pose based on the given XRFrame
  44258. * @param xrFrame xr frame to update the pose with
  44259. * @param referenceSpace reference space to use
  44260. */
  44261. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44262. }
  44263. }
  44264. declare module BABYLON {
  44265. /**
  44266. * The schema for initialization options of the XR Input class
  44267. */
  44268. export interface IWebXRInputOptions {
  44269. /**
  44270. * If set to true no model will be automatically loaded
  44271. */
  44272. doNotLoadControllerMeshes?: boolean;
  44273. /**
  44274. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44275. * If not found, the xr input profile data will be used.
  44276. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44277. */
  44278. forceInputProfile?: string;
  44279. /**
  44280. * Do not send a request to the controller repository to load the profile.
  44281. *
  44282. * Instead, use the controllers available in babylon itself.
  44283. */
  44284. disableOnlineControllerRepository?: boolean;
  44285. /**
  44286. * A custom URL for the controllers repository
  44287. */
  44288. customControllersRepositoryURL?: string;
  44289. /**
  44290. * Should the controller model's components not move according to the user input
  44291. */
  44292. disableControllerAnimation?: boolean;
  44293. }
  44294. /**
  44295. * XR input used to track XR inputs such as controllers/rays
  44296. */
  44297. export class WebXRInput implements IDisposable {
  44298. /**
  44299. * the xr session manager for this session
  44300. */
  44301. xrSessionManager: WebXRSessionManager;
  44302. /**
  44303. * the WebXR camera for this session. Mainly used for teleportation
  44304. */
  44305. xrCamera: WebXRCamera;
  44306. private readonly options;
  44307. /**
  44308. * XR controllers being tracked
  44309. */
  44310. controllers: Array<WebXRInputSource>;
  44311. private _frameObserver;
  44312. private _sessionEndedObserver;
  44313. private _sessionInitObserver;
  44314. /**
  44315. * Event when a controller has been connected/added
  44316. */
  44317. onControllerAddedObservable: Observable<WebXRInputSource>;
  44318. /**
  44319. * Event when a controller has been removed/disconnected
  44320. */
  44321. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44322. /**
  44323. * Initializes the WebXRInput
  44324. * @param xrSessionManager the xr session manager for this session
  44325. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44326. * @param options = initialization options for this xr input
  44327. */
  44328. constructor(
  44329. /**
  44330. * the xr session manager for this session
  44331. */
  44332. xrSessionManager: WebXRSessionManager,
  44333. /**
  44334. * the WebXR camera for this session. Mainly used for teleportation
  44335. */
  44336. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44337. private _onInputSourcesChange;
  44338. private _addAndRemoveControllers;
  44339. /**
  44340. * Disposes of the object
  44341. */
  44342. dispose(): void;
  44343. }
  44344. }
  44345. declare module BABYLON {
  44346. /**
  44347. * This is the base class for all WebXR features.
  44348. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44349. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44350. */
  44351. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44352. protected _xrSessionManager: WebXRSessionManager;
  44353. private _attached;
  44354. private _removeOnDetach;
  44355. /**
  44356. * Should auto-attach be disabled?
  44357. */
  44358. disableAutoAttach: boolean;
  44359. /**
  44360. * Construct a new (abstract) WebXR feature
  44361. * @param _xrSessionManager the xr session manager for this feature
  44362. */
  44363. constructor(_xrSessionManager: WebXRSessionManager);
  44364. /**
  44365. * Is this feature attached
  44366. */
  44367. get attached(): boolean;
  44368. /**
  44369. * attach this feature
  44370. *
  44371. * @param force should attachment be forced (even when already attached)
  44372. * @returns true if successful, false is failed or already attached
  44373. */
  44374. attach(force?: boolean): boolean;
  44375. /**
  44376. * detach this feature.
  44377. *
  44378. * @returns true if successful, false if failed or already detached
  44379. */
  44380. detach(): boolean;
  44381. /**
  44382. * Dispose this feature and all of the resources attached
  44383. */
  44384. dispose(): void;
  44385. /**
  44386. * This is used to register callbacks that will automatically be removed when detach is called.
  44387. * @param observable the observable to which the observer will be attached
  44388. * @param callback the callback to register
  44389. */
  44390. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44391. /**
  44392. * Code in this function will be executed on each xrFrame received from the browser.
  44393. * This function will not execute after the feature is detached.
  44394. * @param _xrFrame the current frame
  44395. */
  44396. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44397. }
  44398. }
  44399. declare module BABYLON {
  44400. /**
  44401. * Renders a layer on top of an existing scene
  44402. */
  44403. export class UtilityLayerRenderer implements IDisposable {
  44404. /** the original scene that will be rendered on top of */
  44405. originalScene: Scene;
  44406. private _pointerCaptures;
  44407. private _lastPointerEvents;
  44408. private static _DefaultUtilityLayer;
  44409. private static _DefaultKeepDepthUtilityLayer;
  44410. private _sharedGizmoLight;
  44411. private _renderCamera;
  44412. /**
  44413. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44414. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44415. * @returns the camera that is used when rendering the utility layer
  44416. */
  44417. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44418. /**
  44419. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44420. * @param cam the camera that should be used when rendering the utility layer
  44421. */
  44422. setRenderCamera(cam: Nullable<Camera>): void;
  44423. /**
  44424. * @hidden
  44425. * Light which used by gizmos to get light shading
  44426. */
  44427. _getSharedGizmoLight(): HemisphericLight;
  44428. /**
  44429. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44430. */
  44431. pickUtilitySceneFirst: boolean;
  44432. /**
  44433. * 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)
  44434. */
  44435. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44436. /**
  44437. * 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)
  44438. */
  44439. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44440. /**
  44441. * The scene that is rendered on top of the original scene
  44442. */
  44443. utilityLayerScene: Scene;
  44444. /**
  44445. * If the utility layer should automatically be rendered on top of existing scene
  44446. */
  44447. shouldRender: boolean;
  44448. /**
  44449. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44450. */
  44451. onlyCheckPointerDownEvents: boolean;
  44452. /**
  44453. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44454. */
  44455. processAllEvents: boolean;
  44456. /**
  44457. * Observable raised when the pointer move from the utility layer scene to the main scene
  44458. */
  44459. onPointerOutObservable: Observable<number>;
  44460. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44461. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44462. private _afterRenderObserver;
  44463. private _sceneDisposeObserver;
  44464. private _originalPointerObserver;
  44465. /**
  44466. * Instantiates a UtilityLayerRenderer
  44467. * @param originalScene the original scene that will be rendered on top of
  44468. * @param handleEvents boolean indicating if the utility layer should handle events
  44469. */
  44470. constructor(
  44471. /** the original scene that will be rendered on top of */
  44472. originalScene: Scene, handleEvents?: boolean);
  44473. private _notifyObservers;
  44474. /**
  44475. * Renders the utility layers scene on top of the original scene
  44476. */
  44477. render(): void;
  44478. /**
  44479. * Disposes of the renderer
  44480. */
  44481. dispose(): void;
  44482. private _updateCamera;
  44483. }
  44484. }
  44485. declare module BABYLON {
  44486. /**
  44487. * Options interface for the pointer selection module
  44488. */
  44489. export interface IWebXRControllerPointerSelectionOptions {
  44490. /**
  44491. * if provided, this scene will be used to render meshes.
  44492. */
  44493. customUtilityLayerScene?: Scene;
  44494. /**
  44495. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  44496. * If not disabled, the last picked point will be used to execute a pointer up event
  44497. * If disabled, pointer up event will be triggered right after the pointer down event.
  44498. * Used in screen and gaze target ray mode only
  44499. */
  44500. disablePointerUpOnTouchOut: boolean;
  44501. /**
  44502. * For gaze mode (time to select instead of press)
  44503. */
  44504. forceGazeMode: boolean;
  44505. /**
  44506. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  44507. * to start a new countdown to the pointer down event.
  44508. * Defaults to 1.
  44509. */
  44510. gazeModePointerMovedFactor?: number;
  44511. /**
  44512. * Different button type to use instead of the main component
  44513. */
  44514. overrideButtonId?: string;
  44515. /**
  44516. * use this rendering group id for the meshes (optional)
  44517. */
  44518. renderingGroupId?: number;
  44519. /**
  44520. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44521. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44522. * 3000 means 3 seconds between pointing at something and selecting it
  44523. */
  44524. timeToSelect?: number;
  44525. /**
  44526. * Should meshes created here be added to a utility layer or the main scene
  44527. */
  44528. useUtilityLayer?: boolean;
  44529. /**
  44530. * the xr input to use with this pointer selection
  44531. */
  44532. xrInput: WebXRInput;
  44533. }
  44534. /**
  44535. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44536. */
  44537. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44538. private readonly _options;
  44539. private static _idCounter;
  44540. private _attachController;
  44541. private _controllers;
  44542. private _scene;
  44543. private _tmpVectorForPickCompare;
  44544. /**
  44545. * The module's name
  44546. */
  44547. static readonly Name: string;
  44548. /**
  44549. * The (Babylon) version of this module.
  44550. * This is an integer representing the implementation version.
  44551. * This number does not correspond to the WebXR specs version
  44552. */
  44553. static readonly Version: number;
  44554. /**
  44555. * Disable lighting on the laser pointer (so it will always be visible)
  44556. */
  44557. disablePointerLighting: boolean;
  44558. /**
  44559. * Disable lighting on the selection mesh (so it will always be visible)
  44560. */
  44561. disableSelectionMeshLighting: boolean;
  44562. /**
  44563. * Should the laser pointer be displayed
  44564. */
  44565. displayLaserPointer: boolean;
  44566. /**
  44567. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44568. */
  44569. displaySelectionMesh: boolean;
  44570. /**
  44571. * This color will be set to the laser pointer when selection is triggered
  44572. */
  44573. laserPointerPickedColor: Color3;
  44574. /**
  44575. * Default color of the laser pointer
  44576. */
  44577. lasterPointerDefaultColor: Color3;
  44578. /**
  44579. * default color of the selection ring
  44580. */
  44581. selectionMeshDefaultColor: Color3;
  44582. /**
  44583. * This color will be applied to the selection ring when selection is triggered
  44584. */
  44585. selectionMeshPickedColor: Color3;
  44586. /**
  44587. * constructs a new background remover module
  44588. * @param _xrSessionManager the session manager for this module
  44589. * @param _options read-only options to be used in this module
  44590. */
  44591. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44592. /**
  44593. * attach this feature
  44594. * Will usually be called by the features manager
  44595. *
  44596. * @returns true if successful.
  44597. */
  44598. attach(): boolean;
  44599. /**
  44600. * detach this feature.
  44601. * Will usually be called by the features manager
  44602. *
  44603. * @returns true if successful.
  44604. */
  44605. detach(): boolean;
  44606. /**
  44607. * Will get the mesh under a specific pointer.
  44608. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44609. * @param controllerId the controllerId to check
  44610. * @returns The mesh under pointer or null if no mesh is under the pointer
  44611. */
  44612. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44613. /**
  44614. * Get the xr controller that correlates to the pointer id in the pointer event
  44615. *
  44616. * @param id the pointer id to search for
  44617. * @returns the controller that correlates to this id or null if not found
  44618. */
  44619. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44620. protected _onXRFrame(_xrFrame: XRFrame): void;
  44621. private _attachGazeMode;
  44622. private _attachScreenRayMode;
  44623. private _attachTrackedPointerRayMode;
  44624. private _convertNormalToDirectionOfRay;
  44625. private _detachController;
  44626. private _generateNewMeshPair;
  44627. private _pickingMoved;
  44628. private _updatePointerDistance;
  44629. }
  44630. }
  44631. declare module BABYLON {
  44632. /**
  44633. * Button which can be used to enter a different mode of XR
  44634. */
  44635. export class WebXREnterExitUIButton {
  44636. /** button element */
  44637. element: HTMLElement;
  44638. /** XR initialization options for the button */
  44639. sessionMode: XRSessionMode;
  44640. /** Reference space type */
  44641. referenceSpaceType: XRReferenceSpaceType;
  44642. /**
  44643. * Creates a WebXREnterExitUIButton
  44644. * @param element button element
  44645. * @param sessionMode XR initialization session mode
  44646. * @param referenceSpaceType the type of reference space to be used
  44647. */
  44648. constructor(
  44649. /** button element */
  44650. element: HTMLElement,
  44651. /** XR initialization options for the button */
  44652. sessionMode: XRSessionMode,
  44653. /** Reference space type */
  44654. referenceSpaceType: XRReferenceSpaceType);
  44655. /**
  44656. * Extendable function which can be used to update the button's visuals when the state changes
  44657. * @param activeButton the current active button in the UI
  44658. */
  44659. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44660. }
  44661. /**
  44662. * Options to create the webXR UI
  44663. */
  44664. export class WebXREnterExitUIOptions {
  44665. /**
  44666. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44667. */
  44668. customButtons?: Array<WebXREnterExitUIButton>;
  44669. /**
  44670. * A reference space type to use when creating the default button.
  44671. * Default is local-floor
  44672. */
  44673. referenceSpaceType?: XRReferenceSpaceType;
  44674. /**
  44675. * Context to enter xr with
  44676. */
  44677. renderTarget?: Nullable<WebXRRenderTarget>;
  44678. /**
  44679. * A session mode to use when creating the default button.
  44680. * Default is immersive-vr
  44681. */
  44682. sessionMode?: XRSessionMode;
  44683. }
  44684. /**
  44685. * UI to allow the user to enter/exit XR mode
  44686. */
  44687. export class WebXREnterExitUI implements IDisposable {
  44688. private scene;
  44689. /** version of the options passed to this UI */
  44690. options: WebXREnterExitUIOptions;
  44691. private _activeButton;
  44692. private _buttons;
  44693. private _overlay;
  44694. /**
  44695. * Fired every time the active button is changed.
  44696. *
  44697. * When xr is entered via a button that launches xr that button will be the callback parameter
  44698. *
  44699. * When exiting xr the callback parameter will be null)
  44700. */
  44701. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44702. /**
  44703. *
  44704. * @param scene babylon scene object to use
  44705. * @param options (read-only) version of the options passed to this UI
  44706. */
  44707. private constructor();
  44708. /**
  44709. * Creates UI to allow the user to enter/exit XR mode
  44710. * @param scene the scene to add the ui to
  44711. * @param helper the xr experience helper to enter/exit xr with
  44712. * @param options options to configure the UI
  44713. * @returns the created ui
  44714. */
  44715. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44716. /**
  44717. * Disposes of the XR UI component
  44718. */
  44719. dispose(): void;
  44720. private _updateButtons;
  44721. }
  44722. }
  44723. declare module BABYLON {
  44724. /**
  44725. * Class containing static functions to help procedurally build meshes
  44726. */
  44727. export class LinesBuilder {
  44728. /**
  44729. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44730. * * 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
  44731. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44732. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44733. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44734. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44735. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44736. * * 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
  44737. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44739. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44740. * @param name defines the name of the new line system
  44741. * @param options defines the options used to create the line system
  44742. * @param scene defines the hosting scene
  44743. * @returns a new line system mesh
  44744. */
  44745. static CreateLineSystem(name: string, options: {
  44746. lines: Vector3[][];
  44747. updatable?: boolean;
  44748. instance?: Nullable<LinesMesh>;
  44749. colors?: Nullable<Color4[][]>;
  44750. useVertexAlpha?: boolean;
  44751. }, scene: Nullable<Scene>): LinesMesh;
  44752. /**
  44753. * Creates a line mesh
  44754. * 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
  44755. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44756. * * The parameter `points` is an array successive Vector3
  44757. * * 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
  44758. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44759. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44760. * * When updating an instance, remember that only point positions can change, not the number of points
  44761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44762. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44763. * @param name defines the name of the new line system
  44764. * @param options defines the options used to create the line system
  44765. * @param scene defines the hosting scene
  44766. * @returns a new line mesh
  44767. */
  44768. static CreateLines(name: string, options: {
  44769. points: Vector3[];
  44770. updatable?: boolean;
  44771. instance?: Nullable<LinesMesh>;
  44772. colors?: Color4[];
  44773. useVertexAlpha?: boolean;
  44774. }, scene?: Nullable<Scene>): LinesMesh;
  44775. /**
  44776. * Creates a dashed line mesh
  44777. * * 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
  44778. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44779. * * The parameter `points` is an array successive Vector3
  44780. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44781. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44782. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44783. * * 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
  44784. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44785. * * When updating an instance, remember that only point positions can change, not the number of points
  44786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44787. * @param name defines the name of the mesh
  44788. * @param options defines the options used to create the mesh
  44789. * @param scene defines the hosting scene
  44790. * @returns the dashed line mesh
  44791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44792. */
  44793. static CreateDashedLines(name: string, options: {
  44794. points: Vector3[];
  44795. dashSize?: number;
  44796. gapSize?: number;
  44797. dashNb?: number;
  44798. updatable?: boolean;
  44799. instance?: LinesMesh;
  44800. useVertexAlpha?: boolean;
  44801. }, scene?: Nullable<Scene>): LinesMesh;
  44802. }
  44803. }
  44804. declare module BABYLON {
  44805. /**
  44806. * The options container for the teleportation module
  44807. */
  44808. export interface IWebXRTeleportationOptions {
  44809. /**
  44810. * if provided, this scene will be used to render meshes.
  44811. */
  44812. customUtilityLayerScene?: Scene;
  44813. /**
  44814. * Values to configure the default target mesh
  44815. */
  44816. defaultTargetMeshOptions?: {
  44817. /**
  44818. * Fill color of the teleportation area
  44819. */
  44820. teleportationFillColor?: string;
  44821. /**
  44822. * Border color for the teleportation area
  44823. */
  44824. teleportationBorderColor?: string;
  44825. /**
  44826. * Disable the mesh's animation sequence
  44827. */
  44828. disableAnimation?: boolean;
  44829. /**
  44830. * Disable lighting on the material or the ring and arrow
  44831. */
  44832. disableLighting?: boolean;
  44833. /**
  44834. * Override the default material of the torus and arrow
  44835. */
  44836. torusArrowMaterial?: Material;
  44837. };
  44838. /**
  44839. * A list of meshes to use as floor meshes.
  44840. * Meshes can be added and removed after initializing the feature using the
  44841. * addFloorMesh and removeFloorMesh functions
  44842. * If empty, rotation will still work
  44843. */
  44844. floorMeshes?: AbstractMesh[];
  44845. /**
  44846. * use this rendering group id for the meshes (optional)
  44847. */
  44848. renderingGroupId?: number;
  44849. /**
  44850. * Should teleportation move only to snap points
  44851. */
  44852. snapPointsOnly?: boolean;
  44853. /**
  44854. * An array of points to which the teleportation will snap to.
  44855. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  44856. */
  44857. snapPositions?: Vector3[];
  44858. /**
  44859. * How close should the teleportation ray be in order to snap to position.
  44860. * Default to 0.8 units (meters)
  44861. */
  44862. snapToPositionRadius?: number;
  44863. /**
  44864. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44865. * If you want to support rotation, make sure your mesh has a direction indicator.
  44866. *
  44867. * When left untouched, the default mesh will be initialized.
  44868. */
  44869. teleportationTargetMesh?: AbstractMesh;
  44870. /**
  44871. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  44872. */
  44873. timeToTeleport?: number;
  44874. /**
  44875. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  44876. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  44877. */
  44878. useMainComponentOnly?: boolean;
  44879. /**
  44880. * Should meshes created here be added to a utility layer or the main scene
  44881. */
  44882. useUtilityLayer?: boolean;
  44883. /**
  44884. * Babylon XR Input class for controller
  44885. */
  44886. xrInput: WebXRInput;
  44887. }
  44888. /**
  44889. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  44890. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  44891. * the input of the attached controllers.
  44892. */
  44893. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44894. private _options;
  44895. private _controllers;
  44896. private _currentTeleportationControllerId;
  44897. private _floorMeshes;
  44898. private _quadraticBezierCurve;
  44899. private _selectionFeature;
  44900. private _snapToPositions;
  44901. private _snappedToPoint;
  44902. private _teleportationRingMaterial?;
  44903. private _tmpRay;
  44904. private _tmpVector;
  44905. /**
  44906. * The module's name
  44907. */
  44908. static readonly Name: string;
  44909. /**
  44910. * The (Babylon) version of this module.
  44911. * This is an integer representing the implementation version.
  44912. * This number does not correspond to the webxr specs version
  44913. */
  44914. static readonly Version: number;
  44915. /**
  44916. * Is movement backwards enabled
  44917. */
  44918. backwardsMovementEnabled: boolean;
  44919. /**
  44920. * Distance to travel when moving backwards
  44921. */
  44922. backwardsTeleportationDistance: number;
  44923. /**
  44924. * The distance from the user to the inspection point in the direction of the controller
  44925. * A higher number will allow the user to move further
  44926. * defaults to 5 (meters, in xr units)
  44927. */
  44928. parabolicCheckRadius: number;
  44929. /**
  44930. * Should the module support parabolic ray on top of direct ray
  44931. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44932. * Very helpful when moving between floors / different heights
  44933. */
  44934. parabolicRayEnabled: boolean;
  44935. /**
  44936. * How much rotation should be applied when rotating right and left
  44937. */
  44938. rotationAngle: number;
  44939. /**
  44940. * Is rotation enabled when moving forward?
  44941. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44942. */
  44943. rotationEnabled: boolean;
  44944. /**
  44945. * constructs a new anchor system
  44946. * @param _xrSessionManager an instance of WebXRSessionManager
  44947. * @param _options configuration object for this feature
  44948. */
  44949. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44950. /**
  44951. * Get the snapPointsOnly flag
  44952. */
  44953. get snapPointsOnly(): boolean;
  44954. /**
  44955. * Sets the snapPointsOnly flag
  44956. * @param snapToPoints should teleportation be exclusively to snap points
  44957. */
  44958. set snapPointsOnly(snapToPoints: boolean);
  44959. /**
  44960. * Add a new mesh to the floor meshes array
  44961. * @param mesh the mesh to use as floor mesh
  44962. */
  44963. addFloorMesh(mesh: AbstractMesh): void;
  44964. /**
  44965. * Add a new snap-to point to fix teleportation to this position
  44966. * @param newSnapPoint The new Snap-To point
  44967. */
  44968. addSnapPoint(newSnapPoint: Vector3): void;
  44969. attach(): boolean;
  44970. detach(): boolean;
  44971. dispose(): void;
  44972. /**
  44973. * Remove a mesh from the floor meshes array
  44974. * @param mesh the mesh to remove
  44975. */
  44976. removeFloorMesh(mesh: AbstractMesh): void;
  44977. /**
  44978. * Remove a mesh from the floor meshes array using its name
  44979. * @param name the mesh name to remove
  44980. */
  44981. removeFloorMeshByName(name: string): void;
  44982. /**
  44983. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  44984. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  44985. * @returns was the point found and removed or not
  44986. */
  44987. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  44988. /**
  44989. * This function sets a selection feature that will be disabled when
  44990. * the forward ray is shown and will be reattached when hidden.
  44991. * This is used to remove the selection rays when moving.
  44992. * @param selectionFeature the feature to disable when forward movement is enabled
  44993. */
  44994. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44995. protected _onXRFrame(_xrFrame: XRFrame): void;
  44996. private _attachController;
  44997. private _createDefaultTargetMesh;
  44998. private _detachController;
  44999. private _findClosestSnapPointWithRadius;
  45000. private _setTargetMeshPosition;
  45001. private _setTargetMeshVisibility;
  45002. private _showParabolicPath;
  45003. private _teleportForward;
  45004. }
  45005. }
  45006. declare module BABYLON {
  45007. /**
  45008. * Options for the default xr helper
  45009. */
  45010. export class WebXRDefaultExperienceOptions {
  45011. /**
  45012. * Enable or disable default UI to enter XR
  45013. */
  45014. disableDefaultUI?: boolean;
  45015. /**
  45016. * Should teleportation not initialize. defaults to false.
  45017. */
  45018. disableTeleportation?: boolean;
  45019. /**
  45020. * Floor meshes that will be used for teleport
  45021. */
  45022. floorMeshes?: Array<AbstractMesh>;
  45023. /**
  45024. * If set to true, the first frame will not be used to reset position
  45025. * The first frame is mainly used when copying transformation from the old camera
  45026. * Mainly used in AR
  45027. */
  45028. ignoreNativeCameraTransformation?: boolean;
  45029. /**
  45030. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45031. */
  45032. inputOptions?: IWebXRInputOptions;
  45033. /**
  45034. * optional configuration for the output canvas
  45035. */
  45036. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45037. /**
  45038. * optional UI options. This can be used among other to change session mode and reference space type
  45039. */
  45040. uiOptions?: WebXREnterExitUIOptions;
  45041. /**
  45042. * When loading teleportation and pointer select, use stable versions instead of latest.
  45043. */
  45044. useStablePlugins?: boolean;
  45045. }
  45046. /**
  45047. * Default experience which provides a similar setup to the previous webVRExperience
  45048. */
  45049. export class WebXRDefaultExperience {
  45050. /**
  45051. * Base experience
  45052. */
  45053. baseExperience: WebXRExperienceHelper;
  45054. /**
  45055. * Enables ui for entering/exiting xr
  45056. */
  45057. enterExitUI: WebXREnterExitUI;
  45058. /**
  45059. * Input experience extension
  45060. */
  45061. input: WebXRInput;
  45062. /**
  45063. * Enables laser pointer and selection
  45064. */
  45065. pointerSelection: WebXRControllerPointerSelection;
  45066. /**
  45067. * Default target xr should render to
  45068. */
  45069. renderTarget: WebXRRenderTarget;
  45070. /**
  45071. * Enables teleportation
  45072. */
  45073. teleportation: WebXRMotionControllerTeleportation;
  45074. private constructor();
  45075. /**
  45076. * Creates the default xr experience
  45077. * @param scene scene
  45078. * @param options options for basic configuration
  45079. * @returns resulting WebXRDefaultExperience
  45080. */
  45081. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45082. /**
  45083. * DIsposes of the experience helper
  45084. */
  45085. dispose(): void;
  45086. }
  45087. }
  45088. declare module BABYLON {
  45089. /**
  45090. * Options to modify the vr teleportation behavior.
  45091. */
  45092. export interface VRTeleportationOptions {
  45093. /**
  45094. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45095. */
  45096. floorMeshName?: string;
  45097. /**
  45098. * A list of meshes to be used as the teleportation floor. (default: empty)
  45099. */
  45100. floorMeshes?: Mesh[];
  45101. /**
  45102. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45103. */
  45104. teleportationMode?: number;
  45105. /**
  45106. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45107. */
  45108. teleportationTime?: number;
  45109. /**
  45110. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45111. */
  45112. teleportationSpeed?: number;
  45113. /**
  45114. * The easing function used in the animation or null for Linear. (default CircleEase)
  45115. */
  45116. easingFunction?: EasingFunction;
  45117. }
  45118. /**
  45119. * Options to modify the vr experience helper's behavior.
  45120. */
  45121. export interface VRExperienceHelperOptions extends WebVROptions {
  45122. /**
  45123. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45124. */
  45125. createDeviceOrientationCamera?: boolean;
  45126. /**
  45127. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45128. */
  45129. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45130. /**
  45131. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45132. */
  45133. laserToggle?: boolean;
  45134. /**
  45135. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45136. */
  45137. floorMeshes?: Mesh[];
  45138. /**
  45139. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45140. */
  45141. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45142. /**
  45143. * Defines if WebXR should be used instead of WebVR (if available)
  45144. */
  45145. useXR?: boolean;
  45146. }
  45147. /**
  45148. * Event containing information after VR has been entered
  45149. */
  45150. export class OnAfterEnteringVRObservableEvent {
  45151. /**
  45152. * If entering vr was successful
  45153. */
  45154. success: boolean;
  45155. }
  45156. /**
  45157. * Helps to quickly add VR support to an existing scene.
  45158. * See http://doc.babylonjs.com/how_to/webvr_helper
  45159. */
  45160. export class VRExperienceHelper {
  45161. /** Options to modify the vr experience helper's behavior. */
  45162. webVROptions: VRExperienceHelperOptions;
  45163. private _scene;
  45164. private _position;
  45165. private _btnVR;
  45166. private _btnVRDisplayed;
  45167. private _webVRsupported;
  45168. private _webVRready;
  45169. private _webVRrequesting;
  45170. private _webVRpresenting;
  45171. private _hasEnteredVR;
  45172. private _fullscreenVRpresenting;
  45173. private _inputElement;
  45174. private _webVRCamera;
  45175. private _vrDeviceOrientationCamera;
  45176. private _deviceOrientationCamera;
  45177. private _existingCamera;
  45178. private _onKeyDown;
  45179. private _onVrDisplayPresentChange;
  45180. private _onVRDisplayChanged;
  45181. private _onVRRequestPresentStart;
  45182. private _onVRRequestPresentComplete;
  45183. /**
  45184. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  45185. */
  45186. enableGazeEvenWhenNoPointerLock: boolean;
  45187. /**
  45188. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45189. */
  45190. exitVROnDoubleTap: boolean;
  45191. /**
  45192. * Observable raised right before entering VR.
  45193. */
  45194. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45195. /**
  45196. * Observable raised when entering VR has completed.
  45197. */
  45198. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45199. /**
  45200. * Observable raised when exiting VR.
  45201. */
  45202. onExitingVRObservable: Observable<VRExperienceHelper>;
  45203. /**
  45204. * Observable raised when controller mesh is loaded.
  45205. */
  45206. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45207. /** Return this.onEnteringVRObservable
  45208. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45209. */
  45210. get onEnteringVR(): Observable<VRExperienceHelper>;
  45211. /** Return this.onExitingVRObservable
  45212. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45213. */
  45214. get onExitingVR(): Observable<VRExperienceHelper>;
  45215. /** Return this.onControllerMeshLoadedObservable
  45216. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45217. */
  45218. get onControllerMeshLoaded(): Observable<WebVRController>;
  45219. private _rayLength;
  45220. private _useCustomVRButton;
  45221. private _teleportationRequested;
  45222. private _teleportActive;
  45223. private _floorMeshName;
  45224. private _floorMeshesCollection;
  45225. private _teleportationMode;
  45226. private _teleportationTime;
  45227. private _teleportationSpeed;
  45228. private _teleportationEasing;
  45229. private _rotationAllowed;
  45230. private _teleportBackwardsVector;
  45231. private _teleportationTarget;
  45232. private _isDefaultTeleportationTarget;
  45233. private _postProcessMove;
  45234. private _teleportationFillColor;
  45235. private _teleportationBorderColor;
  45236. private _rotationAngle;
  45237. private _haloCenter;
  45238. private _cameraGazer;
  45239. private _padSensibilityUp;
  45240. private _padSensibilityDown;
  45241. private _leftController;
  45242. private _rightController;
  45243. private _gazeColor;
  45244. private _laserColor;
  45245. private _pickedLaserColor;
  45246. private _pickedGazeColor;
  45247. /**
  45248. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45249. */
  45250. onNewMeshSelected: Observable<AbstractMesh>;
  45251. /**
  45252. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45253. * This observable will provide the mesh and the controller used to select the mesh
  45254. */
  45255. onMeshSelectedWithController: Observable<{
  45256. mesh: AbstractMesh;
  45257. controller: WebVRController;
  45258. }>;
  45259. /**
  45260. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45261. */
  45262. onNewMeshPicked: Observable<PickingInfo>;
  45263. private _circleEase;
  45264. /**
  45265. * Observable raised before camera teleportation
  45266. */
  45267. onBeforeCameraTeleport: Observable<Vector3>;
  45268. /**
  45269. * Observable raised after camera teleportation
  45270. */
  45271. onAfterCameraTeleport: Observable<Vector3>;
  45272. /**
  45273. * Observable raised when current selected mesh gets unselected
  45274. */
  45275. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45276. private _raySelectionPredicate;
  45277. /**
  45278. * To be optionaly changed by user to define custom ray selection
  45279. */
  45280. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45281. /**
  45282. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45283. */
  45284. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45285. /**
  45286. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45287. */
  45288. teleportationEnabled: boolean;
  45289. private _defaultHeight;
  45290. private _teleportationInitialized;
  45291. private _interactionsEnabled;
  45292. private _interactionsRequested;
  45293. private _displayGaze;
  45294. private _displayLaserPointer;
  45295. /**
  45296. * The mesh used to display where the user is going to teleport.
  45297. */
  45298. get teleportationTarget(): Mesh;
  45299. /**
  45300. * Sets the mesh to be used to display where the user is going to teleport.
  45301. */
  45302. set teleportationTarget(value: Mesh);
  45303. /**
  45304. * 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
  45305. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45306. * See http://doc.babylonjs.com/resources/baking_transformations
  45307. */
  45308. get gazeTrackerMesh(): Mesh;
  45309. set gazeTrackerMesh(value: Mesh);
  45310. /**
  45311. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45312. */
  45313. updateGazeTrackerScale: boolean;
  45314. /**
  45315. * If the gaze trackers color should be updated when selecting meshes
  45316. */
  45317. updateGazeTrackerColor: boolean;
  45318. /**
  45319. * If the controller laser color should be updated when selecting meshes
  45320. */
  45321. updateControllerLaserColor: boolean;
  45322. /**
  45323. * The gaze tracking mesh corresponding to the left controller
  45324. */
  45325. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45326. /**
  45327. * The gaze tracking mesh corresponding to the right controller
  45328. */
  45329. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45330. /**
  45331. * If the ray of the gaze should be displayed.
  45332. */
  45333. get displayGaze(): boolean;
  45334. /**
  45335. * Sets if the ray of the gaze should be displayed.
  45336. */
  45337. set displayGaze(value: boolean);
  45338. /**
  45339. * If the ray of the LaserPointer should be displayed.
  45340. */
  45341. get displayLaserPointer(): boolean;
  45342. /**
  45343. * Sets if the ray of the LaserPointer should be displayed.
  45344. */
  45345. set displayLaserPointer(value: boolean);
  45346. /**
  45347. * The deviceOrientationCamera used as the camera when not in VR.
  45348. */
  45349. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45350. /**
  45351. * Based on the current WebVR support, returns the current VR camera used.
  45352. */
  45353. get currentVRCamera(): Nullable<Camera>;
  45354. /**
  45355. * The webVRCamera which is used when in VR.
  45356. */
  45357. get webVRCamera(): WebVRFreeCamera;
  45358. /**
  45359. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45360. */
  45361. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45362. /**
  45363. * The html button that is used to trigger entering into VR.
  45364. */
  45365. get vrButton(): Nullable<HTMLButtonElement>;
  45366. private get _teleportationRequestInitiated();
  45367. /**
  45368. * Defines whether or not Pointer lock should be requested when switching to
  45369. * full screen.
  45370. */
  45371. requestPointerLockOnFullScreen: boolean;
  45372. /**
  45373. * If asking to force XR, this will be populated with the default xr experience
  45374. */
  45375. xr: WebXRDefaultExperience;
  45376. /**
  45377. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45378. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45379. */
  45380. xrTestDone: boolean;
  45381. /**
  45382. * Instantiates a VRExperienceHelper.
  45383. * Helps to quickly add VR support to an existing scene.
  45384. * @param scene The scene the VRExperienceHelper belongs to.
  45385. * @param webVROptions Options to modify the vr experience helper's behavior.
  45386. */
  45387. constructor(scene: Scene,
  45388. /** Options to modify the vr experience helper's behavior. */
  45389. webVROptions?: VRExperienceHelperOptions);
  45390. private completeVRInit;
  45391. private _onDefaultMeshLoaded;
  45392. private _onResize;
  45393. private _onFullscreenChange;
  45394. /**
  45395. * Gets a value indicating if we are currently in VR mode.
  45396. */
  45397. get isInVRMode(): boolean;
  45398. private onVrDisplayPresentChange;
  45399. private onVRDisplayChanged;
  45400. private moveButtonToBottomRight;
  45401. private displayVRButton;
  45402. private updateButtonVisibility;
  45403. private _cachedAngularSensibility;
  45404. /**
  45405. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45406. * Otherwise, will use the fullscreen API.
  45407. */
  45408. enterVR(): void;
  45409. /**
  45410. * Attempt to exit VR, or fullscreen.
  45411. */
  45412. exitVR(): void;
  45413. /**
  45414. * The position of the vr experience helper.
  45415. */
  45416. get position(): Vector3;
  45417. /**
  45418. * Sets the position of the vr experience helper.
  45419. */
  45420. set position(value: Vector3);
  45421. /**
  45422. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45423. */
  45424. enableInteractions(): void;
  45425. private get _noControllerIsActive();
  45426. private beforeRender;
  45427. private _isTeleportationFloor;
  45428. /**
  45429. * Adds a floor mesh to be used for teleportation.
  45430. * @param floorMesh the mesh to be used for teleportation.
  45431. */
  45432. addFloorMesh(floorMesh: Mesh): void;
  45433. /**
  45434. * Removes a floor mesh from being used for teleportation.
  45435. * @param floorMesh the mesh to be removed.
  45436. */
  45437. removeFloorMesh(floorMesh: Mesh): void;
  45438. /**
  45439. * Enables interactions and teleportation using the VR controllers and gaze.
  45440. * @param vrTeleportationOptions options to modify teleportation behavior.
  45441. */
  45442. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45443. private _onNewGamepadConnected;
  45444. private _tryEnableInteractionOnController;
  45445. private _onNewGamepadDisconnected;
  45446. private _enableInteractionOnController;
  45447. private _checkTeleportWithRay;
  45448. private _checkRotate;
  45449. private _checkTeleportBackwards;
  45450. private _enableTeleportationOnController;
  45451. private _createTeleportationCircles;
  45452. private _displayTeleportationTarget;
  45453. private _hideTeleportationTarget;
  45454. private _rotateCamera;
  45455. private _moveTeleportationSelectorTo;
  45456. private _workingVector;
  45457. private _workingQuaternion;
  45458. private _workingMatrix;
  45459. /**
  45460. * Time Constant Teleportation Mode
  45461. */
  45462. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45463. /**
  45464. * Speed Constant Teleportation Mode
  45465. */
  45466. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45467. /**
  45468. * Teleports the users feet to the desired location
  45469. * @param location The location where the user's feet should be placed
  45470. */
  45471. teleportCamera(location: Vector3): void;
  45472. private _convertNormalToDirectionOfRay;
  45473. private _castRayAndSelectObject;
  45474. private _notifySelectedMeshUnselected;
  45475. /**
  45476. * Permanently set new colors for the laser pointer
  45477. * @param color the new laser color
  45478. * @param pickedColor the new laser color when picked mesh detected
  45479. */
  45480. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45481. /**
  45482. * Set lighting enabled / disabled on the laser pointer of both controllers
  45483. * @param enabled should the lighting be enabled on the laser pointer
  45484. */
  45485. setLaserLightingState(enabled?: boolean): void;
  45486. /**
  45487. * Permanently set new colors for the gaze pointer
  45488. * @param color the new gaze color
  45489. * @param pickedColor the new gaze color when picked mesh detected
  45490. */
  45491. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45492. /**
  45493. * Sets the color of the laser ray from the vr controllers.
  45494. * @param color new color for the ray.
  45495. */
  45496. changeLaserColor(color: Color3): void;
  45497. /**
  45498. * Sets the color of the ray from the vr headsets gaze.
  45499. * @param color new color for the ray.
  45500. */
  45501. changeGazeColor(color: Color3): void;
  45502. /**
  45503. * Exits VR and disposes of the vr experience helper
  45504. */
  45505. dispose(): void;
  45506. /**
  45507. * Gets the name of the VRExperienceHelper class
  45508. * @returns "VRExperienceHelper"
  45509. */
  45510. getClassName(): string;
  45511. }
  45512. }
  45513. declare module BABYLON {
  45514. /**
  45515. * Contains an array of blocks representing the octree
  45516. */
  45517. export interface IOctreeContainer<T> {
  45518. /**
  45519. * Blocks within the octree
  45520. */
  45521. blocks: Array<OctreeBlock<T>>;
  45522. }
  45523. /**
  45524. * Class used to store a cell in an octree
  45525. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45526. */
  45527. export class OctreeBlock<T> {
  45528. /**
  45529. * Gets the content of the current block
  45530. */
  45531. entries: T[];
  45532. /**
  45533. * Gets the list of block children
  45534. */
  45535. blocks: Array<OctreeBlock<T>>;
  45536. private _depth;
  45537. private _maxDepth;
  45538. private _capacity;
  45539. private _minPoint;
  45540. private _maxPoint;
  45541. private _boundingVectors;
  45542. private _creationFunc;
  45543. /**
  45544. * Creates a new block
  45545. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45546. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45547. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45548. * @param depth defines the current depth of this block in the octree
  45549. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45550. * @param creationFunc defines a callback to call when an element is added to the block
  45551. */
  45552. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45553. /**
  45554. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45555. */
  45556. get capacity(): number;
  45557. /**
  45558. * Gets the minimum vector (in world space) of the block's bounding box
  45559. */
  45560. get minPoint(): Vector3;
  45561. /**
  45562. * Gets the maximum vector (in world space) of the block's bounding box
  45563. */
  45564. get maxPoint(): Vector3;
  45565. /**
  45566. * Add a new element to this block
  45567. * @param entry defines the element to add
  45568. */
  45569. addEntry(entry: T): void;
  45570. /**
  45571. * Remove an element from this block
  45572. * @param entry defines the element to remove
  45573. */
  45574. removeEntry(entry: T): void;
  45575. /**
  45576. * Add an array of elements to this block
  45577. * @param entries defines the array of elements to add
  45578. */
  45579. addEntries(entries: T[]): void;
  45580. /**
  45581. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45582. * @param frustumPlanes defines the frustum planes to test
  45583. * @param selection defines the array to store current content if selection is positive
  45584. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45585. */
  45586. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45587. /**
  45588. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45589. * @param sphereCenter defines the bounding sphere center
  45590. * @param sphereRadius defines the bounding sphere radius
  45591. * @param selection defines the array to store current content if selection is positive
  45592. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45593. */
  45594. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45595. /**
  45596. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45597. * @param ray defines the ray to test with
  45598. * @param selection defines the array to store current content if selection is positive
  45599. */
  45600. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45601. /**
  45602. * Subdivide the content into child blocks (this block will then be empty)
  45603. */
  45604. createInnerBlocks(): void;
  45605. /**
  45606. * @hidden
  45607. */
  45608. 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;
  45609. }
  45610. }
  45611. declare module BABYLON {
  45612. /**
  45613. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45614. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45615. */
  45616. export class Octree<T> {
  45617. /** 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.) */
  45618. maxDepth: number;
  45619. /**
  45620. * Blocks within the octree containing objects
  45621. */
  45622. blocks: Array<OctreeBlock<T>>;
  45623. /**
  45624. * Content stored in the octree
  45625. */
  45626. dynamicContent: T[];
  45627. private _maxBlockCapacity;
  45628. private _selectionContent;
  45629. private _creationFunc;
  45630. /**
  45631. * Creates a octree
  45632. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45633. * @param creationFunc function to be used to instatiate the octree
  45634. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45635. * @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.)
  45636. */
  45637. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45638. /** 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.) */
  45639. maxDepth?: number);
  45640. /**
  45641. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45642. * @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);
  45643. * @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);
  45644. * @param entries meshes to be added to the octree blocks
  45645. */
  45646. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45647. /**
  45648. * Adds a mesh to the octree
  45649. * @param entry Mesh to add to the octree
  45650. */
  45651. addMesh(entry: T): void;
  45652. /**
  45653. * Remove an element from the octree
  45654. * @param entry defines the element to remove
  45655. */
  45656. removeMesh(entry: T): void;
  45657. /**
  45658. * Selects an array of meshes within the frustum
  45659. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45660. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45661. * @returns array of meshes within the frustum
  45662. */
  45663. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45664. /**
  45665. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45666. * @param sphereCenter defines the bounding sphere center
  45667. * @param sphereRadius defines the bounding sphere radius
  45668. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45669. * @returns an array of objects that intersect the sphere
  45670. */
  45671. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45672. /**
  45673. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45674. * @param ray defines the ray to test with
  45675. * @returns array of intersected objects
  45676. */
  45677. intersectsRay(ray: Ray): SmartArray<T>;
  45678. /**
  45679. * Adds a mesh into the octree block if it intersects the block
  45680. */
  45681. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45682. /**
  45683. * Adds a submesh into the octree block if it intersects the block
  45684. */
  45685. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45686. }
  45687. }
  45688. declare module BABYLON {
  45689. interface Scene {
  45690. /**
  45691. * @hidden
  45692. * Backing Filed
  45693. */
  45694. _selectionOctree: Octree<AbstractMesh>;
  45695. /**
  45696. * Gets the octree used to boost mesh selection (picking)
  45697. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45698. */
  45699. selectionOctree: Octree<AbstractMesh>;
  45700. /**
  45701. * Creates or updates the octree used to boost selection (picking)
  45702. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45703. * @param maxCapacity defines the maximum capacity per leaf
  45704. * @param maxDepth defines the maximum depth of the octree
  45705. * @returns an octree of AbstractMesh
  45706. */
  45707. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45708. }
  45709. interface AbstractMesh {
  45710. /**
  45711. * @hidden
  45712. * Backing Field
  45713. */
  45714. _submeshesOctree: Octree<SubMesh>;
  45715. /**
  45716. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45717. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45718. * @param maxCapacity defines the maximum size of each block (64 by default)
  45719. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45720. * @returns the new octree
  45721. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45723. */
  45724. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45725. }
  45726. /**
  45727. * Defines the octree scene component responsible to manage any octrees
  45728. * in a given scene.
  45729. */
  45730. export class OctreeSceneComponent {
  45731. /**
  45732. * The component name help to identify the component in the list of scene components.
  45733. */
  45734. readonly name: string;
  45735. /**
  45736. * The scene the component belongs to.
  45737. */
  45738. scene: Scene;
  45739. /**
  45740. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45741. */
  45742. readonly checksIsEnabled: boolean;
  45743. /**
  45744. * Creates a new instance of the component for the given scene
  45745. * @param scene Defines the scene to register the component in
  45746. */
  45747. constructor(scene: Scene);
  45748. /**
  45749. * Registers the component in a given scene
  45750. */
  45751. register(): void;
  45752. /**
  45753. * Return the list of active meshes
  45754. * @returns the list of active meshes
  45755. */
  45756. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45757. /**
  45758. * Return the list of active sub meshes
  45759. * @param mesh The mesh to get the candidates sub meshes from
  45760. * @returns the list of active sub meshes
  45761. */
  45762. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45763. private _tempRay;
  45764. /**
  45765. * Return the list of sub meshes intersecting with a given local ray
  45766. * @param mesh defines the mesh to find the submesh for
  45767. * @param localRay defines the ray in local space
  45768. * @returns the list of intersecting sub meshes
  45769. */
  45770. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45771. /**
  45772. * Return the list of sub meshes colliding with a collider
  45773. * @param mesh defines the mesh to find the submesh for
  45774. * @param collider defines the collider to evaluate the collision against
  45775. * @returns the list of colliding sub meshes
  45776. */
  45777. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45778. /**
  45779. * Rebuilds the elements related to this component in case of
  45780. * context lost for instance.
  45781. */
  45782. rebuild(): void;
  45783. /**
  45784. * Disposes the component and the associated ressources.
  45785. */
  45786. dispose(): void;
  45787. }
  45788. }
  45789. declare module BABYLON {
  45790. /**
  45791. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45792. */
  45793. export class Gizmo implements IDisposable {
  45794. /** The utility layer the gizmo will be added to */
  45795. gizmoLayer: UtilityLayerRenderer;
  45796. /**
  45797. * The root mesh of the gizmo
  45798. */
  45799. _rootMesh: Mesh;
  45800. private _attachedMesh;
  45801. /**
  45802. * Ratio for the scale of the gizmo (Default: 1)
  45803. */
  45804. scaleRatio: number;
  45805. /**
  45806. * If a custom mesh has been set (Default: false)
  45807. */
  45808. protected _customMeshSet: boolean;
  45809. /**
  45810. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45811. * * When set, interactions will be enabled
  45812. */
  45813. get attachedMesh(): Nullable<AbstractMesh>;
  45814. set attachedMesh(value: Nullable<AbstractMesh>);
  45815. /**
  45816. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45817. * @param mesh The mesh to replace the default mesh of the gizmo
  45818. */
  45819. setCustomMesh(mesh: Mesh): void;
  45820. /**
  45821. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45822. */
  45823. updateGizmoRotationToMatchAttachedMesh: boolean;
  45824. /**
  45825. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45826. */
  45827. updateGizmoPositionToMatchAttachedMesh: boolean;
  45828. /**
  45829. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45830. */
  45831. updateScale: boolean;
  45832. protected _interactionsEnabled: boolean;
  45833. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45834. private _beforeRenderObserver;
  45835. private _tempVector;
  45836. /**
  45837. * Creates a gizmo
  45838. * @param gizmoLayer The utility layer the gizmo will be added to
  45839. */
  45840. constructor(
  45841. /** The utility layer the gizmo will be added to */
  45842. gizmoLayer?: UtilityLayerRenderer);
  45843. /**
  45844. * Updates the gizmo to match the attached mesh's position/rotation
  45845. */
  45846. protected _update(): void;
  45847. /**
  45848. * Disposes of the gizmo
  45849. */
  45850. dispose(): void;
  45851. }
  45852. }
  45853. declare module BABYLON {
  45854. /**
  45855. * Single plane drag gizmo
  45856. */
  45857. export class PlaneDragGizmo extends Gizmo {
  45858. /**
  45859. * Drag behavior responsible for the gizmos dragging interactions
  45860. */
  45861. dragBehavior: PointerDragBehavior;
  45862. private _pointerObserver;
  45863. /**
  45864. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45865. */
  45866. snapDistance: number;
  45867. /**
  45868. * Event that fires each time the gizmo snaps to a new location.
  45869. * * snapDistance is the the change in distance
  45870. */
  45871. onSnapObservable: Observable<{
  45872. snapDistance: number;
  45873. }>;
  45874. private _plane;
  45875. private _coloredMaterial;
  45876. private _hoverMaterial;
  45877. private _isEnabled;
  45878. private _parent;
  45879. /** @hidden */
  45880. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45881. /** @hidden */
  45882. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45883. /**
  45884. * Creates a PlaneDragGizmo
  45885. * @param gizmoLayer The utility layer the gizmo will be added to
  45886. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45887. * @param color The color of the gizmo
  45888. */
  45889. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45890. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45891. /**
  45892. * If the gizmo is enabled
  45893. */
  45894. set isEnabled(value: boolean);
  45895. get isEnabled(): boolean;
  45896. /**
  45897. * Disposes of the gizmo
  45898. */
  45899. dispose(): void;
  45900. }
  45901. }
  45902. declare module BABYLON {
  45903. /**
  45904. * Gizmo that enables dragging a mesh along 3 axis
  45905. */
  45906. export class PositionGizmo extends Gizmo {
  45907. /**
  45908. * Internal gizmo used for interactions on the x axis
  45909. */
  45910. xGizmo: AxisDragGizmo;
  45911. /**
  45912. * Internal gizmo used for interactions on the y axis
  45913. */
  45914. yGizmo: AxisDragGizmo;
  45915. /**
  45916. * Internal gizmo used for interactions on the z axis
  45917. */
  45918. zGizmo: AxisDragGizmo;
  45919. /**
  45920. * Internal gizmo used for interactions on the yz plane
  45921. */
  45922. xPlaneGizmo: PlaneDragGizmo;
  45923. /**
  45924. * Internal gizmo used for interactions on the xz plane
  45925. */
  45926. yPlaneGizmo: PlaneDragGizmo;
  45927. /**
  45928. * Internal gizmo used for interactions on the xy plane
  45929. */
  45930. zPlaneGizmo: PlaneDragGizmo;
  45931. /**
  45932. * private variables
  45933. */
  45934. private _meshAttached;
  45935. private _updateGizmoRotationToMatchAttachedMesh;
  45936. private _snapDistance;
  45937. private _scaleRatio;
  45938. /** Fires an event when any of it's sub gizmos are dragged */
  45939. onDragStartObservable: Observable<unknown>;
  45940. /** Fires an event when any of it's sub gizmos are released from dragging */
  45941. onDragEndObservable: Observable<unknown>;
  45942. /**
  45943. * If set to true, planar drag is enabled
  45944. */
  45945. private _planarGizmoEnabled;
  45946. get attachedMesh(): Nullable<AbstractMesh>;
  45947. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45948. /**
  45949. * Creates a PositionGizmo
  45950. * @param gizmoLayer The utility layer the gizmo will be added to
  45951. */
  45952. constructor(gizmoLayer?: UtilityLayerRenderer);
  45953. /**
  45954. * If the planar drag gizmo is enabled
  45955. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45956. */
  45957. set planarGizmoEnabled(value: boolean);
  45958. get planarGizmoEnabled(): boolean;
  45959. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45960. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45961. /**
  45962. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45963. */
  45964. set snapDistance(value: number);
  45965. get snapDistance(): number;
  45966. /**
  45967. * Ratio for the scale of the gizmo (Default: 1)
  45968. */
  45969. set scaleRatio(value: number);
  45970. get scaleRatio(): number;
  45971. /**
  45972. * Disposes of the gizmo
  45973. */
  45974. dispose(): void;
  45975. /**
  45976. * CustomMeshes are not supported by this gizmo
  45977. * @param mesh The mesh to replace the default mesh of the gizmo
  45978. */
  45979. setCustomMesh(mesh: Mesh): void;
  45980. }
  45981. }
  45982. declare module BABYLON {
  45983. /**
  45984. * Single axis drag gizmo
  45985. */
  45986. export class AxisDragGizmo extends Gizmo {
  45987. /**
  45988. * Drag behavior responsible for the gizmos dragging interactions
  45989. */
  45990. dragBehavior: PointerDragBehavior;
  45991. private _pointerObserver;
  45992. /**
  45993. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45994. */
  45995. snapDistance: number;
  45996. /**
  45997. * Event that fires each time the gizmo snaps to a new location.
  45998. * * snapDistance is the the change in distance
  45999. */
  46000. onSnapObservable: Observable<{
  46001. snapDistance: number;
  46002. }>;
  46003. private _isEnabled;
  46004. private _parent;
  46005. private _arrow;
  46006. private _coloredMaterial;
  46007. private _hoverMaterial;
  46008. /** @hidden */
  46009. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46010. /** @hidden */
  46011. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46012. /**
  46013. * Creates an AxisDragGizmo
  46014. * @param gizmoLayer The utility layer the gizmo will be added to
  46015. * @param dragAxis The axis which the gizmo will be able to drag on
  46016. * @param color The color of the gizmo
  46017. */
  46018. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46019. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46020. /**
  46021. * If the gizmo is enabled
  46022. */
  46023. set isEnabled(value: boolean);
  46024. get isEnabled(): boolean;
  46025. /**
  46026. * Disposes of the gizmo
  46027. */
  46028. dispose(): void;
  46029. }
  46030. }
  46031. declare module BABYLON.Debug {
  46032. /**
  46033. * The Axes viewer will show 3 axes in a specific point in space
  46034. */
  46035. export class AxesViewer {
  46036. private _xAxis;
  46037. private _yAxis;
  46038. private _zAxis;
  46039. private _scaleLinesFactor;
  46040. private _instanced;
  46041. /**
  46042. * Gets the hosting scene
  46043. */
  46044. scene: Scene;
  46045. /**
  46046. * Gets or sets a number used to scale line length
  46047. */
  46048. scaleLines: number;
  46049. /** Gets the node hierarchy used to render x-axis */
  46050. get xAxis(): TransformNode;
  46051. /** Gets the node hierarchy used to render y-axis */
  46052. get yAxis(): TransformNode;
  46053. /** Gets the node hierarchy used to render z-axis */
  46054. get zAxis(): TransformNode;
  46055. /**
  46056. * Creates a new AxesViewer
  46057. * @param scene defines the hosting scene
  46058. * @param scaleLines defines a number used to scale line length (1 by default)
  46059. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46060. * @param xAxis defines the node hierarchy used to render the x-axis
  46061. * @param yAxis defines the node hierarchy used to render the y-axis
  46062. * @param zAxis defines the node hierarchy used to render the z-axis
  46063. */
  46064. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46065. /**
  46066. * Force the viewer to update
  46067. * @param position defines the position of the viewer
  46068. * @param xaxis defines the x axis of the viewer
  46069. * @param yaxis defines the y axis of the viewer
  46070. * @param zaxis defines the z axis of the viewer
  46071. */
  46072. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46073. /**
  46074. * Creates an instance of this axes viewer.
  46075. * @returns a new axes viewer with instanced meshes
  46076. */
  46077. createInstance(): AxesViewer;
  46078. /** Releases resources */
  46079. dispose(): void;
  46080. private static _SetRenderingGroupId;
  46081. }
  46082. }
  46083. declare module BABYLON.Debug {
  46084. /**
  46085. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46086. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46087. */
  46088. export class BoneAxesViewer extends AxesViewer {
  46089. /**
  46090. * Gets or sets the target mesh where to display the axes viewer
  46091. */
  46092. mesh: Nullable<Mesh>;
  46093. /**
  46094. * Gets or sets the target bone where to display the axes viewer
  46095. */
  46096. bone: Nullable<Bone>;
  46097. /** Gets current position */
  46098. pos: Vector3;
  46099. /** Gets direction of X axis */
  46100. xaxis: Vector3;
  46101. /** Gets direction of Y axis */
  46102. yaxis: Vector3;
  46103. /** Gets direction of Z axis */
  46104. zaxis: Vector3;
  46105. /**
  46106. * Creates a new BoneAxesViewer
  46107. * @param scene defines the hosting scene
  46108. * @param bone defines the target bone
  46109. * @param mesh defines the target mesh
  46110. * @param scaleLines defines a scaling factor for line length (1 by default)
  46111. */
  46112. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46113. /**
  46114. * Force the viewer to update
  46115. */
  46116. update(): void;
  46117. /** Releases resources */
  46118. dispose(): void;
  46119. }
  46120. }
  46121. declare module BABYLON {
  46122. /**
  46123. * Interface used to define scene explorer extensibility option
  46124. */
  46125. export interface IExplorerExtensibilityOption {
  46126. /**
  46127. * Define the option label
  46128. */
  46129. label: string;
  46130. /**
  46131. * Defines the action to execute on click
  46132. */
  46133. action: (entity: any) => void;
  46134. }
  46135. /**
  46136. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46137. */
  46138. export interface IExplorerExtensibilityGroup {
  46139. /**
  46140. * Defines a predicate to test if a given type mut be extended
  46141. */
  46142. predicate: (entity: any) => boolean;
  46143. /**
  46144. * Gets the list of options added to a type
  46145. */
  46146. entries: IExplorerExtensibilityOption[];
  46147. }
  46148. /**
  46149. * Interface used to define the options to use to create the Inspector
  46150. */
  46151. export interface IInspectorOptions {
  46152. /**
  46153. * Display in overlay mode (default: false)
  46154. */
  46155. overlay?: boolean;
  46156. /**
  46157. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46158. */
  46159. globalRoot?: HTMLElement;
  46160. /**
  46161. * Display the Scene explorer
  46162. */
  46163. showExplorer?: boolean;
  46164. /**
  46165. * Display the property inspector
  46166. */
  46167. showInspector?: boolean;
  46168. /**
  46169. * Display in embed mode (both panes on the right)
  46170. */
  46171. embedMode?: boolean;
  46172. /**
  46173. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46174. */
  46175. handleResize?: boolean;
  46176. /**
  46177. * Allow the panes to popup (default: true)
  46178. */
  46179. enablePopup?: boolean;
  46180. /**
  46181. * Allow the panes to be closed by users (default: true)
  46182. */
  46183. enableClose?: boolean;
  46184. /**
  46185. * Optional list of extensibility entries
  46186. */
  46187. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46188. /**
  46189. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46190. */
  46191. inspectorURL?: string;
  46192. /**
  46193. * Optional initial tab (default to DebugLayerTab.Properties)
  46194. */
  46195. initialTab?: DebugLayerTab;
  46196. }
  46197. interface Scene {
  46198. /**
  46199. * @hidden
  46200. * Backing field
  46201. */
  46202. _debugLayer: DebugLayer;
  46203. /**
  46204. * Gets the debug layer (aka Inspector) associated with the scene
  46205. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46206. */
  46207. debugLayer: DebugLayer;
  46208. }
  46209. /**
  46210. * Enum of inspector action tab
  46211. */
  46212. export enum DebugLayerTab {
  46213. /**
  46214. * Properties tag (default)
  46215. */
  46216. Properties = 0,
  46217. /**
  46218. * Debug tab
  46219. */
  46220. Debug = 1,
  46221. /**
  46222. * Statistics tab
  46223. */
  46224. Statistics = 2,
  46225. /**
  46226. * Tools tab
  46227. */
  46228. Tools = 3,
  46229. /**
  46230. * Settings tab
  46231. */
  46232. Settings = 4
  46233. }
  46234. /**
  46235. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46236. * what is happening in your scene
  46237. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46238. */
  46239. export class DebugLayer {
  46240. /**
  46241. * Define the url to get the inspector script from.
  46242. * By default it uses the babylonjs CDN.
  46243. * @ignoreNaming
  46244. */
  46245. static InspectorURL: string;
  46246. private _scene;
  46247. private BJSINSPECTOR;
  46248. private _onPropertyChangedObservable?;
  46249. /**
  46250. * Observable triggered when a property is changed through the inspector.
  46251. */
  46252. get onPropertyChangedObservable(): any;
  46253. /**
  46254. * Instantiates a new debug layer.
  46255. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46256. * what is happening in your scene
  46257. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46258. * @param scene Defines the scene to inspect
  46259. */
  46260. constructor(scene: Scene);
  46261. /** Creates the inspector window. */
  46262. private _createInspector;
  46263. /**
  46264. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46265. * @param entity defines the entity to select
  46266. * @param lineContainerTitle defines the specific block to highlight
  46267. */
  46268. select(entity: any, lineContainerTitle?: string): void;
  46269. /** Get the inspector from bundle or global */
  46270. private _getGlobalInspector;
  46271. /**
  46272. * Get if the inspector is visible or not.
  46273. * @returns true if visible otherwise, false
  46274. */
  46275. isVisible(): boolean;
  46276. /**
  46277. * Hide the inspector and close its window.
  46278. */
  46279. hide(): void;
  46280. /**
  46281. * Launch the debugLayer.
  46282. * @param config Define the configuration of the inspector
  46283. * @return a promise fulfilled when the debug layer is visible
  46284. */
  46285. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46286. }
  46287. }
  46288. declare module BABYLON {
  46289. /**
  46290. * Class containing static functions to help procedurally build meshes
  46291. */
  46292. export class BoxBuilder {
  46293. /**
  46294. * Creates a box mesh
  46295. * * The parameter `size` sets the size (float) of each box side (default 1)
  46296. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46297. * * 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)
  46298. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46300. * * 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
  46301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46302. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46303. * @param name defines the name of the mesh
  46304. * @param options defines the options used to create the mesh
  46305. * @param scene defines the hosting scene
  46306. * @returns the box mesh
  46307. */
  46308. static CreateBox(name: string, options: {
  46309. size?: number;
  46310. width?: number;
  46311. height?: number;
  46312. depth?: number;
  46313. faceUV?: Vector4[];
  46314. faceColors?: Color4[];
  46315. sideOrientation?: number;
  46316. frontUVs?: Vector4;
  46317. backUVs?: Vector4;
  46318. wrap?: boolean;
  46319. topBaseAt?: number;
  46320. bottomBaseAt?: number;
  46321. updatable?: boolean;
  46322. }, scene?: Nullable<Scene>): Mesh;
  46323. }
  46324. }
  46325. declare module BABYLON.Debug {
  46326. /**
  46327. * Used to show the physics impostor around the specific mesh
  46328. */
  46329. export class PhysicsViewer {
  46330. /** @hidden */
  46331. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46332. /** @hidden */
  46333. protected _meshes: Array<Nullable<AbstractMesh>>;
  46334. /** @hidden */
  46335. protected _scene: Nullable<Scene>;
  46336. /** @hidden */
  46337. protected _numMeshes: number;
  46338. /** @hidden */
  46339. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46340. private _renderFunction;
  46341. private _utilityLayer;
  46342. private _debugBoxMesh;
  46343. private _debugSphereMesh;
  46344. private _debugCylinderMesh;
  46345. private _debugMaterial;
  46346. private _debugMeshMeshes;
  46347. /**
  46348. * Creates a new PhysicsViewer
  46349. * @param scene defines the hosting scene
  46350. */
  46351. constructor(scene: Scene);
  46352. /** @hidden */
  46353. protected _updateDebugMeshes(): void;
  46354. /**
  46355. * Renders a specified physic impostor
  46356. * @param impostor defines the impostor to render
  46357. * @param targetMesh defines the mesh represented by the impostor
  46358. * @returns the new debug mesh used to render the impostor
  46359. */
  46360. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46361. /**
  46362. * Hides a specified physic impostor
  46363. * @param impostor defines the impostor to hide
  46364. */
  46365. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46366. private _getDebugMaterial;
  46367. private _getDebugBoxMesh;
  46368. private _getDebugSphereMesh;
  46369. private _getDebugCylinderMesh;
  46370. private _getDebugMeshMesh;
  46371. private _getDebugMesh;
  46372. /** Releases all resources */
  46373. dispose(): void;
  46374. }
  46375. }
  46376. declare module BABYLON {
  46377. /**
  46378. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46379. * in order to better appreciate the issue one might have.
  46380. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46381. */
  46382. export class RayHelper {
  46383. /**
  46384. * Defines the ray we are currently tryin to visualize.
  46385. */
  46386. ray: Nullable<Ray>;
  46387. private _renderPoints;
  46388. private _renderLine;
  46389. private _renderFunction;
  46390. private _scene;
  46391. private _updateToMeshFunction;
  46392. private _attachedToMesh;
  46393. private _meshSpaceDirection;
  46394. private _meshSpaceOrigin;
  46395. /**
  46396. * Helper function to create a colored helper in a scene in one line.
  46397. * @param ray Defines the ray we are currently tryin to visualize
  46398. * @param scene Defines the scene the ray is used in
  46399. * @param color Defines the color we want to see the ray in
  46400. * @returns The newly created ray helper.
  46401. */
  46402. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46403. /**
  46404. * Instantiate a new ray helper.
  46405. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46406. * in order to better appreciate the issue one might have.
  46407. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46408. * @param ray Defines the ray we are currently tryin to visualize
  46409. */
  46410. constructor(ray: Ray);
  46411. /**
  46412. * Shows the ray we are willing to debug.
  46413. * @param scene Defines the scene the ray needs to be rendered in
  46414. * @param color Defines the color the ray needs to be rendered in
  46415. */
  46416. show(scene: Scene, color?: Color3): void;
  46417. /**
  46418. * Hides the ray we are debugging.
  46419. */
  46420. hide(): void;
  46421. private _render;
  46422. /**
  46423. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46424. * @param mesh Defines the mesh we want the helper attached to
  46425. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46426. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46427. * @param length Defines the length of the ray
  46428. */
  46429. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46430. /**
  46431. * Detach the ray helper from the mesh it has previously been attached to.
  46432. */
  46433. detachFromMesh(): void;
  46434. private _updateToMesh;
  46435. /**
  46436. * Dispose the helper and release its associated resources.
  46437. */
  46438. dispose(): void;
  46439. }
  46440. }
  46441. declare module BABYLON.Debug {
  46442. /**
  46443. * Class used to render a debug view of a given skeleton
  46444. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46445. */
  46446. export class SkeletonViewer {
  46447. /** defines the skeleton to render */
  46448. skeleton: Skeleton;
  46449. /** defines the mesh attached to the skeleton */
  46450. mesh: AbstractMesh;
  46451. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46452. autoUpdateBonesMatrices: boolean;
  46453. /** defines the rendering group id to use with the viewer */
  46454. renderingGroupId: number;
  46455. /** Gets or sets the color used to render the skeleton */
  46456. color: Color3;
  46457. private _scene;
  46458. private _debugLines;
  46459. private _debugMesh;
  46460. private _isEnabled;
  46461. private _renderFunction;
  46462. private _utilityLayer;
  46463. /**
  46464. * Returns the mesh used to render the bones
  46465. */
  46466. get debugMesh(): Nullable<LinesMesh>;
  46467. /**
  46468. * Creates a new SkeletonViewer
  46469. * @param skeleton defines the skeleton to render
  46470. * @param mesh defines the mesh attached to the skeleton
  46471. * @param scene defines the hosting scene
  46472. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46473. * @param renderingGroupId defines the rendering group id to use with the viewer
  46474. */
  46475. constructor(
  46476. /** defines the skeleton to render */
  46477. skeleton: Skeleton,
  46478. /** defines the mesh attached to the skeleton */
  46479. mesh: AbstractMesh, scene: Scene,
  46480. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46481. autoUpdateBonesMatrices?: boolean,
  46482. /** defines the rendering group id to use with the viewer */
  46483. renderingGroupId?: number);
  46484. /** Gets or sets a boolean indicating if the viewer is enabled */
  46485. set isEnabled(value: boolean);
  46486. get isEnabled(): boolean;
  46487. private _getBonePosition;
  46488. private _getLinesForBonesWithLength;
  46489. private _getLinesForBonesNoLength;
  46490. /** Update the viewer to sync with current skeleton state */
  46491. update(): void;
  46492. /** Release associated resources */
  46493. dispose(): void;
  46494. }
  46495. }
  46496. declare module BABYLON {
  46497. /**
  46498. * Options to create the null engine
  46499. */
  46500. export class NullEngineOptions {
  46501. /**
  46502. * Render width (Default: 512)
  46503. */
  46504. renderWidth: number;
  46505. /**
  46506. * Render height (Default: 256)
  46507. */
  46508. renderHeight: number;
  46509. /**
  46510. * Texture size (Default: 512)
  46511. */
  46512. textureSize: number;
  46513. /**
  46514. * If delta time between frames should be constant
  46515. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46516. */
  46517. deterministicLockstep: boolean;
  46518. /**
  46519. * Maximum about of steps between frames (Default: 4)
  46520. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46521. */
  46522. lockstepMaxSteps: number;
  46523. }
  46524. /**
  46525. * The null engine class provides support for headless version of babylon.js.
  46526. * This can be used in server side scenario or for testing purposes
  46527. */
  46528. export class NullEngine extends Engine {
  46529. private _options;
  46530. /**
  46531. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46532. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46533. * @returns true if engine is in deterministic lock step mode
  46534. */
  46535. isDeterministicLockStep(): boolean;
  46536. /**
  46537. * Gets the max steps when engine is running in deterministic lock step
  46538. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46539. * @returns the max steps
  46540. */
  46541. getLockstepMaxSteps(): number;
  46542. /**
  46543. * Gets the current hardware scaling level.
  46544. * By default the hardware scaling level is computed from the window device ratio.
  46545. * 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.
  46546. * @returns a number indicating the current hardware scaling level
  46547. */
  46548. getHardwareScalingLevel(): number;
  46549. constructor(options?: NullEngineOptions);
  46550. /**
  46551. * Creates a vertex buffer
  46552. * @param vertices the data for the vertex buffer
  46553. * @returns the new WebGL static buffer
  46554. */
  46555. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46556. /**
  46557. * Creates a new index buffer
  46558. * @param indices defines the content of the index buffer
  46559. * @param updatable defines if the index buffer must be updatable
  46560. * @returns a new webGL buffer
  46561. */
  46562. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46563. /**
  46564. * Clear the current render buffer or the current render target (if any is set up)
  46565. * @param color defines the color to use
  46566. * @param backBuffer defines if the back buffer must be cleared
  46567. * @param depth defines if the depth buffer must be cleared
  46568. * @param stencil defines if the stencil buffer must be cleared
  46569. */
  46570. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46571. /**
  46572. * Gets the current render width
  46573. * @param useScreen defines if screen size must be used (or the current render target if any)
  46574. * @returns a number defining the current render width
  46575. */
  46576. getRenderWidth(useScreen?: boolean): number;
  46577. /**
  46578. * Gets the current render height
  46579. * @param useScreen defines if screen size must be used (or the current render target if any)
  46580. * @returns a number defining the current render height
  46581. */
  46582. getRenderHeight(useScreen?: boolean): number;
  46583. /**
  46584. * Set the WebGL's viewport
  46585. * @param viewport defines the viewport element to be used
  46586. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46587. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46588. */
  46589. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46590. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46591. /**
  46592. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46593. * @param pipelineContext defines the pipeline context to use
  46594. * @param uniformsNames defines the list of uniform names
  46595. * @returns an array of webGL uniform locations
  46596. */
  46597. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46598. /**
  46599. * Gets the lsit of active attributes for a given webGL program
  46600. * @param pipelineContext defines the pipeline context to use
  46601. * @param attributesNames defines the list of attribute names to get
  46602. * @returns an array of indices indicating the offset of each attribute
  46603. */
  46604. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46605. /**
  46606. * Binds an effect to the webGL context
  46607. * @param effect defines the effect to bind
  46608. */
  46609. bindSamplers(effect: Effect): void;
  46610. /**
  46611. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46612. * @param effect defines the effect to activate
  46613. */
  46614. enableEffect(effect: Effect): void;
  46615. /**
  46616. * Set various states to the webGL context
  46617. * @param culling defines backface culling state
  46618. * @param zOffset defines the value to apply to zOffset (0 by default)
  46619. * @param force defines if states must be applied even if cache is up to date
  46620. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46621. */
  46622. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46623. /**
  46624. * Set the value of an uniform to an array of int32
  46625. * @param uniform defines the webGL uniform location where to store the value
  46626. * @param array defines the array of int32 to store
  46627. */
  46628. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46629. /**
  46630. * Set the value of an uniform to an array of int32 (stored as vec2)
  46631. * @param uniform defines the webGL uniform location where to store the value
  46632. * @param array defines the array of int32 to store
  46633. */
  46634. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46635. /**
  46636. * Set the value of an uniform to an array of int32 (stored as vec3)
  46637. * @param uniform defines the webGL uniform location where to store the value
  46638. * @param array defines the array of int32 to store
  46639. */
  46640. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46641. /**
  46642. * Set the value of an uniform to an array of int32 (stored as vec4)
  46643. * @param uniform defines the webGL uniform location where to store the value
  46644. * @param array defines the array of int32 to store
  46645. */
  46646. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46647. /**
  46648. * Set the value of an uniform to an array of float32
  46649. * @param uniform defines the webGL uniform location where to store the value
  46650. * @param array defines the array of float32 to store
  46651. */
  46652. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46653. /**
  46654. * Set the value of an uniform to an array of float32 (stored as vec2)
  46655. * @param uniform defines the webGL uniform location where to store the value
  46656. * @param array defines the array of float32 to store
  46657. */
  46658. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46659. /**
  46660. * Set the value of an uniform to an array of float32 (stored as vec3)
  46661. * @param uniform defines the webGL uniform location where to store the value
  46662. * @param array defines the array of float32 to store
  46663. */
  46664. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46665. /**
  46666. * Set the value of an uniform to an array of float32 (stored as vec4)
  46667. * @param uniform defines the webGL uniform location where to store the value
  46668. * @param array defines the array of float32 to store
  46669. */
  46670. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46671. /**
  46672. * Set the value of an uniform to an array of number
  46673. * @param uniform defines the webGL uniform location where to store the value
  46674. * @param array defines the array of number to store
  46675. */
  46676. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46677. /**
  46678. * Set the value of an uniform to an array of number (stored as vec2)
  46679. * @param uniform defines the webGL uniform location where to store the value
  46680. * @param array defines the array of number to store
  46681. */
  46682. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46683. /**
  46684. * Set the value of an uniform to an array of number (stored as vec3)
  46685. * @param uniform defines the webGL uniform location where to store the value
  46686. * @param array defines the array of number to store
  46687. */
  46688. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46689. /**
  46690. * Set the value of an uniform to an array of number (stored as vec4)
  46691. * @param uniform defines the webGL uniform location where to store the value
  46692. * @param array defines the array of number to store
  46693. */
  46694. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46695. /**
  46696. * Set the value of an uniform to an array of float32 (stored as matrices)
  46697. * @param uniform defines the webGL uniform location where to store the value
  46698. * @param matrices defines the array of float32 to store
  46699. */
  46700. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46701. /**
  46702. * Set the value of an uniform to a matrix (3x3)
  46703. * @param uniform defines the webGL uniform location where to store the value
  46704. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46705. */
  46706. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46707. /**
  46708. * Set the value of an uniform to a matrix (2x2)
  46709. * @param uniform defines the webGL uniform location where to store the value
  46710. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46711. */
  46712. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46713. /**
  46714. * Set the value of an uniform to a number (float)
  46715. * @param uniform defines the webGL uniform location where to store the value
  46716. * @param value defines the float number to store
  46717. */
  46718. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46719. /**
  46720. * Set the value of an uniform to a vec2
  46721. * @param uniform defines the webGL uniform location where to store the value
  46722. * @param x defines the 1st component of the value
  46723. * @param y defines the 2nd component of the value
  46724. */
  46725. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46726. /**
  46727. * Set the value of an uniform to a vec3
  46728. * @param uniform defines the webGL uniform location where to store the value
  46729. * @param x defines the 1st component of the value
  46730. * @param y defines the 2nd component of the value
  46731. * @param z defines the 3rd component of the value
  46732. */
  46733. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46734. /**
  46735. * Set the value of an uniform to a boolean
  46736. * @param uniform defines the webGL uniform location where to store the value
  46737. * @param bool defines the boolean to store
  46738. */
  46739. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46740. /**
  46741. * Set the value of an uniform to a vec4
  46742. * @param uniform defines the webGL uniform location where to store the value
  46743. * @param x defines the 1st component of the value
  46744. * @param y defines the 2nd component of the value
  46745. * @param z defines the 3rd component of the value
  46746. * @param w defines the 4th component of the value
  46747. */
  46748. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46749. /**
  46750. * Sets the current alpha mode
  46751. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46752. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46753. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46754. */
  46755. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46756. /**
  46757. * Bind webGl buffers directly to the webGL context
  46758. * @param vertexBuffers defines the vertex buffer to bind
  46759. * @param indexBuffer defines the index buffer to bind
  46760. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46761. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46762. * @param effect defines the effect associated with the vertex buffer
  46763. */
  46764. bindBuffers(vertexBuffers: {
  46765. [key: string]: VertexBuffer;
  46766. }, indexBuffer: DataBuffer, effect: Effect): void;
  46767. /**
  46768. * Force the entire cache to be cleared
  46769. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46770. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46771. */
  46772. wipeCaches(bruteForce?: boolean): void;
  46773. /**
  46774. * Send a draw order
  46775. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46776. * @param indexStart defines the starting index
  46777. * @param indexCount defines the number of index to draw
  46778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46779. */
  46780. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46781. /**
  46782. * Draw a list of indexed primitives
  46783. * @param fillMode defines the primitive to use
  46784. * @param indexStart defines the starting index
  46785. * @param indexCount defines the number of index to draw
  46786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46787. */
  46788. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46789. /**
  46790. * Draw a list of unindexed primitives
  46791. * @param fillMode defines the primitive to use
  46792. * @param verticesStart defines the index of first vertex to draw
  46793. * @param verticesCount defines the count of vertices to draw
  46794. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46795. */
  46796. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46797. /** @hidden */
  46798. _createTexture(): WebGLTexture;
  46799. /** @hidden */
  46800. _releaseTexture(texture: InternalTexture): void;
  46801. /**
  46802. * Usually called from Texture.ts.
  46803. * Passed information to create a WebGLTexture
  46804. * @param urlArg defines a value which contains one of the following:
  46805. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46806. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46807. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46808. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46809. * @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)
  46810. * @param scene needed for loading to the correct scene
  46811. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46812. * @param onLoad optional callback to be called upon successful completion
  46813. * @param onError optional callback to be called upon failure
  46814. * @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
  46815. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46816. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46817. * @param forcedExtension defines the extension to use to pick the right loader
  46818. * @param mimeType defines an optional mime type
  46819. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46820. */
  46821. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  46822. /**
  46823. * Creates a new render target texture
  46824. * @param size defines the size of the texture
  46825. * @param options defines the options used to create the texture
  46826. * @returns a new render target texture stored in an InternalTexture
  46827. */
  46828. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46829. /**
  46830. * Update the sampling mode of a given texture
  46831. * @param samplingMode defines the required sampling mode
  46832. * @param texture defines the texture to update
  46833. */
  46834. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46835. /**
  46836. * Binds the frame buffer to the specified texture.
  46837. * @param texture The texture to render to or null for the default canvas
  46838. * @param faceIndex The face of the texture to render to in case of cube texture
  46839. * @param requiredWidth The width of the target to render to
  46840. * @param requiredHeight The height of the target to render to
  46841. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46842. * @param lodLevel defines le lod level to bind to the frame buffer
  46843. */
  46844. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46845. /**
  46846. * Unbind the current render target texture from the webGL context
  46847. * @param texture defines the render target texture to unbind
  46848. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46849. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46850. */
  46851. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46852. /**
  46853. * Creates a dynamic vertex buffer
  46854. * @param vertices the data for the dynamic vertex buffer
  46855. * @returns the new WebGL dynamic buffer
  46856. */
  46857. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46858. /**
  46859. * Update the content of a dynamic texture
  46860. * @param texture defines the texture to update
  46861. * @param canvas defines the canvas containing the source
  46862. * @param invertY defines if data must be stored with Y axis inverted
  46863. * @param premulAlpha defines if alpha is stored as premultiplied
  46864. * @param format defines the format of the data
  46865. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46866. */
  46867. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46868. /**
  46869. * Gets a boolean indicating if all created effects are ready
  46870. * @returns true if all effects are ready
  46871. */
  46872. areAllEffectsReady(): boolean;
  46873. /**
  46874. * @hidden
  46875. * Get the current error code of the webGL context
  46876. * @returns the error code
  46877. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46878. */
  46879. getError(): number;
  46880. /** @hidden */
  46881. _getUnpackAlignement(): number;
  46882. /** @hidden */
  46883. _unpackFlipY(value: boolean): void;
  46884. /**
  46885. * Update a dynamic index buffer
  46886. * @param indexBuffer defines the target index buffer
  46887. * @param indices defines the data to update
  46888. * @param offset defines the offset in the target index buffer where update should start
  46889. */
  46890. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46891. /**
  46892. * Updates a dynamic vertex buffer.
  46893. * @param vertexBuffer the vertex buffer to update
  46894. * @param vertices the data used to update the vertex buffer
  46895. * @param byteOffset the byte offset of the data (optional)
  46896. * @param byteLength the byte length of the data (optional)
  46897. */
  46898. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46899. /** @hidden */
  46900. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46901. /** @hidden */
  46902. _bindTexture(channel: number, texture: InternalTexture): void;
  46903. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46904. /**
  46905. * 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
  46906. */
  46907. releaseEffects(): void;
  46908. displayLoadingUI(): void;
  46909. hideLoadingUI(): void;
  46910. /** @hidden */
  46911. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46912. /** @hidden */
  46913. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46914. /** @hidden */
  46915. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46916. /** @hidden */
  46917. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46918. }
  46919. }
  46920. declare module BABYLON {
  46921. /**
  46922. * @hidden
  46923. **/
  46924. export class _TimeToken {
  46925. _startTimeQuery: Nullable<WebGLQuery>;
  46926. _endTimeQuery: Nullable<WebGLQuery>;
  46927. _timeElapsedQuery: Nullable<WebGLQuery>;
  46928. _timeElapsedQueryEnded: boolean;
  46929. }
  46930. }
  46931. declare module BABYLON {
  46932. /** @hidden */
  46933. export class _OcclusionDataStorage {
  46934. /** @hidden */
  46935. occlusionInternalRetryCounter: number;
  46936. /** @hidden */
  46937. isOcclusionQueryInProgress: boolean;
  46938. /** @hidden */
  46939. isOccluded: boolean;
  46940. /** @hidden */
  46941. occlusionRetryCount: number;
  46942. /** @hidden */
  46943. occlusionType: number;
  46944. /** @hidden */
  46945. occlusionQueryAlgorithmType: number;
  46946. }
  46947. interface Engine {
  46948. /**
  46949. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46950. * @return the new query
  46951. */
  46952. createQuery(): WebGLQuery;
  46953. /**
  46954. * Delete and release a webGL query
  46955. * @param query defines the query to delete
  46956. * @return the current engine
  46957. */
  46958. deleteQuery(query: WebGLQuery): Engine;
  46959. /**
  46960. * Check if a given query has resolved and got its value
  46961. * @param query defines the query to check
  46962. * @returns true if the query got its value
  46963. */
  46964. isQueryResultAvailable(query: WebGLQuery): boolean;
  46965. /**
  46966. * Gets the value of a given query
  46967. * @param query defines the query to check
  46968. * @returns the value of the query
  46969. */
  46970. getQueryResult(query: WebGLQuery): number;
  46971. /**
  46972. * Initiates an occlusion query
  46973. * @param algorithmType defines the algorithm to use
  46974. * @param query defines the query to use
  46975. * @returns the current engine
  46976. * @see http://doc.babylonjs.com/features/occlusionquery
  46977. */
  46978. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46979. /**
  46980. * Ends an occlusion query
  46981. * @see http://doc.babylonjs.com/features/occlusionquery
  46982. * @param algorithmType defines the algorithm to use
  46983. * @returns the current engine
  46984. */
  46985. endOcclusionQuery(algorithmType: number): Engine;
  46986. /**
  46987. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46988. * Please note that only one query can be issued at a time
  46989. * @returns a time token used to track the time span
  46990. */
  46991. startTimeQuery(): Nullable<_TimeToken>;
  46992. /**
  46993. * Ends a time query
  46994. * @param token defines the token used to measure the time span
  46995. * @returns the time spent (in ns)
  46996. */
  46997. endTimeQuery(token: _TimeToken): int;
  46998. /** @hidden */
  46999. _currentNonTimestampToken: Nullable<_TimeToken>;
  47000. /** @hidden */
  47001. _createTimeQuery(): WebGLQuery;
  47002. /** @hidden */
  47003. _deleteTimeQuery(query: WebGLQuery): void;
  47004. /** @hidden */
  47005. _getGlAlgorithmType(algorithmType: number): number;
  47006. /** @hidden */
  47007. _getTimeQueryResult(query: WebGLQuery): any;
  47008. /** @hidden */
  47009. _getTimeQueryAvailability(query: WebGLQuery): any;
  47010. }
  47011. interface AbstractMesh {
  47012. /**
  47013. * Backing filed
  47014. * @hidden
  47015. */
  47016. __occlusionDataStorage: _OcclusionDataStorage;
  47017. /**
  47018. * Access property
  47019. * @hidden
  47020. */
  47021. _occlusionDataStorage: _OcclusionDataStorage;
  47022. /**
  47023. * 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.
  47024. * The default value is -1 which means don't break the query and wait till the result
  47025. * @see http://doc.babylonjs.com/features/occlusionquery
  47026. */
  47027. occlusionRetryCount: number;
  47028. /**
  47029. * 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:
  47030. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47031. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47032. * * 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.
  47033. * @see http://doc.babylonjs.com/features/occlusionquery
  47034. */
  47035. occlusionType: number;
  47036. /**
  47037. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47038. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47039. * * 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.
  47040. * @see http://doc.babylonjs.com/features/occlusionquery
  47041. */
  47042. occlusionQueryAlgorithmType: number;
  47043. /**
  47044. * 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
  47045. * @see http://doc.babylonjs.com/features/occlusionquery
  47046. */
  47047. isOccluded: boolean;
  47048. /**
  47049. * Flag to check the progress status of the query
  47050. * @see http://doc.babylonjs.com/features/occlusionquery
  47051. */
  47052. isOcclusionQueryInProgress: boolean;
  47053. }
  47054. }
  47055. declare module BABYLON {
  47056. /** @hidden */
  47057. export var _forceTransformFeedbackToBundle: boolean;
  47058. interface Engine {
  47059. /**
  47060. * Creates a webGL transform feedback object
  47061. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47062. * @returns the webGL transform feedback object
  47063. */
  47064. createTransformFeedback(): WebGLTransformFeedback;
  47065. /**
  47066. * Delete a webGL transform feedback object
  47067. * @param value defines the webGL transform feedback object to delete
  47068. */
  47069. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47070. /**
  47071. * Bind a webGL transform feedback object to the webgl context
  47072. * @param value defines the webGL transform feedback object to bind
  47073. */
  47074. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47075. /**
  47076. * Begins a transform feedback operation
  47077. * @param usePoints defines if points or triangles must be used
  47078. */
  47079. beginTransformFeedback(usePoints: boolean): void;
  47080. /**
  47081. * Ends a transform feedback operation
  47082. */
  47083. endTransformFeedback(): void;
  47084. /**
  47085. * Specify the varyings to use with transform feedback
  47086. * @param program defines the associated webGL program
  47087. * @param value defines the list of strings representing the varying names
  47088. */
  47089. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47090. /**
  47091. * Bind a webGL buffer for a transform feedback operation
  47092. * @param value defines the webGL buffer to bind
  47093. */
  47094. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47095. }
  47096. }
  47097. declare module BABYLON {
  47098. /**
  47099. * Creation options of the multi render target texture.
  47100. */
  47101. export interface IMultiRenderTargetOptions {
  47102. /**
  47103. * Define if the texture needs to create mip maps after render.
  47104. */
  47105. generateMipMaps?: boolean;
  47106. /**
  47107. * Define the types of all the draw buffers we want to create
  47108. */
  47109. types?: number[];
  47110. /**
  47111. * Define the sampling modes of all the draw buffers we want to create
  47112. */
  47113. samplingModes?: number[];
  47114. /**
  47115. * Define if a depth buffer is required
  47116. */
  47117. generateDepthBuffer?: boolean;
  47118. /**
  47119. * Define if a stencil buffer is required
  47120. */
  47121. generateStencilBuffer?: boolean;
  47122. /**
  47123. * Define if a depth texture is required instead of a depth buffer
  47124. */
  47125. generateDepthTexture?: boolean;
  47126. /**
  47127. * Define the number of desired draw buffers
  47128. */
  47129. textureCount?: number;
  47130. /**
  47131. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47132. */
  47133. doNotChangeAspectRatio?: boolean;
  47134. /**
  47135. * Define the default type of the buffers we are creating
  47136. */
  47137. defaultType?: number;
  47138. }
  47139. /**
  47140. * A multi render target, like a render target provides the ability to render to a texture.
  47141. * Unlike the render target, it can render to several draw buffers in one draw.
  47142. * This is specially interesting in deferred rendering or for any effects requiring more than
  47143. * just one color from a single pass.
  47144. */
  47145. export class MultiRenderTarget extends RenderTargetTexture {
  47146. private _internalTextures;
  47147. private _textures;
  47148. private _multiRenderTargetOptions;
  47149. /**
  47150. * Get if draw buffers are currently supported by the used hardware and browser.
  47151. */
  47152. get isSupported(): boolean;
  47153. /**
  47154. * Get the list of textures generated by the multi render target.
  47155. */
  47156. get textures(): Texture[];
  47157. /**
  47158. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47159. */
  47160. get depthTexture(): Texture;
  47161. /**
  47162. * Set the wrapping mode on U of all the textures we are rendering to.
  47163. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47164. */
  47165. set wrapU(wrap: number);
  47166. /**
  47167. * Set the wrapping mode on V of all the textures we are rendering to.
  47168. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47169. */
  47170. set wrapV(wrap: number);
  47171. /**
  47172. * Instantiate a new multi render target texture.
  47173. * A multi render target, like a render target provides the ability to render to a texture.
  47174. * Unlike the render target, it can render to several draw buffers in one draw.
  47175. * This is specially interesting in deferred rendering or for any effects requiring more than
  47176. * just one color from a single pass.
  47177. * @param name Define the name of the texture
  47178. * @param size Define the size of the buffers to render to
  47179. * @param count Define the number of target we are rendering into
  47180. * @param scene Define the scene the texture belongs to
  47181. * @param options Define the options used to create the multi render target
  47182. */
  47183. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47184. /** @hidden */
  47185. _rebuild(): void;
  47186. private _createInternalTextures;
  47187. private _createTextures;
  47188. /**
  47189. * Define the number of samples used if MSAA is enabled.
  47190. */
  47191. get samples(): number;
  47192. set samples(value: number);
  47193. /**
  47194. * Resize all the textures in the multi render target.
  47195. * Be carrefull as it will recreate all the data in the new texture.
  47196. * @param size Define the new size
  47197. */
  47198. resize(size: any): void;
  47199. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47200. /**
  47201. * Dispose the render targets and their associated resources
  47202. */
  47203. dispose(): void;
  47204. /**
  47205. * Release all the underlying texture used as draw buffers.
  47206. */
  47207. releaseInternalTextures(): void;
  47208. }
  47209. }
  47210. declare module BABYLON {
  47211. interface ThinEngine {
  47212. /**
  47213. * Unbind a list of render target textures from the webGL context
  47214. * This is used only when drawBuffer extension or webGL2 are active
  47215. * @param textures defines the render target textures to unbind
  47216. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47217. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47218. */
  47219. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47220. /**
  47221. * Create a multi render target texture
  47222. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47223. * @param size defines the size of the texture
  47224. * @param options defines the creation options
  47225. * @returns the cube texture as an InternalTexture
  47226. */
  47227. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47228. /**
  47229. * Update the sample count for a given multiple render target texture
  47230. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47231. * @param textures defines the textures to update
  47232. * @param samples defines the sample count to set
  47233. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47234. */
  47235. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47236. }
  47237. }
  47238. declare module BABYLON {
  47239. /**
  47240. * Class used to define an additional view for the engine
  47241. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47242. */
  47243. export class EngineView {
  47244. /** Defines the canvas where to render the view */
  47245. target: HTMLCanvasElement;
  47246. /** Defines an optional camera used to render the view (will use active camera else) */
  47247. camera?: Camera;
  47248. }
  47249. interface Engine {
  47250. /**
  47251. * Gets or sets the HTML element to use for attaching events
  47252. */
  47253. inputElement: Nullable<HTMLElement>;
  47254. /**
  47255. * Gets the current engine view
  47256. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47257. */
  47258. activeView: Nullable<EngineView>;
  47259. /** Gets or sets the list of views */
  47260. views: EngineView[];
  47261. /**
  47262. * Register a new child canvas
  47263. * @param canvas defines the canvas to register
  47264. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47265. * @returns the associated view
  47266. */
  47267. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47268. /**
  47269. * Remove a registered child canvas
  47270. * @param canvas defines the canvas to remove
  47271. * @returns the current engine
  47272. */
  47273. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47274. }
  47275. }
  47276. declare module BABYLON {
  47277. /**
  47278. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47279. */
  47280. export interface CubeMapInfo {
  47281. /**
  47282. * The pixel array for the front face.
  47283. * This is stored in format, left to right, up to down format.
  47284. */
  47285. front: Nullable<ArrayBufferView>;
  47286. /**
  47287. * The pixel array for the back face.
  47288. * This is stored in format, left to right, up to down format.
  47289. */
  47290. back: Nullable<ArrayBufferView>;
  47291. /**
  47292. * The pixel array for the left face.
  47293. * This is stored in format, left to right, up to down format.
  47294. */
  47295. left: Nullable<ArrayBufferView>;
  47296. /**
  47297. * The pixel array for the right face.
  47298. * This is stored in format, left to right, up to down format.
  47299. */
  47300. right: Nullable<ArrayBufferView>;
  47301. /**
  47302. * The pixel array for the up face.
  47303. * This is stored in format, left to right, up to down format.
  47304. */
  47305. up: Nullable<ArrayBufferView>;
  47306. /**
  47307. * The pixel array for the down face.
  47308. * This is stored in format, left to right, up to down format.
  47309. */
  47310. down: Nullable<ArrayBufferView>;
  47311. /**
  47312. * The size of the cubemap stored.
  47313. *
  47314. * Each faces will be size * size pixels.
  47315. */
  47316. size: number;
  47317. /**
  47318. * The format of the texture.
  47319. *
  47320. * RGBA, RGB.
  47321. */
  47322. format: number;
  47323. /**
  47324. * The type of the texture data.
  47325. *
  47326. * UNSIGNED_INT, FLOAT.
  47327. */
  47328. type: number;
  47329. /**
  47330. * Specifies whether the texture is in gamma space.
  47331. */
  47332. gammaSpace: boolean;
  47333. }
  47334. /**
  47335. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47336. */
  47337. export class PanoramaToCubeMapTools {
  47338. private static FACE_FRONT;
  47339. private static FACE_BACK;
  47340. private static FACE_RIGHT;
  47341. private static FACE_LEFT;
  47342. private static FACE_DOWN;
  47343. private static FACE_UP;
  47344. /**
  47345. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47346. *
  47347. * @param float32Array The source data.
  47348. * @param inputWidth The width of the input panorama.
  47349. * @param inputHeight The height of the input panorama.
  47350. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47351. * @return The cubemap data
  47352. */
  47353. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47354. private static CreateCubemapTexture;
  47355. private static CalcProjectionSpherical;
  47356. }
  47357. }
  47358. declare module BABYLON {
  47359. /**
  47360. * Helper class dealing with the extraction of spherical polynomial dataArray
  47361. * from a cube map.
  47362. */
  47363. export class CubeMapToSphericalPolynomialTools {
  47364. private static FileFaces;
  47365. /**
  47366. * Converts a texture to the according Spherical Polynomial data.
  47367. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47368. *
  47369. * @param texture The texture to extract the information from.
  47370. * @return The Spherical Polynomial data.
  47371. */
  47372. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47373. /**
  47374. * Converts a cubemap to the according Spherical Polynomial data.
  47375. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47376. *
  47377. * @param cubeInfo The Cube map to extract the information from.
  47378. * @return The Spherical Polynomial data.
  47379. */
  47380. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47381. }
  47382. }
  47383. declare module BABYLON {
  47384. interface BaseTexture {
  47385. /**
  47386. * Get the polynomial representation of the texture data.
  47387. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47388. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47389. */
  47390. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47391. }
  47392. }
  47393. declare module BABYLON {
  47394. /** @hidden */
  47395. export var rgbdEncodePixelShader: {
  47396. name: string;
  47397. shader: string;
  47398. };
  47399. }
  47400. declare module BABYLON {
  47401. /** @hidden */
  47402. export var rgbdDecodePixelShader: {
  47403. name: string;
  47404. shader: string;
  47405. };
  47406. }
  47407. declare module BABYLON {
  47408. /**
  47409. * Raw texture data and descriptor sufficient for WebGL texture upload
  47410. */
  47411. export interface EnvironmentTextureInfo {
  47412. /**
  47413. * Version of the environment map
  47414. */
  47415. version: number;
  47416. /**
  47417. * Width of image
  47418. */
  47419. width: number;
  47420. /**
  47421. * Irradiance information stored in the file.
  47422. */
  47423. irradiance: any;
  47424. /**
  47425. * Specular information stored in the file.
  47426. */
  47427. specular: any;
  47428. }
  47429. /**
  47430. * Defines One Image in the file. It requires only the position in the file
  47431. * as well as the length.
  47432. */
  47433. interface BufferImageData {
  47434. /**
  47435. * Length of the image data.
  47436. */
  47437. length: number;
  47438. /**
  47439. * Position of the data from the null terminator delimiting the end of the JSON.
  47440. */
  47441. position: number;
  47442. }
  47443. /**
  47444. * Defines the specular data enclosed in the file.
  47445. * This corresponds to the version 1 of the data.
  47446. */
  47447. export interface EnvironmentTextureSpecularInfoV1 {
  47448. /**
  47449. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47450. */
  47451. specularDataPosition?: number;
  47452. /**
  47453. * This contains all the images data needed to reconstruct the cubemap.
  47454. */
  47455. mipmaps: Array<BufferImageData>;
  47456. /**
  47457. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47458. */
  47459. lodGenerationScale: number;
  47460. }
  47461. /**
  47462. * Sets of helpers addressing the serialization and deserialization of environment texture
  47463. * stored in a BabylonJS env file.
  47464. * Those files are usually stored as .env files.
  47465. */
  47466. export class EnvironmentTextureTools {
  47467. /**
  47468. * Magic number identifying the env file.
  47469. */
  47470. private static _MagicBytes;
  47471. /**
  47472. * Gets the environment info from an env file.
  47473. * @param data The array buffer containing the .env bytes.
  47474. * @returns the environment file info (the json header) if successfully parsed.
  47475. */
  47476. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47477. /**
  47478. * Creates an environment texture from a loaded cube texture.
  47479. * @param texture defines the cube texture to convert in env file
  47480. * @return a promise containing the environment data if succesfull.
  47481. */
  47482. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47483. /**
  47484. * Creates a JSON representation of the spherical data.
  47485. * @param texture defines the texture containing the polynomials
  47486. * @return the JSON representation of the spherical info
  47487. */
  47488. private static _CreateEnvTextureIrradiance;
  47489. /**
  47490. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47491. * @param data the image data
  47492. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47493. * @return the views described by info providing access to the underlying buffer
  47494. */
  47495. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47496. /**
  47497. * Uploads the texture info contained in the env file to the GPU.
  47498. * @param texture defines the internal texture to upload to
  47499. * @param data defines the data to load
  47500. * @param info defines the texture info retrieved through the GetEnvInfo method
  47501. * @returns a promise
  47502. */
  47503. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47504. private static _OnImageReadyAsync;
  47505. /**
  47506. * Uploads the levels of image data to the GPU.
  47507. * @param texture defines the internal texture to upload to
  47508. * @param imageData defines the array buffer views of image data [mipmap][face]
  47509. * @returns a promise
  47510. */
  47511. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47512. /**
  47513. * Uploads spherical polynomials information to the texture.
  47514. * @param texture defines the texture we are trying to upload the information to
  47515. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47516. */
  47517. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47518. /** @hidden */
  47519. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47520. }
  47521. }
  47522. declare module BABYLON {
  47523. /**
  47524. * Contains position and normal vectors for a vertex
  47525. */
  47526. export class PositionNormalVertex {
  47527. /** the position of the vertex (defaut: 0,0,0) */
  47528. position: Vector3;
  47529. /** the normal of the vertex (defaut: 0,1,0) */
  47530. normal: Vector3;
  47531. /**
  47532. * Creates a PositionNormalVertex
  47533. * @param position the position of the vertex (defaut: 0,0,0)
  47534. * @param normal the normal of the vertex (defaut: 0,1,0)
  47535. */
  47536. constructor(
  47537. /** the position of the vertex (defaut: 0,0,0) */
  47538. position?: Vector3,
  47539. /** the normal of the vertex (defaut: 0,1,0) */
  47540. normal?: Vector3);
  47541. /**
  47542. * Clones the PositionNormalVertex
  47543. * @returns the cloned PositionNormalVertex
  47544. */
  47545. clone(): PositionNormalVertex;
  47546. }
  47547. /**
  47548. * Contains position, normal and uv vectors for a vertex
  47549. */
  47550. export class PositionNormalTextureVertex {
  47551. /** the position of the vertex (defaut: 0,0,0) */
  47552. position: Vector3;
  47553. /** the normal of the vertex (defaut: 0,1,0) */
  47554. normal: Vector3;
  47555. /** the uv of the vertex (default: 0,0) */
  47556. uv: Vector2;
  47557. /**
  47558. * Creates a PositionNormalTextureVertex
  47559. * @param position the position of the vertex (defaut: 0,0,0)
  47560. * @param normal the normal of the vertex (defaut: 0,1,0)
  47561. * @param uv the uv of the vertex (default: 0,0)
  47562. */
  47563. constructor(
  47564. /** the position of the vertex (defaut: 0,0,0) */
  47565. position?: Vector3,
  47566. /** the normal of the vertex (defaut: 0,1,0) */
  47567. normal?: Vector3,
  47568. /** the uv of the vertex (default: 0,0) */
  47569. uv?: Vector2);
  47570. /**
  47571. * Clones the PositionNormalTextureVertex
  47572. * @returns the cloned PositionNormalTextureVertex
  47573. */
  47574. clone(): PositionNormalTextureVertex;
  47575. }
  47576. }
  47577. declare module BABYLON {
  47578. /** @hidden */
  47579. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47580. private _genericAttributeLocation;
  47581. private _varyingLocationCount;
  47582. private _varyingLocationMap;
  47583. private _replacements;
  47584. private _textureCount;
  47585. private _uniforms;
  47586. lineProcessor(line: string): string;
  47587. attributeProcessor(attribute: string): string;
  47588. varyingProcessor(varying: string, isFragment: boolean): string;
  47589. uniformProcessor(uniform: string): string;
  47590. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47591. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47592. }
  47593. }
  47594. declare module BABYLON {
  47595. /**
  47596. * Container for accessors for natively-stored mesh data buffers.
  47597. */
  47598. class NativeDataBuffer extends DataBuffer {
  47599. /**
  47600. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47601. */
  47602. nativeIndexBuffer?: any;
  47603. /**
  47604. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47605. */
  47606. nativeVertexBuffer?: any;
  47607. }
  47608. /** @hidden */
  47609. class NativeTexture extends InternalTexture {
  47610. getInternalTexture(): InternalTexture;
  47611. getViewCount(): number;
  47612. }
  47613. /** @hidden */
  47614. export class NativeEngine extends Engine {
  47615. private readonly _native;
  47616. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47617. private readonly INVALID_HANDLE;
  47618. getHardwareScalingLevel(): number;
  47619. constructor();
  47620. /**
  47621. * Can be used to override the current requestAnimationFrame requester.
  47622. * @hidden
  47623. */
  47624. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47625. /**
  47626. * Override default engine behavior.
  47627. * @param color
  47628. * @param backBuffer
  47629. * @param depth
  47630. * @param stencil
  47631. */
  47632. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47633. /**
  47634. * Gets host document
  47635. * @returns the host document object
  47636. */
  47637. getHostDocument(): Nullable<Document>;
  47638. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47639. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47640. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47641. recordVertexArrayObject(vertexBuffers: {
  47642. [key: string]: VertexBuffer;
  47643. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47644. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47645. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47646. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47647. /**
  47648. * Draw a list of indexed primitives
  47649. * @param fillMode defines the primitive to use
  47650. * @param indexStart defines the starting index
  47651. * @param indexCount defines the number of index to draw
  47652. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47653. */
  47654. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47655. /**
  47656. * Draw a list of unindexed primitives
  47657. * @param fillMode defines the primitive to use
  47658. * @param verticesStart defines the index of first vertex to draw
  47659. * @param verticesCount defines the count of vertices to draw
  47660. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47661. */
  47662. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47663. createPipelineContext(): IPipelineContext;
  47664. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47665. /** @hidden */
  47666. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47667. /** @hidden */
  47668. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47669. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47670. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47671. protected _setProgram(program: WebGLProgram): void;
  47672. _releaseEffect(effect: Effect): void;
  47673. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47674. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47675. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47676. bindSamplers(effect: Effect): void;
  47677. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47678. getRenderWidth(useScreen?: boolean): number;
  47679. getRenderHeight(useScreen?: boolean): number;
  47680. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47681. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47682. /**
  47683. * Set the z offset to apply to current rendering
  47684. * @param value defines the offset to apply
  47685. */
  47686. setZOffset(value: number): void;
  47687. /**
  47688. * Gets the current value of the zOffset
  47689. * @returns the current zOffset state
  47690. */
  47691. getZOffset(): number;
  47692. /**
  47693. * Enable or disable depth buffering
  47694. * @param enable defines the state to set
  47695. */
  47696. setDepthBuffer(enable: boolean): void;
  47697. /**
  47698. * Gets a boolean indicating if depth writing is enabled
  47699. * @returns the current depth writing state
  47700. */
  47701. getDepthWrite(): boolean;
  47702. /**
  47703. * Enable or disable depth writing
  47704. * @param enable defines the state to set
  47705. */
  47706. setDepthWrite(enable: boolean): void;
  47707. /**
  47708. * Enable or disable color writing
  47709. * @param enable defines the state to set
  47710. */
  47711. setColorWrite(enable: boolean): void;
  47712. /**
  47713. * Gets a boolean indicating if color writing is enabled
  47714. * @returns the current color writing state
  47715. */
  47716. getColorWrite(): boolean;
  47717. /**
  47718. * Sets alpha constants used by some alpha blending modes
  47719. * @param r defines the red component
  47720. * @param g defines the green component
  47721. * @param b defines the blue component
  47722. * @param a defines the alpha component
  47723. */
  47724. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47725. /**
  47726. * Sets the current alpha mode
  47727. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47728. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47729. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47730. */
  47731. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47732. /**
  47733. * Gets the current alpha mode
  47734. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47735. * @returns the current alpha mode
  47736. */
  47737. getAlphaMode(): number;
  47738. setInt(uniform: WebGLUniformLocation, int: number): void;
  47739. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47740. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47741. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47742. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47743. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47744. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47745. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47746. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47747. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47748. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47749. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47750. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47751. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47752. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47753. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47754. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47755. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47756. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47757. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47758. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47759. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47760. wipeCaches(bruteForce?: boolean): void;
  47761. _createTexture(): WebGLTexture;
  47762. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47763. /**
  47764. * Usually called from Texture.ts.
  47765. * Passed information to create a WebGLTexture
  47766. * @param urlArg defines a value which contains one of the following:
  47767. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47768. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47769. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47770. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47771. * @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)
  47772. * @param scene needed for loading to the correct scene
  47773. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47774. * @param onLoad optional callback to be called upon successful completion
  47775. * @param onError optional callback to be called upon failure
  47776. * @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
  47777. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47778. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47779. * @param forcedExtension defines the extension to use to pick the right loader
  47780. * @param mimeType defines an optional mime type
  47781. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47782. */
  47783. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  47784. /**
  47785. * Creates a cube texture
  47786. * @param rootUrl defines the url where the files to load is located
  47787. * @param scene defines the current scene
  47788. * @param files defines the list of files to load (1 per face)
  47789. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47790. * @param onLoad defines an optional callback raised when the texture is loaded
  47791. * @param onError defines an optional callback raised if there is an issue to load the texture
  47792. * @param format defines the format of the data
  47793. * @param forcedExtension defines the extension to use to pick the right loader
  47794. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47795. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47796. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47797. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47798. * @returns the cube texture as an InternalTexture
  47799. */
  47800. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  47801. private _getSamplingFilter;
  47802. private static _GetNativeTextureFormat;
  47803. createRenderTargetTexture(size: number | {
  47804. width: number;
  47805. height: number;
  47806. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47807. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47808. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47809. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47810. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47811. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47812. /**
  47813. * Updates a dynamic vertex buffer.
  47814. * @param vertexBuffer the vertex buffer to update
  47815. * @param data the data used to update the vertex buffer
  47816. * @param byteOffset the byte offset of the data (optional)
  47817. * @param byteLength the byte length of the data (optional)
  47818. */
  47819. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47820. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47821. private _updateAnisotropicLevel;
  47822. private _getAddressMode;
  47823. /** @hidden */
  47824. _bindTexture(channel: number, texture: InternalTexture): void;
  47825. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47826. releaseEffects(): void;
  47827. /** @hidden */
  47828. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47829. /** @hidden */
  47830. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47831. /** @hidden */
  47832. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47833. /** @hidden */
  47834. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47835. }
  47836. }
  47837. declare module BABYLON {
  47838. /**
  47839. * Gather the list of clipboard event types as constants.
  47840. */
  47841. export class ClipboardEventTypes {
  47842. /**
  47843. * The clipboard event is fired when a copy command is active (pressed).
  47844. */
  47845. static readonly COPY: number;
  47846. /**
  47847. * The clipboard event is fired when a cut command is active (pressed).
  47848. */
  47849. static readonly CUT: number;
  47850. /**
  47851. * The clipboard event is fired when a paste command is active (pressed).
  47852. */
  47853. static readonly PASTE: number;
  47854. }
  47855. /**
  47856. * This class is used to store clipboard related info for the onClipboardObservable event.
  47857. */
  47858. export class ClipboardInfo {
  47859. /**
  47860. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47861. */
  47862. type: number;
  47863. /**
  47864. * Defines the related dom event
  47865. */
  47866. event: ClipboardEvent;
  47867. /**
  47868. *Creates an instance of ClipboardInfo.
  47869. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47870. * @param event Defines the related dom event
  47871. */
  47872. constructor(
  47873. /**
  47874. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47875. */
  47876. type: number,
  47877. /**
  47878. * Defines the related dom event
  47879. */
  47880. event: ClipboardEvent);
  47881. /**
  47882. * Get the clipboard event's type from the keycode.
  47883. * @param keyCode Defines the keyCode for the current keyboard event.
  47884. * @return {number}
  47885. */
  47886. static GetTypeFromCharacter(keyCode: number): number;
  47887. }
  47888. }
  47889. declare module BABYLON {
  47890. /**
  47891. * Google Daydream controller
  47892. */
  47893. export class DaydreamController extends WebVRController {
  47894. /**
  47895. * Base Url for the controller model.
  47896. */
  47897. static MODEL_BASE_URL: string;
  47898. /**
  47899. * File name for the controller model.
  47900. */
  47901. static MODEL_FILENAME: string;
  47902. /**
  47903. * Gamepad Id prefix used to identify Daydream Controller.
  47904. */
  47905. static readonly GAMEPAD_ID_PREFIX: string;
  47906. /**
  47907. * Creates a new DaydreamController from a gamepad
  47908. * @param vrGamepad the gamepad that the controller should be created from
  47909. */
  47910. constructor(vrGamepad: any);
  47911. /**
  47912. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47913. * @param scene scene in which to add meshes
  47914. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47915. */
  47916. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47917. /**
  47918. * Called once for each button that changed state since the last frame
  47919. * @param buttonIdx Which button index changed
  47920. * @param state New state of the button
  47921. * @param changes Which properties on the state changed since last frame
  47922. */
  47923. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47924. }
  47925. }
  47926. declare module BABYLON {
  47927. /**
  47928. * Gear VR Controller
  47929. */
  47930. export class GearVRController extends WebVRController {
  47931. /**
  47932. * Base Url for the controller model.
  47933. */
  47934. static MODEL_BASE_URL: string;
  47935. /**
  47936. * File name for the controller model.
  47937. */
  47938. static MODEL_FILENAME: string;
  47939. /**
  47940. * Gamepad Id prefix used to identify this controller.
  47941. */
  47942. static readonly GAMEPAD_ID_PREFIX: string;
  47943. private readonly _buttonIndexToObservableNameMap;
  47944. /**
  47945. * Creates a new GearVRController from a gamepad
  47946. * @param vrGamepad the gamepad that the controller should be created from
  47947. */
  47948. constructor(vrGamepad: any);
  47949. /**
  47950. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47951. * @param scene scene in which to add meshes
  47952. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47953. */
  47954. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47955. /**
  47956. * Called once for each button that changed state since the last frame
  47957. * @param buttonIdx Which button index changed
  47958. * @param state New state of the button
  47959. * @param changes Which properties on the state changed since last frame
  47960. */
  47961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47962. }
  47963. }
  47964. declare module BABYLON {
  47965. /**
  47966. * Generic Controller
  47967. */
  47968. export class GenericController extends WebVRController {
  47969. /**
  47970. * Base Url for the controller model.
  47971. */
  47972. static readonly MODEL_BASE_URL: string;
  47973. /**
  47974. * File name for the controller model.
  47975. */
  47976. static readonly MODEL_FILENAME: string;
  47977. /**
  47978. * Creates a new GenericController from a gamepad
  47979. * @param vrGamepad the gamepad that the controller should be created from
  47980. */
  47981. constructor(vrGamepad: any);
  47982. /**
  47983. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47984. * @param scene scene in which to add meshes
  47985. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47986. */
  47987. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47988. /**
  47989. * Called once for each button that changed state since the last frame
  47990. * @param buttonIdx Which button index changed
  47991. * @param state New state of the button
  47992. * @param changes Which properties on the state changed since last frame
  47993. */
  47994. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47995. }
  47996. }
  47997. declare module BABYLON {
  47998. /**
  47999. * Oculus Touch Controller
  48000. */
  48001. export class OculusTouchController extends WebVRController {
  48002. /**
  48003. * Base Url for the controller model.
  48004. */
  48005. static MODEL_BASE_URL: string;
  48006. /**
  48007. * File name for the left controller model.
  48008. */
  48009. static MODEL_LEFT_FILENAME: string;
  48010. /**
  48011. * File name for the right controller model.
  48012. */
  48013. static MODEL_RIGHT_FILENAME: string;
  48014. /**
  48015. * Base Url for the Quest controller model.
  48016. */
  48017. static QUEST_MODEL_BASE_URL: string;
  48018. /**
  48019. * @hidden
  48020. * If the controllers are running on a device that needs the updated Quest controller models
  48021. */
  48022. static _IsQuest: boolean;
  48023. /**
  48024. * Fired when the secondary trigger on this controller is modified
  48025. */
  48026. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48027. /**
  48028. * Fired when the thumb rest on this controller is modified
  48029. */
  48030. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48031. /**
  48032. * Creates a new OculusTouchController from a gamepad
  48033. * @param vrGamepad the gamepad that the controller should be created from
  48034. */
  48035. constructor(vrGamepad: any);
  48036. /**
  48037. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48038. * @param scene scene in which to add meshes
  48039. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48040. */
  48041. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48042. /**
  48043. * Fired when the A button on this controller is modified
  48044. */
  48045. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48046. /**
  48047. * Fired when the B button on this controller is modified
  48048. */
  48049. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48050. /**
  48051. * Fired when the X button on this controller is modified
  48052. */
  48053. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48054. /**
  48055. * Fired when the Y button on this controller is modified
  48056. */
  48057. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48058. /**
  48059. * Called once for each button that changed state since the last frame
  48060. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48061. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48062. * 2) secondary trigger (same)
  48063. * 3) A (right) X (left), touch, pressed = value
  48064. * 4) B / Y
  48065. * 5) thumb rest
  48066. * @param buttonIdx Which button index changed
  48067. * @param state New state of the button
  48068. * @param changes Which properties on the state changed since last frame
  48069. */
  48070. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48071. }
  48072. }
  48073. declare module BABYLON {
  48074. /**
  48075. * Vive Controller
  48076. */
  48077. export class ViveController extends WebVRController {
  48078. /**
  48079. * Base Url for the controller model.
  48080. */
  48081. static MODEL_BASE_URL: string;
  48082. /**
  48083. * File name for the controller model.
  48084. */
  48085. static MODEL_FILENAME: string;
  48086. /**
  48087. * Creates a new ViveController from a gamepad
  48088. * @param vrGamepad the gamepad that the controller should be created from
  48089. */
  48090. constructor(vrGamepad: any);
  48091. /**
  48092. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48093. * @param scene scene in which to add meshes
  48094. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48095. */
  48096. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48097. /**
  48098. * Fired when the left button on this controller is modified
  48099. */
  48100. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48101. /**
  48102. * Fired when the right button on this controller is modified
  48103. */
  48104. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48105. /**
  48106. * Fired when the menu button on this controller is modified
  48107. */
  48108. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48109. /**
  48110. * Called once for each button that changed state since the last frame
  48111. * Vive mapping:
  48112. * 0: touchpad
  48113. * 1: trigger
  48114. * 2: left AND right buttons
  48115. * 3: menu button
  48116. * @param buttonIdx Which button index changed
  48117. * @param state New state of the button
  48118. * @param changes Which properties on the state changed since last frame
  48119. */
  48120. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48121. }
  48122. }
  48123. declare module BABYLON {
  48124. /**
  48125. * Defines the WindowsMotionController object that the state of the windows motion controller
  48126. */
  48127. export class WindowsMotionController extends WebVRController {
  48128. /**
  48129. * The base url used to load the left and right controller models
  48130. */
  48131. static MODEL_BASE_URL: string;
  48132. /**
  48133. * The name of the left controller model file
  48134. */
  48135. static MODEL_LEFT_FILENAME: string;
  48136. /**
  48137. * The name of the right controller model file
  48138. */
  48139. static MODEL_RIGHT_FILENAME: string;
  48140. /**
  48141. * The controller name prefix for this controller type
  48142. */
  48143. static readonly GAMEPAD_ID_PREFIX: string;
  48144. /**
  48145. * The controller id pattern for this controller type
  48146. */
  48147. private static readonly GAMEPAD_ID_PATTERN;
  48148. private _loadedMeshInfo;
  48149. protected readonly _mapping: {
  48150. buttons: string[];
  48151. buttonMeshNames: {
  48152. 'trigger': string;
  48153. 'menu': string;
  48154. 'grip': string;
  48155. 'thumbstick': string;
  48156. 'trackpad': string;
  48157. };
  48158. buttonObservableNames: {
  48159. 'trigger': string;
  48160. 'menu': string;
  48161. 'grip': string;
  48162. 'thumbstick': string;
  48163. 'trackpad': string;
  48164. };
  48165. axisMeshNames: string[];
  48166. pointingPoseMeshName: string;
  48167. };
  48168. /**
  48169. * Fired when the trackpad on this controller is clicked
  48170. */
  48171. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48172. /**
  48173. * Fired when the trackpad on this controller is modified
  48174. */
  48175. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48176. /**
  48177. * The current x and y values of this controller's trackpad
  48178. */
  48179. trackpad: StickValues;
  48180. /**
  48181. * Creates a new WindowsMotionController from a gamepad
  48182. * @param vrGamepad the gamepad that the controller should be created from
  48183. */
  48184. constructor(vrGamepad: any);
  48185. /**
  48186. * Fired when the trigger on this controller is modified
  48187. */
  48188. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48189. /**
  48190. * Fired when the menu button on this controller is modified
  48191. */
  48192. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48193. /**
  48194. * Fired when the grip button on this controller is modified
  48195. */
  48196. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48197. /**
  48198. * Fired when the thumbstick button on this controller is modified
  48199. */
  48200. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48201. /**
  48202. * Fired when the touchpad button on this controller is modified
  48203. */
  48204. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48205. /**
  48206. * Fired when the touchpad values on this controller are modified
  48207. */
  48208. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48209. protected _updateTrackpad(): void;
  48210. /**
  48211. * Called once per frame by the engine.
  48212. */
  48213. update(): void;
  48214. /**
  48215. * Called once for each button that changed state since the last frame
  48216. * @param buttonIdx Which button index changed
  48217. * @param state New state of the button
  48218. * @param changes Which properties on the state changed since last frame
  48219. */
  48220. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48221. /**
  48222. * Moves the buttons on the controller mesh based on their current state
  48223. * @param buttonName the name of the button to move
  48224. * @param buttonValue the value of the button which determines the buttons new position
  48225. */
  48226. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48227. /**
  48228. * Moves the axis on the controller mesh based on its current state
  48229. * @param axis the index of the axis
  48230. * @param axisValue the value of the axis which determines the meshes new position
  48231. * @hidden
  48232. */
  48233. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48234. /**
  48235. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48236. * @param scene scene in which to add meshes
  48237. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48238. */
  48239. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48240. /**
  48241. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48242. * can be transformed by button presses and axes values, based on this._mapping.
  48243. *
  48244. * @param scene scene in which the meshes exist
  48245. * @param meshes list of meshes that make up the controller model to process
  48246. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48247. */
  48248. private processModel;
  48249. private createMeshInfo;
  48250. /**
  48251. * Gets the ray of the controller in the direction the controller is pointing
  48252. * @param length the length the resulting ray should be
  48253. * @returns a ray in the direction the controller is pointing
  48254. */
  48255. getForwardRay(length?: number): Ray;
  48256. /**
  48257. * Disposes of the controller
  48258. */
  48259. dispose(): void;
  48260. }
  48261. /**
  48262. * This class represents a new windows motion controller in XR.
  48263. */
  48264. export class XRWindowsMotionController extends WindowsMotionController {
  48265. /**
  48266. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48267. */
  48268. protected readonly _mapping: {
  48269. buttons: string[];
  48270. buttonMeshNames: {
  48271. 'trigger': string;
  48272. 'menu': string;
  48273. 'grip': string;
  48274. 'thumbstick': string;
  48275. 'trackpad': string;
  48276. };
  48277. buttonObservableNames: {
  48278. 'trigger': string;
  48279. 'menu': string;
  48280. 'grip': string;
  48281. 'thumbstick': string;
  48282. 'trackpad': string;
  48283. };
  48284. axisMeshNames: string[];
  48285. pointingPoseMeshName: string;
  48286. };
  48287. /**
  48288. * Construct a new XR-Based windows motion controller
  48289. *
  48290. * @param gamepadInfo the gamepad object from the browser
  48291. */
  48292. constructor(gamepadInfo: any);
  48293. /**
  48294. * holds the thumbstick values (X,Y)
  48295. */
  48296. thumbstickValues: StickValues;
  48297. /**
  48298. * Fired when the thumbstick on this controller is clicked
  48299. */
  48300. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48301. /**
  48302. * Fired when the thumbstick on this controller is modified
  48303. */
  48304. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48305. /**
  48306. * Fired when the touchpad button on this controller is modified
  48307. */
  48308. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48309. /**
  48310. * Fired when the touchpad values on this controller are modified
  48311. */
  48312. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48313. /**
  48314. * Fired when the thumbstick button on this controller is modified
  48315. * here to prevent breaking changes
  48316. */
  48317. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48318. /**
  48319. * updating the thumbstick(!) and not the trackpad.
  48320. * This is named this way due to the difference between WebVR and XR and to avoid
  48321. * changing the parent class.
  48322. */
  48323. protected _updateTrackpad(): void;
  48324. /**
  48325. * Disposes the class with joy
  48326. */
  48327. dispose(): void;
  48328. }
  48329. }
  48330. declare module BABYLON {
  48331. /**
  48332. * Class containing static functions to help procedurally build meshes
  48333. */
  48334. export class PolyhedronBuilder {
  48335. /**
  48336. * Creates a polyhedron mesh
  48337. * * 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
  48338. * * The parameter `size` (positive float, default 1) sets the polygon size
  48339. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48340. * * 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`
  48341. * * 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
  48342. * * 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)`)
  48343. * * 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
  48344. * * 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
  48345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48346. * * 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
  48347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48348. * @param name defines the name of the mesh
  48349. * @param options defines the options used to create the mesh
  48350. * @param scene defines the hosting scene
  48351. * @returns the polyhedron mesh
  48352. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48353. */
  48354. static CreatePolyhedron(name: string, options: {
  48355. type?: number;
  48356. size?: number;
  48357. sizeX?: number;
  48358. sizeY?: number;
  48359. sizeZ?: number;
  48360. custom?: any;
  48361. faceUV?: Vector4[];
  48362. faceColors?: Color4[];
  48363. flat?: boolean;
  48364. updatable?: boolean;
  48365. sideOrientation?: number;
  48366. frontUVs?: Vector4;
  48367. backUVs?: Vector4;
  48368. }, scene?: Nullable<Scene>): Mesh;
  48369. }
  48370. }
  48371. declare module BABYLON {
  48372. /**
  48373. * Gizmo that enables scaling a mesh along 3 axis
  48374. */
  48375. export class ScaleGizmo extends Gizmo {
  48376. /**
  48377. * Internal gizmo used for interactions on the x axis
  48378. */
  48379. xGizmo: AxisScaleGizmo;
  48380. /**
  48381. * Internal gizmo used for interactions on the y axis
  48382. */
  48383. yGizmo: AxisScaleGizmo;
  48384. /**
  48385. * Internal gizmo used for interactions on the z axis
  48386. */
  48387. zGizmo: AxisScaleGizmo;
  48388. /**
  48389. * Internal gizmo used to scale all axis equally
  48390. */
  48391. uniformScaleGizmo: AxisScaleGizmo;
  48392. private _meshAttached;
  48393. private _updateGizmoRotationToMatchAttachedMesh;
  48394. private _snapDistance;
  48395. private _scaleRatio;
  48396. private _uniformScalingMesh;
  48397. private _octahedron;
  48398. private _sensitivity;
  48399. /** Fires an event when any of it's sub gizmos are dragged */
  48400. onDragStartObservable: Observable<unknown>;
  48401. /** Fires an event when any of it's sub gizmos are released from dragging */
  48402. onDragEndObservable: Observable<unknown>;
  48403. get attachedMesh(): Nullable<AbstractMesh>;
  48404. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48405. /**
  48406. * Creates a ScaleGizmo
  48407. * @param gizmoLayer The utility layer the gizmo will be added to
  48408. */
  48409. constructor(gizmoLayer?: UtilityLayerRenderer);
  48410. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48411. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48412. /**
  48413. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48414. */
  48415. set snapDistance(value: number);
  48416. get snapDistance(): number;
  48417. /**
  48418. * Ratio for the scale of the gizmo (Default: 1)
  48419. */
  48420. set scaleRatio(value: number);
  48421. get scaleRatio(): number;
  48422. /**
  48423. * Sensitivity factor for dragging (Default: 1)
  48424. */
  48425. set sensitivity(value: number);
  48426. get sensitivity(): number;
  48427. /**
  48428. * Disposes of the gizmo
  48429. */
  48430. dispose(): void;
  48431. }
  48432. }
  48433. declare module BABYLON {
  48434. /**
  48435. * Single axis scale gizmo
  48436. */
  48437. export class AxisScaleGizmo extends Gizmo {
  48438. /**
  48439. * Drag behavior responsible for the gizmos dragging interactions
  48440. */
  48441. dragBehavior: PointerDragBehavior;
  48442. private _pointerObserver;
  48443. /**
  48444. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48445. */
  48446. snapDistance: number;
  48447. /**
  48448. * Event that fires each time the gizmo snaps to a new location.
  48449. * * snapDistance is the the change in distance
  48450. */
  48451. onSnapObservable: Observable<{
  48452. snapDistance: number;
  48453. }>;
  48454. /**
  48455. * If the scaling operation should be done on all axis (default: false)
  48456. */
  48457. uniformScaling: boolean;
  48458. /**
  48459. * Custom sensitivity value for the drag strength
  48460. */
  48461. sensitivity: number;
  48462. private _isEnabled;
  48463. private _parent;
  48464. private _arrow;
  48465. private _coloredMaterial;
  48466. private _hoverMaterial;
  48467. /**
  48468. * Creates an AxisScaleGizmo
  48469. * @param gizmoLayer The utility layer the gizmo will be added to
  48470. * @param dragAxis The axis which the gizmo will be able to scale on
  48471. * @param color The color of the gizmo
  48472. */
  48473. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48474. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48475. /**
  48476. * If the gizmo is enabled
  48477. */
  48478. set isEnabled(value: boolean);
  48479. get isEnabled(): boolean;
  48480. /**
  48481. * Disposes of the gizmo
  48482. */
  48483. dispose(): void;
  48484. /**
  48485. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48486. * @param mesh The mesh to replace the default mesh of the gizmo
  48487. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48488. */
  48489. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48490. }
  48491. }
  48492. declare module BABYLON {
  48493. /**
  48494. * Bounding box gizmo
  48495. */
  48496. export class BoundingBoxGizmo extends Gizmo {
  48497. private _lineBoundingBox;
  48498. private _rotateSpheresParent;
  48499. private _scaleBoxesParent;
  48500. private _boundingDimensions;
  48501. private _renderObserver;
  48502. private _pointerObserver;
  48503. private _scaleDragSpeed;
  48504. private _tmpQuaternion;
  48505. private _tmpVector;
  48506. private _tmpRotationMatrix;
  48507. /**
  48508. * 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)
  48509. */
  48510. ignoreChildren: boolean;
  48511. /**
  48512. * 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)
  48513. */
  48514. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48515. /**
  48516. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48517. */
  48518. rotationSphereSize: number;
  48519. /**
  48520. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48521. */
  48522. scaleBoxSize: number;
  48523. /**
  48524. * 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)
  48525. */
  48526. fixedDragMeshScreenSize: boolean;
  48527. /**
  48528. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48529. */
  48530. fixedDragMeshScreenSizeDistanceFactor: number;
  48531. /**
  48532. * Fired when a rotation sphere or scale box is dragged
  48533. */
  48534. onDragStartObservable: Observable<{}>;
  48535. /**
  48536. * Fired when a scale box is dragged
  48537. */
  48538. onScaleBoxDragObservable: Observable<{}>;
  48539. /**
  48540. * Fired when a scale box drag is ended
  48541. */
  48542. onScaleBoxDragEndObservable: Observable<{}>;
  48543. /**
  48544. * Fired when a rotation sphere is dragged
  48545. */
  48546. onRotationSphereDragObservable: Observable<{}>;
  48547. /**
  48548. * Fired when a rotation sphere drag is ended
  48549. */
  48550. onRotationSphereDragEndObservable: Observable<{}>;
  48551. /**
  48552. * 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)
  48553. */
  48554. scalePivot: Nullable<Vector3>;
  48555. /**
  48556. * Mesh used as a pivot to rotate the attached mesh
  48557. */
  48558. private _anchorMesh;
  48559. private _existingMeshScale;
  48560. private _dragMesh;
  48561. private pointerDragBehavior;
  48562. private coloredMaterial;
  48563. private hoverColoredMaterial;
  48564. /**
  48565. * Sets the color of the bounding box gizmo
  48566. * @param color the color to set
  48567. */
  48568. setColor(color: Color3): void;
  48569. /**
  48570. * Creates an BoundingBoxGizmo
  48571. * @param gizmoLayer The utility layer the gizmo will be added to
  48572. * @param color The color of the gizmo
  48573. */
  48574. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48575. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48576. private _selectNode;
  48577. /**
  48578. * Updates the bounding box information for the Gizmo
  48579. */
  48580. updateBoundingBox(): void;
  48581. private _updateRotationSpheres;
  48582. private _updateScaleBoxes;
  48583. /**
  48584. * Enables rotation on the specified axis and disables rotation on the others
  48585. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48586. */
  48587. setEnabledRotationAxis(axis: string): void;
  48588. /**
  48589. * Enables/disables scaling
  48590. * @param enable if scaling should be enabled
  48591. */
  48592. setEnabledScaling(enable: boolean): void;
  48593. private _updateDummy;
  48594. /**
  48595. * Enables a pointer drag behavior on the bounding box of the gizmo
  48596. */
  48597. enableDragBehavior(): void;
  48598. /**
  48599. * Disposes of the gizmo
  48600. */
  48601. dispose(): void;
  48602. /**
  48603. * 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)
  48604. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48605. * @returns the bounding box mesh with the passed in mesh as a child
  48606. */
  48607. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48608. /**
  48609. * CustomMeshes are not supported by this gizmo
  48610. * @param mesh The mesh to replace the default mesh of the gizmo
  48611. */
  48612. setCustomMesh(mesh: Mesh): void;
  48613. }
  48614. }
  48615. declare module BABYLON {
  48616. /**
  48617. * Single plane rotation gizmo
  48618. */
  48619. export class PlaneRotationGizmo extends Gizmo {
  48620. /**
  48621. * Drag behavior responsible for the gizmos dragging interactions
  48622. */
  48623. dragBehavior: PointerDragBehavior;
  48624. private _pointerObserver;
  48625. /**
  48626. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48627. */
  48628. snapDistance: number;
  48629. /**
  48630. * Event that fires each time the gizmo snaps to a new location.
  48631. * * snapDistance is the the change in distance
  48632. */
  48633. onSnapObservable: Observable<{
  48634. snapDistance: number;
  48635. }>;
  48636. private _isEnabled;
  48637. private _parent;
  48638. /**
  48639. * Creates a PlaneRotationGizmo
  48640. * @param gizmoLayer The utility layer the gizmo will be added to
  48641. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48642. * @param color The color of the gizmo
  48643. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48644. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48645. */
  48646. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48647. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48648. /**
  48649. * If the gizmo is enabled
  48650. */
  48651. set isEnabled(value: boolean);
  48652. get isEnabled(): boolean;
  48653. /**
  48654. * Disposes of the gizmo
  48655. */
  48656. dispose(): void;
  48657. }
  48658. }
  48659. declare module BABYLON {
  48660. /**
  48661. * Gizmo that enables rotating a mesh along 3 axis
  48662. */
  48663. export class RotationGizmo extends Gizmo {
  48664. /**
  48665. * Internal gizmo used for interactions on the x axis
  48666. */
  48667. xGizmo: PlaneRotationGizmo;
  48668. /**
  48669. * Internal gizmo used for interactions on the y axis
  48670. */
  48671. yGizmo: PlaneRotationGizmo;
  48672. /**
  48673. * Internal gizmo used for interactions on the z axis
  48674. */
  48675. zGizmo: PlaneRotationGizmo;
  48676. /** Fires an event when any of it's sub gizmos are dragged */
  48677. onDragStartObservable: Observable<unknown>;
  48678. /** Fires an event when any of it's sub gizmos are released from dragging */
  48679. onDragEndObservable: Observable<unknown>;
  48680. private _meshAttached;
  48681. get attachedMesh(): Nullable<AbstractMesh>;
  48682. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48683. /**
  48684. * Creates a RotationGizmo
  48685. * @param gizmoLayer The utility layer the gizmo will be added to
  48686. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48687. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48688. */
  48689. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48690. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48691. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48692. /**
  48693. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48694. */
  48695. set snapDistance(value: number);
  48696. get snapDistance(): number;
  48697. /**
  48698. * Ratio for the scale of the gizmo (Default: 1)
  48699. */
  48700. set scaleRatio(value: number);
  48701. get scaleRatio(): number;
  48702. /**
  48703. * Disposes of the gizmo
  48704. */
  48705. dispose(): void;
  48706. /**
  48707. * CustomMeshes are not supported by this gizmo
  48708. * @param mesh The mesh to replace the default mesh of the gizmo
  48709. */
  48710. setCustomMesh(mesh: Mesh): void;
  48711. }
  48712. }
  48713. declare module BABYLON {
  48714. /**
  48715. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48716. */
  48717. export class GizmoManager implements IDisposable {
  48718. private scene;
  48719. /**
  48720. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48721. */
  48722. gizmos: {
  48723. positionGizmo: Nullable<PositionGizmo>;
  48724. rotationGizmo: Nullable<RotationGizmo>;
  48725. scaleGizmo: Nullable<ScaleGizmo>;
  48726. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48727. };
  48728. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48729. clearGizmoOnEmptyPointerEvent: boolean;
  48730. /** Fires an event when the manager is attached to a mesh */
  48731. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48732. private _gizmosEnabled;
  48733. private _pointerObserver;
  48734. private _attachedMesh;
  48735. private _boundingBoxColor;
  48736. private _defaultUtilityLayer;
  48737. private _defaultKeepDepthUtilityLayer;
  48738. /**
  48739. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48740. */
  48741. boundingBoxDragBehavior: SixDofDragBehavior;
  48742. /**
  48743. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48744. */
  48745. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48746. /**
  48747. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48748. */
  48749. usePointerToAttachGizmos: boolean;
  48750. /**
  48751. * Utility layer that the bounding box gizmo belongs to
  48752. */
  48753. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48754. /**
  48755. * Utility layer that all gizmos besides bounding box belong to
  48756. */
  48757. get utilityLayer(): UtilityLayerRenderer;
  48758. /**
  48759. * Instatiates a gizmo manager
  48760. * @param scene the scene to overlay the gizmos on top of
  48761. */
  48762. constructor(scene: Scene);
  48763. /**
  48764. * Attaches a set of gizmos to the specified mesh
  48765. * @param mesh The mesh the gizmo's should be attached to
  48766. */
  48767. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48768. /**
  48769. * If the position gizmo is enabled
  48770. */
  48771. set positionGizmoEnabled(value: boolean);
  48772. get positionGizmoEnabled(): boolean;
  48773. /**
  48774. * If the rotation gizmo is enabled
  48775. */
  48776. set rotationGizmoEnabled(value: boolean);
  48777. get rotationGizmoEnabled(): boolean;
  48778. /**
  48779. * If the scale gizmo is enabled
  48780. */
  48781. set scaleGizmoEnabled(value: boolean);
  48782. get scaleGizmoEnabled(): boolean;
  48783. /**
  48784. * If the boundingBox gizmo is enabled
  48785. */
  48786. set boundingBoxGizmoEnabled(value: boolean);
  48787. get boundingBoxGizmoEnabled(): boolean;
  48788. /**
  48789. * Disposes of the gizmo manager
  48790. */
  48791. dispose(): void;
  48792. }
  48793. }
  48794. declare module BABYLON {
  48795. /**
  48796. * A directional light is defined by a direction (what a surprise!).
  48797. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48798. * 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.
  48799. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48800. */
  48801. export class DirectionalLight extends ShadowLight {
  48802. private _shadowFrustumSize;
  48803. /**
  48804. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48805. */
  48806. get shadowFrustumSize(): number;
  48807. /**
  48808. * Specifies a fix frustum size for the shadow generation.
  48809. */
  48810. set shadowFrustumSize(value: number);
  48811. private _shadowOrthoScale;
  48812. /**
  48813. * Gets the shadow projection scale against the optimal computed one.
  48814. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48815. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48816. */
  48817. get shadowOrthoScale(): number;
  48818. /**
  48819. * Sets the shadow projection scale against the optimal computed one.
  48820. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48821. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48822. */
  48823. set shadowOrthoScale(value: number);
  48824. /**
  48825. * Automatically compute the projection matrix to best fit (including all the casters)
  48826. * on each frame.
  48827. */
  48828. autoUpdateExtends: boolean;
  48829. /**
  48830. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48831. * on each frame. autoUpdateExtends must be set to true for this to work
  48832. */
  48833. autoCalcShadowZBounds: boolean;
  48834. private _orthoLeft;
  48835. private _orthoRight;
  48836. private _orthoTop;
  48837. private _orthoBottom;
  48838. /**
  48839. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48840. * The directional light is emitted from everywhere in the given direction.
  48841. * It can cast shadows.
  48842. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48843. * @param name The friendly name of the light
  48844. * @param direction The direction of the light
  48845. * @param scene The scene the light belongs to
  48846. */
  48847. constructor(name: string, direction: Vector3, scene: Scene);
  48848. /**
  48849. * Returns the string "DirectionalLight".
  48850. * @return The class name
  48851. */
  48852. getClassName(): string;
  48853. /**
  48854. * Returns the integer 1.
  48855. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48856. */
  48857. getTypeID(): number;
  48858. /**
  48859. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48860. * Returns the DirectionalLight Shadow projection matrix.
  48861. */
  48862. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48863. /**
  48864. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48865. * Returns the DirectionalLight Shadow projection matrix.
  48866. */
  48867. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48868. /**
  48869. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48870. * Returns the DirectionalLight Shadow projection matrix.
  48871. */
  48872. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48873. protected _buildUniformLayout(): void;
  48874. /**
  48875. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48876. * @param effect The effect to update
  48877. * @param lightIndex The index of the light in the effect to update
  48878. * @returns The directional light
  48879. */
  48880. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48881. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48882. /**
  48883. * Gets the minZ used for shadow according to both the scene and the light.
  48884. *
  48885. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48886. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48887. * @param activeCamera The camera we are returning the min for
  48888. * @returns the depth min z
  48889. */
  48890. getDepthMinZ(activeCamera: Camera): number;
  48891. /**
  48892. * Gets the maxZ used for shadow according to both the scene and the light.
  48893. *
  48894. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48895. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48896. * @param activeCamera The camera we are returning the max for
  48897. * @returns the depth max z
  48898. */
  48899. getDepthMaxZ(activeCamera: Camera): number;
  48900. /**
  48901. * Prepares the list of defines specific to the light type.
  48902. * @param defines the list of defines
  48903. * @param lightIndex defines the index of the light for the effect
  48904. */
  48905. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48906. }
  48907. }
  48908. declare module BABYLON {
  48909. /**
  48910. * Class containing static functions to help procedurally build meshes
  48911. */
  48912. export class HemisphereBuilder {
  48913. /**
  48914. * Creates a hemisphere mesh
  48915. * @param name defines the name of the mesh
  48916. * @param options defines the options used to create the mesh
  48917. * @param scene defines the hosting scene
  48918. * @returns the hemisphere mesh
  48919. */
  48920. static CreateHemisphere(name: string, options: {
  48921. segments?: number;
  48922. diameter?: number;
  48923. sideOrientation?: number;
  48924. }, scene: any): Mesh;
  48925. }
  48926. }
  48927. declare module BABYLON {
  48928. /**
  48929. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48930. * These values define a cone of light starting from the position, emitting toward the direction.
  48931. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48932. * and the exponent defines the speed of the decay of the light with distance (reach).
  48933. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48934. */
  48935. export class SpotLight extends ShadowLight {
  48936. private _angle;
  48937. private _innerAngle;
  48938. private _cosHalfAngle;
  48939. private _lightAngleScale;
  48940. private _lightAngleOffset;
  48941. /**
  48942. * Gets the cone angle of the spot light in Radians.
  48943. */
  48944. get angle(): number;
  48945. /**
  48946. * Sets the cone angle of the spot light in Radians.
  48947. */
  48948. set angle(value: number);
  48949. /**
  48950. * Only used in gltf falloff mode, this defines the angle where
  48951. * the directional falloff will start before cutting at angle which could be seen
  48952. * as outer angle.
  48953. */
  48954. get innerAngle(): number;
  48955. /**
  48956. * Only used in gltf falloff mode, this defines the angle where
  48957. * the directional falloff will start before cutting at angle which could be seen
  48958. * as outer angle.
  48959. */
  48960. set innerAngle(value: number);
  48961. private _shadowAngleScale;
  48962. /**
  48963. * Allows scaling the angle of the light for shadow generation only.
  48964. */
  48965. get shadowAngleScale(): number;
  48966. /**
  48967. * Allows scaling the angle of the light for shadow generation only.
  48968. */
  48969. set shadowAngleScale(value: number);
  48970. /**
  48971. * The light decay speed with the distance from the emission spot.
  48972. */
  48973. exponent: number;
  48974. private _projectionTextureMatrix;
  48975. /**
  48976. * Allows reading the projecton texture
  48977. */
  48978. get projectionTextureMatrix(): Matrix;
  48979. protected _projectionTextureLightNear: number;
  48980. /**
  48981. * Gets the near clip of the Spotlight for texture projection.
  48982. */
  48983. get projectionTextureLightNear(): number;
  48984. /**
  48985. * Sets the near clip of the Spotlight for texture projection.
  48986. */
  48987. set projectionTextureLightNear(value: number);
  48988. protected _projectionTextureLightFar: number;
  48989. /**
  48990. * Gets the far clip of the Spotlight for texture projection.
  48991. */
  48992. get projectionTextureLightFar(): number;
  48993. /**
  48994. * Sets the far clip of the Spotlight for texture projection.
  48995. */
  48996. set projectionTextureLightFar(value: number);
  48997. protected _projectionTextureUpDirection: Vector3;
  48998. /**
  48999. * Gets the Up vector of the Spotlight for texture projection.
  49000. */
  49001. get projectionTextureUpDirection(): Vector3;
  49002. /**
  49003. * Sets the Up vector of the Spotlight for texture projection.
  49004. */
  49005. set projectionTextureUpDirection(value: Vector3);
  49006. private _projectionTexture;
  49007. /**
  49008. * Gets the projection texture of the light.
  49009. */
  49010. get projectionTexture(): Nullable<BaseTexture>;
  49011. /**
  49012. * Sets the projection texture of the light.
  49013. */
  49014. set projectionTexture(value: Nullable<BaseTexture>);
  49015. private _projectionTextureViewLightDirty;
  49016. private _projectionTextureProjectionLightDirty;
  49017. private _projectionTextureDirty;
  49018. private _projectionTextureViewTargetVector;
  49019. private _projectionTextureViewLightMatrix;
  49020. private _projectionTextureProjectionLightMatrix;
  49021. private _projectionTextureScalingMatrix;
  49022. /**
  49023. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49024. * It can cast shadows.
  49025. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49026. * @param name The light friendly name
  49027. * @param position The position of the spot light in the scene
  49028. * @param direction The direction of the light in the scene
  49029. * @param angle The cone angle of the light in Radians
  49030. * @param exponent The light decay speed with the distance from the emission spot
  49031. * @param scene The scene the lights belongs to
  49032. */
  49033. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49034. /**
  49035. * Returns the string "SpotLight".
  49036. * @returns the class name
  49037. */
  49038. getClassName(): string;
  49039. /**
  49040. * Returns the integer 2.
  49041. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49042. */
  49043. getTypeID(): number;
  49044. /**
  49045. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49046. */
  49047. protected _setDirection(value: Vector3): void;
  49048. /**
  49049. * Overrides the position setter to recompute the projection texture view light Matrix.
  49050. */
  49051. protected _setPosition(value: Vector3): void;
  49052. /**
  49053. * 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.
  49054. * Returns the SpotLight.
  49055. */
  49056. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49057. protected _computeProjectionTextureViewLightMatrix(): void;
  49058. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49059. /**
  49060. * Main function for light texture projection matrix computing.
  49061. */
  49062. protected _computeProjectionTextureMatrix(): void;
  49063. protected _buildUniformLayout(): void;
  49064. private _computeAngleValues;
  49065. /**
  49066. * Sets the passed Effect "effect" with the Light textures.
  49067. * @param effect The effect to update
  49068. * @param lightIndex The index of the light in the effect to update
  49069. * @returns The light
  49070. */
  49071. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49072. /**
  49073. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49074. * @param effect The effect to update
  49075. * @param lightIndex The index of the light in the effect to update
  49076. * @returns The spot light
  49077. */
  49078. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49079. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49080. /**
  49081. * Disposes the light and the associated resources.
  49082. */
  49083. dispose(): void;
  49084. /**
  49085. * Prepares the list of defines specific to the light type.
  49086. * @param defines the list of defines
  49087. * @param lightIndex defines the index of the light for the effect
  49088. */
  49089. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49090. }
  49091. }
  49092. declare module BABYLON {
  49093. /**
  49094. * Gizmo that enables viewing a light
  49095. */
  49096. export class LightGizmo extends Gizmo {
  49097. private _lightMesh;
  49098. private _material;
  49099. private _cachedPosition;
  49100. private _cachedForward;
  49101. private _attachedMeshParent;
  49102. /**
  49103. * Creates a LightGizmo
  49104. * @param gizmoLayer The utility layer the gizmo will be added to
  49105. */
  49106. constructor(gizmoLayer?: UtilityLayerRenderer);
  49107. private _light;
  49108. /**
  49109. * The light that the gizmo is attached to
  49110. */
  49111. set light(light: Nullable<Light>);
  49112. get light(): Nullable<Light>;
  49113. /**
  49114. * Gets the material used to render the light gizmo
  49115. */
  49116. get material(): StandardMaterial;
  49117. /**
  49118. * @hidden
  49119. * Updates the gizmo to match the attached mesh's position/rotation
  49120. */
  49121. protected _update(): void;
  49122. private static _Scale;
  49123. /**
  49124. * Creates the lines for a light mesh
  49125. */
  49126. private static _CreateLightLines;
  49127. /**
  49128. * Disposes of the light gizmo
  49129. */
  49130. dispose(): void;
  49131. private static _CreateHemisphericLightMesh;
  49132. private static _CreatePointLightMesh;
  49133. private static _CreateSpotLightMesh;
  49134. private static _CreateDirectionalLightMesh;
  49135. }
  49136. }
  49137. declare module BABYLON {
  49138. /** @hidden */
  49139. export var backgroundFragmentDeclaration: {
  49140. name: string;
  49141. shader: string;
  49142. };
  49143. }
  49144. declare module BABYLON {
  49145. /** @hidden */
  49146. export var backgroundUboDeclaration: {
  49147. name: string;
  49148. shader: string;
  49149. };
  49150. }
  49151. declare module BABYLON {
  49152. /** @hidden */
  49153. export var backgroundPixelShader: {
  49154. name: string;
  49155. shader: string;
  49156. };
  49157. }
  49158. declare module BABYLON {
  49159. /** @hidden */
  49160. export var backgroundVertexDeclaration: {
  49161. name: string;
  49162. shader: string;
  49163. };
  49164. }
  49165. declare module BABYLON {
  49166. /** @hidden */
  49167. export var backgroundVertexShader: {
  49168. name: string;
  49169. shader: string;
  49170. };
  49171. }
  49172. declare module BABYLON {
  49173. /**
  49174. * Background material used to create an efficient environement around your scene.
  49175. */
  49176. export class BackgroundMaterial extends PushMaterial {
  49177. /**
  49178. * Standard reflectance value at parallel view angle.
  49179. */
  49180. static StandardReflectance0: number;
  49181. /**
  49182. * Standard reflectance value at grazing angle.
  49183. */
  49184. static StandardReflectance90: number;
  49185. protected _primaryColor: Color3;
  49186. /**
  49187. * Key light Color (multiply against the environement texture)
  49188. */
  49189. primaryColor: Color3;
  49190. protected __perceptualColor: Nullable<Color3>;
  49191. /**
  49192. * Experimental Internal Use Only.
  49193. *
  49194. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49195. * This acts as a helper to set the primary color to a more "human friendly" value.
  49196. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49197. * output color as close as possible from the chosen value.
  49198. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49199. * part of lighting setup.)
  49200. */
  49201. get _perceptualColor(): Nullable<Color3>;
  49202. set _perceptualColor(value: Nullable<Color3>);
  49203. protected _primaryColorShadowLevel: float;
  49204. /**
  49205. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49206. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49207. */
  49208. get primaryColorShadowLevel(): float;
  49209. set primaryColorShadowLevel(value: float);
  49210. protected _primaryColorHighlightLevel: float;
  49211. /**
  49212. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49213. * The primary color is used at the level chosen to define what the white area would look.
  49214. */
  49215. get primaryColorHighlightLevel(): float;
  49216. set primaryColorHighlightLevel(value: float);
  49217. protected _reflectionTexture: Nullable<BaseTexture>;
  49218. /**
  49219. * Reflection Texture used in the material.
  49220. * Should be author in a specific way for the best result (refer to the documentation).
  49221. */
  49222. reflectionTexture: Nullable<BaseTexture>;
  49223. protected _reflectionBlur: float;
  49224. /**
  49225. * Reflection Texture level of blur.
  49226. *
  49227. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49228. * texture twice.
  49229. */
  49230. reflectionBlur: float;
  49231. protected _diffuseTexture: Nullable<BaseTexture>;
  49232. /**
  49233. * Diffuse Texture used in the material.
  49234. * Should be author in a specific way for the best result (refer to the documentation).
  49235. */
  49236. diffuseTexture: Nullable<BaseTexture>;
  49237. protected _shadowLights: Nullable<IShadowLight[]>;
  49238. /**
  49239. * Specify the list of lights casting shadow on the material.
  49240. * All scene shadow lights will be included if null.
  49241. */
  49242. shadowLights: Nullable<IShadowLight[]>;
  49243. protected _shadowLevel: float;
  49244. /**
  49245. * Helps adjusting the shadow to a softer level if required.
  49246. * 0 means black shadows and 1 means no shadows.
  49247. */
  49248. shadowLevel: float;
  49249. protected _sceneCenter: Vector3;
  49250. /**
  49251. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49252. * It is usually zero but might be interesting to modify according to your setup.
  49253. */
  49254. sceneCenter: Vector3;
  49255. protected _opacityFresnel: boolean;
  49256. /**
  49257. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49258. * This helps ensuring a nice transition when the camera goes under the ground.
  49259. */
  49260. opacityFresnel: boolean;
  49261. protected _reflectionFresnel: boolean;
  49262. /**
  49263. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49264. * This helps adding a mirror texture on the ground.
  49265. */
  49266. reflectionFresnel: boolean;
  49267. protected _reflectionFalloffDistance: number;
  49268. /**
  49269. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49270. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49271. */
  49272. reflectionFalloffDistance: number;
  49273. protected _reflectionAmount: number;
  49274. /**
  49275. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49276. */
  49277. reflectionAmount: number;
  49278. protected _reflectionReflectance0: number;
  49279. /**
  49280. * This specifies the weight of the reflection at grazing angle.
  49281. */
  49282. reflectionReflectance0: number;
  49283. protected _reflectionReflectance90: number;
  49284. /**
  49285. * This specifies the weight of the reflection at a perpendicular point of view.
  49286. */
  49287. reflectionReflectance90: number;
  49288. /**
  49289. * Sets the reflection reflectance fresnel values according to the default standard
  49290. * empirically know to work well :-)
  49291. */
  49292. set reflectionStandardFresnelWeight(value: number);
  49293. protected _useRGBColor: boolean;
  49294. /**
  49295. * Helps to directly use the maps channels instead of their level.
  49296. */
  49297. useRGBColor: boolean;
  49298. protected _enableNoise: boolean;
  49299. /**
  49300. * This helps reducing the banding effect that could occur on the background.
  49301. */
  49302. enableNoise: boolean;
  49303. /**
  49304. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49305. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49306. * Recommended to be keep at 1.0 except for special cases.
  49307. */
  49308. get fovMultiplier(): number;
  49309. set fovMultiplier(value: number);
  49310. private _fovMultiplier;
  49311. /**
  49312. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49313. */
  49314. useEquirectangularFOV: boolean;
  49315. private _maxSimultaneousLights;
  49316. /**
  49317. * Number of Simultaneous lights allowed on the material.
  49318. */
  49319. maxSimultaneousLights: int;
  49320. /**
  49321. * Default configuration related to image processing available in the Background Material.
  49322. */
  49323. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49324. /**
  49325. * Keep track of the image processing observer to allow dispose and replace.
  49326. */
  49327. private _imageProcessingObserver;
  49328. /**
  49329. * Attaches a new image processing configuration to the PBR Material.
  49330. * @param configuration (if null the scene configuration will be use)
  49331. */
  49332. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49333. /**
  49334. * Gets the image processing configuration used either in this material.
  49335. */
  49336. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49337. /**
  49338. * Sets the Default image processing configuration used either in the this material.
  49339. *
  49340. * If sets to null, the scene one is in use.
  49341. */
  49342. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49343. /**
  49344. * Gets wether the color curves effect is enabled.
  49345. */
  49346. get cameraColorCurvesEnabled(): boolean;
  49347. /**
  49348. * Sets wether the color curves effect is enabled.
  49349. */
  49350. set cameraColorCurvesEnabled(value: boolean);
  49351. /**
  49352. * Gets wether the color grading effect is enabled.
  49353. */
  49354. get cameraColorGradingEnabled(): boolean;
  49355. /**
  49356. * Gets wether the color grading effect is enabled.
  49357. */
  49358. set cameraColorGradingEnabled(value: boolean);
  49359. /**
  49360. * Gets wether tonemapping is enabled or not.
  49361. */
  49362. get cameraToneMappingEnabled(): boolean;
  49363. /**
  49364. * Sets wether tonemapping is enabled or not
  49365. */
  49366. set cameraToneMappingEnabled(value: boolean);
  49367. /**
  49368. * The camera exposure used on this material.
  49369. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49370. * This corresponds to a photographic exposure.
  49371. */
  49372. get cameraExposure(): float;
  49373. /**
  49374. * The camera exposure used on this material.
  49375. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49376. * This corresponds to a photographic exposure.
  49377. */
  49378. set cameraExposure(value: float);
  49379. /**
  49380. * Gets The camera contrast used on this material.
  49381. */
  49382. get cameraContrast(): float;
  49383. /**
  49384. * Sets The camera contrast used on this material.
  49385. */
  49386. set cameraContrast(value: float);
  49387. /**
  49388. * Gets the Color Grading 2D Lookup Texture.
  49389. */
  49390. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49391. /**
  49392. * Sets the Color Grading 2D Lookup Texture.
  49393. */
  49394. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49395. /**
  49396. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49397. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49398. * 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;
  49399. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49400. */
  49401. get cameraColorCurves(): Nullable<ColorCurves>;
  49402. /**
  49403. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49404. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49405. * 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;
  49406. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49407. */
  49408. set cameraColorCurves(value: Nullable<ColorCurves>);
  49409. /**
  49410. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49411. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49412. */
  49413. switchToBGR: boolean;
  49414. private _renderTargets;
  49415. private _reflectionControls;
  49416. private _white;
  49417. private _primaryShadowColor;
  49418. private _primaryHighlightColor;
  49419. /**
  49420. * Instantiates a Background Material in the given scene
  49421. * @param name The friendly name of the material
  49422. * @param scene The scene to add the material to
  49423. */
  49424. constructor(name: string, scene: Scene);
  49425. /**
  49426. * Gets a boolean indicating that current material needs to register RTT
  49427. */
  49428. get hasRenderTargetTextures(): boolean;
  49429. /**
  49430. * The entire material has been created in order to prevent overdraw.
  49431. * @returns false
  49432. */
  49433. needAlphaTesting(): boolean;
  49434. /**
  49435. * The entire material has been created in order to prevent overdraw.
  49436. * @returns true if blending is enable
  49437. */
  49438. needAlphaBlending(): boolean;
  49439. /**
  49440. * Checks wether the material is ready to be rendered for a given mesh.
  49441. * @param mesh The mesh to render
  49442. * @param subMesh The submesh to check against
  49443. * @param useInstances Specify wether or not the material is used with instances
  49444. * @returns true if all the dependencies are ready (Textures, Effects...)
  49445. */
  49446. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49447. /**
  49448. * Compute the primary color according to the chosen perceptual color.
  49449. */
  49450. private _computePrimaryColorFromPerceptualColor;
  49451. /**
  49452. * Compute the highlights and shadow colors according to their chosen levels.
  49453. */
  49454. private _computePrimaryColors;
  49455. /**
  49456. * Build the uniform buffer used in the material.
  49457. */
  49458. buildUniformLayout(): void;
  49459. /**
  49460. * Unbind the material.
  49461. */
  49462. unbind(): void;
  49463. /**
  49464. * Bind only the world matrix to the material.
  49465. * @param world The world matrix to bind.
  49466. */
  49467. bindOnlyWorldMatrix(world: Matrix): void;
  49468. /**
  49469. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49470. * @param world The world matrix to bind.
  49471. * @param subMesh The submesh to bind for.
  49472. */
  49473. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49474. /**
  49475. * Checks to see if a texture is used in the material.
  49476. * @param texture - Base texture to use.
  49477. * @returns - Boolean specifying if a texture is used in the material.
  49478. */
  49479. hasTexture(texture: BaseTexture): boolean;
  49480. /**
  49481. * Dispose the material.
  49482. * @param forceDisposeEffect Force disposal of the associated effect.
  49483. * @param forceDisposeTextures Force disposal of the associated textures.
  49484. */
  49485. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49486. /**
  49487. * Clones the material.
  49488. * @param name The cloned name.
  49489. * @returns The cloned material.
  49490. */
  49491. clone(name: string): BackgroundMaterial;
  49492. /**
  49493. * Serializes the current material to its JSON representation.
  49494. * @returns The JSON representation.
  49495. */
  49496. serialize(): any;
  49497. /**
  49498. * Gets the class name of the material
  49499. * @returns "BackgroundMaterial"
  49500. */
  49501. getClassName(): string;
  49502. /**
  49503. * Parse a JSON input to create back a background material.
  49504. * @param source The JSON data to parse
  49505. * @param scene The scene to create the parsed material in
  49506. * @param rootUrl The root url of the assets the material depends upon
  49507. * @returns the instantiated BackgroundMaterial.
  49508. */
  49509. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49510. }
  49511. }
  49512. declare module BABYLON {
  49513. /**
  49514. * Represents the different options available during the creation of
  49515. * a Environment helper.
  49516. *
  49517. * This can control the default ground, skybox and image processing setup of your scene.
  49518. */
  49519. export interface IEnvironmentHelperOptions {
  49520. /**
  49521. * Specifies whether or not to create a ground.
  49522. * True by default.
  49523. */
  49524. createGround: boolean;
  49525. /**
  49526. * Specifies the ground size.
  49527. * 15 by default.
  49528. */
  49529. groundSize: number;
  49530. /**
  49531. * The texture used on the ground for the main color.
  49532. * Comes from the BabylonJS CDN by default.
  49533. *
  49534. * Remarks: Can be either a texture or a url.
  49535. */
  49536. groundTexture: string | BaseTexture;
  49537. /**
  49538. * The color mixed in the ground texture by default.
  49539. * BabylonJS clearColor by default.
  49540. */
  49541. groundColor: Color3;
  49542. /**
  49543. * Specifies the ground opacity.
  49544. * 1 by default.
  49545. */
  49546. groundOpacity: number;
  49547. /**
  49548. * Enables the ground to receive shadows.
  49549. * True by default.
  49550. */
  49551. enableGroundShadow: boolean;
  49552. /**
  49553. * Helps preventing the shadow to be fully black on the ground.
  49554. * 0.5 by default.
  49555. */
  49556. groundShadowLevel: number;
  49557. /**
  49558. * Creates a mirror texture attach to the ground.
  49559. * false by default.
  49560. */
  49561. enableGroundMirror: boolean;
  49562. /**
  49563. * Specifies the ground mirror size ratio.
  49564. * 0.3 by default as the default kernel is 64.
  49565. */
  49566. groundMirrorSizeRatio: number;
  49567. /**
  49568. * Specifies the ground mirror blur kernel size.
  49569. * 64 by default.
  49570. */
  49571. groundMirrorBlurKernel: number;
  49572. /**
  49573. * Specifies the ground mirror visibility amount.
  49574. * 1 by default
  49575. */
  49576. groundMirrorAmount: number;
  49577. /**
  49578. * Specifies the ground mirror reflectance weight.
  49579. * This uses the standard weight of the background material to setup the fresnel effect
  49580. * of the mirror.
  49581. * 1 by default.
  49582. */
  49583. groundMirrorFresnelWeight: number;
  49584. /**
  49585. * Specifies the ground mirror Falloff distance.
  49586. * This can helps reducing the size of the reflection.
  49587. * 0 by Default.
  49588. */
  49589. groundMirrorFallOffDistance: number;
  49590. /**
  49591. * Specifies the ground mirror texture type.
  49592. * Unsigned Int by Default.
  49593. */
  49594. groundMirrorTextureType: number;
  49595. /**
  49596. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49597. * the shown objects.
  49598. */
  49599. groundYBias: number;
  49600. /**
  49601. * Specifies whether or not to create a skybox.
  49602. * True by default.
  49603. */
  49604. createSkybox: boolean;
  49605. /**
  49606. * Specifies the skybox size.
  49607. * 20 by default.
  49608. */
  49609. skyboxSize: number;
  49610. /**
  49611. * The texture used on the skybox for the main color.
  49612. * Comes from the BabylonJS CDN by default.
  49613. *
  49614. * Remarks: Can be either a texture or a url.
  49615. */
  49616. skyboxTexture: string | BaseTexture;
  49617. /**
  49618. * The color mixed in the skybox texture by default.
  49619. * BabylonJS clearColor by default.
  49620. */
  49621. skyboxColor: Color3;
  49622. /**
  49623. * The background rotation around the Y axis of the scene.
  49624. * This helps aligning the key lights of your scene with the background.
  49625. * 0 by default.
  49626. */
  49627. backgroundYRotation: number;
  49628. /**
  49629. * Compute automatically the size of the elements to best fit with the scene.
  49630. */
  49631. sizeAuto: boolean;
  49632. /**
  49633. * Default position of the rootMesh if autoSize is not true.
  49634. */
  49635. rootPosition: Vector3;
  49636. /**
  49637. * Sets up the image processing in the scene.
  49638. * true by default.
  49639. */
  49640. setupImageProcessing: boolean;
  49641. /**
  49642. * The texture used as your environment texture in the scene.
  49643. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49644. *
  49645. * Remarks: Can be either a texture or a url.
  49646. */
  49647. environmentTexture: string | BaseTexture;
  49648. /**
  49649. * The value of the exposure to apply to the scene.
  49650. * 0.6 by default if setupImageProcessing is true.
  49651. */
  49652. cameraExposure: number;
  49653. /**
  49654. * The value of the contrast to apply to the scene.
  49655. * 1.6 by default if setupImageProcessing is true.
  49656. */
  49657. cameraContrast: number;
  49658. /**
  49659. * Specifies whether or not tonemapping should be enabled in the scene.
  49660. * true by default if setupImageProcessing is true.
  49661. */
  49662. toneMappingEnabled: boolean;
  49663. }
  49664. /**
  49665. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49666. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49667. * It also helps with the default setup of your imageProcessing configuration.
  49668. */
  49669. export class EnvironmentHelper {
  49670. /**
  49671. * Default ground texture URL.
  49672. */
  49673. private static _groundTextureCDNUrl;
  49674. /**
  49675. * Default skybox texture URL.
  49676. */
  49677. private static _skyboxTextureCDNUrl;
  49678. /**
  49679. * Default environment texture URL.
  49680. */
  49681. private static _environmentTextureCDNUrl;
  49682. /**
  49683. * Creates the default options for the helper.
  49684. */
  49685. private static _getDefaultOptions;
  49686. private _rootMesh;
  49687. /**
  49688. * Gets the root mesh created by the helper.
  49689. */
  49690. get rootMesh(): Mesh;
  49691. private _skybox;
  49692. /**
  49693. * Gets the skybox created by the helper.
  49694. */
  49695. get skybox(): Nullable<Mesh>;
  49696. private _skyboxTexture;
  49697. /**
  49698. * Gets the skybox texture created by the helper.
  49699. */
  49700. get skyboxTexture(): Nullable<BaseTexture>;
  49701. private _skyboxMaterial;
  49702. /**
  49703. * Gets the skybox material created by the helper.
  49704. */
  49705. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49706. private _ground;
  49707. /**
  49708. * Gets the ground mesh created by the helper.
  49709. */
  49710. get ground(): Nullable<Mesh>;
  49711. private _groundTexture;
  49712. /**
  49713. * Gets the ground texture created by the helper.
  49714. */
  49715. get groundTexture(): Nullable<BaseTexture>;
  49716. private _groundMirror;
  49717. /**
  49718. * Gets the ground mirror created by the helper.
  49719. */
  49720. get groundMirror(): Nullable<MirrorTexture>;
  49721. /**
  49722. * Gets the ground mirror render list to helps pushing the meshes
  49723. * you wish in the ground reflection.
  49724. */
  49725. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49726. private _groundMaterial;
  49727. /**
  49728. * Gets the ground material created by the helper.
  49729. */
  49730. get groundMaterial(): Nullable<BackgroundMaterial>;
  49731. /**
  49732. * Stores the creation options.
  49733. */
  49734. private readonly _scene;
  49735. private _options;
  49736. /**
  49737. * This observable will be notified with any error during the creation of the environment,
  49738. * mainly texture creation errors.
  49739. */
  49740. onErrorObservable: Observable<{
  49741. message?: string;
  49742. exception?: any;
  49743. }>;
  49744. /**
  49745. * constructor
  49746. * @param options Defines the options we want to customize the helper
  49747. * @param scene The scene to add the material to
  49748. */
  49749. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49750. /**
  49751. * Updates the background according to the new options
  49752. * @param options
  49753. */
  49754. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49755. /**
  49756. * Sets the primary color of all the available elements.
  49757. * @param color the main color to affect to the ground and the background
  49758. */
  49759. setMainColor(color: Color3): void;
  49760. /**
  49761. * Setup the image processing according to the specified options.
  49762. */
  49763. private _setupImageProcessing;
  49764. /**
  49765. * Setup the environment texture according to the specified options.
  49766. */
  49767. private _setupEnvironmentTexture;
  49768. /**
  49769. * Setup the background according to the specified options.
  49770. */
  49771. private _setupBackground;
  49772. /**
  49773. * Get the scene sizes according to the setup.
  49774. */
  49775. private _getSceneSize;
  49776. /**
  49777. * Setup the ground according to the specified options.
  49778. */
  49779. private _setupGround;
  49780. /**
  49781. * Setup the ground material according to the specified options.
  49782. */
  49783. private _setupGroundMaterial;
  49784. /**
  49785. * Setup the ground diffuse texture according to the specified options.
  49786. */
  49787. private _setupGroundDiffuseTexture;
  49788. /**
  49789. * Setup the ground mirror texture according to the specified options.
  49790. */
  49791. private _setupGroundMirrorTexture;
  49792. /**
  49793. * Setup the ground to receive the mirror texture.
  49794. */
  49795. private _setupMirrorInGroundMaterial;
  49796. /**
  49797. * Setup the skybox according to the specified options.
  49798. */
  49799. private _setupSkybox;
  49800. /**
  49801. * Setup the skybox material according to the specified options.
  49802. */
  49803. private _setupSkyboxMaterial;
  49804. /**
  49805. * Setup the skybox reflection texture according to the specified options.
  49806. */
  49807. private _setupSkyboxReflectionTexture;
  49808. private _errorHandler;
  49809. /**
  49810. * Dispose all the elements created by the Helper.
  49811. */
  49812. dispose(): void;
  49813. }
  49814. }
  49815. declare module BABYLON {
  49816. /**
  49817. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49818. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49819. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49820. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49821. */
  49822. export class PhotoDome extends TransformNode {
  49823. /**
  49824. * Define the image as a Monoscopic panoramic 360 image.
  49825. */
  49826. static readonly MODE_MONOSCOPIC: number;
  49827. /**
  49828. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49829. */
  49830. static readonly MODE_TOPBOTTOM: number;
  49831. /**
  49832. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49833. */
  49834. static readonly MODE_SIDEBYSIDE: number;
  49835. private _useDirectMapping;
  49836. /**
  49837. * The texture being displayed on the sphere
  49838. */
  49839. protected _photoTexture: Texture;
  49840. /**
  49841. * Gets or sets the texture being displayed on the sphere
  49842. */
  49843. get photoTexture(): Texture;
  49844. set photoTexture(value: Texture);
  49845. /**
  49846. * Observable raised when an error occured while loading the 360 image
  49847. */
  49848. onLoadErrorObservable: Observable<string>;
  49849. /**
  49850. * The skybox material
  49851. */
  49852. protected _material: BackgroundMaterial;
  49853. /**
  49854. * The surface used for the skybox
  49855. */
  49856. protected _mesh: Mesh;
  49857. /**
  49858. * Gets the mesh used for the skybox.
  49859. */
  49860. get mesh(): Mesh;
  49861. /**
  49862. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49863. * Also see the options.resolution property.
  49864. */
  49865. get fovMultiplier(): number;
  49866. set fovMultiplier(value: number);
  49867. private _imageMode;
  49868. /**
  49869. * Gets or set the current video mode for the video. It can be:
  49870. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49871. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49872. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49873. */
  49874. get imageMode(): number;
  49875. set imageMode(value: number);
  49876. /**
  49877. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49878. * @param name Element's name, child elements will append suffixes for their own names.
  49879. * @param urlsOfPhoto defines the url of the photo to display
  49880. * @param options defines an object containing optional or exposed sub element properties
  49881. * @param onError defines a callback called when an error occured while loading the texture
  49882. */
  49883. constructor(name: string, urlOfPhoto: string, options: {
  49884. resolution?: number;
  49885. size?: number;
  49886. useDirectMapping?: boolean;
  49887. faceForward?: boolean;
  49888. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49889. private _onBeforeCameraRenderObserver;
  49890. private _changeImageMode;
  49891. /**
  49892. * Releases resources associated with this node.
  49893. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49894. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49895. */
  49896. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49897. }
  49898. }
  49899. declare module BABYLON {
  49900. /**
  49901. * Class used to host RGBD texture specific utilities
  49902. */
  49903. export class RGBDTextureTools {
  49904. /**
  49905. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49906. * @param texture the texture to expand.
  49907. */
  49908. static ExpandRGBDTexture(texture: Texture): void;
  49909. }
  49910. }
  49911. declare module BABYLON {
  49912. /**
  49913. * Class used to host texture specific utilities
  49914. */
  49915. export class BRDFTextureTools {
  49916. /**
  49917. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49918. * @param scene defines the hosting scene
  49919. * @returns the environment BRDF texture
  49920. */
  49921. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49922. private static _environmentBRDFBase64Texture;
  49923. }
  49924. }
  49925. declare module BABYLON {
  49926. /**
  49927. * @hidden
  49928. */
  49929. export interface IMaterialClearCoatDefines {
  49930. CLEARCOAT: boolean;
  49931. CLEARCOAT_DEFAULTIOR: boolean;
  49932. CLEARCOAT_TEXTURE: boolean;
  49933. CLEARCOAT_TEXTUREDIRECTUV: number;
  49934. CLEARCOAT_BUMP: boolean;
  49935. CLEARCOAT_BUMPDIRECTUV: number;
  49936. CLEARCOAT_TINT: boolean;
  49937. CLEARCOAT_TINT_TEXTURE: boolean;
  49938. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49939. /** @hidden */
  49940. _areTexturesDirty: boolean;
  49941. }
  49942. /**
  49943. * Define the code related to the clear coat parameters of the pbr material.
  49944. */
  49945. export class PBRClearCoatConfiguration {
  49946. /**
  49947. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49948. * The default fits with a polyurethane material.
  49949. */
  49950. private static readonly _DefaultIndexOfRefraction;
  49951. private _isEnabled;
  49952. /**
  49953. * Defines if the clear coat is enabled in the material.
  49954. */
  49955. isEnabled: boolean;
  49956. /**
  49957. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49958. */
  49959. intensity: number;
  49960. /**
  49961. * Defines the clear coat layer roughness.
  49962. */
  49963. roughness: number;
  49964. private _indexOfRefraction;
  49965. /**
  49966. * Defines the index of refraction of the clear coat.
  49967. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49968. * The default fits with a polyurethane material.
  49969. * Changing the default value is more performance intensive.
  49970. */
  49971. indexOfRefraction: number;
  49972. private _texture;
  49973. /**
  49974. * Stores the clear coat values in a texture.
  49975. */
  49976. texture: Nullable<BaseTexture>;
  49977. private _bumpTexture;
  49978. /**
  49979. * Define the clear coat specific bump texture.
  49980. */
  49981. bumpTexture: Nullable<BaseTexture>;
  49982. private _isTintEnabled;
  49983. /**
  49984. * Defines if the clear coat tint is enabled in the material.
  49985. */
  49986. isTintEnabled: boolean;
  49987. /**
  49988. * Defines the clear coat tint of the material.
  49989. * This is only use if tint is enabled
  49990. */
  49991. tintColor: Color3;
  49992. /**
  49993. * Defines the distance at which the tint color should be found in the
  49994. * clear coat media.
  49995. * This is only use if tint is enabled
  49996. */
  49997. tintColorAtDistance: number;
  49998. /**
  49999. * Defines the clear coat layer thickness.
  50000. * This is only use if tint is enabled
  50001. */
  50002. tintThickness: number;
  50003. private _tintTexture;
  50004. /**
  50005. * Stores the clear tint values in a texture.
  50006. * rgb is tint
  50007. * a is a thickness factor
  50008. */
  50009. tintTexture: Nullable<BaseTexture>;
  50010. /** @hidden */
  50011. private _internalMarkAllSubMeshesAsTexturesDirty;
  50012. /** @hidden */
  50013. _markAllSubMeshesAsTexturesDirty(): void;
  50014. /**
  50015. * Instantiate a new istance of clear coat configuration.
  50016. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50017. */
  50018. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50019. /**
  50020. * Gets wehter the submesh is ready to be used or not.
  50021. * @param defines the list of "defines" to update.
  50022. * @param scene defines the scene the material belongs to.
  50023. * @param engine defines the engine the material belongs to.
  50024. * @param disableBumpMap defines wether the material disables bump or not.
  50025. * @returns - boolean indicating that the submesh is ready or not.
  50026. */
  50027. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50028. /**
  50029. * Checks to see if a texture is used in the material.
  50030. * @param defines the list of "defines" to update.
  50031. * @param scene defines the scene to the material belongs to.
  50032. */
  50033. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50034. /**
  50035. * Binds the material data.
  50036. * @param uniformBuffer defines the Uniform buffer to fill in.
  50037. * @param scene defines the scene the material belongs to.
  50038. * @param engine defines the engine the material belongs to.
  50039. * @param disableBumpMap defines wether the material disables bump or not.
  50040. * @param isFrozen defines wether the material is frozen or not.
  50041. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50042. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50043. */
  50044. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50045. /**
  50046. * Checks to see if a texture is used in the material.
  50047. * @param texture - Base texture to use.
  50048. * @returns - Boolean specifying if a texture is used in the material.
  50049. */
  50050. hasTexture(texture: BaseTexture): boolean;
  50051. /**
  50052. * Returns an array of the actively used textures.
  50053. * @param activeTextures Array of BaseTextures
  50054. */
  50055. getActiveTextures(activeTextures: BaseTexture[]): void;
  50056. /**
  50057. * Returns the animatable textures.
  50058. * @param animatables Array of animatable textures.
  50059. */
  50060. getAnimatables(animatables: IAnimatable[]): void;
  50061. /**
  50062. * Disposes the resources of the material.
  50063. * @param forceDisposeTextures - Forces the disposal of all textures.
  50064. */
  50065. dispose(forceDisposeTextures?: boolean): void;
  50066. /**
  50067. * Get the current class name of the texture useful for serialization or dynamic coding.
  50068. * @returns "PBRClearCoatConfiguration"
  50069. */
  50070. getClassName(): string;
  50071. /**
  50072. * Add fallbacks to the effect fallbacks list.
  50073. * @param defines defines the Base texture to use.
  50074. * @param fallbacks defines the current fallback list.
  50075. * @param currentRank defines the current fallback rank.
  50076. * @returns the new fallback rank.
  50077. */
  50078. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50079. /**
  50080. * Add the required uniforms to the current list.
  50081. * @param uniforms defines the current uniform list.
  50082. */
  50083. static AddUniforms(uniforms: string[]): void;
  50084. /**
  50085. * Add the required samplers to the current list.
  50086. * @param samplers defines the current sampler list.
  50087. */
  50088. static AddSamplers(samplers: string[]): void;
  50089. /**
  50090. * Add the required uniforms to the current buffer.
  50091. * @param uniformBuffer defines the current uniform buffer.
  50092. */
  50093. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50094. /**
  50095. * Makes a duplicate of the current configuration into another one.
  50096. * @param clearCoatConfiguration define the config where to copy the info
  50097. */
  50098. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50099. /**
  50100. * Serializes this clear coat configuration.
  50101. * @returns - An object with the serialized config.
  50102. */
  50103. serialize(): any;
  50104. /**
  50105. * Parses a anisotropy Configuration from a serialized object.
  50106. * @param source - Serialized object.
  50107. * @param scene Defines the scene we are parsing for
  50108. * @param rootUrl Defines the rootUrl to load from
  50109. */
  50110. parse(source: any, scene: Scene, rootUrl: string): void;
  50111. }
  50112. }
  50113. declare module BABYLON {
  50114. /**
  50115. * @hidden
  50116. */
  50117. export interface IMaterialAnisotropicDefines {
  50118. ANISOTROPIC: boolean;
  50119. ANISOTROPIC_TEXTURE: boolean;
  50120. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50121. MAINUV1: boolean;
  50122. _areTexturesDirty: boolean;
  50123. _needUVs: boolean;
  50124. }
  50125. /**
  50126. * Define the code related to the anisotropic parameters of the pbr material.
  50127. */
  50128. export class PBRAnisotropicConfiguration {
  50129. private _isEnabled;
  50130. /**
  50131. * Defines if the anisotropy is enabled in the material.
  50132. */
  50133. isEnabled: boolean;
  50134. /**
  50135. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50136. */
  50137. intensity: number;
  50138. /**
  50139. * Defines if the effect is along the tangents, bitangents or in between.
  50140. * By default, the effect is "strectching" the highlights along the tangents.
  50141. */
  50142. direction: Vector2;
  50143. private _texture;
  50144. /**
  50145. * Stores the anisotropy values in a texture.
  50146. * rg is direction (like normal from -1 to 1)
  50147. * b is a intensity
  50148. */
  50149. texture: Nullable<BaseTexture>;
  50150. /** @hidden */
  50151. private _internalMarkAllSubMeshesAsTexturesDirty;
  50152. /** @hidden */
  50153. _markAllSubMeshesAsTexturesDirty(): void;
  50154. /**
  50155. * Instantiate a new istance of anisotropy configuration.
  50156. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50157. */
  50158. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50159. /**
  50160. * Specifies that the submesh is ready to be used.
  50161. * @param defines the list of "defines" to update.
  50162. * @param scene defines the scene the material belongs to.
  50163. * @returns - boolean indicating that the submesh is ready or not.
  50164. */
  50165. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50166. /**
  50167. * Checks to see if a texture is used in the material.
  50168. * @param defines the list of "defines" to update.
  50169. * @param mesh the mesh we are preparing the defines for.
  50170. * @param scene defines the scene the material belongs to.
  50171. */
  50172. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50173. /**
  50174. * Binds the material data.
  50175. * @param uniformBuffer defines the Uniform buffer to fill in.
  50176. * @param scene defines the scene the material belongs to.
  50177. * @param isFrozen defines wether the material is frozen or not.
  50178. */
  50179. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50180. /**
  50181. * Checks to see if a texture is used in the material.
  50182. * @param texture - Base texture to use.
  50183. * @returns - Boolean specifying if a texture is used in the material.
  50184. */
  50185. hasTexture(texture: BaseTexture): boolean;
  50186. /**
  50187. * Returns an array of the actively used textures.
  50188. * @param activeTextures Array of BaseTextures
  50189. */
  50190. getActiveTextures(activeTextures: BaseTexture[]): void;
  50191. /**
  50192. * Returns the animatable textures.
  50193. * @param animatables Array of animatable textures.
  50194. */
  50195. getAnimatables(animatables: IAnimatable[]): void;
  50196. /**
  50197. * Disposes the resources of the material.
  50198. * @param forceDisposeTextures - Forces the disposal of all textures.
  50199. */
  50200. dispose(forceDisposeTextures?: boolean): void;
  50201. /**
  50202. * Get the current class name of the texture useful for serialization or dynamic coding.
  50203. * @returns "PBRAnisotropicConfiguration"
  50204. */
  50205. getClassName(): string;
  50206. /**
  50207. * Add fallbacks to the effect fallbacks list.
  50208. * @param defines defines the Base texture to use.
  50209. * @param fallbacks defines the current fallback list.
  50210. * @param currentRank defines the current fallback rank.
  50211. * @returns the new fallback rank.
  50212. */
  50213. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50214. /**
  50215. * Add the required uniforms to the current list.
  50216. * @param uniforms defines the current uniform list.
  50217. */
  50218. static AddUniforms(uniforms: string[]): void;
  50219. /**
  50220. * Add the required uniforms to the current buffer.
  50221. * @param uniformBuffer defines the current uniform buffer.
  50222. */
  50223. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50224. /**
  50225. * Add the required samplers to the current list.
  50226. * @param samplers defines the current sampler list.
  50227. */
  50228. static AddSamplers(samplers: string[]): void;
  50229. /**
  50230. * Makes a duplicate of the current configuration into another one.
  50231. * @param anisotropicConfiguration define the config where to copy the info
  50232. */
  50233. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50234. /**
  50235. * Serializes this anisotropy configuration.
  50236. * @returns - An object with the serialized config.
  50237. */
  50238. serialize(): any;
  50239. /**
  50240. * Parses a anisotropy Configuration from a serialized object.
  50241. * @param source - Serialized object.
  50242. * @param scene Defines the scene we are parsing for
  50243. * @param rootUrl Defines the rootUrl to load from
  50244. */
  50245. parse(source: any, scene: Scene, rootUrl: string): void;
  50246. }
  50247. }
  50248. declare module BABYLON {
  50249. /**
  50250. * @hidden
  50251. */
  50252. export interface IMaterialBRDFDefines {
  50253. BRDF_V_HEIGHT_CORRELATED: boolean;
  50254. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50255. SPHERICAL_HARMONICS: boolean;
  50256. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50257. /** @hidden */
  50258. _areMiscDirty: boolean;
  50259. }
  50260. /**
  50261. * Define the code related to the BRDF parameters of the pbr material.
  50262. */
  50263. export class PBRBRDFConfiguration {
  50264. /**
  50265. * Default value used for the energy conservation.
  50266. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50267. */
  50268. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50269. /**
  50270. * Default value used for the Smith Visibility Height Correlated mode.
  50271. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50272. */
  50273. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50274. /**
  50275. * Default value used for the IBL diffuse part.
  50276. * This can help switching back to the polynomials mode globally which is a tiny bit
  50277. * less GPU intensive at the drawback of a lower quality.
  50278. */
  50279. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50280. /**
  50281. * Default value used for activating energy conservation for the specular workflow.
  50282. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50283. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50284. */
  50285. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50286. private _useEnergyConservation;
  50287. /**
  50288. * Defines if the material uses energy conservation.
  50289. */
  50290. useEnergyConservation: boolean;
  50291. private _useSmithVisibilityHeightCorrelated;
  50292. /**
  50293. * LEGACY Mode set to false
  50294. * Defines if the material uses height smith correlated visibility term.
  50295. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50296. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50297. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50298. * Not relying on height correlated will also disable energy conservation.
  50299. */
  50300. useSmithVisibilityHeightCorrelated: boolean;
  50301. private _useSphericalHarmonics;
  50302. /**
  50303. * LEGACY Mode set to false
  50304. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50305. * diffuse part of the IBL.
  50306. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50307. * to the ground truth.
  50308. */
  50309. useSphericalHarmonics: boolean;
  50310. private _useSpecularGlossinessInputEnergyConservation;
  50311. /**
  50312. * Defines if the material uses energy conservation, when the specular workflow is active.
  50313. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50314. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50315. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50316. */
  50317. useSpecularGlossinessInputEnergyConservation: boolean;
  50318. /** @hidden */
  50319. private _internalMarkAllSubMeshesAsMiscDirty;
  50320. /** @hidden */
  50321. _markAllSubMeshesAsMiscDirty(): void;
  50322. /**
  50323. * Instantiate a new istance of clear coat configuration.
  50324. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50325. */
  50326. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50327. /**
  50328. * Checks to see if a texture is used in the material.
  50329. * @param defines the list of "defines" to update.
  50330. */
  50331. prepareDefines(defines: IMaterialBRDFDefines): void;
  50332. /**
  50333. * Get the current class name of the texture useful for serialization or dynamic coding.
  50334. * @returns "PBRClearCoatConfiguration"
  50335. */
  50336. getClassName(): string;
  50337. /**
  50338. * Makes a duplicate of the current configuration into another one.
  50339. * @param brdfConfiguration define the config where to copy the info
  50340. */
  50341. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50342. /**
  50343. * Serializes this BRDF configuration.
  50344. * @returns - An object with the serialized config.
  50345. */
  50346. serialize(): any;
  50347. /**
  50348. * Parses a anisotropy Configuration from a serialized object.
  50349. * @param source - Serialized object.
  50350. * @param scene Defines the scene we are parsing for
  50351. * @param rootUrl Defines the rootUrl to load from
  50352. */
  50353. parse(source: any, scene: Scene, rootUrl: string): void;
  50354. }
  50355. }
  50356. declare module BABYLON {
  50357. /**
  50358. * @hidden
  50359. */
  50360. export interface IMaterialSheenDefines {
  50361. SHEEN: boolean;
  50362. SHEEN_TEXTURE: boolean;
  50363. SHEEN_TEXTUREDIRECTUV: number;
  50364. SHEEN_LINKWITHALBEDO: boolean;
  50365. SHEEN_ROUGHNESS: boolean;
  50366. SHEEN_ALBEDOSCALING: boolean;
  50367. /** @hidden */
  50368. _areTexturesDirty: boolean;
  50369. }
  50370. /**
  50371. * Define the code related to the Sheen parameters of the pbr material.
  50372. */
  50373. export class PBRSheenConfiguration {
  50374. private _isEnabled;
  50375. /**
  50376. * Defines if the material uses sheen.
  50377. */
  50378. isEnabled: boolean;
  50379. private _linkSheenWithAlbedo;
  50380. /**
  50381. * Defines if the sheen is linked to the sheen color.
  50382. */
  50383. linkSheenWithAlbedo: boolean;
  50384. /**
  50385. * Defines the sheen intensity.
  50386. */
  50387. intensity: number;
  50388. /**
  50389. * Defines the sheen color.
  50390. */
  50391. color: Color3;
  50392. private _texture;
  50393. /**
  50394. * Stores the sheen tint values in a texture.
  50395. * rgb is tint
  50396. * a is a intensity
  50397. */
  50398. texture: Nullable<BaseTexture>;
  50399. private _roughness;
  50400. /**
  50401. * Defines the sheen roughness.
  50402. * It is not taken into account if linkSheenWithAlbedo is true.
  50403. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50404. */
  50405. roughness: Nullable<number>;
  50406. private _albedoScaling;
  50407. /**
  50408. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50409. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50410. * making it easier to setup and tweak the effect
  50411. */
  50412. albedoScaling: boolean;
  50413. /** @hidden */
  50414. private _internalMarkAllSubMeshesAsTexturesDirty;
  50415. /** @hidden */
  50416. _markAllSubMeshesAsTexturesDirty(): void;
  50417. /**
  50418. * Instantiate a new istance of clear coat configuration.
  50419. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50420. */
  50421. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50422. /**
  50423. * Specifies that the submesh is ready to be used.
  50424. * @param defines the list of "defines" to update.
  50425. * @param scene defines the scene the material belongs to.
  50426. * @returns - boolean indicating that the submesh is ready or not.
  50427. */
  50428. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50429. /**
  50430. * Checks to see if a texture is used in the material.
  50431. * @param defines the list of "defines" to update.
  50432. * @param scene defines the scene the material belongs to.
  50433. */
  50434. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50435. /**
  50436. * Binds the material data.
  50437. * @param uniformBuffer defines the Uniform buffer to fill in.
  50438. * @param scene defines the scene the material belongs to.
  50439. * @param isFrozen defines wether the material is frozen or not.
  50440. */
  50441. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50442. /**
  50443. * Checks to see if a texture is used in the material.
  50444. * @param texture - Base texture to use.
  50445. * @returns - Boolean specifying if a texture is used in the material.
  50446. */
  50447. hasTexture(texture: BaseTexture): boolean;
  50448. /**
  50449. * Returns an array of the actively used textures.
  50450. * @param activeTextures Array of BaseTextures
  50451. */
  50452. getActiveTextures(activeTextures: BaseTexture[]): void;
  50453. /**
  50454. * Returns the animatable textures.
  50455. * @param animatables Array of animatable textures.
  50456. */
  50457. getAnimatables(animatables: IAnimatable[]): void;
  50458. /**
  50459. * Disposes the resources of the material.
  50460. * @param forceDisposeTextures - Forces the disposal of all textures.
  50461. */
  50462. dispose(forceDisposeTextures?: boolean): void;
  50463. /**
  50464. * Get the current class name of the texture useful for serialization or dynamic coding.
  50465. * @returns "PBRSheenConfiguration"
  50466. */
  50467. getClassName(): string;
  50468. /**
  50469. * Add fallbacks to the effect fallbacks list.
  50470. * @param defines defines the Base texture to use.
  50471. * @param fallbacks defines the current fallback list.
  50472. * @param currentRank defines the current fallback rank.
  50473. * @returns the new fallback rank.
  50474. */
  50475. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50476. /**
  50477. * Add the required uniforms to the current list.
  50478. * @param uniforms defines the current uniform list.
  50479. */
  50480. static AddUniforms(uniforms: string[]): void;
  50481. /**
  50482. * Add the required uniforms to the current buffer.
  50483. * @param uniformBuffer defines the current uniform buffer.
  50484. */
  50485. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50486. /**
  50487. * Add the required samplers to the current list.
  50488. * @param samplers defines the current sampler list.
  50489. */
  50490. static AddSamplers(samplers: string[]): void;
  50491. /**
  50492. * Makes a duplicate of the current configuration into another one.
  50493. * @param sheenConfiguration define the config where to copy the info
  50494. */
  50495. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50496. /**
  50497. * Serializes this BRDF configuration.
  50498. * @returns - An object with the serialized config.
  50499. */
  50500. serialize(): any;
  50501. /**
  50502. * Parses a anisotropy Configuration from a serialized object.
  50503. * @param source - Serialized object.
  50504. * @param scene Defines the scene we are parsing for
  50505. * @param rootUrl Defines the rootUrl to load from
  50506. */
  50507. parse(source: any, scene: Scene, rootUrl: string): void;
  50508. }
  50509. }
  50510. declare module BABYLON {
  50511. /**
  50512. * @hidden
  50513. */
  50514. export interface IMaterialSubSurfaceDefines {
  50515. SUBSURFACE: boolean;
  50516. SS_REFRACTION: boolean;
  50517. SS_TRANSLUCENCY: boolean;
  50518. SS_SCATERRING: boolean;
  50519. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50520. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50521. SS_REFRACTIONMAP_3D: boolean;
  50522. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50523. SS_LODINREFRACTIONALPHA: boolean;
  50524. SS_GAMMAREFRACTION: boolean;
  50525. SS_RGBDREFRACTION: boolean;
  50526. SS_LINEARSPECULARREFRACTION: boolean;
  50527. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50528. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50529. /** @hidden */
  50530. _areTexturesDirty: boolean;
  50531. }
  50532. /**
  50533. * Define the code related to the sub surface parameters of the pbr material.
  50534. */
  50535. export class PBRSubSurfaceConfiguration {
  50536. private _isRefractionEnabled;
  50537. /**
  50538. * Defines if the refraction is enabled in the material.
  50539. */
  50540. isRefractionEnabled: boolean;
  50541. private _isTranslucencyEnabled;
  50542. /**
  50543. * Defines if the translucency is enabled in the material.
  50544. */
  50545. isTranslucencyEnabled: boolean;
  50546. private _isScatteringEnabled;
  50547. /**
  50548. * Defines the refraction intensity of the material.
  50549. * The refraction when enabled replaces the Diffuse part of the material.
  50550. * The intensity helps transitionning between diffuse and refraction.
  50551. */
  50552. refractionIntensity: number;
  50553. /**
  50554. * Defines the translucency intensity of the material.
  50555. * When translucency has been enabled, this defines how much of the "translucency"
  50556. * is addded to the diffuse part of the material.
  50557. */
  50558. translucencyIntensity: number;
  50559. /**
  50560. * Defines the scattering intensity of the material.
  50561. * When scattering has been enabled, this defines how much of the "scattered light"
  50562. * is addded to the diffuse part of the material.
  50563. */
  50564. scatteringIntensity: number;
  50565. private _thicknessTexture;
  50566. /**
  50567. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50568. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50569. * 0 would mean minimumThickness
  50570. * 1 would mean maximumThickness
  50571. * The other channels might be use as a mask to vary the different effects intensity.
  50572. */
  50573. thicknessTexture: Nullable<BaseTexture>;
  50574. private _refractionTexture;
  50575. /**
  50576. * Defines the texture to use for refraction.
  50577. */
  50578. refractionTexture: Nullable<BaseTexture>;
  50579. private _indexOfRefraction;
  50580. /**
  50581. * Defines the index of refraction used in the material.
  50582. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50583. */
  50584. indexOfRefraction: number;
  50585. private _invertRefractionY;
  50586. /**
  50587. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50588. */
  50589. invertRefractionY: boolean;
  50590. private _linkRefractionWithTransparency;
  50591. /**
  50592. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50593. * Materials half opaque for instance using refraction could benefit from this control.
  50594. */
  50595. linkRefractionWithTransparency: boolean;
  50596. /**
  50597. * Defines the minimum thickness stored in the thickness map.
  50598. * If no thickness map is defined, this value will be used to simulate thickness.
  50599. */
  50600. minimumThickness: number;
  50601. /**
  50602. * Defines the maximum thickness stored in the thickness map.
  50603. */
  50604. maximumThickness: number;
  50605. /**
  50606. * Defines the volume tint of the material.
  50607. * This is used for both translucency and scattering.
  50608. */
  50609. tintColor: Color3;
  50610. /**
  50611. * Defines the distance at which the tint color should be found in the media.
  50612. * This is used for refraction only.
  50613. */
  50614. tintColorAtDistance: number;
  50615. /**
  50616. * Defines how far each channel transmit through the media.
  50617. * It is defined as a color to simplify it selection.
  50618. */
  50619. diffusionDistance: Color3;
  50620. private _useMaskFromThicknessTexture;
  50621. /**
  50622. * Stores the intensity of the different subsurface effects in the thickness texture.
  50623. * * the green channel is the translucency intensity.
  50624. * * the blue channel is the scattering intensity.
  50625. * * the alpha channel is the refraction intensity.
  50626. */
  50627. useMaskFromThicknessTexture: boolean;
  50628. /** @hidden */
  50629. private _internalMarkAllSubMeshesAsTexturesDirty;
  50630. /** @hidden */
  50631. _markAllSubMeshesAsTexturesDirty(): void;
  50632. /**
  50633. * Instantiate a new istance of sub surface configuration.
  50634. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50635. */
  50636. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50637. /**
  50638. * Gets wehter the submesh is ready to be used or not.
  50639. * @param defines the list of "defines" to update.
  50640. * @param scene defines the scene the material belongs to.
  50641. * @returns - boolean indicating that the submesh is ready or not.
  50642. */
  50643. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50644. /**
  50645. * Checks to see if a texture is used in the material.
  50646. * @param defines the list of "defines" to update.
  50647. * @param scene defines the scene to the material belongs to.
  50648. */
  50649. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50650. /**
  50651. * Binds the material data.
  50652. * @param uniformBuffer defines the Uniform buffer to fill in.
  50653. * @param scene defines the scene the material belongs to.
  50654. * @param engine defines the engine the material belongs to.
  50655. * @param isFrozen defines wether the material is frozen or not.
  50656. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50657. */
  50658. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50659. /**
  50660. * Unbinds the material from the mesh.
  50661. * @param activeEffect defines the effect that should be unbound from.
  50662. * @returns true if unbound, otherwise false
  50663. */
  50664. unbind(activeEffect: Effect): boolean;
  50665. /**
  50666. * Returns the texture used for refraction or null if none is used.
  50667. * @param scene defines the scene the material belongs to.
  50668. * @returns - Refraction texture if present. If no refraction texture and refraction
  50669. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50670. */
  50671. private _getRefractionTexture;
  50672. /**
  50673. * Returns true if alpha blending should be disabled.
  50674. */
  50675. get disableAlphaBlending(): boolean;
  50676. /**
  50677. * Fills the list of render target textures.
  50678. * @param renderTargets the list of render targets to update
  50679. */
  50680. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50681. /**
  50682. * Checks to see if a texture is used in the material.
  50683. * @param texture - Base texture to use.
  50684. * @returns - Boolean specifying if a texture is used in the material.
  50685. */
  50686. hasTexture(texture: BaseTexture): boolean;
  50687. /**
  50688. * Gets a boolean indicating that current material needs to register RTT
  50689. * @returns true if this uses a render target otherwise false.
  50690. */
  50691. hasRenderTargetTextures(): boolean;
  50692. /**
  50693. * Returns an array of the actively used textures.
  50694. * @param activeTextures Array of BaseTextures
  50695. */
  50696. getActiveTextures(activeTextures: BaseTexture[]): void;
  50697. /**
  50698. * Returns the animatable textures.
  50699. * @param animatables Array of animatable textures.
  50700. */
  50701. getAnimatables(animatables: IAnimatable[]): void;
  50702. /**
  50703. * Disposes the resources of the material.
  50704. * @param forceDisposeTextures - Forces the disposal of all textures.
  50705. */
  50706. dispose(forceDisposeTextures?: boolean): void;
  50707. /**
  50708. * Get the current class name of the texture useful for serialization or dynamic coding.
  50709. * @returns "PBRSubSurfaceConfiguration"
  50710. */
  50711. getClassName(): string;
  50712. /**
  50713. * Add fallbacks to the effect fallbacks list.
  50714. * @param defines defines the Base texture to use.
  50715. * @param fallbacks defines the current fallback list.
  50716. * @param currentRank defines the current fallback rank.
  50717. * @returns the new fallback rank.
  50718. */
  50719. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50720. /**
  50721. * Add the required uniforms to the current list.
  50722. * @param uniforms defines the current uniform list.
  50723. */
  50724. static AddUniforms(uniforms: string[]): void;
  50725. /**
  50726. * Add the required samplers to the current list.
  50727. * @param samplers defines the current sampler list.
  50728. */
  50729. static AddSamplers(samplers: string[]): void;
  50730. /**
  50731. * Add the required uniforms to the current buffer.
  50732. * @param uniformBuffer defines the current uniform buffer.
  50733. */
  50734. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50735. /**
  50736. * Makes a duplicate of the current configuration into another one.
  50737. * @param configuration define the config where to copy the info
  50738. */
  50739. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50740. /**
  50741. * Serializes this Sub Surface configuration.
  50742. * @returns - An object with the serialized config.
  50743. */
  50744. serialize(): any;
  50745. /**
  50746. * Parses a anisotropy Configuration from a serialized object.
  50747. * @param source - Serialized object.
  50748. * @param scene Defines the scene we are parsing for
  50749. * @param rootUrl Defines the rootUrl to load from
  50750. */
  50751. parse(source: any, scene: Scene, rootUrl: string): void;
  50752. }
  50753. }
  50754. declare module BABYLON {
  50755. /** @hidden */
  50756. export var pbrFragmentDeclaration: {
  50757. name: string;
  50758. shader: string;
  50759. };
  50760. }
  50761. declare module BABYLON {
  50762. /** @hidden */
  50763. export var pbrUboDeclaration: {
  50764. name: string;
  50765. shader: string;
  50766. };
  50767. }
  50768. declare module BABYLON {
  50769. /** @hidden */
  50770. export var pbrFragmentExtraDeclaration: {
  50771. name: string;
  50772. shader: string;
  50773. };
  50774. }
  50775. declare module BABYLON {
  50776. /** @hidden */
  50777. export var pbrFragmentSamplersDeclaration: {
  50778. name: string;
  50779. shader: string;
  50780. };
  50781. }
  50782. declare module BABYLON {
  50783. /** @hidden */
  50784. export var pbrHelperFunctions: {
  50785. name: string;
  50786. shader: string;
  50787. };
  50788. }
  50789. declare module BABYLON {
  50790. /** @hidden */
  50791. export var harmonicsFunctions: {
  50792. name: string;
  50793. shader: string;
  50794. };
  50795. }
  50796. declare module BABYLON {
  50797. /** @hidden */
  50798. export var pbrDirectLightingSetupFunctions: {
  50799. name: string;
  50800. shader: string;
  50801. };
  50802. }
  50803. declare module BABYLON {
  50804. /** @hidden */
  50805. export var pbrDirectLightingFalloffFunctions: {
  50806. name: string;
  50807. shader: string;
  50808. };
  50809. }
  50810. declare module BABYLON {
  50811. /** @hidden */
  50812. export var pbrBRDFFunctions: {
  50813. name: string;
  50814. shader: string;
  50815. };
  50816. }
  50817. declare module BABYLON {
  50818. /** @hidden */
  50819. export var pbrDirectLightingFunctions: {
  50820. name: string;
  50821. shader: string;
  50822. };
  50823. }
  50824. declare module BABYLON {
  50825. /** @hidden */
  50826. export var pbrIBLFunctions: {
  50827. name: string;
  50828. shader: string;
  50829. };
  50830. }
  50831. declare module BABYLON {
  50832. /** @hidden */
  50833. export var pbrDebug: {
  50834. name: string;
  50835. shader: string;
  50836. };
  50837. }
  50838. declare module BABYLON {
  50839. /** @hidden */
  50840. export var pbrPixelShader: {
  50841. name: string;
  50842. shader: string;
  50843. };
  50844. }
  50845. declare module BABYLON {
  50846. /** @hidden */
  50847. export var pbrVertexDeclaration: {
  50848. name: string;
  50849. shader: string;
  50850. };
  50851. }
  50852. declare module BABYLON {
  50853. /** @hidden */
  50854. export var pbrVertexShader: {
  50855. name: string;
  50856. shader: string;
  50857. };
  50858. }
  50859. declare module BABYLON {
  50860. /**
  50861. * Manages the defines for the PBR Material.
  50862. * @hidden
  50863. */
  50864. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50865. PBR: boolean;
  50866. MAINUV1: boolean;
  50867. MAINUV2: boolean;
  50868. UV1: boolean;
  50869. UV2: boolean;
  50870. ALBEDO: boolean;
  50871. GAMMAALBEDO: boolean;
  50872. ALBEDODIRECTUV: number;
  50873. VERTEXCOLOR: boolean;
  50874. AMBIENT: boolean;
  50875. AMBIENTDIRECTUV: number;
  50876. AMBIENTINGRAYSCALE: boolean;
  50877. OPACITY: boolean;
  50878. VERTEXALPHA: boolean;
  50879. OPACITYDIRECTUV: number;
  50880. OPACITYRGB: boolean;
  50881. ALPHATEST: boolean;
  50882. DEPTHPREPASS: boolean;
  50883. ALPHABLEND: boolean;
  50884. ALPHAFROMALBEDO: boolean;
  50885. ALPHATESTVALUE: string;
  50886. SPECULAROVERALPHA: boolean;
  50887. RADIANCEOVERALPHA: boolean;
  50888. ALPHAFRESNEL: boolean;
  50889. LINEARALPHAFRESNEL: boolean;
  50890. PREMULTIPLYALPHA: boolean;
  50891. EMISSIVE: boolean;
  50892. EMISSIVEDIRECTUV: number;
  50893. REFLECTIVITY: boolean;
  50894. REFLECTIVITYDIRECTUV: number;
  50895. SPECULARTERM: boolean;
  50896. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50897. MICROSURFACEAUTOMATIC: boolean;
  50898. LODBASEDMICROSFURACE: boolean;
  50899. MICROSURFACEMAP: boolean;
  50900. MICROSURFACEMAPDIRECTUV: number;
  50901. METALLICWORKFLOW: boolean;
  50902. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50903. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50904. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50905. AOSTOREINMETALMAPRED: boolean;
  50906. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50907. ENVIRONMENTBRDF: boolean;
  50908. ENVIRONMENTBRDF_RGBD: boolean;
  50909. NORMAL: boolean;
  50910. TANGENT: boolean;
  50911. BUMP: boolean;
  50912. BUMPDIRECTUV: number;
  50913. OBJECTSPACE_NORMALMAP: boolean;
  50914. PARALLAX: boolean;
  50915. PARALLAXOCCLUSION: boolean;
  50916. NORMALXYSCALE: boolean;
  50917. LIGHTMAP: boolean;
  50918. LIGHTMAPDIRECTUV: number;
  50919. USELIGHTMAPASSHADOWMAP: boolean;
  50920. GAMMALIGHTMAP: boolean;
  50921. RGBDLIGHTMAP: boolean;
  50922. REFLECTION: boolean;
  50923. REFLECTIONMAP_3D: boolean;
  50924. REFLECTIONMAP_SPHERICAL: boolean;
  50925. REFLECTIONMAP_PLANAR: boolean;
  50926. REFLECTIONMAP_CUBIC: boolean;
  50927. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50928. REFLECTIONMAP_PROJECTION: boolean;
  50929. REFLECTIONMAP_SKYBOX: boolean;
  50930. REFLECTIONMAP_EXPLICIT: boolean;
  50931. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50932. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50933. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50934. INVERTCUBICMAP: boolean;
  50935. USESPHERICALFROMREFLECTIONMAP: boolean;
  50936. USEIRRADIANCEMAP: boolean;
  50937. SPHERICAL_HARMONICS: boolean;
  50938. USESPHERICALINVERTEX: boolean;
  50939. REFLECTIONMAP_OPPOSITEZ: boolean;
  50940. LODINREFLECTIONALPHA: boolean;
  50941. GAMMAREFLECTION: boolean;
  50942. RGBDREFLECTION: boolean;
  50943. LINEARSPECULARREFLECTION: boolean;
  50944. RADIANCEOCCLUSION: boolean;
  50945. HORIZONOCCLUSION: boolean;
  50946. INSTANCES: boolean;
  50947. NUM_BONE_INFLUENCERS: number;
  50948. BonesPerMesh: number;
  50949. BONETEXTURE: boolean;
  50950. NONUNIFORMSCALING: boolean;
  50951. MORPHTARGETS: boolean;
  50952. MORPHTARGETS_NORMAL: boolean;
  50953. MORPHTARGETS_TANGENT: boolean;
  50954. MORPHTARGETS_UV: boolean;
  50955. NUM_MORPH_INFLUENCERS: number;
  50956. IMAGEPROCESSING: boolean;
  50957. VIGNETTE: boolean;
  50958. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50959. VIGNETTEBLENDMODEOPAQUE: boolean;
  50960. TONEMAPPING: boolean;
  50961. TONEMAPPING_ACES: boolean;
  50962. CONTRAST: boolean;
  50963. COLORCURVES: boolean;
  50964. COLORGRADING: boolean;
  50965. COLORGRADING3D: boolean;
  50966. SAMPLER3DGREENDEPTH: boolean;
  50967. SAMPLER3DBGRMAP: boolean;
  50968. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50969. EXPOSURE: boolean;
  50970. MULTIVIEW: boolean;
  50971. USEPHYSICALLIGHTFALLOFF: boolean;
  50972. USEGLTFLIGHTFALLOFF: boolean;
  50973. TWOSIDEDLIGHTING: boolean;
  50974. SHADOWFLOAT: boolean;
  50975. CLIPPLANE: boolean;
  50976. CLIPPLANE2: boolean;
  50977. CLIPPLANE3: boolean;
  50978. CLIPPLANE4: boolean;
  50979. CLIPPLANE5: boolean;
  50980. CLIPPLANE6: boolean;
  50981. POINTSIZE: boolean;
  50982. FOG: boolean;
  50983. LOGARITHMICDEPTH: boolean;
  50984. FORCENORMALFORWARD: boolean;
  50985. SPECULARAA: boolean;
  50986. CLEARCOAT: boolean;
  50987. CLEARCOAT_DEFAULTIOR: boolean;
  50988. CLEARCOAT_TEXTURE: boolean;
  50989. CLEARCOAT_TEXTUREDIRECTUV: number;
  50990. CLEARCOAT_BUMP: boolean;
  50991. CLEARCOAT_BUMPDIRECTUV: number;
  50992. CLEARCOAT_TINT: boolean;
  50993. CLEARCOAT_TINT_TEXTURE: boolean;
  50994. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50995. ANISOTROPIC: boolean;
  50996. ANISOTROPIC_TEXTURE: boolean;
  50997. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50998. BRDF_V_HEIGHT_CORRELATED: boolean;
  50999. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51000. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51001. SHEEN: boolean;
  51002. SHEEN_TEXTURE: boolean;
  51003. SHEEN_TEXTUREDIRECTUV: number;
  51004. SHEEN_LINKWITHALBEDO: boolean;
  51005. SHEEN_ROUGHNESS: boolean;
  51006. SHEEN_ALBEDOSCALING: boolean;
  51007. SUBSURFACE: boolean;
  51008. SS_REFRACTION: boolean;
  51009. SS_TRANSLUCENCY: boolean;
  51010. SS_SCATERRING: boolean;
  51011. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51012. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51013. SS_REFRACTIONMAP_3D: boolean;
  51014. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51015. SS_LODINREFRACTIONALPHA: boolean;
  51016. SS_GAMMAREFRACTION: boolean;
  51017. SS_RGBDREFRACTION: boolean;
  51018. SS_LINEARSPECULARREFRACTION: boolean;
  51019. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51020. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51021. UNLIT: boolean;
  51022. DEBUGMODE: number;
  51023. /**
  51024. * Initializes the PBR Material defines.
  51025. */
  51026. constructor();
  51027. /**
  51028. * Resets the PBR Material defines.
  51029. */
  51030. reset(): void;
  51031. }
  51032. /**
  51033. * The Physically based material base class of BJS.
  51034. *
  51035. * This offers the main features of a standard PBR material.
  51036. * For more information, please refer to the documentation :
  51037. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51038. */
  51039. export abstract class PBRBaseMaterial extends PushMaterial {
  51040. /**
  51041. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51042. */
  51043. static readonly PBRMATERIAL_OPAQUE: number;
  51044. /**
  51045. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51046. */
  51047. static readonly PBRMATERIAL_ALPHATEST: number;
  51048. /**
  51049. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51050. */
  51051. static readonly PBRMATERIAL_ALPHABLEND: number;
  51052. /**
  51053. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51054. * They are also discarded below the alpha cutoff threshold to improve performances.
  51055. */
  51056. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51057. /**
  51058. * Defines the default value of how much AO map is occluding the analytical lights
  51059. * (point spot...).
  51060. */
  51061. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51062. /**
  51063. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51064. */
  51065. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51066. /**
  51067. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51068. * to enhance interoperability with other engines.
  51069. */
  51070. static readonly LIGHTFALLOFF_GLTF: number;
  51071. /**
  51072. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51073. * to enhance interoperability with other materials.
  51074. */
  51075. static readonly LIGHTFALLOFF_STANDARD: number;
  51076. /**
  51077. * Intensity of the direct lights e.g. the four lights available in your scene.
  51078. * This impacts both the direct diffuse and specular highlights.
  51079. */
  51080. protected _directIntensity: number;
  51081. /**
  51082. * Intensity of the emissive part of the material.
  51083. * This helps controlling the emissive effect without modifying the emissive color.
  51084. */
  51085. protected _emissiveIntensity: number;
  51086. /**
  51087. * Intensity of the environment e.g. how much the environment will light the object
  51088. * either through harmonics for rough material or through the refelction for shiny ones.
  51089. */
  51090. protected _environmentIntensity: number;
  51091. /**
  51092. * This is a special control allowing the reduction of the specular highlights coming from the
  51093. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51094. */
  51095. protected _specularIntensity: number;
  51096. /**
  51097. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51098. */
  51099. private _lightingInfos;
  51100. /**
  51101. * Debug Control allowing disabling the bump map on this material.
  51102. */
  51103. protected _disableBumpMap: boolean;
  51104. /**
  51105. * AKA Diffuse Texture in standard nomenclature.
  51106. */
  51107. protected _albedoTexture: Nullable<BaseTexture>;
  51108. /**
  51109. * AKA Occlusion Texture in other nomenclature.
  51110. */
  51111. protected _ambientTexture: Nullable<BaseTexture>;
  51112. /**
  51113. * AKA Occlusion Texture Intensity in other nomenclature.
  51114. */
  51115. protected _ambientTextureStrength: number;
  51116. /**
  51117. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51118. * 1 means it completely occludes it
  51119. * 0 mean it has no impact
  51120. */
  51121. protected _ambientTextureImpactOnAnalyticalLights: number;
  51122. /**
  51123. * Stores the alpha values in a texture.
  51124. */
  51125. protected _opacityTexture: Nullable<BaseTexture>;
  51126. /**
  51127. * Stores the reflection values in a texture.
  51128. */
  51129. protected _reflectionTexture: Nullable<BaseTexture>;
  51130. /**
  51131. * Stores the emissive values in a texture.
  51132. */
  51133. protected _emissiveTexture: Nullable<BaseTexture>;
  51134. /**
  51135. * AKA Specular texture in other nomenclature.
  51136. */
  51137. protected _reflectivityTexture: Nullable<BaseTexture>;
  51138. /**
  51139. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51140. */
  51141. protected _metallicTexture: Nullable<BaseTexture>;
  51142. /**
  51143. * Specifies the metallic scalar of the metallic/roughness workflow.
  51144. * Can also be used to scale the metalness values of the metallic texture.
  51145. */
  51146. protected _metallic: Nullable<number>;
  51147. /**
  51148. * Specifies the roughness scalar of the metallic/roughness workflow.
  51149. * Can also be used to scale the roughness values of the metallic texture.
  51150. */
  51151. protected _roughness: Nullable<number>;
  51152. /**
  51153. * Specifies the an F0 factor to help configuring the material F0.
  51154. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51155. * to 0.5 the previously hard coded value stays the same.
  51156. * Can also be used to scale the F0 values of the metallic texture.
  51157. */
  51158. protected _metallicF0Factor: number;
  51159. /**
  51160. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51161. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51162. * your expectation as it multiplies with the texture data.
  51163. */
  51164. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51165. /**
  51166. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51167. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51168. */
  51169. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51170. /**
  51171. * Stores surface normal data used to displace a mesh in a texture.
  51172. */
  51173. protected _bumpTexture: Nullable<BaseTexture>;
  51174. /**
  51175. * Stores the pre-calculated light information of a mesh in a texture.
  51176. */
  51177. protected _lightmapTexture: Nullable<BaseTexture>;
  51178. /**
  51179. * The color of a material in ambient lighting.
  51180. */
  51181. protected _ambientColor: Color3;
  51182. /**
  51183. * AKA Diffuse Color in other nomenclature.
  51184. */
  51185. protected _albedoColor: Color3;
  51186. /**
  51187. * AKA Specular Color in other nomenclature.
  51188. */
  51189. protected _reflectivityColor: Color3;
  51190. /**
  51191. * The color applied when light is reflected from a material.
  51192. */
  51193. protected _reflectionColor: Color3;
  51194. /**
  51195. * The color applied when light is emitted from a material.
  51196. */
  51197. protected _emissiveColor: Color3;
  51198. /**
  51199. * AKA Glossiness in other nomenclature.
  51200. */
  51201. protected _microSurface: number;
  51202. /**
  51203. * Specifies that the material will use the light map as a show map.
  51204. */
  51205. protected _useLightmapAsShadowmap: boolean;
  51206. /**
  51207. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51208. * makes the reflect vector face the model (under horizon).
  51209. */
  51210. protected _useHorizonOcclusion: boolean;
  51211. /**
  51212. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51213. * too much the area relying on ambient texture to define their ambient occlusion.
  51214. */
  51215. protected _useRadianceOcclusion: boolean;
  51216. /**
  51217. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51218. */
  51219. protected _useAlphaFromAlbedoTexture: boolean;
  51220. /**
  51221. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51222. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51223. */
  51224. protected _useSpecularOverAlpha: boolean;
  51225. /**
  51226. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51227. */
  51228. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51229. /**
  51230. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51231. */
  51232. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51233. /**
  51234. * Specifies if the metallic texture contains the roughness information in its green channel.
  51235. */
  51236. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51237. /**
  51238. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51239. */
  51240. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51241. /**
  51242. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51243. */
  51244. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51245. /**
  51246. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51247. */
  51248. protected _useAmbientInGrayScale: boolean;
  51249. /**
  51250. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51251. * The material will try to infer what glossiness each pixel should be.
  51252. */
  51253. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51254. /**
  51255. * Defines the falloff type used in this material.
  51256. * It by default is Physical.
  51257. */
  51258. protected _lightFalloff: number;
  51259. /**
  51260. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51261. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51262. */
  51263. protected _useRadianceOverAlpha: boolean;
  51264. /**
  51265. * Allows using an object space normal map (instead of tangent space).
  51266. */
  51267. protected _useObjectSpaceNormalMap: boolean;
  51268. /**
  51269. * Allows using the bump map in parallax mode.
  51270. */
  51271. protected _useParallax: boolean;
  51272. /**
  51273. * Allows using the bump map in parallax occlusion mode.
  51274. */
  51275. protected _useParallaxOcclusion: boolean;
  51276. /**
  51277. * Controls the scale bias of the parallax mode.
  51278. */
  51279. protected _parallaxScaleBias: number;
  51280. /**
  51281. * If sets to true, disables all the lights affecting the material.
  51282. */
  51283. protected _disableLighting: boolean;
  51284. /**
  51285. * Number of Simultaneous lights allowed on the material.
  51286. */
  51287. protected _maxSimultaneousLights: number;
  51288. /**
  51289. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51290. */
  51291. protected _invertNormalMapX: boolean;
  51292. /**
  51293. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51294. */
  51295. protected _invertNormalMapY: boolean;
  51296. /**
  51297. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51298. */
  51299. protected _twoSidedLighting: boolean;
  51300. /**
  51301. * Defines the alpha limits in alpha test mode.
  51302. */
  51303. protected _alphaCutOff: number;
  51304. /**
  51305. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51306. */
  51307. protected _forceAlphaTest: boolean;
  51308. /**
  51309. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51310. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51311. */
  51312. protected _useAlphaFresnel: boolean;
  51313. /**
  51314. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51315. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51316. */
  51317. protected _useLinearAlphaFresnel: boolean;
  51318. /**
  51319. * The transparency mode of the material.
  51320. */
  51321. protected _transparencyMode: Nullable<number>;
  51322. /**
  51323. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51324. * from cos thetav and roughness:
  51325. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51326. */
  51327. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51328. /**
  51329. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51330. */
  51331. protected _forceIrradianceInFragment: boolean;
  51332. /**
  51333. * Force normal to face away from face.
  51334. */
  51335. protected _forceNormalForward: boolean;
  51336. /**
  51337. * Enables specular anti aliasing in the PBR shader.
  51338. * It will both interacts on the Geometry for analytical and IBL lighting.
  51339. * It also prefilter the roughness map based on the bump values.
  51340. */
  51341. protected _enableSpecularAntiAliasing: boolean;
  51342. /**
  51343. * Default configuration related to image processing available in the PBR Material.
  51344. */
  51345. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51346. /**
  51347. * Keep track of the image processing observer to allow dispose and replace.
  51348. */
  51349. private _imageProcessingObserver;
  51350. /**
  51351. * Attaches a new image processing configuration to the PBR Material.
  51352. * @param configuration
  51353. */
  51354. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51355. /**
  51356. * Stores the available render targets.
  51357. */
  51358. private _renderTargets;
  51359. /**
  51360. * Sets the global ambient color for the material used in lighting calculations.
  51361. */
  51362. private _globalAmbientColor;
  51363. /**
  51364. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51365. */
  51366. private _useLogarithmicDepth;
  51367. /**
  51368. * If set to true, no lighting calculations will be applied.
  51369. */
  51370. private _unlit;
  51371. private _debugMode;
  51372. /**
  51373. * @hidden
  51374. * This is reserved for the inspector.
  51375. * Defines the material debug mode.
  51376. * It helps seeing only some components of the material while troubleshooting.
  51377. */
  51378. debugMode: number;
  51379. /**
  51380. * @hidden
  51381. * This is reserved for the inspector.
  51382. * Specify from where on screen the debug mode should start.
  51383. * The value goes from -1 (full screen) to 1 (not visible)
  51384. * It helps with side by side comparison against the final render
  51385. * This defaults to -1
  51386. */
  51387. private debugLimit;
  51388. /**
  51389. * @hidden
  51390. * This is reserved for the inspector.
  51391. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51392. * You can use the factor to better multiply the final value.
  51393. */
  51394. private debugFactor;
  51395. /**
  51396. * Defines the clear coat layer parameters for the material.
  51397. */
  51398. readonly clearCoat: PBRClearCoatConfiguration;
  51399. /**
  51400. * Defines the anisotropic parameters for the material.
  51401. */
  51402. readonly anisotropy: PBRAnisotropicConfiguration;
  51403. /**
  51404. * Defines the BRDF parameters for the material.
  51405. */
  51406. readonly brdf: PBRBRDFConfiguration;
  51407. /**
  51408. * Defines the Sheen parameters for the material.
  51409. */
  51410. readonly sheen: PBRSheenConfiguration;
  51411. /**
  51412. * Defines the SubSurface parameters for the material.
  51413. */
  51414. readonly subSurface: PBRSubSurfaceConfiguration;
  51415. /**
  51416. * Custom callback helping to override the default shader used in the material.
  51417. */
  51418. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51419. protected _rebuildInParallel: boolean;
  51420. /**
  51421. * Instantiates a new PBRMaterial instance.
  51422. *
  51423. * @param name The material name
  51424. * @param scene The scene the material will be use in.
  51425. */
  51426. constructor(name: string, scene: Scene);
  51427. /**
  51428. * Gets a boolean indicating that current material needs to register RTT
  51429. */
  51430. get hasRenderTargetTextures(): boolean;
  51431. /**
  51432. * Gets the name of the material class.
  51433. */
  51434. getClassName(): string;
  51435. /**
  51436. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51437. */
  51438. get useLogarithmicDepth(): boolean;
  51439. /**
  51440. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51441. */
  51442. set useLogarithmicDepth(value: boolean);
  51443. /**
  51444. * Gets the current transparency mode.
  51445. */
  51446. get transparencyMode(): Nullable<number>;
  51447. /**
  51448. * Sets the transparency mode of the material.
  51449. *
  51450. * | Value | Type | Description |
  51451. * | ----- | ----------------------------------- | ----------- |
  51452. * | 0 | OPAQUE | |
  51453. * | 1 | ALPHATEST | |
  51454. * | 2 | ALPHABLEND | |
  51455. * | 3 | ALPHATESTANDBLEND | |
  51456. *
  51457. */
  51458. set transparencyMode(value: Nullable<number>);
  51459. /**
  51460. * Returns true if alpha blending should be disabled.
  51461. */
  51462. private get _disableAlphaBlending();
  51463. /**
  51464. * Specifies whether or not this material should be rendered in alpha blend mode.
  51465. */
  51466. needAlphaBlending(): boolean;
  51467. /**
  51468. * Specifies if the mesh will require alpha blending.
  51469. * @param mesh - BJS mesh.
  51470. */
  51471. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51472. /**
  51473. * Specifies whether or not this material should be rendered in alpha test mode.
  51474. */
  51475. needAlphaTesting(): boolean;
  51476. /**
  51477. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51478. */
  51479. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51480. /**
  51481. * Gets the texture used for the alpha test.
  51482. */
  51483. getAlphaTestTexture(): Nullable<BaseTexture>;
  51484. /**
  51485. * Specifies that the submesh is ready to be used.
  51486. * @param mesh - BJS mesh.
  51487. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51488. * @param useInstances - Specifies that instances should be used.
  51489. * @returns - boolean indicating that the submesh is ready or not.
  51490. */
  51491. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51492. /**
  51493. * Specifies if the material uses metallic roughness workflow.
  51494. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51495. */
  51496. isMetallicWorkflow(): boolean;
  51497. private _prepareEffect;
  51498. private _prepareDefines;
  51499. /**
  51500. * Force shader compilation
  51501. */
  51502. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51503. /**
  51504. * Initializes the uniform buffer layout for the shader.
  51505. */
  51506. buildUniformLayout(): void;
  51507. /**
  51508. * Unbinds the material from the mesh
  51509. */
  51510. unbind(): void;
  51511. /**
  51512. * Binds the submesh data.
  51513. * @param world - The world matrix.
  51514. * @param mesh - The BJS mesh.
  51515. * @param subMesh - A submesh of the BJS mesh.
  51516. */
  51517. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51518. /**
  51519. * Returns the animatable textures.
  51520. * @returns - Array of animatable textures.
  51521. */
  51522. getAnimatables(): IAnimatable[];
  51523. /**
  51524. * Returns the texture used for reflections.
  51525. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51526. */
  51527. private _getReflectionTexture;
  51528. /**
  51529. * Returns an array of the actively used textures.
  51530. * @returns - Array of BaseTextures
  51531. */
  51532. getActiveTextures(): BaseTexture[];
  51533. /**
  51534. * Checks to see if a texture is used in the material.
  51535. * @param texture - Base texture to use.
  51536. * @returns - Boolean specifying if a texture is used in the material.
  51537. */
  51538. hasTexture(texture: BaseTexture): boolean;
  51539. /**
  51540. * Disposes the resources of the material.
  51541. * @param forceDisposeEffect - Forces the disposal of effects.
  51542. * @param forceDisposeTextures - Forces the disposal of all textures.
  51543. */
  51544. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51545. }
  51546. }
  51547. declare module BABYLON {
  51548. /**
  51549. * The Physically based material of BJS.
  51550. *
  51551. * This offers the main features of a standard PBR material.
  51552. * For more information, please refer to the documentation :
  51553. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51554. */
  51555. export class PBRMaterial extends PBRBaseMaterial {
  51556. /**
  51557. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51558. */
  51559. static readonly PBRMATERIAL_OPAQUE: number;
  51560. /**
  51561. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51562. */
  51563. static readonly PBRMATERIAL_ALPHATEST: number;
  51564. /**
  51565. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51566. */
  51567. static readonly PBRMATERIAL_ALPHABLEND: number;
  51568. /**
  51569. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51570. * They are also discarded below the alpha cutoff threshold to improve performances.
  51571. */
  51572. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51573. /**
  51574. * Defines the default value of how much AO map is occluding the analytical lights
  51575. * (point spot...).
  51576. */
  51577. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51578. /**
  51579. * Intensity of the direct lights e.g. the four lights available in your scene.
  51580. * This impacts both the direct diffuse and specular highlights.
  51581. */
  51582. directIntensity: number;
  51583. /**
  51584. * Intensity of the emissive part of the material.
  51585. * This helps controlling the emissive effect without modifying the emissive color.
  51586. */
  51587. emissiveIntensity: number;
  51588. /**
  51589. * Intensity of the environment e.g. how much the environment will light the object
  51590. * either through harmonics for rough material or through the refelction for shiny ones.
  51591. */
  51592. environmentIntensity: number;
  51593. /**
  51594. * This is a special control allowing the reduction of the specular highlights coming from the
  51595. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51596. */
  51597. specularIntensity: number;
  51598. /**
  51599. * Debug Control allowing disabling the bump map on this material.
  51600. */
  51601. disableBumpMap: boolean;
  51602. /**
  51603. * AKA Diffuse Texture in standard nomenclature.
  51604. */
  51605. albedoTexture: BaseTexture;
  51606. /**
  51607. * AKA Occlusion Texture in other nomenclature.
  51608. */
  51609. ambientTexture: BaseTexture;
  51610. /**
  51611. * AKA Occlusion Texture Intensity in other nomenclature.
  51612. */
  51613. ambientTextureStrength: number;
  51614. /**
  51615. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51616. * 1 means it completely occludes it
  51617. * 0 mean it has no impact
  51618. */
  51619. ambientTextureImpactOnAnalyticalLights: number;
  51620. /**
  51621. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51622. */
  51623. opacityTexture: BaseTexture;
  51624. /**
  51625. * Stores the reflection values in a texture.
  51626. */
  51627. reflectionTexture: Nullable<BaseTexture>;
  51628. /**
  51629. * Stores the emissive values in a texture.
  51630. */
  51631. emissiveTexture: BaseTexture;
  51632. /**
  51633. * AKA Specular texture in other nomenclature.
  51634. */
  51635. reflectivityTexture: BaseTexture;
  51636. /**
  51637. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51638. */
  51639. metallicTexture: BaseTexture;
  51640. /**
  51641. * Specifies the metallic scalar of the metallic/roughness workflow.
  51642. * Can also be used to scale the metalness values of the metallic texture.
  51643. */
  51644. metallic: Nullable<number>;
  51645. /**
  51646. * Specifies the roughness scalar of the metallic/roughness workflow.
  51647. * Can also be used to scale the roughness values of the metallic texture.
  51648. */
  51649. roughness: Nullable<number>;
  51650. /**
  51651. * Specifies the an F0 factor to help configuring the material F0.
  51652. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51653. * to 0.5 the previously hard coded value stays the same.
  51654. * Can also be used to scale the F0 values of the metallic texture.
  51655. */
  51656. metallicF0Factor: number;
  51657. /**
  51658. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51659. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51660. * your expectation as it multiplies with the texture data.
  51661. */
  51662. useMetallicF0FactorFromMetallicTexture: boolean;
  51663. /**
  51664. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51665. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51666. */
  51667. microSurfaceTexture: BaseTexture;
  51668. /**
  51669. * Stores surface normal data used to displace a mesh in a texture.
  51670. */
  51671. bumpTexture: BaseTexture;
  51672. /**
  51673. * Stores the pre-calculated light information of a mesh in a texture.
  51674. */
  51675. lightmapTexture: BaseTexture;
  51676. /**
  51677. * Stores the refracted light information in a texture.
  51678. */
  51679. get refractionTexture(): Nullable<BaseTexture>;
  51680. set refractionTexture(value: Nullable<BaseTexture>);
  51681. /**
  51682. * The color of a material in ambient lighting.
  51683. */
  51684. ambientColor: Color3;
  51685. /**
  51686. * AKA Diffuse Color in other nomenclature.
  51687. */
  51688. albedoColor: Color3;
  51689. /**
  51690. * AKA Specular Color in other nomenclature.
  51691. */
  51692. reflectivityColor: Color3;
  51693. /**
  51694. * The color reflected from the material.
  51695. */
  51696. reflectionColor: Color3;
  51697. /**
  51698. * The color emitted from the material.
  51699. */
  51700. emissiveColor: Color3;
  51701. /**
  51702. * AKA Glossiness in other nomenclature.
  51703. */
  51704. microSurface: number;
  51705. /**
  51706. * source material index of refraction (IOR)' / 'destination material IOR.
  51707. */
  51708. get indexOfRefraction(): number;
  51709. set indexOfRefraction(value: number);
  51710. /**
  51711. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51712. */
  51713. get invertRefractionY(): boolean;
  51714. set invertRefractionY(value: boolean);
  51715. /**
  51716. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51717. * Materials half opaque for instance using refraction could benefit from this control.
  51718. */
  51719. get linkRefractionWithTransparency(): boolean;
  51720. set linkRefractionWithTransparency(value: boolean);
  51721. /**
  51722. * If true, the light map contains occlusion information instead of lighting info.
  51723. */
  51724. useLightmapAsShadowmap: boolean;
  51725. /**
  51726. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51727. */
  51728. useAlphaFromAlbedoTexture: boolean;
  51729. /**
  51730. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51731. */
  51732. forceAlphaTest: boolean;
  51733. /**
  51734. * Defines the alpha limits in alpha test mode.
  51735. */
  51736. alphaCutOff: number;
  51737. /**
  51738. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51739. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51740. */
  51741. useSpecularOverAlpha: boolean;
  51742. /**
  51743. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51744. */
  51745. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51746. /**
  51747. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51748. */
  51749. useRoughnessFromMetallicTextureAlpha: boolean;
  51750. /**
  51751. * Specifies if the metallic texture contains the roughness information in its green channel.
  51752. */
  51753. useRoughnessFromMetallicTextureGreen: boolean;
  51754. /**
  51755. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51756. */
  51757. useMetallnessFromMetallicTextureBlue: boolean;
  51758. /**
  51759. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51760. */
  51761. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51762. /**
  51763. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51764. */
  51765. useAmbientInGrayScale: boolean;
  51766. /**
  51767. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51768. * The material will try to infer what glossiness each pixel should be.
  51769. */
  51770. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51771. /**
  51772. * BJS is using an harcoded light falloff based on a manually sets up range.
  51773. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51774. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51775. */
  51776. get usePhysicalLightFalloff(): boolean;
  51777. /**
  51778. * BJS is using an harcoded light falloff based on a manually sets up range.
  51779. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51780. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51781. */
  51782. set usePhysicalLightFalloff(value: boolean);
  51783. /**
  51784. * In order to support the falloff compatibility with gltf, a special mode has been added
  51785. * to reproduce the gltf light falloff.
  51786. */
  51787. get useGLTFLightFalloff(): boolean;
  51788. /**
  51789. * In order to support the falloff compatibility with gltf, a special mode has been added
  51790. * to reproduce the gltf light falloff.
  51791. */
  51792. set useGLTFLightFalloff(value: boolean);
  51793. /**
  51794. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51795. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51796. */
  51797. useRadianceOverAlpha: boolean;
  51798. /**
  51799. * Allows using an object space normal map (instead of tangent space).
  51800. */
  51801. useObjectSpaceNormalMap: boolean;
  51802. /**
  51803. * Allows using the bump map in parallax mode.
  51804. */
  51805. useParallax: boolean;
  51806. /**
  51807. * Allows using the bump map in parallax occlusion mode.
  51808. */
  51809. useParallaxOcclusion: boolean;
  51810. /**
  51811. * Controls the scale bias of the parallax mode.
  51812. */
  51813. parallaxScaleBias: number;
  51814. /**
  51815. * If sets to true, disables all the lights affecting the material.
  51816. */
  51817. disableLighting: boolean;
  51818. /**
  51819. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51820. */
  51821. forceIrradianceInFragment: boolean;
  51822. /**
  51823. * Number of Simultaneous lights allowed on the material.
  51824. */
  51825. maxSimultaneousLights: number;
  51826. /**
  51827. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51828. */
  51829. invertNormalMapX: boolean;
  51830. /**
  51831. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51832. */
  51833. invertNormalMapY: boolean;
  51834. /**
  51835. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51836. */
  51837. twoSidedLighting: boolean;
  51838. /**
  51839. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51840. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51841. */
  51842. useAlphaFresnel: boolean;
  51843. /**
  51844. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51845. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51846. */
  51847. useLinearAlphaFresnel: boolean;
  51848. /**
  51849. * Let user defines the brdf lookup texture used for IBL.
  51850. * A default 8bit version is embedded but you could point at :
  51851. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51852. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51853. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51854. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51855. */
  51856. environmentBRDFTexture: Nullable<BaseTexture>;
  51857. /**
  51858. * Force normal to face away from face.
  51859. */
  51860. forceNormalForward: boolean;
  51861. /**
  51862. * Enables specular anti aliasing in the PBR shader.
  51863. * It will both interacts on the Geometry for analytical and IBL lighting.
  51864. * It also prefilter the roughness map based on the bump values.
  51865. */
  51866. enableSpecularAntiAliasing: boolean;
  51867. /**
  51868. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51869. * makes the reflect vector face the model (under horizon).
  51870. */
  51871. useHorizonOcclusion: boolean;
  51872. /**
  51873. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51874. * too much the area relying on ambient texture to define their ambient occlusion.
  51875. */
  51876. useRadianceOcclusion: boolean;
  51877. /**
  51878. * If set to true, no lighting calculations will be applied.
  51879. */
  51880. unlit: boolean;
  51881. /**
  51882. * Gets the image processing configuration used either in this material.
  51883. */
  51884. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51885. /**
  51886. * Sets the Default image processing configuration used either in the this material.
  51887. *
  51888. * If sets to null, the scene one is in use.
  51889. */
  51890. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51891. /**
  51892. * Gets wether the color curves effect is enabled.
  51893. */
  51894. get cameraColorCurvesEnabled(): boolean;
  51895. /**
  51896. * Sets wether the color curves effect is enabled.
  51897. */
  51898. set cameraColorCurvesEnabled(value: boolean);
  51899. /**
  51900. * Gets wether the color grading effect is enabled.
  51901. */
  51902. get cameraColorGradingEnabled(): boolean;
  51903. /**
  51904. * Gets wether the color grading effect is enabled.
  51905. */
  51906. set cameraColorGradingEnabled(value: boolean);
  51907. /**
  51908. * Gets wether tonemapping is enabled or not.
  51909. */
  51910. get cameraToneMappingEnabled(): boolean;
  51911. /**
  51912. * Sets wether tonemapping is enabled or not
  51913. */
  51914. set cameraToneMappingEnabled(value: boolean);
  51915. /**
  51916. * The camera exposure used on this material.
  51917. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51918. * This corresponds to a photographic exposure.
  51919. */
  51920. get cameraExposure(): number;
  51921. /**
  51922. * The camera exposure used on this material.
  51923. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51924. * This corresponds to a photographic exposure.
  51925. */
  51926. set cameraExposure(value: number);
  51927. /**
  51928. * Gets The camera contrast used on this material.
  51929. */
  51930. get cameraContrast(): number;
  51931. /**
  51932. * Sets The camera contrast used on this material.
  51933. */
  51934. set cameraContrast(value: number);
  51935. /**
  51936. * Gets the Color Grading 2D Lookup Texture.
  51937. */
  51938. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51939. /**
  51940. * Sets the Color Grading 2D Lookup Texture.
  51941. */
  51942. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51943. /**
  51944. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51945. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51946. * 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;
  51947. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51948. */
  51949. get cameraColorCurves(): Nullable<ColorCurves>;
  51950. /**
  51951. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51952. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51953. * 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;
  51954. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51955. */
  51956. set cameraColorCurves(value: Nullable<ColorCurves>);
  51957. /**
  51958. * Instantiates a new PBRMaterial instance.
  51959. *
  51960. * @param name The material name
  51961. * @param scene The scene the material will be use in.
  51962. */
  51963. constructor(name: string, scene: Scene);
  51964. /**
  51965. * Returns the name of this material class.
  51966. */
  51967. getClassName(): string;
  51968. /**
  51969. * Makes a duplicate of the current material.
  51970. * @param name - name to use for the new material.
  51971. */
  51972. clone(name: string): PBRMaterial;
  51973. /**
  51974. * Serializes this PBR Material.
  51975. * @returns - An object with the serialized material.
  51976. */
  51977. serialize(): any;
  51978. /**
  51979. * Parses a PBR Material from a serialized object.
  51980. * @param source - Serialized object.
  51981. * @param scene - BJS scene instance.
  51982. * @param rootUrl - url for the scene object
  51983. * @returns - PBRMaterial
  51984. */
  51985. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51986. }
  51987. }
  51988. declare module BABYLON {
  51989. /**
  51990. * Direct draw surface info
  51991. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51992. */
  51993. export interface DDSInfo {
  51994. /**
  51995. * Width of the texture
  51996. */
  51997. width: number;
  51998. /**
  51999. * Width of the texture
  52000. */
  52001. height: number;
  52002. /**
  52003. * Number of Mipmaps for the texture
  52004. * @see https://en.wikipedia.org/wiki/Mipmap
  52005. */
  52006. mipmapCount: number;
  52007. /**
  52008. * If the textures format is a known fourCC format
  52009. * @see https://www.fourcc.org/
  52010. */
  52011. isFourCC: boolean;
  52012. /**
  52013. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52014. */
  52015. isRGB: boolean;
  52016. /**
  52017. * If the texture is a lumincance format
  52018. */
  52019. isLuminance: boolean;
  52020. /**
  52021. * If this is a cube texture
  52022. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52023. */
  52024. isCube: boolean;
  52025. /**
  52026. * If the texture is a compressed format eg. FOURCC_DXT1
  52027. */
  52028. isCompressed: boolean;
  52029. /**
  52030. * The dxgiFormat of the texture
  52031. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52032. */
  52033. dxgiFormat: number;
  52034. /**
  52035. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52036. */
  52037. textureType: number;
  52038. /**
  52039. * Sphericle polynomial created for the dds texture
  52040. */
  52041. sphericalPolynomial?: SphericalPolynomial;
  52042. }
  52043. /**
  52044. * Class used to provide DDS decompression tools
  52045. */
  52046. export class DDSTools {
  52047. /**
  52048. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52049. */
  52050. static StoreLODInAlphaChannel: boolean;
  52051. /**
  52052. * Gets DDS information from an array buffer
  52053. * @param data defines the array buffer view to read data from
  52054. * @returns the DDS information
  52055. */
  52056. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52057. private static _FloatView;
  52058. private static _Int32View;
  52059. private static _ToHalfFloat;
  52060. private static _FromHalfFloat;
  52061. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52062. private static _GetHalfFloatRGBAArrayBuffer;
  52063. private static _GetFloatRGBAArrayBuffer;
  52064. private static _GetFloatAsUIntRGBAArrayBuffer;
  52065. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52066. private static _GetRGBAArrayBuffer;
  52067. private static _ExtractLongWordOrder;
  52068. private static _GetRGBArrayBuffer;
  52069. private static _GetLuminanceArrayBuffer;
  52070. /**
  52071. * Uploads DDS Levels to a Babylon Texture
  52072. * @hidden
  52073. */
  52074. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52075. }
  52076. interface ThinEngine {
  52077. /**
  52078. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52079. * @param rootUrl defines the url where the file to load is located
  52080. * @param scene defines the current scene
  52081. * @param lodScale defines scale to apply to the mip map selection
  52082. * @param lodOffset defines offset to apply to the mip map selection
  52083. * @param onLoad defines an optional callback raised when the texture is loaded
  52084. * @param onError defines an optional callback raised if there is an issue to load the texture
  52085. * @param format defines the format of the data
  52086. * @param forcedExtension defines the extension to use to pick the right loader
  52087. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52088. * @returns the cube texture as an InternalTexture
  52089. */
  52090. 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;
  52091. }
  52092. }
  52093. declare module BABYLON {
  52094. /**
  52095. * Implementation of the DDS Texture Loader.
  52096. * @hidden
  52097. */
  52098. export class _DDSTextureLoader implements IInternalTextureLoader {
  52099. /**
  52100. * Defines wether the loader supports cascade loading the different faces.
  52101. */
  52102. readonly supportCascades: boolean;
  52103. /**
  52104. * This returns if the loader support the current file information.
  52105. * @param extension defines the file extension of the file being loaded
  52106. * @returns true if the loader can load the specified file
  52107. */
  52108. canLoad(extension: string): boolean;
  52109. /**
  52110. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52111. * @param data contains the texture data
  52112. * @param texture defines the BabylonJS internal texture
  52113. * @param createPolynomials will be true if polynomials have been requested
  52114. * @param onLoad defines the callback to trigger once the texture is ready
  52115. * @param onError defines the callback to trigger in case of error
  52116. */
  52117. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52118. /**
  52119. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52120. * @param data contains the texture data
  52121. * @param texture defines the BabylonJS internal texture
  52122. * @param callback defines the method to call once ready to upload
  52123. */
  52124. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52125. }
  52126. }
  52127. declare module BABYLON {
  52128. /**
  52129. * Implementation of the ENV Texture Loader.
  52130. * @hidden
  52131. */
  52132. export class _ENVTextureLoader implements IInternalTextureLoader {
  52133. /**
  52134. * Defines wether the loader supports cascade loading the different faces.
  52135. */
  52136. readonly supportCascades: boolean;
  52137. /**
  52138. * This returns if the loader support the current file information.
  52139. * @param extension defines the file extension of the file being loaded
  52140. * @returns true if the loader can load the specified file
  52141. */
  52142. canLoad(extension: string): boolean;
  52143. /**
  52144. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52145. * @param data contains the texture data
  52146. * @param texture defines the BabylonJS internal texture
  52147. * @param createPolynomials will be true if polynomials have been requested
  52148. * @param onLoad defines the callback to trigger once the texture is ready
  52149. * @param onError defines the callback to trigger in case of error
  52150. */
  52151. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52152. /**
  52153. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52154. * @param data contains the texture data
  52155. * @param texture defines the BabylonJS internal texture
  52156. * @param callback defines the method to call once ready to upload
  52157. */
  52158. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52159. }
  52160. }
  52161. declare module BABYLON {
  52162. /**
  52163. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52164. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52165. */
  52166. export class KhronosTextureContainer {
  52167. /** contents of the KTX container file */
  52168. data: ArrayBufferView;
  52169. private static HEADER_LEN;
  52170. private static COMPRESSED_2D;
  52171. private static COMPRESSED_3D;
  52172. private static TEX_2D;
  52173. private static TEX_3D;
  52174. /**
  52175. * Gets the openGL type
  52176. */
  52177. glType: number;
  52178. /**
  52179. * Gets the openGL type size
  52180. */
  52181. glTypeSize: number;
  52182. /**
  52183. * Gets the openGL format
  52184. */
  52185. glFormat: number;
  52186. /**
  52187. * Gets the openGL internal format
  52188. */
  52189. glInternalFormat: number;
  52190. /**
  52191. * Gets the base internal format
  52192. */
  52193. glBaseInternalFormat: number;
  52194. /**
  52195. * Gets image width in pixel
  52196. */
  52197. pixelWidth: number;
  52198. /**
  52199. * Gets image height in pixel
  52200. */
  52201. pixelHeight: number;
  52202. /**
  52203. * Gets image depth in pixels
  52204. */
  52205. pixelDepth: number;
  52206. /**
  52207. * Gets the number of array elements
  52208. */
  52209. numberOfArrayElements: number;
  52210. /**
  52211. * Gets the number of faces
  52212. */
  52213. numberOfFaces: number;
  52214. /**
  52215. * Gets the number of mipmap levels
  52216. */
  52217. numberOfMipmapLevels: number;
  52218. /**
  52219. * Gets the bytes of key value data
  52220. */
  52221. bytesOfKeyValueData: number;
  52222. /**
  52223. * Gets the load type
  52224. */
  52225. loadType: number;
  52226. /**
  52227. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52228. */
  52229. isInvalid: boolean;
  52230. /**
  52231. * Creates a new KhronosTextureContainer
  52232. * @param data contents of the KTX container file
  52233. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52234. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52235. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52236. */
  52237. constructor(
  52238. /** contents of the KTX container file */
  52239. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52240. /**
  52241. * Uploads KTX content to a Babylon Texture.
  52242. * It is assumed that the texture has already been created & is currently bound
  52243. * @hidden
  52244. */
  52245. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52246. private _upload2DCompressedLevels;
  52247. /**
  52248. * Checks if the given data starts with a KTX file identifier.
  52249. * @param data the data to check
  52250. * @returns true if the data is a KTX file or false otherwise
  52251. */
  52252. static IsValid(data: ArrayBufferView): boolean;
  52253. }
  52254. }
  52255. declare module BABYLON {
  52256. /**
  52257. * Class for loading KTX2 files
  52258. * !!! Experimental Extension Subject to Changes !!!
  52259. * @hidden
  52260. */
  52261. export class KhronosTextureContainer2 {
  52262. private static _ModulePromise;
  52263. private static _TranscodeFormat;
  52264. constructor(engine: ThinEngine);
  52265. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52266. private _determineTranscodeFormat;
  52267. /**
  52268. * Checks if the given data starts with a KTX2 file identifier.
  52269. * @param data the data to check
  52270. * @returns true if the data is a KTX2 file or false otherwise
  52271. */
  52272. static IsValid(data: ArrayBufferView): boolean;
  52273. }
  52274. }
  52275. declare module BABYLON {
  52276. /**
  52277. * Implementation of the KTX Texture Loader.
  52278. * @hidden
  52279. */
  52280. export class _KTXTextureLoader implements IInternalTextureLoader {
  52281. /**
  52282. * Defines wether the loader supports cascade loading the different faces.
  52283. */
  52284. readonly supportCascades: boolean;
  52285. /**
  52286. * This returns if the loader support the current file information.
  52287. * @param extension defines the file extension of the file being loaded
  52288. * @returns true if the loader can load the specified file
  52289. */
  52290. canLoad(extension: string): boolean;
  52291. /**
  52292. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52293. * @param data contains the texture data
  52294. * @param texture defines the BabylonJS internal texture
  52295. * @param createPolynomials will be true if polynomials have been requested
  52296. * @param onLoad defines the callback to trigger once the texture is ready
  52297. * @param onError defines the callback to trigger in case of error
  52298. */
  52299. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52300. /**
  52301. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52302. * @param data contains the texture data
  52303. * @param texture defines the BabylonJS internal texture
  52304. * @param callback defines the method to call once ready to upload
  52305. */
  52306. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52307. }
  52308. }
  52309. declare module BABYLON {
  52310. /** @hidden */
  52311. export var _forceSceneHelpersToBundle: boolean;
  52312. interface Scene {
  52313. /**
  52314. * Creates a default light for the scene.
  52315. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52316. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52317. */
  52318. createDefaultLight(replace?: boolean): void;
  52319. /**
  52320. * Creates a default camera for the scene.
  52321. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52322. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52323. * @param replace has default false, when true replaces the active camera in the scene
  52324. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52325. */
  52326. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52327. /**
  52328. * Creates a default camera and a default light.
  52329. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52330. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52331. * @param replace has the default false, when true replaces the active camera/light in the scene
  52332. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52333. */
  52334. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52335. /**
  52336. * Creates a new sky box
  52337. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52338. * @param environmentTexture defines the texture to use as environment texture
  52339. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52340. * @param scale defines the overall scale of the skybox
  52341. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52342. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52343. * @returns a new mesh holding the sky box
  52344. */
  52345. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52346. /**
  52347. * Creates a new environment
  52348. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52349. * @param options defines the options you can use to configure the environment
  52350. * @returns the new EnvironmentHelper
  52351. */
  52352. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52353. /**
  52354. * Creates a new VREXperienceHelper
  52355. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52356. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52357. * @returns a new VREXperienceHelper
  52358. */
  52359. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52360. /**
  52361. * Creates a new WebXRDefaultExperience
  52362. * @see http://doc.babylonjs.com/how_to/webxr
  52363. * @param options experience options
  52364. * @returns a promise for a new WebXRDefaultExperience
  52365. */
  52366. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52367. }
  52368. }
  52369. declare module BABYLON {
  52370. /**
  52371. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52372. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52373. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52374. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52375. */
  52376. export class VideoDome extends TransformNode {
  52377. /**
  52378. * Define the video source as a Monoscopic panoramic 360 video.
  52379. */
  52380. static readonly MODE_MONOSCOPIC: number;
  52381. /**
  52382. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52383. */
  52384. static readonly MODE_TOPBOTTOM: number;
  52385. /**
  52386. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52387. */
  52388. static readonly MODE_SIDEBYSIDE: number;
  52389. private _halfDome;
  52390. private _useDirectMapping;
  52391. /**
  52392. * The video texture being displayed on the sphere
  52393. */
  52394. protected _videoTexture: VideoTexture;
  52395. /**
  52396. * Gets the video texture being displayed on the sphere
  52397. */
  52398. get videoTexture(): VideoTexture;
  52399. /**
  52400. * The skybox material
  52401. */
  52402. protected _material: BackgroundMaterial;
  52403. /**
  52404. * The surface used for the skybox
  52405. */
  52406. protected _mesh: Mesh;
  52407. /**
  52408. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52409. */
  52410. private _halfDomeMask;
  52411. /**
  52412. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52413. * Also see the options.resolution property.
  52414. */
  52415. get fovMultiplier(): number;
  52416. set fovMultiplier(value: number);
  52417. private _videoMode;
  52418. /**
  52419. * Gets or set the current video mode for the video. It can be:
  52420. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52421. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52422. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52423. */
  52424. get videoMode(): number;
  52425. set videoMode(value: number);
  52426. /**
  52427. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52428. *
  52429. */
  52430. get halfDome(): boolean;
  52431. /**
  52432. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52433. */
  52434. set halfDome(enabled: boolean);
  52435. /**
  52436. * Oberserver used in Stereoscopic VR Mode.
  52437. */
  52438. private _onBeforeCameraRenderObserver;
  52439. /**
  52440. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52441. * @param name Element's name, child elements will append suffixes for their own names.
  52442. * @param urlsOrVideo defines the url(s) or the video element to use
  52443. * @param options An object containing optional or exposed sub element properties
  52444. */
  52445. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52446. resolution?: number;
  52447. clickToPlay?: boolean;
  52448. autoPlay?: boolean;
  52449. loop?: boolean;
  52450. size?: number;
  52451. poster?: string;
  52452. faceForward?: boolean;
  52453. useDirectMapping?: boolean;
  52454. halfDomeMode?: boolean;
  52455. }, scene: Scene);
  52456. private _changeVideoMode;
  52457. /**
  52458. * Releases resources associated with this node.
  52459. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52460. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52461. */
  52462. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52463. }
  52464. }
  52465. declare module BABYLON {
  52466. /**
  52467. * This class can be used to get instrumentation data from a Babylon engine
  52468. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52469. */
  52470. export class EngineInstrumentation implements IDisposable {
  52471. /**
  52472. * Define the instrumented engine.
  52473. */
  52474. engine: Engine;
  52475. private _captureGPUFrameTime;
  52476. private _gpuFrameTimeToken;
  52477. private _gpuFrameTime;
  52478. private _captureShaderCompilationTime;
  52479. private _shaderCompilationTime;
  52480. private _onBeginFrameObserver;
  52481. private _onEndFrameObserver;
  52482. private _onBeforeShaderCompilationObserver;
  52483. private _onAfterShaderCompilationObserver;
  52484. /**
  52485. * Gets the perf counter used for GPU frame time
  52486. */
  52487. get gpuFrameTimeCounter(): PerfCounter;
  52488. /**
  52489. * Gets the GPU frame time capture status
  52490. */
  52491. get captureGPUFrameTime(): boolean;
  52492. /**
  52493. * Enable or disable the GPU frame time capture
  52494. */
  52495. set captureGPUFrameTime(value: boolean);
  52496. /**
  52497. * Gets the perf counter used for shader compilation time
  52498. */
  52499. get shaderCompilationTimeCounter(): PerfCounter;
  52500. /**
  52501. * Gets the shader compilation time capture status
  52502. */
  52503. get captureShaderCompilationTime(): boolean;
  52504. /**
  52505. * Enable or disable the shader compilation time capture
  52506. */
  52507. set captureShaderCompilationTime(value: boolean);
  52508. /**
  52509. * Instantiates a new engine instrumentation.
  52510. * This class can be used to get instrumentation data from a Babylon engine
  52511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52512. * @param engine Defines the engine to instrument
  52513. */
  52514. constructor(
  52515. /**
  52516. * Define the instrumented engine.
  52517. */
  52518. engine: Engine);
  52519. /**
  52520. * Dispose and release associated resources.
  52521. */
  52522. dispose(): void;
  52523. }
  52524. }
  52525. declare module BABYLON {
  52526. /**
  52527. * This class can be used to get instrumentation data from a Babylon engine
  52528. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52529. */
  52530. export class SceneInstrumentation implements IDisposable {
  52531. /**
  52532. * Defines the scene to instrument
  52533. */
  52534. scene: Scene;
  52535. private _captureActiveMeshesEvaluationTime;
  52536. private _activeMeshesEvaluationTime;
  52537. private _captureRenderTargetsRenderTime;
  52538. private _renderTargetsRenderTime;
  52539. private _captureFrameTime;
  52540. private _frameTime;
  52541. private _captureRenderTime;
  52542. private _renderTime;
  52543. private _captureInterFrameTime;
  52544. private _interFrameTime;
  52545. private _captureParticlesRenderTime;
  52546. private _particlesRenderTime;
  52547. private _captureSpritesRenderTime;
  52548. private _spritesRenderTime;
  52549. private _capturePhysicsTime;
  52550. private _physicsTime;
  52551. private _captureAnimationsTime;
  52552. private _animationsTime;
  52553. private _captureCameraRenderTime;
  52554. private _cameraRenderTime;
  52555. private _onBeforeActiveMeshesEvaluationObserver;
  52556. private _onAfterActiveMeshesEvaluationObserver;
  52557. private _onBeforeRenderTargetsRenderObserver;
  52558. private _onAfterRenderTargetsRenderObserver;
  52559. private _onAfterRenderObserver;
  52560. private _onBeforeDrawPhaseObserver;
  52561. private _onAfterDrawPhaseObserver;
  52562. private _onBeforeAnimationsObserver;
  52563. private _onBeforeParticlesRenderingObserver;
  52564. private _onAfterParticlesRenderingObserver;
  52565. private _onBeforeSpritesRenderingObserver;
  52566. private _onAfterSpritesRenderingObserver;
  52567. private _onBeforePhysicsObserver;
  52568. private _onAfterPhysicsObserver;
  52569. private _onAfterAnimationsObserver;
  52570. private _onBeforeCameraRenderObserver;
  52571. private _onAfterCameraRenderObserver;
  52572. /**
  52573. * Gets the perf counter used for active meshes evaluation time
  52574. */
  52575. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52576. /**
  52577. * Gets the active meshes evaluation time capture status
  52578. */
  52579. get captureActiveMeshesEvaluationTime(): boolean;
  52580. /**
  52581. * Enable or disable the active meshes evaluation time capture
  52582. */
  52583. set captureActiveMeshesEvaluationTime(value: boolean);
  52584. /**
  52585. * Gets the perf counter used for render targets render time
  52586. */
  52587. get renderTargetsRenderTimeCounter(): PerfCounter;
  52588. /**
  52589. * Gets the render targets render time capture status
  52590. */
  52591. get captureRenderTargetsRenderTime(): boolean;
  52592. /**
  52593. * Enable or disable the render targets render time capture
  52594. */
  52595. set captureRenderTargetsRenderTime(value: boolean);
  52596. /**
  52597. * Gets the perf counter used for particles render time
  52598. */
  52599. get particlesRenderTimeCounter(): PerfCounter;
  52600. /**
  52601. * Gets the particles render time capture status
  52602. */
  52603. get captureParticlesRenderTime(): boolean;
  52604. /**
  52605. * Enable or disable the particles render time capture
  52606. */
  52607. set captureParticlesRenderTime(value: boolean);
  52608. /**
  52609. * Gets the perf counter used for sprites render time
  52610. */
  52611. get spritesRenderTimeCounter(): PerfCounter;
  52612. /**
  52613. * Gets the sprites render time capture status
  52614. */
  52615. get captureSpritesRenderTime(): boolean;
  52616. /**
  52617. * Enable or disable the sprites render time capture
  52618. */
  52619. set captureSpritesRenderTime(value: boolean);
  52620. /**
  52621. * Gets the perf counter used for physics time
  52622. */
  52623. get physicsTimeCounter(): PerfCounter;
  52624. /**
  52625. * Gets the physics time capture status
  52626. */
  52627. get capturePhysicsTime(): boolean;
  52628. /**
  52629. * Enable or disable the physics time capture
  52630. */
  52631. set capturePhysicsTime(value: boolean);
  52632. /**
  52633. * Gets the perf counter used for animations time
  52634. */
  52635. get animationsTimeCounter(): PerfCounter;
  52636. /**
  52637. * Gets the animations time capture status
  52638. */
  52639. get captureAnimationsTime(): boolean;
  52640. /**
  52641. * Enable or disable the animations time capture
  52642. */
  52643. set captureAnimationsTime(value: boolean);
  52644. /**
  52645. * Gets the perf counter used for frame time capture
  52646. */
  52647. get frameTimeCounter(): PerfCounter;
  52648. /**
  52649. * Gets the frame time capture status
  52650. */
  52651. get captureFrameTime(): boolean;
  52652. /**
  52653. * Enable or disable the frame time capture
  52654. */
  52655. set captureFrameTime(value: boolean);
  52656. /**
  52657. * Gets the perf counter used for inter-frames time capture
  52658. */
  52659. get interFrameTimeCounter(): PerfCounter;
  52660. /**
  52661. * Gets the inter-frames time capture status
  52662. */
  52663. get captureInterFrameTime(): boolean;
  52664. /**
  52665. * Enable or disable the inter-frames time capture
  52666. */
  52667. set captureInterFrameTime(value: boolean);
  52668. /**
  52669. * Gets the perf counter used for render time capture
  52670. */
  52671. get renderTimeCounter(): PerfCounter;
  52672. /**
  52673. * Gets the render time capture status
  52674. */
  52675. get captureRenderTime(): boolean;
  52676. /**
  52677. * Enable or disable the render time capture
  52678. */
  52679. set captureRenderTime(value: boolean);
  52680. /**
  52681. * Gets the perf counter used for camera render time capture
  52682. */
  52683. get cameraRenderTimeCounter(): PerfCounter;
  52684. /**
  52685. * Gets the camera render time capture status
  52686. */
  52687. get captureCameraRenderTime(): boolean;
  52688. /**
  52689. * Enable or disable the camera render time capture
  52690. */
  52691. set captureCameraRenderTime(value: boolean);
  52692. /**
  52693. * Gets the perf counter used for draw calls
  52694. */
  52695. get drawCallsCounter(): PerfCounter;
  52696. /**
  52697. * Instantiates a new scene instrumentation.
  52698. * This class can be used to get instrumentation data from a Babylon engine
  52699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52700. * @param scene Defines the scene to instrument
  52701. */
  52702. constructor(
  52703. /**
  52704. * Defines the scene to instrument
  52705. */
  52706. scene: Scene);
  52707. /**
  52708. * Dispose and release associated resources.
  52709. */
  52710. dispose(): void;
  52711. }
  52712. }
  52713. declare module BABYLON {
  52714. /** @hidden */
  52715. export var glowMapGenerationPixelShader: {
  52716. name: string;
  52717. shader: string;
  52718. };
  52719. }
  52720. declare module BABYLON {
  52721. /** @hidden */
  52722. export var glowMapGenerationVertexShader: {
  52723. name: string;
  52724. shader: string;
  52725. };
  52726. }
  52727. declare module BABYLON {
  52728. /**
  52729. * Effect layer options. This helps customizing the behaviour
  52730. * of the effect layer.
  52731. */
  52732. export interface IEffectLayerOptions {
  52733. /**
  52734. * Multiplication factor apply to the canvas size to compute the render target size
  52735. * used to generated the objects (the smaller the faster).
  52736. */
  52737. mainTextureRatio: number;
  52738. /**
  52739. * Enforces a fixed size texture to ensure effect stability across devices.
  52740. */
  52741. mainTextureFixedSize?: number;
  52742. /**
  52743. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52744. */
  52745. alphaBlendingMode: number;
  52746. /**
  52747. * The camera attached to the layer.
  52748. */
  52749. camera: Nullable<Camera>;
  52750. /**
  52751. * The rendering group to draw the layer in.
  52752. */
  52753. renderingGroupId: number;
  52754. }
  52755. /**
  52756. * The effect layer Helps adding post process effect blended with the main pass.
  52757. *
  52758. * This can be for instance use to generate glow or higlight effects on the scene.
  52759. *
  52760. * The effect layer class can not be used directly and is intented to inherited from to be
  52761. * customized per effects.
  52762. */
  52763. export abstract class EffectLayer {
  52764. private _vertexBuffers;
  52765. private _indexBuffer;
  52766. private _cachedDefines;
  52767. private _effectLayerMapGenerationEffect;
  52768. private _effectLayerOptions;
  52769. private _mergeEffect;
  52770. protected _scene: Scene;
  52771. protected _engine: Engine;
  52772. protected _maxSize: number;
  52773. protected _mainTextureDesiredSize: ISize;
  52774. protected _mainTexture: RenderTargetTexture;
  52775. protected _shouldRender: boolean;
  52776. protected _postProcesses: PostProcess[];
  52777. protected _textures: BaseTexture[];
  52778. protected _emissiveTextureAndColor: {
  52779. texture: Nullable<BaseTexture>;
  52780. color: Color4;
  52781. };
  52782. /**
  52783. * The name of the layer
  52784. */
  52785. name: string;
  52786. /**
  52787. * The clear color of the texture used to generate the glow map.
  52788. */
  52789. neutralColor: Color4;
  52790. /**
  52791. * Specifies whether the highlight layer is enabled or not.
  52792. */
  52793. isEnabled: boolean;
  52794. /**
  52795. * Gets the camera attached to the layer.
  52796. */
  52797. get camera(): Nullable<Camera>;
  52798. /**
  52799. * Gets the rendering group id the layer should render in.
  52800. */
  52801. get renderingGroupId(): number;
  52802. set renderingGroupId(renderingGroupId: number);
  52803. /**
  52804. * An event triggered when the effect layer has been disposed.
  52805. */
  52806. onDisposeObservable: Observable<EffectLayer>;
  52807. /**
  52808. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52809. */
  52810. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52811. /**
  52812. * An event triggered when the generated texture is being merged in the scene.
  52813. */
  52814. onBeforeComposeObservable: Observable<EffectLayer>;
  52815. /**
  52816. * An event triggered when the mesh is rendered into the effect render target.
  52817. */
  52818. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52819. /**
  52820. * An event triggered after the mesh has been rendered into the effect render target.
  52821. */
  52822. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52823. /**
  52824. * An event triggered when the generated texture has been merged in the scene.
  52825. */
  52826. onAfterComposeObservable: Observable<EffectLayer>;
  52827. /**
  52828. * An event triggered when the efffect layer changes its size.
  52829. */
  52830. onSizeChangedObservable: Observable<EffectLayer>;
  52831. /** @hidden */
  52832. static _SceneComponentInitialization: (scene: Scene) => void;
  52833. /**
  52834. * Instantiates a new effect Layer and references it in the scene.
  52835. * @param name The name of the layer
  52836. * @param scene The scene to use the layer in
  52837. */
  52838. constructor(
  52839. /** The Friendly of the effect in the scene */
  52840. name: string, scene: Scene);
  52841. /**
  52842. * Get the effect name of the layer.
  52843. * @return The effect name
  52844. */
  52845. abstract getEffectName(): string;
  52846. /**
  52847. * Checks for the readiness of the element composing the layer.
  52848. * @param subMesh the mesh to check for
  52849. * @param useInstances specify whether or not to use instances to render the mesh
  52850. * @return true if ready otherwise, false
  52851. */
  52852. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52853. /**
  52854. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  52855. * @returns true if the effect requires stencil during the main canvas render pass.
  52856. */
  52857. abstract needStencil(): boolean;
  52858. /**
  52859. * Create the merge effect. This is the shader use to blit the information back
  52860. * to the main canvas at the end of the scene rendering.
  52861. * @returns The effect containing the shader used to merge the effect on the main canvas
  52862. */
  52863. protected abstract _createMergeEffect(): Effect;
  52864. /**
  52865. * Creates the render target textures and post processes used in the effect layer.
  52866. */
  52867. protected abstract _createTextureAndPostProcesses(): void;
  52868. /**
  52869. * Implementation specific of rendering the generating effect on the main canvas.
  52870. * @param effect The effect used to render through
  52871. */
  52872. protected abstract _internalRender(effect: Effect): void;
  52873. /**
  52874. * Sets the required values for both the emissive texture and and the main color.
  52875. */
  52876. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52877. /**
  52878. * Free any resources and references associated to a mesh.
  52879. * Internal use
  52880. * @param mesh The mesh to free.
  52881. */
  52882. abstract _disposeMesh(mesh: Mesh): void;
  52883. /**
  52884. * Serializes this layer (Glow or Highlight for example)
  52885. * @returns a serialized layer object
  52886. */
  52887. abstract serialize?(): any;
  52888. /**
  52889. * Initializes the effect layer with the required options.
  52890. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52891. */
  52892. protected _init(options: Partial<IEffectLayerOptions>): void;
  52893. /**
  52894. * Generates the index buffer of the full screen quad blending to the main canvas.
  52895. */
  52896. private _generateIndexBuffer;
  52897. /**
  52898. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52899. */
  52900. private _generateVertexBuffer;
  52901. /**
  52902. * Sets the main texture desired size which is the closest power of two
  52903. * of the engine canvas size.
  52904. */
  52905. private _setMainTextureSize;
  52906. /**
  52907. * Creates the main texture for the effect layer.
  52908. */
  52909. protected _createMainTexture(): void;
  52910. /**
  52911. * Adds specific effects defines.
  52912. * @param defines The defines to add specifics to.
  52913. */
  52914. protected _addCustomEffectDefines(defines: string[]): void;
  52915. /**
  52916. * Checks for the readiness of the element composing the layer.
  52917. * @param subMesh the mesh to check for
  52918. * @param useInstances specify whether or not to use instances to render the mesh
  52919. * @param emissiveTexture the associated emissive texture used to generate the glow
  52920. * @return true if ready otherwise, false
  52921. */
  52922. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52923. /**
  52924. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52925. */
  52926. render(): void;
  52927. /**
  52928. * Determine if a given mesh will be used in the current effect.
  52929. * @param mesh mesh to test
  52930. * @returns true if the mesh will be used
  52931. */
  52932. hasMesh(mesh: AbstractMesh): boolean;
  52933. /**
  52934. * Returns true if the layer contains information to display, otherwise false.
  52935. * @returns true if the glow layer should be rendered
  52936. */
  52937. shouldRender(): boolean;
  52938. /**
  52939. * Returns true if the mesh should render, otherwise false.
  52940. * @param mesh The mesh to render
  52941. * @returns true if it should render otherwise false
  52942. */
  52943. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52944. /**
  52945. * Returns true if the mesh can be rendered, otherwise false.
  52946. * @param mesh The mesh to render
  52947. * @param material The material used on the mesh
  52948. * @returns true if it can be rendered otherwise false
  52949. */
  52950. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52951. /**
  52952. * Returns true if the mesh should render, otherwise false.
  52953. * @param mesh The mesh to render
  52954. * @returns true if it should render otherwise false
  52955. */
  52956. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52957. /**
  52958. * Renders the submesh passed in parameter to the generation map.
  52959. */
  52960. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52961. /**
  52962. * Defines whether the current material of the mesh should be use to render the effect.
  52963. * @param mesh defines the current mesh to render
  52964. */
  52965. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52966. /**
  52967. * Rebuild the required buffers.
  52968. * @hidden Internal use only.
  52969. */
  52970. _rebuild(): void;
  52971. /**
  52972. * Dispose only the render target textures and post process.
  52973. */
  52974. private _disposeTextureAndPostProcesses;
  52975. /**
  52976. * Dispose the highlight layer and free resources.
  52977. */
  52978. dispose(): void;
  52979. /**
  52980. * Gets the class name of the effect layer
  52981. * @returns the string with the class name of the effect layer
  52982. */
  52983. getClassName(): string;
  52984. /**
  52985. * Creates an effect layer from parsed effect layer data
  52986. * @param parsedEffectLayer defines effect layer data
  52987. * @param scene defines the current scene
  52988. * @param rootUrl defines the root URL containing the effect layer information
  52989. * @returns a parsed effect Layer
  52990. */
  52991. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52992. }
  52993. }
  52994. declare module BABYLON {
  52995. interface AbstractScene {
  52996. /**
  52997. * The list of effect layers (highlights/glow) added to the scene
  52998. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52999. * @see http://doc.babylonjs.com/how_to/glow_layer
  53000. */
  53001. effectLayers: Array<EffectLayer>;
  53002. /**
  53003. * Removes the given effect layer from this scene.
  53004. * @param toRemove defines the effect layer to remove
  53005. * @returns the index of the removed effect layer
  53006. */
  53007. removeEffectLayer(toRemove: EffectLayer): number;
  53008. /**
  53009. * Adds the given effect layer to this scene
  53010. * @param newEffectLayer defines the effect layer to add
  53011. */
  53012. addEffectLayer(newEffectLayer: EffectLayer): void;
  53013. }
  53014. /**
  53015. * Defines the layer scene component responsible to manage any effect layers
  53016. * in a given scene.
  53017. */
  53018. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53019. /**
  53020. * The component name helpfull to identify the component in the list of scene components.
  53021. */
  53022. readonly name: string;
  53023. /**
  53024. * The scene the component belongs to.
  53025. */
  53026. scene: Scene;
  53027. private _engine;
  53028. private _renderEffects;
  53029. private _needStencil;
  53030. private _previousStencilState;
  53031. /**
  53032. * Creates a new instance of the component for the given scene
  53033. * @param scene Defines the scene to register the component in
  53034. */
  53035. constructor(scene: Scene);
  53036. /**
  53037. * Registers the component in a given scene
  53038. */
  53039. register(): void;
  53040. /**
  53041. * Rebuilds the elements related to this component in case of
  53042. * context lost for instance.
  53043. */
  53044. rebuild(): void;
  53045. /**
  53046. * Serializes the component data to the specified json object
  53047. * @param serializationObject The object to serialize to
  53048. */
  53049. serialize(serializationObject: any): void;
  53050. /**
  53051. * Adds all the elements from the container to the scene
  53052. * @param container the container holding the elements
  53053. */
  53054. addFromContainer(container: AbstractScene): void;
  53055. /**
  53056. * Removes all the elements in the container from the scene
  53057. * @param container contains the elements to remove
  53058. * @param dispose if the removed element should be disposed (default: false)
  53059. */
  53060. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53061. /**
  53062. * Disposes the component and the associated ressources.
  53063. */
  53064. dispose(): void;
  53065. private _isReadyForMesh;
  53066. private _renderMainTexture;
  53067. private _setStencil;
  53068. private _setStencilBack;
  53069. private _draw;
  53070. private _drawCamera;
  53071. private _drawRenderingGroup;
  53072. }
  53073. }
  53074. declare module BABYLON {
  53075. /** @hidden */
  53076. export var glowMapMergePixelShader: {
  53077. name: string;
  53078. shader: string;
  53079. };
  53080. }
  53081. declare module BABYLON {
  53082. /** @hidden */
  53083. export var glowMapMergeVertexShader: {
  53084. name: string;
  53085. shader: string;
  53086. };
  53087. }
  53088. declare module BABYLON {
  53089. interface AbstractScene {
  53090. /**
  53091. * Return a the first highlight layer of the scene with a given name.
  53092. * @param name The name of the highlight layer to look for.
  53093. * @return The highlight layer if found otherwise null.
  53094. */
  53095. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53096. }
  53097. /**
  53098. * Glow layer options. This helps customizing the behaviour
  53099. * of the glow layer.
  53100. */
  53101. export interface IGlowLayerOptions {
  53102. /**
  53103. * Multiplication factor apply to the canvas size to compute the render target size
  53104. * used to generated the glowing objects (the smaller the faster).
  53105. */
  53106. mainTextureRatio: number;
  53107. /**
  53108. * Enforces a fixed size texture to ensure resize independant blur.
  53109. */
  53110. mainTextureFixedSize?: number;
  53111. /**
  53112. * How big is the kernel of the blur texture.
  53113. */
  53114. blurKernelSize: number;
  53115. /**
  53116. * The camera attached to the layer.
  53117. */
  53118. camera: Nullable<Camera>;
  53119. /**
  53120. * Enable MSAA by chosing the number of samples.
  53121. */
  53122. mainTextureSamples?: number;
  53123. /**
  53124. * The rendering group to draw the layer in.
  53125. */
  53126. renderingGroupId: number;
  53127. }
  53128. /**
  53129. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53130. *
  53131. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53132. *
  53133. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53134. */
  53135. export class GlowLayer extends EffectLayer {
  53136. /**
  53137. * Effect Name of the layer.
  53138. */
  53139. static readonly EffectName: string;
  53140. /**
  53141. * The default blur kernel size used for the glow.
  53142. */
  53143. static DefaultBlurKernelSize: number;
  53144. /**
  53145. * The default texture size ratio used for the glow.
  53146. */
  53147. static DefaultTextureRatio: number;
  53148. /**
  53149. * Sets the kernel size of the blur.
  53150. */
  53151. set blurKernelSize(value: number);
  53152. /**
  53153. * Gets the kernel size of the blur.
  53154. */
  53155. get blurKernelSize(): number;
  53156. /**
  53157. * Sets the glow intensity.
  53158. */
  53159. set intensity(value: number);
  53160. /**
  53161. * Gets the glow intensity.
  53162. */
  53163. get intensity(): number;
  53164. private _options;
  53165. private _intensity;
  53166. private _horizontalBlurPostprocess1;
  53167. private _verticalBlurPostprocess1;
  53168. private _horizontalBlurPostprocess2;
  53169. private _verticalBlurPostprocess2;
  53170. private _blurTexture1;
  53171. private _blurTexture2;
  53172. private _postProcesses1;
  53173. private _postProcesses2;
  53174. private _includedOnlyMeshes;
  53175. private _excludedMeshes;
  53176. private _meshesUsingTheirOwnMaterials;
  53177. /**
  53178. * Callback used to let the user override the color selection on a per mesh basis
  53179. */
  53180. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53181. /**
  53182. * Callback used to let the user override the texture selection on a per mesh basis
  53183. */
  53184. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53185. /**
  53186. * Instantiates a new glow Layer and references it to the scene.
  53187. * @param name The name of the layer
  53188. * @param scene The scene to use the layer in
  53189. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53190. */
  53191. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53192. /**
  53193. * Get the effect name of the layer.
  53194. * @return The effect name
  53195. */
  53196. getEffectName(): string;
  53197. /**
  53198. * Create the merge effect. This is the shader use to blit the information back
  53199. * to the main canvas at the end of the scene rendering.
  53200. */
  53201. protected _createMergeEffect(): Effect;
  53202. /**
  53203. * Creates the render target textures and post processes used in the glow layer.
  53204. */
  53205. protected _createTextureAndPostProcesses(): void;
  53206. /**
  53207. * Checks for the readiness of the element composing the layer.
  53208. * @param subMesh the mesh to check for
  53209. * @param useInstances specify wether or not to use instances to render the mesh
  53210. * @param emissiveTexture the associated emissive texture used to generate the glow
  53211. * @return true if ready otherwise, false
  53212. */
  53213. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53214. /**
  53215. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53216. */
  53217. needStencil(): boolean;
  53218. /**
  53219. * Returns true if the mesh can be rendered, otherwise false.
  53220. * @param mesh The mesh to render
  53221. * @param material The material used on the mesh
  53222. * @returns true if it can be rendered otherwise false
  53223. */
  53224. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53225. /**
  53226. * Implementation specific of rendering the generating effect on the main canvas.
  53227. * @param effect The effect used to render through
  53228. */
  53229. protected _internalRender(effect: Effect): void;
  53230. /**
  53231. * Sets the required values for both the emissive texture and and the main color.
  53232. */
  53233. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53234. /**
  53235. * Returns true if the mesh should render, otherwise false.
  53236. * @param mesh The mesh to render
  53237. * @returns true if it should render otherwise false
  53238. */
  53239. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53240. /**
  53241. * Adds specific effects defines.
  53242. * @param defines The defines to add specifics to.
  53243. */
  53244. protected _addCustomEffectDefines(defines: string[]): void;
  53245. /**
  53246. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53247. * @param mesh The mesh to exclude from the glow layer
  53248. */
  53249. addExcludedMesh(mesh: Mesh): void;
  53250. /**
  53251. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53252. * @param mesh The mesh to remove
  53253. */
  53254. removeExcludedMesh(mesh: Mesh): void;
  53255. /**
  53256. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53257. * @param mesh The mesh to include in the glow layer
  53258. */
  53259. addIncludedOnlyMesh(mesh: Mesh): void;
  53260. /**
  53261. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53262. * @param mesh The mesh to remove
  53263. */
  53264. removeIncludedOnlyMesh(mesh: Mesh): void;
  53265. /**
  53266. * Determine if a given mesh will be used in the glow layer
  53267. * @param mesh The mesh to test
  53268. * @returns true if the mesh will be highlighted by the current glow layer
  53269. */
  53270. hasMesh(mesh: AbstractMesh): boolean;
  53271. /**
  53272. * Defines whether the current material of the mesh should be use to render the effect.
  53273. * @param mesh defines the current mesh to render
  53274. */
  53275. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53276. /**
  53277. * Add a mesh to be rendered through its own material and not with emissive only.
  53278. * @param mesh The mesh for which we need to use its material
  53279. */
  53280. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53281. /**
  53282. * Remove a mesh from being rendered through its own material and not with emissive only.
  53283. * @param mesh The mesh for which we need to not use its material
  53284. */
  53285. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53286. /**
  53287. * Free any resources and references associated to a mesh.
  53288. * Internal use
  53289. * @param mesh The mesh to free.
  53290. * @hidden
  53291. */
  53292. _disposeMesh(mesh: Mesh): void;
  53293. /**
  53294. * Gets the class name of the effect layer
  53295. * @returns the string with the class name of the effect layer
  53296. */
  53297. getClassName(): string;
  53298. /**
  53299. * Serializes this glow layer
  53300. * @returns a serialized glow layer object
  53301. */
  53302. serialize(): any;
  53303. /**
  53304. * Creates a Glow Layer from parsed glow layer data
  53305. * @param parsedGlowLayer defines glow layer data
  53306. * @param scene defines the current scene
  53307. * @param rootUrl defines the root URL containing the glow layer information
  53308. * @returns a parsed Glow Layer
  53309. */
  53310. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53311. }
  53312. }
  53313. declare module BABYLON {
  53314. /** @hidden */
  53315. export var glowBlurPostProcessPixelShader: {
  53316. name: string;
  53317. shader: string;
  53318. };
  53319. }
  53320. declare module BABYLON {
  53321. interface AbstractScene {
  53322. /**
  53323. * Return a the first highlight layer of the scene with a given name.
  53324. * @param name The name of the highlight layer to look for.
  53325. * @return The highlight layer if found otherwise null.
  53326. */
  53327. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53328. }
  53329. /**
  53330. * Highlight layer options. This helps customizing the behaviour
  53331. * of the highlight layer.
  53332. */
  53333. export interface IHighlightLayerOptions {
  53334. /**
  53335. * Multiplication factor apply to the canvas size to compute the render target size
  53336. * used to generated the glowing objects (the smaller the faster).
  53337. */
  53338. mainTextureRatio: number;
  53339. /**
  53340. * Enforces a fixed size texture to ensure resize independant blur.
  53341. */
  53342. mainTextureFixedSize?: number;
  53343. /**
  53344. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53345. * of the picture to blur (the smaller the faster).
  53346. */
  53347. blurTextureSizeRatio: number;
  53348. /**
  53349. * How big in texel of the blur texture is the vertical blur.
  53350. */
  53351. blurVerticalSize: number;
  53352. /**
  53353. * How big in texel of the blur texture is the horizontal blur.
  53354. */
  53355. blurHorizontalSize: number;
  53356. /**
  53357. * Alpha blending mode used to apply the blur. Default is combine.
  53358. */
  53359. alphaBlendingMode: number;
  53360. /**
  53361. * The camera attached to the layer.
  53362. */
  53363. camera: Nullable<Camera>;
  53364. /**
  53365. * Should we display highlight as a solid stroke?
  53366. */
  53367. isStroke?: boolean;
  53368. /**
  53369. * The rendering group to draw the layer in.
  53370. */
  53371. renderingGroupId: number;
  53372. }
  53373. /**
  53374. * The highlight layer Helps adding a glow effect around a mesh.
  53375. *
  53376. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53377. * glowy meshes to your scene.
  53378. *
  53379. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53380. */
  53381. export class HighlightLayer extends EffectLayer {
  53382. name: string;
  53383. /**
  53384. * Effect Name of the highlight layer.
  53385. */
  53386. static readonly EffectName: string;
  53387. /**
  53388. * The neutral color used during the preparation of the glow effect.
  53389. * This is black by default as the blend operation is a blend operation.
  53390. */
  53391. static NeutralColor: Color4;
  53392. /**
  53393. * Stencil value used for glowing meshes.
  53394. */
  53395. static GlowingMeshStencilReference: number;
  53396. /**
  53397. * Stencil value used for the other meshes in the scene.
  53398. */
  53399. static NormalMeshStencilReference: number;
  53400. /**
  53401. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53402. */
  53403. innerGlow: boolean;
  53404. /**
  53405. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53406. */
  53407. outerGlow: boolean;
  53408. /**
  53409. * Specifies the horizontal size of the blur.
  53410. */
  53411. set blurHorizontalSize(value: number);
  53412. /**
  53413. * Specifies the vertical size of the blur.
  53414. */
  53415. set blurVerticalSize(value: number);
  53416. /**
  53417. * Gets the horizontal size of the blur.
  53418. */
  53419. get blurHorizontalSize(): number;
  53420. /**
  53421. * Gets the vertical size of the blur.
  53422. */
  53423. get blurVerticalSize(): number;
  53424. /**
  53425. * An event triggered when the highlight layer is being blurred.
  53426. */
  53427. onBeforeBlurObservable: Observable<HighlightLayer>;
  53428. /**
  53429. * An event triggered when the highlight layer has been blurred.
  53430. */
  53431. onAfterBlurObservable: Observable<HighlightLayer>;
  53432. private _instanceGlowingMeshStencilReference;
  53433. private _options;
  53434. private _downSamplePostprocess;
  53435. private _horizontalBlurPostprocess;
  53436. private _verticalBlurPostprocess;
  53437. private _blurTexture;
  53438. private _meshes;
  53439. private _excludedMeshes;
  53440. /**
  53441. * Instantiates a new highlight Layer and references it to the scene..
  53442. * @param name The name of the layer
  53443. * @param scene The scene to use the layer in
  53444. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53445. */
  53446. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53447. /**
  53448. * Get the effect name of the layer.
  53449. * @return The effect name
  53450. */
  53451. getEffectName(): string;
  53452. /**
  53453. * Create the merge effect. This is the shader use to blit the information back
  53454. * to the main canvas at the end of the scene rendering.
  53455. */
  53456. protected _createMergeEffect(): Effect;
  53457. /**
  53458. * Creates the render target textures and post processes used in the highlight layer.
  53459. */
  53460. protected _createTextureAndPostProcesses(): void;
  53461. /**
  53462. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53463. */
  53464. needStencil(): boolean;
  53465. /**
  53466. * Checks for the readiness of the element composing the layer.
  53467. * @param subMesh the mesh to check for
  53468. * @param useInstances specify wether or not to use instances to render the mesh
  53469. * @param emissiveTexture the associated emissive texture used to generate the glow
  53470. * @return true if ready otherwise, false
  53471. */
  53472. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53473. /**
  53474. * Implementation specific of rendering the generating effect on the main canvas.
  53475. * @param effect The effect used to render through
  53476. */
  53477. protected _internalRender(effect: Effect): void;
  53478. /**
  53479. * Returns true if the layer contains information to display, otherwise false.
  53480. */
  53481. shouldRender(): boolean;
  53482. /**
  53483. * Returns true if the mesh should render, otherwise false.
  53484. * @param mesh The mesh to render
  53485. * @returns true if it should render otherwise false
  53486. */
  53487. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53488. /**
  53489. * Sets the required values for both the emissive texture and and the main color.
  53490. */
  53491. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53492. /**
  53493. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53494. * @param mesh The mesh to exclude from the highlight layer
  53495. */
  53496. addExcludedMesh(mesh: Mesh): void;
  53497. /**
  53498. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53499. * @param mesh The mesh to highlight
  53500. */
  53501. removeExcludedMesh(mesh: Mesh): void;
  53502. /**
  53503. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53504. * @param mesh mesh to test
  53505. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53506. */
  53507. hasMesh(mesh: AbstractMesh): boolean;
  53508. /**
  53509. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53510. * @param mesh The mesh to highlight
  53511. * @param color The color of the highlight
  53512. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53513. */
  53514. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53515. /**
  53516. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53517. * @param mesh The mesh to highlight
  53518. */
  53519. removeMesh(mesh: Mesh): void;
  53520. /**
  53521. * Remove all the meshes currently referenced in the highlight layer
  53522. */
  53523. removeAllMeshes(): void;
  53524. /**
  53525. * Force the stencil to the normal expected value for none glowing parts
  53526. */
  53527. private _defaultStencilReference;
  53528. /**
  53529. * Free any resources and references associated to a mesh.
  53530. * Internal use
  53531. * @param mesh The mesh to free.
  53532. * @hidden
  53533. */
  53534. _disposeMesh(mesh: Mesh): void;
  53535. /**
  53536. * Dispose the highlight layer and free resources.
  53537. */
  53538. dispose(): void;
  53539. /**
  53540. * Gets the class name of the effect layer
  53541. * @returns the string with the class name of the effect layer
  53542. */
  53543. getClassName(): string;
  53544. /**
  53545. * Serializes this Highlight layer
  53546. * @returns a serialized Highlight layer object
  53547. */
  53548. serialize(): any;
  53549. /**
  53550. * Creates a Highlight layer from parsed Highlight layer data
  53551. * @param parsedHightlightLayer defines the Highlight layer data
  53552. * @param scene defines the current scene
  53553. * @param rootUrl defines the root URL containing the Highlight layer information
  53554. * @returns a parsed Highlight layer
  53555. */
  53556. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53557. }
  53558. }
  53559. declare module BABYLON {
  53560. interface AbstractScene {
  53561. /**
  53562. * The list of layers (background and foreground) of the scene
  53563. */
  53564. layers: Array<Layer>;
  53565. }
  53566. /**
  53567. * Defines the layer scene component responsible to manage any layers
  53568. * in a given scene.
  53569. */
  53570. export class LayerSceneComponent implements ISceneComponent {
  53571. /**
  53572. * The component name helpfull to identify the component in the list of scene components.
  53573. */
  53574. readonly name: string;
  53575. /**
  53576. * The scene the component belongs to.
  53577. */
  53578. scene: Scene;
  53579. private _engine;
  53580. /**
  53581. * Creates a new instance of the component for the given scene
  53582. * @param scene Defines the scene to register the component in
  53583. */
  53584. constructor(scene: Scene);
  53585. /**
  53586. * Registers the component in a given scene
  53587. */
  53588. register(): void;
  53589. /**
  53590. * Rebuilds the elements related to this component in case of
  53591. * context lost for instance.
  53592. */
  53593. rebuild(): void;
  53594. /**
  53595. * Disposes the component and the associated ressources.
  53596. */
  53597. dispose(): void;
  53598. private _draw;
  53599. private _drawCameraPredicate;
  53600. private _drawCameraBackground;
  53601. private _drawCameraForeground;
  53602. private _drawRenderTargetPredicate;
  53603. private _drawRenderTargetBackground;
  53604. private _drawRenderTargetForeground;
  53605. /**
  53606. * Adds all the elements from the container to the scene
  53607. * @param container the container holding the elements
  53608. */
  53609. addFromContainer(container: AbstractScene): void;
  53610. /**
  53611. * Removes all the elements in the container from the scene
  53612. * @param container contains the elements to remove
  53613. * @param dispose if the removed element should be disposed (default: false)
  53614. */
  53615. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53616. }
  53617. }
  53618. declare module BABYLON {
  53619. /** @hidden */
  53620. export var layerPixelShader: {
  53621. name: string;
  53622. shader: string;
  53623. };
  53624. }
  53625. declare module BABYLON {
  53626. /** @hidden */
  53627. export var layerVertexShader: {
  53628. name: string;
  53629. shader: string;
  53630. };
  53631. }
  53632. declare module BABYLON {
  53633. /**
  53634. * This represents a full screen 2d layer.
  53635. * This can be useful to display a picture in the background of your scene for instance.
  53636. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53637. */
  53638. export class Layer {
  53639. /**
  53640. * Define the name of the layer.
  53641. */
  53642. name: string;
  53643. /**
  53644. * Define the texture the layer should display.
  53645. */
  53646. texture: Nullable<Texture>;
  53647. /**
  53648. * Is the layer in background or foreground.
  53649. */
  53650. isBackground: boolean;
  53651. /**
  53652. * Define the color of the layer (instead of texture).
  53653. */
  53654. color: Color4;
  53655. /**
  53656. * Define the scale of the layer in order to zoom in out of the texture.
  53657. */
  53658. scale: Vector2;
  53659. /**
  53660. * Define an offset for the layer in order to shift the texture.
  53661. */
  53662. offset: Vector2;
  53663. /**
  53664. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53665. */
  53666. alphaBlendingMode: number;
  53667. /**
  53668. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53669. * Alpha test will not mix with the background color in case of transparency.
  53670. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53671. */
  53672. alphaTest: boolean;
  53673. /**
  53674. * Define a mask to restrict the layer to only some of the scene cameras.
  53675. */
  53676. layerMask: number;
  53677. /**
  53678. * Define the list of render target the layer is visible into.
  53679. */
  53680. renderTargetTextures: RenderTargetTexture[];
  53681. /**
  53682. * Define if the layer is only used in renderTarget or if it also
  53683. * renders in the main frame buffer of the canvas.
  53684. */
  53685. renderOnlyInRenderTargetTextures: boolean;
  53686. private _scene;
  53687. private _vertexBuffers;
  53688. private _indexBuffer;
  53689. private _effect;
  53690. private _previousDefines;
  53691. /**
  53692. * An event triggered when the layer is disposed.
  53693. */
  53694. onDisposeObservable: Observable<Layer>;
  53695. private _onDisposeObserver;
  53696. /**
  53697. * Back compatibility with callback before the onDisposeObservable existed.
  53698. * The set callback will be triggered when the layer has been disposed.
  53699. */
  53700. set onDispose(callback: () => void);
  53701. /**
  53702. * An event triggered before rendering the scene
  53703. */
  53704. onBeforeRenderObservable: Observable<Layer>;
  53705. private _onBeforeRenderObserver;
  53706. /**
  53707. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53708. * The set callback will be triggered just before rendering the layer.
  53709. */
  53710. set onBeforeRender(callback: () => void);
  53711. /**
  53712. * An event triggered after rendering the scene
  53713. */
  53714. onAfterRenderObservable: Observable<Layer>;
  53715. private _onAfterRenderObserver;
  53716. /**
  53717. * Back compatibility with callback before the onAfterRenderObservable existed.
  53718. * The set callback will be triggered just after rendering the layer.
  53719. */
  53720. set onAfterRender(callback: () => void);
  53721. /**
  53722. * Instantiates a new layer.
  53723. * This represents a full screen 2d layer.
  53724. * This can be useful to display a picture in the background of your scene for instance.
  53725. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53726. * @param name Define the name of the layer in the scene
  53727. * @param imgUrl Define the url of the texture to display in the layer
  53728. * @param scene Define the scene the layer belongs to
  53729. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53730. * @param color Defines a color for the layer
  53731. */
  53732. constructor(
  53733. /**
  53734. * Define the name of the layer.
  53735. */
  53736. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53737. private _createIndexBuffer;
  53738. /** @hidden */
  53739. _rebuild(): void;
  53740. /**
  53741. * Renders the layer in the scene.
  53742. */
  53743. render(): void;
  53744. /**
  53745. * Disposes and releases the associated ressources.
  53746. */
  53747. dispose(): void;
  53748. }
  53749. }
  53750. declare module BABYLON {
  53751. /** @hidden */
  53752. export var lensFlarePixelShader: {
  53753. name: string;
  53754. shader: string;
  53755. };
  53756. }
  53757. declare module BABYLON {
  53758. /** @hidden */
  53759. export var lensFlareVertexShader: {
  53760. name: string;
  53761. shader: string;
  53762. };
  53763. }
  53764. declare module BABYLON {
  53765. /**
  53766. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53767. * It is usually composed of several `lensFlare`.
  53768. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53769. */
  53770. export class LensFlareSystem {
  53771. /**
  53772. * Define the name of the lens flare system
  53773. */
  53774. name: string;
  53775. /**
  53776. * List of lens flares used in this system.
  53777. */
  53778. lensFlares: LensFlare[];
  53779. /**
  53780. * Define a limit from the border the lens flare can be visible.
  53781. */
  53782. borderLimit: number;
  53783. /**
  53784. * Define a viewport border we do not want to see the lens flare in.
  53785. */
  53786. viewportBorder: number;
  53787. /**
  53788. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53789. */
  53790. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53791. /**
  53792. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53793. */
  53794. layerMask: number;
  53795. /**
  53796. * Define the id of the lens flare system in the scene.
  53797. * (equal to name by default)
  53798. */
  53799. id: string;
  53800. private _scene;
  53801. private _emitter;
  53802. private _vertexBuffers;
  53803. private _indexBuffer;
  53804. private _effect;
  53805. private _positionX;
  53806. private _positionY;
  53807. private _isEnabled;
  53808. /** @hidden */
  53809. static _SceneComponentInitialization: (scene: Scene) => void;
  53810. /**
  53811. * Instantiates a lens flare system.
  53812. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53813. * It is usually composed of several `lensFlare`.
  53814. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53815. * @param name Define the name of the lens flare system in the scene
  53816. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53817. * @param scene Define the scene the lens flare system belongs to
  53818. */
  53819. constructor(
  53820. /**
  53821. * Define the name of the lens flare system
  53822. */
  53823. name: string, emitter: any, scene: Scene);
  53824. /**
  53825. * Define if the lens flare system is enabled.
  53826. */
  53827. get isEnabled(): boolean;
  53828. set isEnabled(value: boolean);
  53829. /**
  53830. * Get the scene the effects belongs to.
  53831. * @returns the scene holding the lens flare system
  53832. */
  53833. getScene(): Scene;
  53834. /**
  53835. * Get the emitter of the lens flare system.
  53836. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53837. * @returns the emitter of the lens flare system
  53838. */
  53839. getEmitter(): any;
  53840. /**
  53841. * Set the emitter of the lens flare system.
  53842. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53843. * @param newEmitter Define the new emitter of the system
  53844. */
  53845. setEmitter(newEmitter: any): void;
  53846. /**
  53847. * Get the lens flare system emitter position.
  53848. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53849. * @returns the position
  53850. */
  53851. getEmitterPosition(): Vector3;
  53852. /**
  53853. * @hidden
  53854. */
  53855. computeEffectivePosition(globalViewport: Viewport): boolean;
  53856. /** @hidden */
  53857. _isVisible(): boolean;
  53858. /**
  53859. * @hidden
  53860. */
  53861. render(): boolean;
  53862. /**
  53863. * Dispose and release the lens flare with its associated resources.
  53864. */
  53865. dispose(): void;
  53866. /**
  53867. * Parse a lens flare system from a JSON repressentation
  53868. * @param parsedLensFlareSystem Define the JSON to parse
  53869. * @param scene Define the scene the parsed system should be instantiated in
  53870. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53871. * @returns the parsed system
  53872. */
  53873. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53874. /**
  53875. * Serialize the current Lens Flare System into a JSON representation.
  53876. * @returns the serialized JSON
  53877. */
  53878. serialize(): any;
  53879. }
  53880. }
  53881. declare module BABYLON {
  53882. /**
  53883. * This represents one of the lens effect in a `lensFlareSystem`.
  53884. * It controls one of the indiviual texture used in the effect.
  53885. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53886. */
  53887. export class LensFlare {
  53888. /**
  53889. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53890. */
  53891. size: number;
  53892. /**
  53893. * 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.
  53894. */
  53895. position: number;
  53896. /**
  53897. * Define the lens color.
  53898. */
  53899. color: Color3;
  53900. /**
  53901. * Define the lens texture.
  53902. */
  53903. texture: Nullable<Texture>;
  53904. /**
  53905. * Define the alpha mode to render this particular lens.
  53906. */
  53907. alphaMode: number;
  53908. private _system;
  53909. /**
  53910. * Creates a new Lens Flare.
  53911. * This represents one of the lens effect in a `lensFlareSystem`.
  53912. * It controls one of the indiviual texture used in the effect.
  53913. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53914. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53915. * @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.
  53916. * @param color Define the lens color
  53917. * @param imgUrl Define the lens texture url
  53918. * @param system Define the `lensFlareSystem` this flare is part of
  53919. * @returns The newly created Lens Flare
  53920. */
  53921. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53922. /**
  53923. * Instantiates a new Lens Flare.
  53924. * This represents one of the lens effect in a `lensFlareSystem`.
  53925. * It controls one of the indiviual texture used in the effect.
  53926. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53927. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53928. * @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.
  53929. * @param color Define the lens color
  53930. * @param imgUrl Define the lens texture url
  53931. * @param system Define the `lensFlareSystem` this flare is part of
  53932. */
  53933. constructor(
  53934. /**
  53935. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53936. */
  53937. size: number,
  53938. /**
  53939. * 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.
  53940. */
  53941. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53942. /**
  53943. * Dispose and release the lens flare with its associated resources.
  53944. */
  53945. dispose(): void;
  53946. }
  53947. }
  53948. declare module BABYLON {
  53949. interface AbstractScene {
  53950. /**
  53951. * The list of lens flare system added to the scene
  53952. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53953. */
  53954. lensFlareSystems: Array<LensFlareSystem>;
  53955. /**
  53956. * Removes the given lens flare system from this scene.
  53957. * @param toRemove The lens flare system to remove
  53958. * @returns The index of the removed lens flare system
  53959. */
  53960. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53961. /**
  53962. * Adds the given lens flare system to this scene
  53963. * @param newLensFlareSystem The lens flare system to add
  53964. */
  53965. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53966. /**
  53967. * Gets a lens flare system using its name
  53968. * @param name defines the name to look for
  53969. * @returns the lens flare system or null if not found
  53970. */
  53971. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53972. /**
  53973. * Gets a lens flare system using its id
  53974. * @param id defines the id to look for
  53975. * @returns the lens flare system or null if not found
  53976. */
  53977. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53978. }
  53979. /**
  53980. * Defines the lens flare scene component responsible to manage any lens flares
  53981. * in a given scene.
  53982. */
  53983. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53984. /**
  53985. * The component name helpfull to identify the component in the list of scene components.
  53986. */
  53987. readonly name: string;
  53988. /**
  53989. * The scene the component belongs to.
  53990. */
  53991. scene: Scene;
  53992. /**
  53993. * Creates a new instance of the component for the given scene
  53994. * @param scene Defines the scene to register the component in
  53995. */
  53996. constructor(scene: Scene);
  53997. /**
  53998. * Registers the component in a given scene
  53999. */
  54000. register(): void;
  54001. /**
  54002. * Rebuilds the elements related to this component in case of
  54003. * context lost for instance.
  54004. */
  54005. rebuild(): void;
  54006. /**
  54007. * Adds all the elements from the container to the scene
  54008. * @param container the container holding the elements
  54009. */
  54010. addFromContainer(container: AbstractScene): void;
  54011. /**
  54012. * Removes all the elements in the container from the scene
  54013. * @param container contains the elements to remove
  54014. * @param dispose if the removed element should be disposed (default: false)
  54015. */
  54016. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54017. /**
  54018. * Serializes the component data to the specified json object
  54019. * @param serializationObject The object to serialize to
  54020. */
  54021. serialize(serializationObject: any): void;
  54022. /**
  54023. * Disposes the component and the associated ressources.
  54024. */
  54025. dispose(): void;
  54026. private _draw;
  54027. }
  54028. }
  54029. declare module BABYLON {
  54030. /** @hidden */
  54031. export var depthPixelShader: {
  54032. name: string;
  54033. shader: string;
  54034. };
  54035. }
  54036. declare module BABYLON {
  54037. /** @hidden */
  54038. export var depthVertexShader: {
  54039. name: string;
  54040. shader: string;
  54041. };
  54042. }
  54043. declare module BABYLON {
  54044. /**
  54045. * This represents a depth renderer in Babylon.
  54046. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54047. */
  54048. export class DepthRenderer {
  54049. private _scene;
  54050. private _depthMap;
  54051. private _effect;
  54052. private readonly _storeNonLinearDepth;
  54053. private readonly _clearColor;
  54054. /** Get if the depth renderer is using packed depth or not */
  54055. readonly isPacked: boolean;
  54056. private _cachedDefines;
  54057. private _camera;
  54058. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54059. enabled: boolean;
  54060. /**
  54061. * Specifiess that the depth renderer will only be used within
  54062. * the camera it is created for.
  54063. * This can help forcing its rendering during the camera processing.
  54064. */
  54065. useOnlyInActiveCamera: boolean;
  54066. /** @hidden */
  54067. static _SceneComponentInitialization: (scene: Scene) => void;
  54068. /**
  54069. * Instantiates a depth renderer
  54070. * @param scene The scene the renderer belongs to
  54071. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54072. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54073. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54074. */
  54075. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54076. /**
  54077. * Creates the depth rendering effect and checks if the effect is ready.
  54078. * @param subMesh The submesh to be used to render the depth map of
  54079. * @param useInstances If multiple world instances should be used
  54080. * @returns if the depth renderer is ready to render the depth map
  54081. */
  54082. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54083. /**
  54084. * Gets the texture which the depth map will be written to.
  54085. * @returns The depth map texture
  54086. */
  54087. getDepthMap(): RenderTargetTexture;
  54088. /**
  54089. * Disposes of the depth renderer.
  54090. */
  54091. dispose(): void;
  54092. }
  54093. }
  54094. declare module BABYLON {
  54095. /** @hidden */
  54096. export var minmaxReduxPixelShader: {
  54097. name: string;
  54098. shader: string;
  54099. };
  54100. }
  54101. declare module BABYLON {
  54102. /**
  54103. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54104. * and maximum values from all values of the texture.
  54105. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54106. * The source values are read from the red channel of the texture.
  54107. */
  54108. export class MinMaxReducer {
  54109. /**
  54110. * Observable triggered when the computation has been performed
  54111. */
  54112. onAfterReductionPerformed: Observable<{
  54113. min: number;
  54114. max: number;
  54115. }>;
  54116. protected _camera: Camera;
  54117. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54118. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54119. protected _postProcessManager: PostProcessManager;
  54120. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54121. protected _forceFullscreenViewport: boolean;
  54122. /**
  54123. * Creates a min/max reducer
  54124. * @param camera The camera to use for the post processes
  54125. */
  54126. constructor(camera: Camera);
  54127. /**
  54128. * Gets the texture used to read the values from.
  54129. */
  54130. get sourceTexture(): Nullable<RenderTargetTexture>;
  54131. /**
  54132. * Sets the source texture to read the values from.
  54133. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54134. * because in such textures '1' value must not be taken into account to compute the maximum
  54135. * as this value is used to clear the texture.
  54136. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54137. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54138. * @param depthRedux Indicates if the texture is a depth texture or not
  54139. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54140. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54141. */
  54142. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54143. /**
  54144. * Defines the refresh rate of the computation.
  54145. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54146. */
  54147. get refreshRate(): number;
  54148. set refreshRate(value: number);
  54149. protected _activated: boolean;
  54150. /**
  54151. * Gets the activation status of the reducer
  54152. */
  54153. get activated(): boolean;
  54154. /**
  54155. * Activates the reduction computation.
  54156. * When activated, the observers registered in onAfterReductionPerformed are
  54157. * called after the compuation is performed
  54158. */
  54159. activate(): void;
  54160. /**
  54161. * Deactivates the reduction computation.
  54162. */
  54163. deactivate(): void;
  54164. /**
  54165. * Disposes the min/max reducer
  54166. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54167. */
  54168. dispose(disposeAll?: boolean): void;
  54169. }
  54170. }
  54171. declare module BABYLON {
  54172. /**
  54173. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54174. */
  54175. export class DepthReducer extends MinMaxReducer {
  54176. private _depthRenderer;
  54177. private _depthRendererId;
  54178. /**
  54179. * Gets the depth renderer used for the computation.
  54180. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54181. */
  54182. get depthRenderer(): Nullable<DepthRenderer>;
  54183. /**
  54184. * Creates a depth reducer
  54185. * @param camera The camera used to render the depth texture
  54186. */
  54187. constructor(camera: Camera);
  54188. /**
  54189. * Sets the depth renderer to use to generate the depth map
  54190. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54191. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54192. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54193. */
  54194. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54195. /** @hidden */
  54196. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54197. /**
  54198. * Activates the reduction computation.
  54199. * When activated, the observers registered in onAfterReductionPerformed are
  54200. * called after the compuation is performed
  54201. */
  54202. activate(): void;
  54203. /**
  54204. * Deactivates the reduction computation.
  54205. */
  54206. deactivate(): void;
  54207. /**
  54208. * Disposes the depth reducer
  54209. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54210. */
  54211. dispose(disposeAll?: boolean): void;
  54212. }
  54213. }
  54214. declare module BABYLON {
  54215. /**
  54216. * A CSM implementation allowing casting shadows on large scenes.
  54217. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54218. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54219. */
  54220. export class CascadedShadowGenerator extends ShadowGenerator {
  54221. private static readonly frustumCornersNDCSpace;
  54222. /**
  54223. * Name of the CSM class
  54224. */
  54225. static CLASSNAME: string;
  54226. /**
  54227. * Defines the default number of cascades used by the CSM.
  54228. */
  54229. static readonly DEFAULT_CASCADES_COUNT: number;
  54230. /**
  54231. * Defines the minimum number of cascades used by the CSM.
  54232. */
  54233. static readonly MIN_CASCADES_COUNT: number;
  54234. /**
  54235. * Defines the maximum number of cascades used by the CSM.
  54236. */
  54237. static readonly MAX_CASCADES_COUNT: number;
  54238. protected _validateFilter(filter: number): number;
  54239. /**
  54240. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54241. */
  54242. penumbraDarkness: number;
  54243. private _numCascades;
  54244. /**
  54245. * Gets or set the number of cascades used by the CSM.
  54246. */
  54247. get numCascades(): number;
  54248. set numCascades(value: number);
  54249. /**
  54250. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54251. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54252. */
  54253. stabilizeCascades: boolean;
  54254. private _freezeShadowCastersBoundingInfo;
  54255. private _freezeShadowCastersBoundingInfoObservable;
  54256. /**
  54257. * Enables or disables the shadow casters bounding info computation.
  54258. * If your shadow casters don't move, you can disable this feature.
  54259. * If it is enabled, the bounding box computation is done every frame.
  54260. */
  54261. get freezeShadowCastersBoundingInfo(): boolean;
  54262. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54263. private _scbiMin;
  54264. private _scbiMax;
  54265. protected _computeShadowCastersBoundingInfo(): void;
  54266. protected _shadowCastersBoundingInfo: BoundingInfo;
  54267. /**
  54268. * Gets or sets the shadow casters bounding info.
  54269. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54270. * so that the system won't overwrite the bounds you provide
  54271. */
  54272. get shadowCastersBoundingInfo(): BoundingInfo;
  54273. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54274. protected _breaksAreDirty: boolean;
  54275. protected _minDistance: number;
  54276. protected _maxDistance: number;
  54277. /**
  54278. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54279. *
  54280. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54281. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54282. * @param min minimal distance for the breaks (default to 0.)
  54283. * @param max maximal distance for the breaks (default to 1.)
  54284. */
  54285. setMinMaxDistance(min: number, max: number): void;
  54286. /** Gets the minimal distance used in the cascade break computation */
  54287. get minDistance(): number;
  54288. /** Gets the maximal distance used in the cascade break computation */
  54289. get maxDistance(): number;
  54290. /**
  54291. * Gets the class name of that object
  54292. * @returns "CascadedShadowGenerator"
  54293. */
  54294. getClassName(): string;
  54295. private _cascadeMinExtents;
  54296. private _cascadeMaxExtents;
  54297. /**
  54298. * Gets a cascade minimum extents
  54299. * @param cascadeIndex index of the cascade
  54300. * @returns the minimum cascade extents
  54301. */
  54302. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54303. /**
  54304. * Gets a cascade maximum extents
  54305. * @param cascadeIndex index of the cascade
  54306. * @returns the maximum cascade extents
  54307. */
  54308. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54309. private _cascades;
  54310. private _currentLayer;
  54311. private _viewSpaceFrustumsZ;
  54312. private _viewMatrices;
  54313. private _projectionMatrices;
  54314. private _transformMatrices;
  54315. private _transformMatricesAsArray;
  54316. private _frustumLengths;
  54317. private _lightSizeUVCorrection;
  54318. private _depthCorrection;
  54319. private _frustumCornersWorldSpace;
  54320. private _frustumCenter;
  54321. private _shadowCameraPos;
  54322. private _shadowMaxZ;
  54323. /**
  54324. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54325. * It defaults to camera.maxZ
  54326. */
  54327. get shadowMaxZ(): number;
  54328. /**
  54329. * Sets the shadow max z distance.
  54330. */
  54331. set shadowMaxZ(value: number);
  54332. protected _debug: boolean;
  54333. /**
  54334. * Gets or sets the debug flag.
  54335. * When enabled, the cascades are materialized by different colors on the screen.
  54336. */
  54337. get debug(): boolean;
  54338. set debug(dbg: boolean);
  54339. private _depthClamp;
  54340. /**
  54341. * Gets or sets the depth clamping value.
  54342. *
  54343. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54344. * to account for the shadow casters far away.
  54345. *
  54346. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54347. */
  54348. get depthClamp(): boolean;
  54349. set depthClamp(value: boolean);
  54350. private _cascadeBlendPercentage;
  54351. /**
  54352. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54353. * It defaults to 0.1 (10% blending).
  54354. */
  54355. get cascadeBlendPercentage(): number;
  54356. set cascadeBlendPercentage(value: number);
  54357. private _lambda;
  54358. /**
  54359. * Gets or set the lambda parameter.
  54360. * This parameter is used to split the camera frustum and create the cascades.
  54361. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  54362. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54363. */
  54364. get lambda(): number;
  54365. set lambda(value: number);
  54366. /**
  54367. * Gets the view matrix corresponding to a given cascade
  54368. * @param cascadeNum cascade to retrieve the view matrix from
  54369. * @returns the cascade view matrix
  54370. */
  54371. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54372. /**
  54373. * Gets the projection matrix corresponding to a given cascade
  54374. * @param cascadeNum cascade to retrieve the projection matrix from
  54375. * @returns the cascade projection matrix
  54376. */
  54377. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54378. /**
  54379. * Gets the transformation matrix corresponding to a given cascade
  54380. * @param cascadeNum cascade to retrieve the transformation matrix from
  54381. * @returns the cascade transformation matrix
  54382. */
  54383. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54384. private _depthRenderer;
  54385. /**
  54386. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54387. *
  54388. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54389. *
  54390. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54391. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54392. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  54393. */
  54394. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54395. private _depthReducer;
  54396. private _autoCalcDepthBounds;
  54397. /**
  54398. * Gets or sets the autoCalcDepthBounds property.
  54399. *
  54400. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54401. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54402. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54403. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54404. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54405. */
  54406. get autoCalcDepthBounds(): boolean;
  54407. set autoCalcDepthBounds(value: boolean);
  54408. /**
  54409. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54410. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54411. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54412. * for setting the refresh rate on the renderer yourself!
  54413. */
  54414. get autoCalcDepthBoundsRefreshRate(): number;
  54415. set autoCalcDepthBoundsRefreshRate(value: number);
  54416. /**
  54417. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54418. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54419. * you change the camera near/far planes!
  54420. */
  54421. splitFrustum(): void;
  54422. private _splitFrustum;
  54423. private _computeMatrices;
  54424. private _computeFrustumInWorldSpace;
  54425. private _computeCascadeFrustum;
  54426. /** @hidden */
  54427. static _SceneComponentInitialization: (scene: Scene) => void;
  54428. /**
  54429. * Creates a Cascaded Shadow Generator object.
  54430. * A ShadowGenerator is the required tool to use the shadows.
  54431. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54432. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54433. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54434. * @param light The directional light object generating the shadows.
  54435. * @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.
  54436. */
  54437. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54438. protected _initializeGenerator(): void;
  54439. protected _createTargetRenderTexture(): void;
  54440. protected _initializeShadowMap(): void;
  54441. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54442. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54443. /**
  54444. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54445. * @param defines Defines of the material we want to update
  54446. * @param lightIndex Index of the light in the enabled light list of the material
  54447. */
  54448. prepareDefines(defines: any, lightIndex: number): void;
  54449. /**
  54450. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54451. * defined in the generator but impacting the effect).
  54452. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54453. * @param effect The effect we are binfing the information for
  54454. */
  54455. bindShadowLight(lightIndex: string, effect: Effect): void;
  54456. /**
  54457. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54458. * (eq to view projection * shadow projection matrices)
  54459. * @returns The transform matrix used to create the shadow map
  54460. */
  54461. getTransformMatrix(): Matrix;
  54462. /**
  54463. * Disposes the ShadowGenerator.
  54464. * Returns nothing.
  54465. */
  54466. dispose(): void;
  54467. /**
  54468. * Serializes the shadow generator setup to a json object.
  54469. * @returns The serialized JSON object
  54470. */
  54471. serialize(): any;
  54472. /**
  54473. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54474. * @param parsedShadowGenerator The JSON object to parse
  54475. * @param scene The scene to create the shadow map for
  54476. * @returns The parsed shadow generator
  54477. */
  54478. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54479. }
  54480. }
  54481. declare module BABYLON {
  54482. /**
  54483. * Defines the shadow generator component responsible to manage any shadow generators
  54484. * in a given scene.
  54485. */
  54486. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54487. /**
  54488. * The component name helpfull to identify the component in the list of scene components.
  54489. */
  54490. readonly name: string;
  54491. /**
  54492. * The scene the component belongs to.
  54493. */
  54494. scene: Scene;
  54495. /**
  54496. * Creates a new instance of the component for the given scene
  54497. * @param scene Defines the scene to register the component in
  54498. */
  54499. constructor(scene: Scene);
  54500. /**
  54501. * Registers the component in a given scene
  54502. */
  54503. register(): void;
  54504. /**
  54505. * Rebuilds the elements related to this component in case of
  54506. * context lost for instance.
  54507. */
  54508. rebuild(): void;
  54509. /**
  54510. * Serializes the component data to the specified json object
  54511. * @param serializationObject The object to serialize to
  54512. */
  54513. serialize(serializationObject: any): void;
  54514. /**
  54515. * Adds all the elements from the container to the scene
  54516. * @param container the container holding the elements
  54517. */
  54518. addFromContainer(container: AbstractScene): void;
  54519. /**
  54520. * Removes all the elements in the container from the scene
  54521. * @param container contains the elements to remove
  54522. * @param dispose if the removed element should be disposed (default: false)
  54523. */
  54524. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54525. /**
  54526. * Rebuilds the elements related to this component in case of
  54527. * context lost for instance.
  54528. */
  54529. dispose(): void;
  54530. private _gatherRenderTargets;
  54531. }
  54532. }
  54533. declare module BABYLON {
  54534. /**
  54535. * A point light is a light defined by an unique point in world space.
  54536. * The light is emitted in every direction from this point.
  54537. * A good example of a point light is a standard light bulb.
  54538. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54539. */
  54540. export class PointLight extends ShadowLight {
  54541. private _shadowAngle;
  54542. /**
  54543. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54544. * This specifies what angle the shadow will use to be created.
  54545. *
  54546. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54547. */
  54548. get shadowAngle(): number;
  54549. /**
  54550. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54551. * This specifies what angle the shadow will use to be created.
  54552. *
  54553. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54554. */
  54555. set shadowAngle(value: number);
  54556. /**
  54557. * Gets the direction if it has been set.
  54558. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54559. */
  54560. get direction(): Vector3;
  54561. /**
  54562. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54563. */
  54564. set direction(value: Vector3);
  54565. /**
  54566. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54567. * A PointLight emits the light in every direction.
  54568. * It can cast shadows.
  54569. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54570. * ```javascript
  54571. * var pointLight = new PointLight("pl", camera.position, scene);
  54572. * ```
  54573. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54574. * @param name The light friendly name
  54575. * @param position The position of the point light in the scene
  54576. * @param scene The scene the lights belongs to
  54577. */
  54578. constructor(name: string, position: Vector3, scene: Scene);
  54579. /**
  54580. * Returns the string "PointLight"
  54581. * @returns the class name
  54582. */
  54583. getClassName(): string;
  54584. /**
  54585. * Returns the integer 0.
  54586. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54587. */
  54588. getTypeID(): number;
  54589. /**
  54590. * Specifies wether or not the shadowmap should be a cube texture.
  54591. * @returns true if the shadowmap needs to be a cube texture.
  54592. */
  54593. needCube(): boolean;
  54594. /**
  54595. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54596. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54597. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54598. */
  54599. getShadowDirection(faceIndex?: number): Vector3;
  54600. /**
  54601. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54602. * - fov = PI / 2
  54603. * - aspect ratio : 1.0
  54604. * - z-near and far equal to the active camera minZ and maxZ.
  54605. * Returns the PointLight.
  54606. */
  54607. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54608. protected _buildUniformLayout(): void;
  54609. /**
  54610. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54611. * @param effect The effect to update
  54612. * @param lightIndex The index of the light in the effect to update
  54613. * @returns The point light
  54614. */
  54615. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54616. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54617. /**
  54618. * Prepares the list of defines specific to the light type.
  54619. * @param defines the list of defines
  54620. * @param lightIndex defines the index of the light for the effect
  54621. */
  54622. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54623. }
  54624. }
  54625. declare module BABYLON {
  54626. /**
  54627. * Header information of HDR texture files.
  54628. */
  54629. export interface HDRInfo {
  54630. /**
  54631. * The height of the texture in pixels.
  54632. */
  54633. height: number;
  54634. /**
  54635. * The width of the texture in pixels.
  54636. */
  54637. width: number;
  54638. /**
  54639. * The index of the beginning of the data in the binary file.
  54640. */
  54641. dataPosition: number;
  54642. }
  54643. /**
  54644. * This groups tools to convert HDR texture to native colors array.
  54645. */
  54646. export class HDRTools {
  54647. private static Ldexp;
  54648. private static Rgbe2float;
  54649. private static readStringLine;
  54650. /**
  54651. * Reads header information from an RGBE texture stored in a native array.
  54652. * More information on this format are available here:
  54653. * https://en.wikipedia.org/wiki/RGBE_image_format
  54654. *
  54655. * @param uint8array The binary file stored in native array.
  54656. * @return The header information.
  54657. */
  54658. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54659. /**
  54660. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54661. * This RGBE texture needs to store the information as a panorama.
  54662. *
  54663. * More information on this format are available here:
  54664. * https://en.wikipedia.org/wiki/RGBE_image_format
  54665. *
  54666. * @param buffer The binary file stored in an array buffer.
  54667. * @param size The expected size of the extracted cubemap.
  54668. * @return The Cube Map information.
  54669. */
  54670. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54671. /**
  54672. * Returns the pixels data extracted from an RGBE texture.
  54673. * This pixels will be stored left to right up to down in the R G B order in one array.
  54674. *
  54675. * More information on this format are available here:
  54676. * https://en.wikipedia.org/wiki/RGBE_image_format
  54677. *
  54678. * @param uint8array The binary file stored in an array buffer.
  54679. * @param hdrInfo The header information of the file.
  54680. * @return The pixels data in RGB right to left up to down order.
  54681. */
  54682. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54683. private static RGBE_ReadPixels_RLE;
  54684. }
  54685. }
  54686. declare module BABYLON {
  54687. /**
  54688. * This represents a texture coming from an HDR input.
  54689. *
  54690. * The only supported format is currently panorama picture stored in RGBE format.
  54691. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54692. */
  54693. export class HDRCubeTexture extends BaseTexture {
  54694. private static _facesMapping;
  54695. private _generateHarmonics;
  54696. private _noMipmap;
  54697. private _textureMatrix;
  54698. private _size;
  54699. private _onLoad;
  54700. private _onError;
  54701. /**
  54702. * The texture URL.
  54703. */
  54704. url: string;
  54705. /**
  54706. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54707. */
  54708. coordinatesMode: number;
  54709. protected _isBlocking: boolean;
  54710. /**
  54711. * Sets wether or not the texture is blocking during loading.
  54712. */
  54713. set isBlocking(value: boolean);
  54714. /**
  54715. * Gets wether or not the texture is blocking during loading.
  54716. */
  54717. get isBlocking(): boolean;
  54718. protected _rotationY: number;
  54719. /**
  54720. * Sets texture matrix rotation angle around Y axis in radians.
  54721. */
  54722. set rotationY(value: number);
  54723. /**
  54724. * Gets texture matrix rotation angle around Y axis radians.
  54725. */
  54726. get rotationY(): number;
  54727. /**
  54728. * Gets or sets the center of the bounding box associated with the cube texture
  54729. * It must define where the camera used to render the texture was set
  54730. */
  54731. boundingBoxPosition: Vector3;
  54732. private _boundingBoxSize;
  54733. /**
  54734. * Gets or sets the size of the bounding box associated with the cube texture
  54735. * When defined, the cubemap will switch to local mode
  54736. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54737. * @example https://www.babylonjs-playground.com/#RNASML
  54738. */
  54739. set boundingBoxSize(value: Vector3);
  54740. get boundingBoxSize(): Vector3;
  54741. /**
  54742. * Instantiates an HDRTexture from the following parameters.
  54743. *
  54744. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54745. * @param scene The scene the texture will be used in
  54746. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54747. * @param noMipmap Forces to not generate the mipmap if true
  54748. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54749. * @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)
  54750. * @param reserved Reserved flag for internal use.
  54751. */
  54752. 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>);
  54753. /**
  54754. * Get the current class name of the texture useful for serialization or dynamic coding.
  54755. * @returns "HDRCubeTexture"
  54756. */
  54757. getClassName(): string;
  54758. /**
  54759. * Occurs when the file is raw .hdr file.
  54760. */
  54761. private loadTexture;
  54762. clone(): HDRCubeTexture;
  54763. delayLoad(): void;
  54764. /**
  54765. * Get the texture reflection matrix used to rotate/transform the reflection.
  54766. * @returns the reflection matrix
  54767. */
  54768. getReflectionTextureMatrix(): Matrix;
  54769. /**
  54770. * Set the texture reflection matrix used to rotate/transform the reflection.
  54771. * @param value Define the reflection matrix to set
  54772. */
  54773. setReflectionTextureMatrix(value: Matrix): void;
  54774. /**
  54775. * Parses a JSON representation of an HDR Texture in order to create the texture
  54776. * @param parsedTexture Define the JSON representation
  54777. * @param scene Define the scene the texture should be created in
  54778. * @param rootUrl Define the root url in case we need to load relative dependencies
  54779. * @returns the newly created texture after parsing
  54780. */
  54781. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54782. serialize(): any;
  54783. }
  54784. }
  54785. declare module BABYLON {
  54786. /**
  54787. * Class used to control physics engine
  54788. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54789. */
  54790. export class PhysicsEngine implements IPhysicsEngine {
  54791. private _physicsPlugin;
  54792. /**
  54793. * Global value used to control the smallest number supported by the simulation
  54794. */
  54795. static Epsilon: number;
  54796. private _impostors;
  54797. private _joints;
  54798. private _subTimeStep;
  54799. /**
  54800. * Gets the gravity vector used by the simulation
  54801. */
  54802. gravity: Vector3;
  54803. /**
  54804. * Factory used to create the default physics plugin.
  54805. * @returns The default physics plugin
  54806. */
  54807. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54808. /**
  54809. * Creates a new Physics Engine
  54810. * @param gravity defines the gravity vector used by the simulation
  54811. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54812. */
  54813. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54814. /**
  54815. * Sets the gravity vector used by the simulation
  54816. * @param gravity defines the gravity vector to use
  54817. */
  54818. setGravity(gravity: Vector3): void;
  54819. /**
  54820. * Set the time step of the physics engine.
  54821. * Default is 1/60.
  54822. * To slow it down, enter 1/600 for example.
  54823. * To speed it up, 1/30
  54824. * @param newTimeStep defines the new timestep to apply to this world.
  54825. */
  54826. setTimeStep(newTimeStep?: number): void;
  54827. /**
  54828. * Get the time step of the physics engine.
  54829. * @returns the current time step
  54830. */
  54831. getTimeStep(): number;
  54832. /**
  54833. * Set the sub time step of the physics engine.
  54834. * Default is 0 meaning there is no sub steps
  54835. * To increase physics resolution precision, set a small value (like 1 ms)
  54836. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54837. */
  54838. setSubTimeStep(subTimeStep?: number): void;
  54839. /**
  54840. * Get the sub time step of the physics engine.
  54841. * @returns the current sub time step
  54842. */
  54843. getSubTimeStep(): number;
  54844. /**
  54845. * Release all resources
  54846. */
  54847. dispose(): void;
  54848. /**
  54849. * Gets the name of the current physics plugin
  54850. * @returns the name of the plugin
  54851. */
  54852. getPhysicsPluginName(): string;
  54853. /**
  54854. * Adding a new impostor for the impostor tracking.
  54855. * This will be done by the impostor itself.
  54856. * @param impostor the impostor to add
  54857. */
  54858. addImpostor(impostor: PhysicsImpostor): void;
  54859. /**
  54860. * Remove an impostor from the engine.
  54861. * This impostor and its mesh will not longer be updated by the physics engine.
  54862. * @param impostor the impostor to remove
  54863. */
  54864. removeImpostor(impostor: PhysicsImpostor): void;
  54865. /**
  54866. * Add a joint to the physics engine
  54867. * @param mainImpostor defines the main impostor to which the joint is added.
  54868. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54869. * @param joint defines the joint that will connect both impostors.
  54870. */
  54871. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54872. /**
  54873. * Removes a joint from the simulation
  54874. * @param mainImpostor defines the impostor used with the joint
  54875. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54876. * @param joint defines the joint to remove
  54877. */
  54878. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54879. /**
  54880. * Called by the scene. No need to call it.
  54881. * @param delta defines the timespam between frames
  54882. */
  54883. _step(delta: number): void;
  54884. /**
  54885. * Gets the current plugin used to run the simulation
  54886. * @returns current plugin
  54887. */
  54888. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54889. /**
  54890. * Gets the list of physic impostors
  54891. * @returns an array of PhysicsImpostor
  54892. */
  54893. getImpostors(): Array<PhysicsImpostor>;
  54894. /**
  54895. * Gets the impostor for a physics enabled object
  54896. * @param object defines the object impersonated by the impostor
  54897. * @returns the PhysicsImpostor or null if not found
  54898. */
  54899. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54900. /**
  54901. * Gets the impostor for a physics body object
  54902. * @param body defines physics body used by the impostor
  54903. * @returns the PhysicsImpostor or null if not found
  54904. */
  54905. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54906. /**
  54907. * Does a raycast in the physics world
  54908. * @param from when should the ray start?
  54909. * @param to when should the ray end?
  54910. * @returns PhysicsRaycastResult
  54911. */
  54912. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54913. }
  54914. }
  54915. declare module BABYLON {
  54916. /** @hidden */
  54917. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54918. private _useDeltaForWorldStep;
  54919. world: any;
  54920. name: string;
  54921. private _physicsMaterials;
  54922. private _fixedTimeStep;
  54923. private _cannonRaycastResult;
  54924. private _raycastResult;
  54925. private _physicsBodysToRemoveAfterStep;
  54926. BJSCANNON: any;
  54927. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54928. setGravity(gravity: Vector3): void;
  54929. setTimeStep(timeStep: number): void;
  54930. getTimeStep(): number;
  54931. executeStep(delta: number): void;
  54932. private _removeMarkedPhysicsBodiesFromWorld;
  54933. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54934. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54935. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54936. private _processChildMeshes;
  54937. removePhysicsBody(impostor: PhysicsImpostor): void;
  54938. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54939. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54940. private _addMaterial;
  54941. private _checkWithEpsilon;
  54942. private _createShape;
  54943. private _createHeightmap;
  54944. private _minus90X;
  54945. private _plus90X;
  54946. private _tmpPosition;
  54947. private _tmpDeltaPosition;
  54948. private _tmpUnityRotation;
  54949. private _updatePhysicsBodyTransformation;
  54950. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54951. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54952. isSupported(): boolean;
  54953. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54954. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54955. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54956. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54957. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54958. getBodyMass(impostor: PhysicsImpostor): number;
  54959. getBodyFriction(impostor: PhysicsImpostor): number;
  54960. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54961. getBodyRestitution(impostor: PhysicsImpostor): number;
  54962. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54963. sleepBody(impostor: PhysicsImpostor): void;
  54964. wakeUpBody(impostor: PhysicsImpostor): void;
  54965. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54966. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54967. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54968. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54969. getRadius(impostor: PhysicsImpostor): number;
  54970. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54971. dispose(): void;
  54972. private _extendNamespace;
  54973. /**
  54974. * Does a raycast in the physics world
  54975. * @param from when should the ray start?
  54976. * @param to when should the ray end?
  54977. * @returns PhysicsRaycastResult
  54978. */
  54979. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54980. }
  54981. }
  54982. declare module BABYLON {
  54983. /** @hidden */
  54984. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54985. world: any;
  54986. name: string;
  54987. BJSOIMO: any;
  54988. private _raycastResult;
  54989. constructor(iterations?: number, oimoInjection?: any);
  54990. setGravity(gravity: Vector3): void;
  54991. setTimeStep(timeStep: number): void;
  54992. getTimeStep(): number;
  54993. private _tmpImpostorsArray;
  54994. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54995. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54996. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54997. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54998. private _tmpPositionVector;
  54999. removePhysicsBody(impostor: PhysicsImpostor): void;
  55000. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55001. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55002. isSupported(): boolean;
  55003. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55004. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55005. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55006. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55007. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55008. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55009. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55010. getBodyMass(impostor: PhysicsImpostor): number;
  55011. getBodyFriction(impostor: PhysicsImpostor): number;
  55012. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55013. getBodyRestitution(impostor: PhysicsImpostor): number;
  55014. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55015. sleepBody(impostor: PhysicsImpostor): void;
  55016. wakeUpBody(impostor: PhysicsImpostor): void;
  55017. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55018. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55019. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55020. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55021. getRadius(impostor: PhysicsImpostor): number;
  55022. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55023. dispose(): void;
  55024. /**
  55025. * Does a raycast in the physics world
  55026. * @param from when should the ray start?
  55027. * @param to when should the ray end?
  55028. * @returns PhysicsRaycastResult
  55029. */
  55030. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55031. }
  55032. }
  55033. declare module BABYLON {
  55034. /**
  55035. * Class containing static functions to help procedurally build meshes
  55036. */
  55037. export class RibbonBuilder {
  55038. /**
  55039. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55040. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55041. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55042. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55043. * * 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
  55044. * * 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
  55045. * * 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
  55046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55047. * * 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
  55048. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55049. * * 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
  55050. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55051. * * 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
  55052. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55054. * @param name defines the name of the mesh
  55055. * @param options defines the options used to create the mesh
  55056. * @param scene defines the hosting scene
  55057. * @returns the ribbon mesh
  55058. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55059. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55060. */
  55061. static CreateRibbon(name: string, options: {
  55062. pathArray: Vector3[][];
  55063. closeArray?: boolean;
  55064. closePath?: boolean;
  55065. offset?: number;
  55066. updatable?: boolean;
  55067. sideOrientation?: number;
  55068. frontUVs?: Vector4;
  55069. backUVs?: Vector4;
  55070. instance?: Mesh;
  55071. invertUV?: boolean;
  55072. uvs?: Vector2[];
  55073. colors?: Color4[];
  55074. }, scene?: Nullable<Scene>): Mesh;
  55075. }
  55076. }
  55077. declare module BABYLON {
  55078. /**
  55079. * Class containing static functions to help procedurally build meshes
  55080. */
  55081. export class ShapeBuilder {
  55082. /**
  55083. * 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.
  55084. * * 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.
  55085. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55086. * * 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.
  55087. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55088. * * 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
  55089. * * 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
  55090. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55092. * * 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
  55093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55095. * @param name defines the name of the mesh
  55096. * @param options defines the options used to create the mesh
  55097. * @param scene defines the hosting scene
  55098. * @returns the extruded shape mesh
  55099. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55101. */
  55102. static ExtrudeShape(name: string, options: {
  55103. shape: Vector3[];
  55104. path: Vector3[];
  55105. scale?: number;
  55106. rotation?: number;
  55107. cap?: number;
  55108. updatable?: boolean;
  55109. sideOrientation?: number;
  55110. frontUVs?: Vector4;
  55111. backUVs?: Vector4;
  55112. instance?: Mesh;
  55113. invertUV?: boolean;
  55114. }, scene?: Nullable<Scene>): Mesh;
  55115. /**
  55116. * Creates an custom extruded shape mesh.
  55117. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55118. * * 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.
  55119. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55120. * * 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
  55121. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55122. * * 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
  55123. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55124. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55125. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55126. * * 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
  55127. * * 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
  55128. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55130. * * 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
  55131. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55133. * @param name defines the name of the mesh
  55134. * @param options defines the options used to create the mesh
  55135. * @param scene defines the hosting scene
  55136. * @returns the custom extruded shape mesh
  55137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55138. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55140. */
  55141. static ExtrudeShapeCustom(name: string, options: {
  55142. shape: Vector3[];
  55143. path: Vector3[];
  55144. scaleFunction?: any;
  55145. rotationFunction?: any;
  55146. ribbonCloseArray?: boolean;
  55147. ribbonClosePath?: boolean;
  55148. cap?: number;
  55149. updatable?: boolean;
  55150. sideOrientation?: number;
  55151. frontUVs?: Vector4;
  55152. backUVs?: Vector4;
  55153. instance?: Mesh;
  55154. invertUV?: boolean;
  55155. }, scene?: Nullable<Scene>): Mesh;
  55156. private static _ExtrudeShapeGeneric;
  55157. }
  55158. }
  55159. declare module BABYLON {
  55160. /**
  55161. * AmmoJS Physics plugin
  55162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55163. * @see https://github.com/kripken/ammo.js/
  55164. */
  55165. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55166. private _useDeltaForWorldStep;
  55167. /**
  55168. * Reference to the Ammo library
  55169. */
  55170. bjsAMMO: any;
  55171. /**
  55172. * Created ammoJS world which physics bodies are added to
  55173. */
  55174. world: any;
  55175. /**
  55176. * Name of the plugin
  55177. */
  55178. name: string;
  55179. private _timeStep;
  55180. private _fixedTimeStep;
  55181. private _maxSteps;
  55182. private _tmpQuaternion;
  55183. private _tmpAmmoTransform;
  55184. private _tmpAmmoQuaternion;
  55185. private _tmpAmmoConcreteContactResultCallback;
  55186. private _collisionConfiguration;
  55187. private _dispatcher;
  55188. private _overlappingPairCache;
  55189. private _solver;
  55190. private _softBodySolver;
  55191. private _tmpAmmoVectorA;
  55192. private _tmpAmmoVectorB;
  55193. private _tmpAmmoVectorC;
  55194. private _tmpAmmoVectorD;
  55195. private _tmpContactCallbackResult;
  55196. private _tmpAmmoVectorRCA;
  55197. private _tmpAmmoVectorRCB;
  55198. private _raycastResult;
  55199. private static readonly DISABLE_COLLISION_FLAG;
  55200. private static readonly KINEMATIC_FLAG;
  55201. private static readonly DISABLE_DEACTIVATION_FLAG;
  55202. /**
  55203. * Initializes the ammoJS plugin
  55204. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55205. * @param ammoInjection can be used to inject your own ammo reference
  55206. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55207. */
  55208. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55209. /**
  55210. * Sets the gravity of the physics world (m/(s^2))
  55211. * @param gravity Gravity to set
  55212. */
  55213. setGravity(gravity: Vector3): void;
  55214. /**
  55215. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55216. * @param timeStep timestep to use in seconds
  55217. */
  55218. setTimeStep(timeStep: number): void;
  55219. /**
  55220. * 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)
  55221. * @param fixedTimeStep fixedTimeStep to use in seconds
  55222. */
  55223. setFixedTimeStep(fixedTimeStep: number): void;
  55224. /**
  55225. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55226. * @param maxSteps the maximum number of steps by the physics engine per frame
  55227. */
  55228. setMaxSteps(maxSteps: number): void;
  55229. /**
  55230. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55231. * @returns the current timestep in seconds
  55232. */
  55233. getTimeStep(): number;
  55234. /**
  55235. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55236. */
  55237. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55238. private _isImpostorInContact;
  55239. private _isImpostorPairInContact;
  55240. private _stepSimulation;
  55241. /**
  55242. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55243. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55244. * After the step the babylon meshes are set to the position of the physics imposters
  55245. * @param delta amount of time to step forward
  55246. * @param impostors array of imposters to update before/after the step
  55247. */
  55248. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55249. /**
  55250. * Update babylon mesh to match physics world object
  55251. * @param impostor imposter to match
  55252. */
  55253. private _afterSoftStep;
  55254. /**
  55255. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55256. * @param impostor imposter to match
  55257. */
  55258. private _ropeStep;
  55259. /**
  55260. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55261. * @param impostor imposter to match
  55262. */
  55263. private _softbodyOrClothStep;
  55264. private _tmpVector;
  55265. private _tmpMatrix;
  55266. /**
  55267. * Applies an impulse on the imposter
  55268. * @param impostor imposter to apply impulse to
  55269. * @param force amount of force to be applied to the imposter
  55270. * @param contactPoint the location to apply the impulse on the imposter
  55271. */
  55272. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55273. /**
  55274. * Applies a force on the imposter
  55275. * @param impostor imposter to apply force
  55276. * @param force amount of force to be applied to the imposter
  55277. * @param contactPoint the location to apply the force on the imposter
  55278. */
  55279. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55280. /**
  55281. * Creates a physics body using the plugin
  55282. * @param impostor the imposter to create the physics body on
  55283. */
  55284. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55285. /**
  55286. * Removes the physics body from the imposter and disposes of the body's memory
  55287. * @param impostor imposter to remove the physics body from
  55288. */
  55289. removePhysicsBody(impostor: PhysicsImpostor): void;
  55290. /**
  55291. * Generates a joint
  55292. * @param impostorJoint the imposter joint to create the joint with
  55293. */
  55294. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55295. /**
  55296. * Removes a joint
  55297. * @param impostorJoint the imposter joint to remove the joint from
  55298. */
  55299. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55300. private _addMeshVerts;
  55301. /**
  55302. * Initialise the soft body vertices to match its object's (mesh) vertices
  55303. * Softbody vertices (nodes) are in world space and to match this
  55304. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55305. * @param impostor to create the softbody for
  55306. */
  55307. private _softVertexData;
  55308. /**
  55309. * Create an impostor's soft body
  55310. * @param impostor to create the softbody for
  55311. */
  55312. private _createSoftbody;
  55313. /**
  55314. * Create cloth for an impostor
  55315. * @param impostor to create the softbody for
  55316. */
  55317. private _createCloth;
  55318. /**
  55319. * Create rope for an impostor
  55320. * @param impostor to create the softbody for
  55321. */
  55322. private _createRope;
  55323. /**
  55324. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55325. * @param impostor to create the custom physics shape for
  55326. */
  55327. private _createCustom;
  55328. private _addHullVerts;
  55329. private _createShape;
  55330. /**
  55331. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55332. * @param impostor imposter containing the physics body and babylon object
  55333. */
  55334. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55335. /**
  55336. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55337. * @param impostor imposter containing the physics body and babylon object
  55338. * @param newPosition new position
  55339. * @param newRotation new rotation
  55340. */
  55341. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55342. /**
  55343. * If this plugin is supported
  55344. * @returns true if its supported
  55345. */
  55346. isSupported(): boolean;
  55347. /**
  55348. * Sets the linear velocity of the physics body
  55349. * @param impostor imposter to set the velocity on
  55350. * @param velocity velocity to set
  55351. */
  55352. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55353. /**
  55354. * Sets the angular velocity of the physics body
  55355. * @param impostor imposter to set the velocity on
  55356. * @param velocity velocity to set
  55357. */
  55358. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55359. /**
  55360. * gets the linear velocity
  55361. * @param impostor imposter to get linear velocity from
  55362. * @returns linear velocity
  55363. */
  55364. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55365. /**
  55366. * gets the angular velocity
  55367. * @param impostor imposter to get angular velocity from
  55368. * @returns angular velocity
  55369. */
  55370. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55371. /**
  55372. * Sets the mass of physics body
  55373. * @param impostor imposter to set the mass on
  55374. * @param mass mass to set
  55375. */
  55376. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55377. /**
  55378. * Gets the mass of the physics body
  55379. * @param impostor imposter to get the mass from
  55380. * @returns mass
  55381. */
  55382. getBodyMass(impostor: PhysicsImpostor): number;
  55383. /**
  55384. * Gets friction of the impostor
  55385. * @param impostor impostor to get friction from
  55386. * @returns friction value
  55387. */
  55388. getBodyFriction(impostor: PhysicsImpostor): number;
  55389. /**
  55390. * Sets friction of the impostor
  55391. * @param impostor impostor to set friction on
  55392. * @param friction friction value
  55393. */
  55394. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55395. /**
  55396. * Gets restitution of the impostor
  55397. * @param impostor impostor to get restitution from
  55398. * @returns restitution value
  55399. */
  55400. getBodyRestitution(impostor: PhysicsImpostor): number;
  55401. /**
  55402. * Sets resitution of the impostor
  55403. * @param impostor impostor to set resitution on
  55404. * @param restitution resitution value
  55405. */
  55406. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55407. /**
  55408. * Gets pressure inside the impostor
  55409. * @param impostor impostor to get pressure from
  55410. * @returns pressure value
  55411. */
  55412. getBodyPressure(impostor: PhysicsImpostor): number;
  55413. /**
  55414. * Sets pressure inside a soft body impostor
  55415. * Cloth and rope must remain 0 pressure
  55416. * @param impostor impostor to set pressure on
  55417. * @param pressure pressure value
  55418. */
  55419. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55420. /**
  55421. * Gets stiffness of the impostor
  55422. * @param impostor impostor to get stiffness from
  55423. * @returns pressure value
  55424. */
  55425. getBodyStiffness(impostor: PhysicsImpostor): number;
  55426. /**
  55427. * Sets stiffness of the impostor
  55428. * @param impostor impostor to set stiffness on
  55429. * @param stiffness stiffness value from 0 to 1
  55430. */
  55431. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55432. /**
  55433. * Gets velocityIterations of the impostor
  55434. * @param impostor impostor to get velocity iterations from
  55435. * @returns velocityIterations value
  55436. */
  55437. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55438. /**
  55439. * Sets velocityIterations of the impostor
  55440. * @param impostor impostor to set velocity iterations on
  55441. * @param velocityIterations velocityIterations value
  55442. */
  55443. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55444. /**
  55445. * Gets positionIterations of the impostor
  55446. * @param impostor impostor to get position iterations from
  55447. * @returns positionIterations value
  55448. */
  55449. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55450. /**
  55451. * Sets positionIterations of the impostor
  55452. * @param impostor impostor to set position on
  55453. * @param positionIterations positionIterations value
  55454. */
  55455. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55456. /**
  55457. * Append an anchor to a cloth object
  55458. * @param impostor is the cloth impostor to add anchor to
  55459. * @param otherImpostor is the rigid impostor to anchor to
  55460. * @param width ratio across width from 0 to 1
  55461. * @param height ratio up height from 0 to 1
  55462. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55463. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55464. */
  55465. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55466. /**
  55467. * Append an hook to a rope object
  55468. * @param impostor is the rope impostor to add hook to
  55469. * @param otherImpostor is the rigid impostor to hook to
  55470. * @param length ratio along the rope from 0 to 1
  55471. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55472. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55473. */
  55474. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55475. /**
  55476. * Sleeps the physics body and stops it from being active
  55477. * @param impostor impostor to sleep
  55478. */
  55479. sleepBody(impostor: PhysicsImpostor): void;
  55480. /**
  55481. * Activates the physics body
  55482. * @param impostor impostor to activate
  55483. */
  55484. wakeUpBody(impostor: PhysicsImpostor): void;
  55485. /**
  55486. * Updates the distance parameters of the joint
  55487. * @param joint joint to update
  55488. * @param maxDistance maximum distance of the joint
  55489. * @param minDistance minimum distance of the joint
  55490. */
  55491. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55492. /**
  55493. * Sets a motor on the joint
  55494. * @param joint joint to set motor on
  55495. * @param speed speed of the motor
  55496. * @param maxForce maximum force of the motor
  55497. * @param motorIndex index of the motor
  55498. */
  55499. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55500. /**
  55501. * Sets the motors limit
  55502. * @param joint joint to set limit on
  55503. * @param upperLimit upper limit
  55504. * @param lowerLimit lower limit
  55505. */
  55506. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55507. /**
  55508. * Syncs the position and rotation of a mesh with the impostor
  55509. * @param mesh mesh to sync
  55510. * @param impostor impostor to update the mesh with
  55511. */
  55512. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55513. /**
  55514. * Gets the radius of the impostor
  55515. * @param impostor impostor to get radius from
  55516. * @returns the radius
  55517. */
  55518. getRadius(impostor: PhysicsImpostor): number;
  55519. /**
  55520. * Gets the box size of the impostor
  55521. * @param impostor impostor to get box size from
  55522. * @param result the resulting box size
  55523. */
  55524. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55525. /**
  55526. * Disposes of the impostor
  55527. */
  55528. dispose(): void;
  55529. /**
  55530. * Does a raycast in the physics world
  55531. * @param from when should the ray start?
  55532. * @param to when should the ray end?
  55533. * @returns PhysicsRaycastResult
  55534. */
  55535. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55536. }
  55537. }
  55538. declare module BABYLON {
  55539. interface AbstractScene {
  55540. /**
  55541. * The list of reflection probes added to the scene
  55542. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55543. */
  55544. reflectionProbes: Array<ReflectionProbe>;
  55545. /**
  55546. * Removes the given reflection probe from this scene.
  55547. * @param toRemove The reflection probe to remove
  55548. * @returns The index of the removed reflection probe
  55549. */
  55550. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55551. /**
  55552. * Adds the given reflection probe to this scene.
  55553. * @param newReflectionProbe The reflection probe to add
  55554. */
  55555. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55556. }
  55557. /**
  55558. * Class used to generate realtime reflection / refraction cube textures
  55559. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55560. */
  55561. export class ReflectionProbe {
  55562. /** defines the name of the probe */
  55563. name: string;
  55564. private _scene;
  55565. private _renderTargetTexture;
  55566. private _projectionMatrix;
  55567. private _viewMatrix;
  55568. private _target;
  55569. private _add;
  55570. private _attachedMesh;
  55571. private _invertYAxis;
  55572. /** Gets or sets probe position (center of the cube map) */
  55573. position: Vector3;
  55574. /**
  55575. * Creates a new reflection probe
  55576. * @param name defines the name of the probe
  55577. * @param size defines the texture resolution (for each face)
  55578. * @param scene defines the hosting scene
  55579. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55580. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55581. */
  55582. constructor(
  55583. /** defines the name of the probe */
  55584. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55585. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55586. get samples(): number;
  55587. set samples(value: number);
  55588. /** Gets or sets the refresh rate to use (on every frame by default) */
  55589. get refreshRate(): number;
  55590. set refreshRate(value: number);
  55591. /**
  55592. * Gets the hosting scene
  55593. * @returns a Scene
  55594. */
  55595. getScene(): Scene;
  55596. /** Gets the internal CubeTexture used to render to */
  55597. get cubeTexture(): RenderTargetTexture;
  55598. /** Gets the list of meshes to render */
  55599. get renderList(): Nullable<AbstractMesh[]>;
  55600. /**
  55601. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55602. * @param mesh defines the mesh to attach to
  55603. */
  55604. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55605. /**
  55606. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55607. * @param renderingGroupId The rendering group id corresponding to its index
  55608. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55609. */
  55610. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55611. /**
  55612. * Clean all associated resources
  55613. */
  55614. dispose(): void;
  55615. /**
  55616. * Converts the reflection probe information to a readable string for debug purpose.
  55617. * @param fullDetails Supports for multiple levels of logging within scene loading
  55618. * @returns the human readable reflection probe info
  55619. */
  55620. toString(fullDetails?: boolean): string;
  55621. /**
  55622. * Get the class name of the relfection probe.
  55623. * @returns "ReflectionProbe"
  55624. */
  55625. getClassName(): string;
  55626. /**
  55627. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55628. * @returns The JSON representation of the texture
  55629. */
  55630. serialize(): any;
  55631. /**
  55632. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55633. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55634. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55635. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55636. * @returns The parsed reflection probe if successful
  55637. */
  55638. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55639. }
  55640. }
  55641. declare module BABYLON {
  55642. /** @hidden */
  55643. export var _BabylonLoaderRegistered: boolean;
  55644. /**
  55645. * Helps setting up some configuration for the babylon file loader.
  55646. */
  55647. export class BabylonFileLoaderConfiguration {
  55648. /**
  55649. * The loader does not allow injecting custom physix engine into the plugins.
  55650. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55651. * So you could set this variable to your engine import to make it work.
  55652. */
  55653. static LoaderInjectedPhysicsEngine: any;
  55654. }
  55655. }
  55656. declare module BABYLON {
  55657. /**
  55658. * The Physically based simple base material of BJS.
  55659. *
  55660. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55661. * It is used as the base class for both the specGloss and metalRough conventions.
  55662. */
  55663. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55664. /**
  55665. * Number of Simultaneous lights allowed on the material.
  55666. */
  55667. maxSimultaneousLights: number;
  55668. /**
  55669. * If sets to true, disables all the lights affecting the material.
  55670. */
  55671. disableLighting: boolean;
  55672. /**
  55673. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55674. */
  55675. environmentTexture: BaseTexture;
  55676. /**
  55677. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55678. */
  55679. invertNormalMapX: boolean;
  55680. /**
  55681. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55682. */
  55683. invertNormalMapY: boolean;
  55684. /**
  55685. * Normal map used in the model.
  55686. */
  55687. normalTexture: BaseTexture;
  55688. /**
  55689. * Emissivie color used to self-illuminate the model.
  55690. */
  55691. emissiveColor: Color3;
  55692. /**
  55693. * Emissivie texture used to self-illuminate the model.
  55694. */
  55695. emissiveTexture: BaseTexture;
  55696. /**
  55697. * Occlusion Channel Strenght.
  55698. */
  55699. occlusionStrength: number;
  55700. /**
  55701. * Occlusion Texture of the material (adding extra occlusion effects).
  55702. */
  55703. occlusionTexture: BaseTexture;
  55704. /**
  55705. * Defines the alpha limits in alpha test mode.
  55706. */
  55707. alphaCutOff: number;
  55708. /**
  55709. * Gets the current double sided mode.
  55710. */
  55711. get doubleSided(): boolean;
  55712. /**
  55713. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55714. */
  55715. set doubleSided(value: boolean);
  55716. /**
  55717. * Stores the pre-calculated light information of a mesh in a texture.
  55718. */
  55719. lightmapTexture: BaseTexture;
  55720. /**
  55721. * If true, the light map contains occlusion information instead of lighting info.
  55722. */
  55723. useLightmapAsShadowmap: boolean;
  55724. /**
  55725. * Instantiates a new PBRMaterial instance.
  55726. *
  55727. * @param name The material name
  55728. * @param scene The scene the material will be use in.
  55729. */
  55730. constructor(name: string, scene: Scene);
  55731. getClassName(): string;
  55732. }
  55733. }
  55734. declare module BABYLON {
  55735. /**
  55736. * The PBR material of BJS following the metal roughness convention.
  55737. *
  55738. * This fits to the PBR convention in the GLTF definition:
  55739. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55740. */
  55741. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55742. /**
  55743. * The base color has two different interpretations depending on the value of metalness.
  55744. * When the material is a metal, the base color is the specific measured reflectance value
  55745. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55746. * of the material.
  55747. */
  55748. baseColor: Color3;
  55749. /**
  55750. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55751. * well as opacity information in the alpha channel.
  55752. */
  55753. baseTexture: BaseTexture;
  55754. /**
  55755. * Specifies the metallic scalar value of the material.
  55756. * Can also be used to scale the metalness values of the metallic texture.
  55757. */
  55758. metallic: number;
  55759. /**
  55760. * Specifies the roughness scalar value of the material.
  55761. * Can also be used to scale the roughness values of the metallic texture.
  55762. */
  55763. roughness: number;
  55764. /**
  55765. * Texture containing both the metallic value in the B channel and the
  55766. * roughness value in the G channel to keep better precision.
  55767. */
  55768. metallicRoughnessTexture: BaseTexture;
  55769. /**
  55770. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55771. *
  55772. * @param name The material name
  55773. * @param scene The scene the material will be use in.
  55774. */
  55775. constructor(name: string, scene: Scene);
  55776. /**
  55777. * Return the currrent class name of the material.
  55778. */
  55779. getClassName(): string;
  55780. /**
  55781. * Makes a duplicate of the current material.
  55782. * @param name - name to use for the new material.
  55783. */
  55784. clone(name: string): PBRMetallicRoughnessMaterial;
  55785. /**
  55786. * Serialize the material to a parsable JSON object.
  55787. */
  55788. serialize(): any;
  55789. /**
  55790. * Parses a JSON object correponding to the serialize function.
  55791. */
  55792. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55793. }
  55794. }
  55795. declare module BABYLON {
  55796. /**
  55797. * The PBR material of BJS following the specular glossiness convention.
  55798. *
  55799. * This fits to the PBR convention in the GLTF definition:
  55800. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55801. */
  55802. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55803. /**
  55804. * Specifies the diffuse color of the material.
  55805. */
  55806. diffuseColor: Color3;
  55807. /**
  55808. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55809. * channel.
  55810. */
  55811. diffuseTexture: BaseTexture;
  55812. /**
  55813. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55814. */
  55815. specularColor: Color3;
  55816. /**
  55817. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55818. */
  55819. glossiness: number;
  55820. /**
  55821. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55822. */
  55823. specularGlossinessTexture: BaseTexture;
  55824. /**
  55825. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55826. *
  55827. * @param name The material name
  55828. * @param scene The scene the material will be use in.
  55829. */
  55830. constructor(name: string, scene: Scene);
  55831. /**
  55832. * Return the currrent class name of the material.
  55833. */
  55834. getClassName(): string;
  55835. /**
  55836. * Makes a duplicate of the current material.
  55837. * @param name - name to use for the new material.
  55838. */
  55839. clone(name: string): PBRSpecularGlossinessMaterial;
  55840. /**
  55841. * Serialize the material to a parsable JSON object.
  55842. */
  55843. serialize(): any;
  55844. /**
  55845. * Parses a JSON object correponding to the serialize function.
  55846. */
  55847. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55848. }
  55849. }
  55850. declare module BABYLON {
  55851. /**
  55852. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55853. * It can help converting any input color in a desired output one. This can then be used to create effects
  55854. * from sepia, black and white to sixties or futuristic rendering...
  55855. *
  55856. * The only supported format is currently 3dl.
  55857. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55858. */
  55859. export class ColorGradingTexture extends BaseTexture {
  55860. /**
  55861. * The current texture matrix. (will always be identity in color grading texture)
  55862. */
  55863. private _textureMatrix;
  55864. /**
  55865. * The texture URL.
  55866. */
  55867. url: string;
  55868. /**
  55869. * Empty line regex stored for GC.
  55870. */
  55871. private static _noneEmptyLineRegex;
  55872. private _engine;
  55873. /**
  55874. * Instantiates a ColorGradingTexture from the following parameters.
  55875. *
  55876. * @param url The location of the color gradind data (currently only supporting 3dl)
  55877. * @param scene The scene the texture will be used in
  55878. */
  55879. constructor(url: string, scene: Scene);
  55880. /**
  55881. * Returns the texture matrix used in most of the material.
  55882. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55883. */
  55884. getTextureMatrix(): Matrix;
  55885. /**
  55886. * Occurs when the file being loaded is a .3dl LUT file.
  55887. */
  55888. private load3dlTexture;
  55889. /**
  55890. * Starts the loading process of the texture.
  55891. */
  55892. private loadTexture;
  55893. /**
  55894. * Clones the color gradind texture.
  55895. */
  55896. clone(): ColorGradingTexture;
  55897. /**
  55898. * Called during delayed load for textures.
  55899. */
  55900. delayLoad(): void;
  55901. /**
  55902. * Parses a color grading texture serialized by Babylon.
  55903. * @param parsedTexture The texture information being parsedTexture
  55904. * @param scene The scene to load the texture in
  55905. * @param rootUrl The root url of the data assets to load
  55906. * @return A color gradind texture
  55907. */
  55908. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55909. /**
  55910. * Serializes the LUT texture to json format.
  55911. */
  55912. serialize(): any;
  55913. }
  55914. }
  55915. declare module BABYLON {
  55916. /**
  55917. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55918. */
  55919. export class EquiRectangularCubeTexture extends BaseTexture {
  55920. /** The six faces of the cube. */
  55921. private static _FacesMapping;
  55922. private _noMipmap;
  55923. private _onLoad;
  55924. private _onError;
  55925. /** The size of the cubemap. */
  55926. private _size;
  55927. /** The buffer of the image. */
  55928. private _buffer;
  55929. /** The width of the input image. */
  55930. private _width;
  55931. /** The height of the input image. */
  55932. private _height;
  55933. /** The URL to the image. */
  55934. url: string;
  55935. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55936. coordinatesMode: number;
  55937. /**
  55938. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55939. * @param url The location of the image
  55940. * @param scene The scene the texture will be used in
  55941. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55942. * @param noMipmap Forces to not generate the mipmap if true
  55943. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55944. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55945. * @param onLoad — defines a callback called when texture is loaded
  55946. * @param onError — defines a callback called if there is an error
  55947. */
  55948. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55949. /**
  55950. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55951. */
  55952. private loadImage;
  55953. /**
  55954. * Convert the image buffer into a cubemap and create a CubeTexture.
  55955. */
  55956. private loadTexture;
  55957. /**
  55958. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55959. * @param buffer The ArrayBuffer that should be converted.
  55960. * @returns The buffer as Float32Array.
  55961. */
  55962. private getFloat32ArrayFromArrayBuffer;
  55963. /**
  55964. * Get the current class name of the texture useful for serialization or dynamic coding.
  55965. * @returns "EquiRectangularCubeTexture"
  55966. */
  55967. getClassName(): string;
  55968. /**
  55969. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55970. * @returns A clone of the current EquiRectangularCubeTexture.
  55971. */
  55972. clone(): EquiRectangularCubeTexture;
  55973. }
  55974. }
  55975. declare module BABYLON {
  55976. /**
  55977. * Based on jsTGALoader - Javascript loader for TGA file
  55978. * By Vincent Thibault
  55979. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55980. */
  55981. export class TGATools {
  55982. private static _TYPE_INDEXED;
  55983. private static _TYPE_RGB;
  55984. private static _TYPE_GREY;
  55985. private static _TYPE_RLE_INDEXED;
  55986. private static _TYPE_RLE_RGB;
  55987. private static _TYPE_RLE_GREY;
  55988. private static _ORIGIN_MASK;
  55989. private static _ORIGIN_SHIFT;
  55990. private static _ORIGIN_BL;
  55991. private static _ORIGIN_BR;
  55992. private static _ORIGIN_UL;
  55993. private static _ORIGIN_UR;
  55994. /**
  55995. * Gets the header of a TGA file
  55996. * @param data defines the TGA data
  55997. * @returns the header
  55998. */
  55999. static GetTGAHeader(data: Uint8Array): any;
  56000. /**
  56001. * Uploads TGA content to a Babylon Texture
  56002. * @hidden
  56003. */
  56004. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56005. /** @hidden */
  56006. 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;
  56007. /** @hidden */
  56008. 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;
  56009. /** @hidden */
  56010. 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;
  56011. /** @hidden */
  56012. 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;
  56013. /** @hidden */
  56014. 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;
  56015. /** @hidden */
  56016. 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;
  56017. }
  56018. }
  56019. declare module BABYLON {
  56020. /**
  56021. * Implementation of the TGA Texture Loader.
  56022. * @hidden
  56023. */
  56024. export class _TGATextureLoader implements IInternalTextureLoader {
  56025. /**
  56026. * Defines wether the loader supports cascade loading the different faces.
  56027. */
  56028. readonly supportCascades: boolean;
  56029. /**
  56030. * This returns if the loader support the current file information.
  56031. * @param extension defines the file extension of the file being loaded
  56032. * @returns true if the loader can load the specified file
  56033. */
  56034. canLoad(extension: string): boolean;
  56035. /**
  56036. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56037. * @param data contains the texture data
  56038. * @param texture defines the BabylonJS internal texture
  56039. * @param createPolynomials will be true if polynomials have been requested
  56040. * @param onLoad defines the callback to trigger once the texture is ready
  56041. * @param onError defines the callback to trigger in case of error
  56042. */
  56043. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56044. /**
  56045. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56046. * @param data contains the texture data
  56047. * @param texture defines the BabylonJS internal texture
  56048. * @param callback defines the method to call once ready to upload
  56049. */
  56050. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56051. }
  56052. }
  56053. declare module BABYLON {
  56054. /**
  56055. * Info about the .basis files
  56056. */
  56057. class BasisFileInfo {
  56058. /**
  56059. * If the file has alpha
  56060. */
  56061. hasAlpha: boolean;
  56062. /**
  56063. * Info about each image of the basis file
  56064. */
  56065. images: Array<{
  56066. levels: Array<{
  56067. width: number;
  56068. height: number;
  56069. transcodedPixels: ArrayBufferView;
  56070. }>;
  56071. }>;
  56072. }
  56073. /**
  56074. * Result of transcoding a basis file
  56075. */
  56076. class TranscodeResult {
  56077. /**
  56078. * Info about the .basis file
  56079. */
  56080. fileInfo: BasisFileInfo;
  56081. /**
  56082. * Format to use when loading the file
  56083. */
  56084. format: number;
  56085. }
  56086. /**
  56087. * Configuration options for the Basis transcoder
  56088. */
  56089. export class BasisTranscodeConfiguration {
  56090. /**
  56091. * Supported compression formats used to determine the supported output format of the transcoder
  56092. */
  56093. supportedCompressionFormats?: {
  56094. /**
  56095. * etc1 compression format
  56096. */
  56097. etc1?: boolean;
  56098. /**
  56099. * s3tc compression format
  56100. */
  56101. s3tc?: boolean;
  56102. /**
  56103. * pvrtc compression format
  56104. */
  56105. pvrtc?: boolean;
  56106. /**
  56107. * etc2 compression format
  56108. */
  56109. etc2?: boolean;
  56110. };
  56111. /**
  56112. * If mipmap levels should be loaded for transcoded images (Default: true)
  56113. */
  56114. loadMipmapLevels?: boolean;
  56115. /**
  56116. * Index of a single image to load (Default: all images)
  56117. */
  56118. loadSingleImage?: number;
  56119. }
  56120. /**
  56121. * Used to load .Basis files
  56122. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56123. */
  56124. export class BasisTools {
  56125. private static _IgnoreSupportedFormats;
  56126. /**
  56127. * URL to use when loading the basis transcoder
  56128. */
  56129. static JSModuleURL: string;
  56130. /**
  56131. * URL to use when loading the wasm module for the transcoder
  56132. */
  56133. static WasmModuleURL: string;
  56134. /**
  56135. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56136. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56137. * @returns internal format corresponding to the Basis format
  56138. */
  56139. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56140. private static _WorkerPromise;
  56141. private static _Worker;
  56142. private static _actionId;
  56143. private static _CreateWorkerAsync;
  56144. /**
  56145. * Transcodes a loaded image file to compressed pixel data
  56146. * @param data image data to transcode
  56147. * @param config configuration options for the transcoding
  56148. * @returns a promise resulting in the transcoded image
  56149. */
  56150. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56151. /**
  56152. * Loads a texture from the transcode result
  56153. * @param texture texture load to
  56154. * @param transcodeResult the result of transcoding the basis file to load from
  56155. */
  56156. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56157. }
  56158. }
  56159. declare module BABYLON {
  56160. /**
  56161. * Loader for .basis file format
  56162. */
  56163. export class _BasisTextureLoader implements IInternalTextureLoader {
  56164. /**
  56165. * Defines whether the loader supports cascade loading the different faces.
  56166. */
  56167. readonly supportCascades: boolean;
  56168. /**
  56169. * This returns if the loader support the current file information.
  56170. * @param extension defines the file extension of the file being loaded
  56171. * @returns true if the loader can load the specified file
  56172. */
  56173. canLoad(extension: string): boolean;
  56174. /**
  56175. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56176. * @param data contains the texture data
  56177. * @param texture defines the BabylonJS internal texture
  56178. * @param createPolynomials will be true if polynomials have been requested
  56179. * @param onLoad defines the callback to trigger once the texture is ready
  56180. * @param onError defines the callback to trigger in case of error
  56181. */
  56182. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56183. /**
  56184. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56185. * @param data contains the texture data
  56186. * @param texture defines the BabylonJS internal texture
  56187. * @param callback defines the method to call once ready to upload
  56188. */
  56189. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56190. }
  56191. }
  56192. declare module BABYLON {
  56193. /**
  56194. * 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.
  56195. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56196. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56197. */
  56198. export class CustomProceduralTexture extends ProceduralTexture {
  56199. private _animate;
  56200. private _time;
  56201. private _config;
  56202. private _texturePath;
  56203. /**
  56204. * Instantiates a new Custom Procedural Texture.
  56205. * 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.
  56206. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56207. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56208. * @param name Define the name of the texture
  56209. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56210. * @param size Define the size of the texture to create
  56211. * @param scene Define the scene the texture belongs to
  56212. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56213. * @param generateMipMaps Define if the texture should creates mip maps or not
  56214. */
  56215. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56216. private _loadJson;
  56217. /**
  56218. * Is the texture ready to be used ? (rendered at least once)
  56219. * @returns true if ready, otherwise, false.
  56220. */
  56221. isReady(): boolean;
  56222. /**
  56223. * Render the texture to its associated render target.
  56224. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56225. */
  56226. render(useCameraPostProcess?: boolean): void;
  56227. /**
  56228. * Update the list of dependant textures samplers in the shader.
  56229. */
  56230. updateTextures(): void;
  56231. /**
  56232. * Update the uniform values of the procedural texture in the shader.
  56233. */
  56234. updateShaderUniforms(): void;
  56235. /**
  56236. * Define if the texture animates or not.
  56237. */
  56238. get animate(): boolean;
  56239. set animate(value: boolean);
  56240. }
  56241. }
  56242. declare module BABYLON {
  56243. /** @hidden */
  56244. export var noisePixelShader: {
  56245. name: string;
  56246. shader: string;
  56247. };
  56248. }
  56249. declare module BABYLON {
  56250. /**
  56251. * Class used to generate noise procedural textures
  56252. */
  56253. export class NoiseProceduralTexture extends ProceduralTexture {
  56254. private _time;
  56255. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56256. brightness: number;
  56257. /** Defines the number of octaves to process */
  56258. octaves: number;
  56259. /** Defines the level of persistence (0.8 by default) */
  56260. persistence: number;
  56261. /** Gets or sets animation speed factor (default is 1) */
  56262. animationSpeedFactor: number;
  56263. /**
  56264. * Creates a new NoiseProceduralTexture
  56265. * @param name defines the name fo the texture
  56266. * @param size defines the size of the texture (default is 256)
  56267. * @param scene defines the hosting scene
  56268. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56269. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56270. */
  56271. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56272. private _updateShaderUniforms;
  56273. protected _getDefines(): string;
  56274. /** Generate the current state of the procedural texture */
  56275. render(useCameraPostProcess?: boolean): void;
  56276. /**
  56277. * Serializes this noise procedural texture
  56278. * @returns a serialized noise procedural texture object
  56279. */
  56280. serialize(): any;
  56281. /**
  56282. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56283. * @param parsedTexture defines parsed texture data
  56284. * @param scene defines the current scene
  56285. * @param rootUrl defines the root URL containing noise procedural texture information
  56286. * @returns a parsed NoiseProceduralTexture
  56287. */
  56288. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56289. }
  56290. }
  56291. declare module BABYLON {
  56292. /**
  56293. * Raw cube texture where the raw buffers are passed in
  56294. */
  56295. export class RawCubeTexture extends CubeTexture {
  56296. /**
  56297. * Creates a cube texture where the raw buffers are passed in.
  56298. * @param scene defines the scene the texture is attached to
  56299. * @param data defines the array of data to use to create each face
  56300. * @param size defines the size of the textures
  56301. * @param format defines the format of the data
  56302. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56303. * @param generateMipMaps defines if the engine should generate the mip levels
  56304. * @param invertY defines if data must be stored with Y axis inverted
  56305. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56306. * @param compression defines the compression used (null by default)
  56307. */
  56308. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56309. /**
  56310. * Updates the raw cube texture.
  56311. * @param data defines the data to store
  56312. * @param format defines the data format
  56313. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56314. * @param invertY defines if data must be stored with Y axis inverted
  56315. * @param compression defines the compression used (null by default)
  56316. * @param level defines which level of the texture to update
  56317. */
  56318. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56319. /**
  56320. * Updates a raw cube texture with RGBD encoded data.
  56321. * @param data defines the array of data [mipmap][face] to use to create each face
  56322. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56323. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56324. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56325. * @returns a promsie that resolves when the operation is complete
  56326. */
  56327. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56328. /**
  56329. * Clones the raw cube texture.
  56330. * @return a new cube texture
  56331. */
  56332. clone(): CubeTexture;
  56333. /** @hidden */
  56334. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56335. }
  56336. }
  56337. declare module BABYLON {
  56338. /**
  56339. * Class used to store 3D textures containing user data
  56340. */
  56341. export class RawTexture3D extends Texture {
  56342. /** Gets or sets the texture format to use */
  56343. format: number;
  56344. private _engine;
  56345. /**
  56346. * Create a new RawTexture3D
  56347. * @param data defines the data of the texture
  56348. * @param width defines the width of the texture
  56349. * @param height defines the height of the texture
  56350. * @param depth defines the depth of the texture
  56351. * @param format defines the texture format to use
  56352. * @param scene defines the hosting scene
  56353. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56354. * @param invertY defines if texture must be stored with Y axis inverted
  56355. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56356. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56357. */
  56358. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56359. /** Gets or sets the texture format to use */
  56360. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56361. /**
  56362. * Update the texture with new data
  56363. * @param data defines the data to store in the texture
  56364. */
  56365. update(data: ArrayBufferView): void;
  56366. }
  56367. }
  56368. declare module BABYLON {
  56369. /**
  56370. * Class used to store 2D array textures containing user data
  56371. */
  56372. export class RawTexture2DArray extends Texture {
  56373. /** Gets or sets the texture format to use */
  56374. format: number;
  56375. private _engine;
  56376. /**
  56377. * Create a new RawTexture2DArray
  56378. * @param data defines the data of the texture
  56379. * @param width defines the width of the texture
  56380. * @param height defines the height of the texture
  56381. * @param depth defines the number of layers of the texture
  56382. * @param format defines the texture format to use
  56383. * @param scene defines the hosting scene
  56384. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56385. * @param invertY defines if texture must be stored with Y axis inverted
  56386. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56387. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56388. */
  56389. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56390. /** Gets or sets the texture format to use */
  56391. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56392. /**
  56393. * Update the texture with new data
  56394. * @param data defines the data to store in the texture
  56395. */
  56396. update(data: ArrayBufferView): void;
  56397. }
  56398. }
  56399. declare module BABYLON {
  56400. /**
  56401. * Creates a refraction texture used by refraction channel of the standard material.
  56402. * It is like a mirror but to see through a material.
  56403. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56404. */
  56405. export class RefractionTexture extends RenderTargetTexture {
  56406. /**
  56407. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56408. * 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.
  56409. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56410. */
  56411. refractionPlane: Plane;
  56412. /**
  56413. * Define how deep under the surface we should see.
  56414. */
  56415. depth: number;
  56416. /**
  56417. * Creates a refraction texture used by refraction channel of the standard material.
  56418. * It is like a mirror but to see through a material.
  56419. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56420. * @param name Define the texture name
  56421. * @param size Define the size of the underlying texture
  56422. * @param scene Define the scene the refraction belongs to
  56423. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56424. */
  56425. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56426. /**
  56427. * Clone the refraction texture.
  56428. * @returns the cloned texture
  56429. */
  56430. clone(): RefractionTexture;
  56431. /**
  56432. * Serialize the texture to a JSON representation you could use in Parse later on
  56433. * @returns the serialized JSON representation
  56434. */
  56435. serialize(): any;
  56436. }
  56437. }
  56438. declare module BABYLON {
  56439. /**
  56440. * Defines the options related to the creation of an HtmlElementTexture
  56441. */
  56442. export interface IHtmlElementTextureOptions {
  56443. /**
  56444. * Defines wether mip maps should be created or not.
  56445. */
  56446. generateMipMaps?: boolean;
  56447. /**
  56448. * Defines the sampling mode of the texture.
  56449. */
  56450. samplingMode?: number;
  56451. /**
  56452. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56453. */
  56454. engine: Nullable<ThinEngine>;
  56455. /**
  56456. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56457. */
  56458. scene: Nullable<Scene>;
  56459. }
  56460. /**
  56461. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56462. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56463. * is automatically managed.
  56464. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56465. * in your application.
  56466. *
  56467. * As the update is not automatic, you need to call them manually.
  56468. */
  56469. export class HtmlElementTexture extends BaseTexture {
  56470. /**
  56471. * The texture URL.
  56472. */
  56473. element: HTMLVideoElement | HTMLCanvasElement;
  56474. private static readonly DefaultOptions;
  56475. private _textureMatrix;
  56476. private _engine;
  56477. private _isVideo;
  56478. private _generateMipMaps;
  56479. private _samplingMode;
  56480. /**
  56481. * Instantiates a HtmlElementTexture from the following parameters.
  56482. *
  56483. * @param name Defines the name of the texture
  56484. * @param element Defines the video or canvas the texture is filled with
  56485. * @param options Defines the other none mandatory texture creation options
  56486. */
  56487. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56488. private _createInternalTexture;
  56489. /**
  56490. * Returns the texture matrix used in most of the material.
  56491. */
  56492. getTextureMatrix(): Matrix;
  56493. /**
  56494. * Updates the content of the texture.
  56495. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56496. */
  56497. update(invertY?: Nullable<boolean>): void;
  56498. }
  56499. }
  56500. declare module BABYLON {
  56501. /**
  56502. * Defines the basic options interface of a TexturePacker Frame
  56503. */
  56504. export interface ITexturePackerFrame {
  56505. /**
  56506. * The frame ID
  56507. */
  56508. id: number;
  56509. /**
  56510. * The frames Scale
  56511. */
  56512. scale: Vector2;
  56513. /**
  56514. * The Frames offset
  56515. */
  56516. offset: Vector2;
  56517. }
  56518. /**
  56519. * This is a support class for frame Data on texture packer sets.
  56520. */
  56521. export class TexturePackerFrame implements ITexturePackerFrame {
  56522. /**
  56523. * The frame ID
  56524. */
  56525. id: number;
  56526. /**
  56527. * The frames Scale
  56528. */
  56529. scale: Vector2;
  56530. /**
  56531. * The Frames offset
  56532. */
  56533. offset: Vector2;
  56534. /**
  56535. * Initializes a texture package frame.
  56536. * @param id The numerical frame identifier
  56537. * @param scale Scalar Vector2 for UV frame
  56538. * @param offset Vector2 for the frame position in UV units.
  56539. * @returns TexturePackerFrame
  56540. */
  56541. constructor(id: number, scale: Vector2, offset: Vector2);
  56542. }
  56543. }
  56544. declare module BABYLON {
  56545. /**
  56546. * Defines the basic options interface of a TexturePacker
  56547. */
  56548. export interface ITexturePackerOptions {
  56549. /**
  56550. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56551. */
  56552. map?: string[];
  56553. /**
  56554. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56555. */
  56556. uvsIn?: string;
  56557. /**
  56558. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56559. */
  56560. uvsOut?: string;
  56561. /**
  56562. * number representing the layout style. Defaults to LAYOUT_STRIP
  56563. */
  56564. layout?: number;
  56565. /**
  56566. * number of columns if using custom column count layout(2). This defaults to 4.
  56567. */
  56568. colnum?: number;
  56569. /**
  56570. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56571. */
  56572. updateInputMeshes?: boolean;
  56573. /**
  56574. * boolean flag to dispose all the source textures. Defaults to true.
  56575. */
  56576. disposeSources?: boolean;
  56577. /**
  56578. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56579. */
  56580. fillBlanks?: boolean;
  56581. /**
  56582. * string value representing the context fill style color. Defaults to 'black'.
  56583. */
  56584. customFillColor?: string;
  56585. /**
  56586. * Width and Height Value of each Frame in the TexturePacker Sets
  56587. */
  56588. frameSize?: number;
  56589. /**
  56590. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56591. */
  56592. paddingRatio?: number;
  56593. /**
  56594. * Number that declares the fill method for the padding gutter.
  56595. */
  56596. paddingMode?: number;
  56597. /**
  56598. * If in SUBUV_COLOR padding mode what color to use.
  56599. */
  56600. paddingColor?: Color3 | Color4;
  56601. }
  56602. /**
  56603. * Defines the basic interface of a TexturePacker JSON File
  56604. */
  56605. export interface ITexturePackerJSON {
  56606. /**
  56607. * The frame ID
  56608. */
  56609. name: string;
  56610. /**
  56611. * The base64 channel data
  56612. */
  56613. sets: any;
  56614. /**
  56615. * The options of the Packer
  56616. */
  56617. options: ITexturePackerOptions;
  56618. /**
  56619. * The frame data of the Packer
  56620. */
  56621. frames: Array<number>;
  56622. }
  56623. /**
  56624. * This is a support class that generates a series of packed texture sets.
  56625. * @see https://doc.babylonjs.com/babylon101/materials
  56626. */
  56627. export class TexturePacker {
  56628. /** Packer Layout Constant 0 */
  56629. static readonly LAYOUT_STRIP: number;
  56630. /** Packer Layout Constant 1 */
  56631. static readonly LAYOUT_POWER2: number;
  56632. /** Packer Layout Constant 2 */
  56633. static readonly LAYOUT_COLNUM: number;
  56634. /** Packer Layout Constant 0 */
  56635. static readonly SUBUV_WRAP: number;
  56636. /** Packer Layout Constant 1 */
  56637. static readonly SUBUV_EXTEND: number;
  56638. /** Packer Layout Constant 2 */
  56639. static readonly SUBUV_COLOR: number;
  56640. /** The Name of the Texture Package */
  56641. name: string;
  56642. /** The scene scope of the TexturePacker */
  56643. scene: Scene;
  56644. /** The Meshes to target */
  56645. meshes: AbstractMesh[];
  56646. /** Arguments passed with the Constructor */
  56647. options: ITexturePackerOptions;
  56648. /** The promise that is started upon initialization */
  56649. promise: Nullable<Promise<TexturePacker | string>>;
  56650. /** The Container object for the channel sets that are generated */
  56651. sets: object;
  56652. /** The Container array for the frames that are generated */
  56653. frames: TexturePackerFrame[];
  56654. /** The expected number of textures the system is parsing. */
  56655. private _expecting;
  56656. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56657. private _paddingValue;
  56658. /**
  56659. * Initializes a texture package series from an array of meshes or a single mesh.
  56660. * @param name The name of the package
  56661. * @param meshes The target meshes to compose the package from
  56662. * @param options The arguments that texture packer should follow while building.
  56663. * @param scene The scene which the textures are scoped to.
  56664. * @returns TexturePacker
  56665. */
  56666. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56667. /**
  56668. * Starts the package process
  56669. * @param resolve The promises resolution function
  56670. * @returns TexturePacker
  56671. */
  56672. private _createFrames;
  56673. /**
  56674. * Calculates the Size of the Channel Sets
  56675. * @returns Vector2
  56676. */
  56677. private _calculateSize;
  56678. /**
  56679. * Calculates the UV data for the frames.
  56680. * @param baseSize the base frameSize
  56681. * @param padding the base frame padding
  56682. * @param dtSize size of the Dynamic Texture for that channel
  56683. * @param dtUnits is 1/dtSize
  56684. * @param update flag to update the input meshes
  56685. */
  56686. private _calculateMeshUVFrames;
  56687. /**
  56688. * Calculates the frames Offset.
  56689. * @param index of the frame
  56690. * @returns Vector2
  56691. */
  56692. private _getFrameOffset;
  56693. /**
  56694. * Updates a Mesh to the frame data
  56695. * @param mesh that is the target
  56696. * @param frameID or the frame index
  56697. */
  56698. private _updateMeshUV;
  56699. /**
  56700. * Updates a Meshes materials to use the texture packer channels
  56701. * @param m is the mesh to target
  56702. * @param force all channels on the packer to be set.
  56703. */
  56704. private _updateTextureReferences;
  56705. /**
  56706. * Public method to set a Mesh to a frame
  56707. * @param m that is the target
  56708. * @param frameID or the frame index
  56709. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56710. */
  56711. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56712. /**
  56713. * Starts the async promise to compile the texture packer.
  56714. * @returns Promise<void>
  56715. */
  56716. processAsync(): Promise<void>;
  56717. /**
  56718. * Disposes all textures associated with this packer
  56719. */
  56720. dispose(): void;
  56721. /**
  56722. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56723. * @param imageType is the image type to use.
  56724. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56725. */
  56726. download(imageType?: string, quality?: number): void;
  56727. /**
  56728. * Public method to load a texturePacker JSON file.
  56729. * @param data of the JSON file in string format.
  56730. */
  56731. updateFromJSON(data: string): void;
  56732. }
  56733. }
  56734. declare module BABYLON {
  56735. /**
  56736. * Enum used to define the target of a block
  56737. */
  56738. export enum NodeMaterialBlockTargets {
  56739. /** Vertex shader */
  56740. Vertex = 1,
  56741. /** Fragment shader */
  56742. Fragment = 2,
  56743. /** Neutral */
  56744. Neutral = 4,
  56745. /** Vertex and Fragment */
  56746. VertexAndFragment = 3
  56747. }
  56748. }
  56749. declare module BABYLON {
  56750. /**
  56751. * Defines the kind of connection point for node based material
  56752. */
  56753. export enum NodeMaterialBlockConnectionPointTypes {
  56754. /** Float */
  56755. Float = 1,
  56756. /** Int */
  56757. Int = 2,
  56758. /** Vector2 */
  56759. Vector2 = 4,
  56760. /** Vector3 */
  56761. Vector3 = 8,
  56762. /** Vector4 */
  56763. Vector4 = 16,
  56764. /** Color3 */
  56765. Color3 = 32,
  56766. /** Color4 */
  56767. Color4 = 64,
  56768. /** Matrix */
  56769. Matrix = 128,
  56770. /** Detect type based on connection */
  56771. AutoDetect = 1024,
  56772. /** Output type that will be defined by input type */
  56773. BasedOnInput = 2048
  56774. }
  56775. }
  56776. declare module BABYLON {
  56777. /**
  56778. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56779. */
  56780. export enum NodeMaterialBlockConnectionPointMode {
  56781. /** Value is an uniform */
  56782. Uniform = 0,
  56783. /** Value is a mesh attribute */
  56784. Attribute = 1,
  56785. /** Value is a varying between vertex and fragment shaders */
  56786. Varying = 2,
  56787. /** Mode is undefined */
  56788. Undefined = 3
  56789. }
  56790. }
  56791. declare module BABYLON {
  56792. /**
  56793. * Enum used to define system values e.g. values automatically provided by the system
  56794. */
  56795. export enum NodeMaterialSystemValues {
  56796. /** World */
  56797. World = 1,
  56798. /** View */
  56799. View = 2,
  56800. /** Projection */
  56801. Projection = 3,
  56802. /** ViewProjection */
  56803. ViewProjection = 4,
  56804. /** WorldView */
  56805. WorldView = 5,
  56806. /** WorldViewProjection */
  56807. WorldViewProjection = 6,
  56808. /** CameraPosition */
  56809. CameraPosition = 7,
  56810. /** Fog Color */
  56811. FogColor = 8,
  56812. /** Delta time */
  56813. DeltaTime = 9
  56814. }
  56815. }
  56816. declare module BABYLON {
  56817. /**
  56818. * Root class for all node material optimizers
  56819. */
  56820. export class NodeMaterialOptimizer {
  56821. /**
  56822. * Function used to optimize a NodeMaterial graph
  56823. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56824. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56825. */
  56826. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56827. }
  56828. }
  56829. declare module BABYLON {
  56830. /**
  56831. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56832. */
  56833. export class TransformBlock extends NodeMaterialBlock {
  56834. /**
  56835. * Defines the value to use to complement W value to transform it to a Vector4
  56836. */
  56837. complementW: number;
  56838. /**
  56839. * Defines the value to use to complement z value to transform it to a Vector4
  56840. */
  56841. complementZ: number;
  56842. /**
  56843. * Creates a new TransformBlock
  56844. * @param name defines the block name
  56845. */
  56846. constructor(name: string);
  56847. /**
  56848. * Gets the current class name
  56849. * @returns the class name
  56850. */
  56851. getClassName(): string;
  56852. /**
  56853. * Gets the vector input
  56854. */
  56855. get vector(): NodeMaterialConnectionPoint;
  56856. /**
  56857. * Gets the output component
  56858. */
  56859. get output(): NodeMaterialConnectionPoint;
  56860. /**
  56861. * Gets the xyz output component
  56862. */
  56863. get xyz(): NodeMaterialConnectionPoint;
  56864. /**
  56865. * Gets the matrix transform input
  56866. */
  56867. get transform(): NodeMaterialConnectionPoint;
  56868. protected _buildBlock(state: NodeMaterialBuildState): this;
  56869. serialize(): any;
  56870. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56871. protected _dumpPropertiesCode(): string;
  56872. }
  56873. }
  56874. declare module BABYLON {
  56875. /**
  56876. * Block used to output the vertex position
  56877. */
  56878. export class VertexOutputBlock extends NodeMaterialBlock {
  56879. /**
  56880. * Creates a new VertexOutputBlock
  56881. * @param name defines the block name
  56882. */
  56883. constructor(name: string);
  56884. /**
  56885. * Gets the current class name
  56886. * @returns the class name
  56887. */
  56888. getClassName(): string;
  56889. /**
  56890. * Gets the vector input component
  56891. */
  56892. get vector(): NodeMaterialConnectionPoint;
  56893. protected _buildBlock(state: NodeMaterialBuildState): this;
  56894. }
  56895. }
  56896. declare module BABYLON {
  56897. /**
  56898. * Block used to output the final color
  56899. */
  56900. export class FragmentOutputBlock extends NodeMaterialBlock {
  56901. /**
  56902. * Create a new FragmentOutputBlock
  56903. * @param name defines the block name
  56904. */
  56905. constructor(name: string);
  56906. /**
  56907. * Gets the current class name
  56908. * @returns the class name
  56909. */
  56910. getClassName(): string;
  56911. /**
  56912. * Gets the rgba input component
  56913. */
  56914. get rgba(): NodeMaterialConnectionPoint;
  56915. /**
  56916. * Gets the rgb input component
  56917. */
  56918. get rgb(): NodeMaterialConnectionPoint;
  56919. /**
  56920. * Gets the a input component
  56921. */
  56922. get a(): NodeMaterialConnectionPoint;
  56923. protected _buildBlock(state: NodeMaterialBuildState): this;
  56924. }
  56925. }
  56926. declare module BABYLON {
  56927. /**
  56928. * Block used to read a reflection texture from a sampler
  56929. */
  56930. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56931. private _define3DName;
  56932. private _defineCubicName;
  56933. private _defineExplicitName;
  56934. private _defineProjectionName;
  56935. private _defineLocalCubicName;
  56936. private _defineSphericalName;
  56937. private _definePlanarName;
  56938. private _defineEquirectangularName;
  56939. private _defineMirroredEquirectangularFixedName;
  56940. private _defineEquirectangularFixedName;
  56941. private _defineSkyboxName;
  56942. private _cubeSamplerName;
  56943. private _2DSamplerName;
  56944. private _positionUVWName;
  56945. private _directionWName;
  56946. private _reflectionCoordsName;
  56947. private _reflection2DCoordsName;
  56948. private _reflectionColorName;
  56949. private _reflectionMatrixName;
  56950. /**
  56951. * Gets or sets the texture associated with the node
  56952. */
  56953. texture: Nullable<BaseTexture>;
  56954. /**
  56955. * Create a new TextureBlock
  56956. * @param name defines the block name
  56957. */
  56958. constructor(name: string);
  56959. /**
  56960. * Gets the current class name
  56961. * @returns the class name
  56962. */
  56963. getClassName(): string;
  56964. /**
  56965. * Gets the world position input component
  56966. */
  56967. get position(): NodeMaterialConnectionPoint;
  56968. /**
  56969. * Gets the world position input component
  56970. */
  56971. get worldPosition(): NodeMaterialConnectionPoint;
  56972. /**
  56973. * Gets the world normal input component
  56974. */
  56975. get worldNormal(): NodeMaterialConnectionPoint;
  56976. /**
  56977. * Gets the world input component
  56978. */
  56979. get world(): NodeMaterialConnectionPoint;
  56980. /**
  56981. * Gets the camera (or eye) position component
  56982. */
  56983. get cameraPosition(): NodeMaterialConnectionPoint;
  56984. /**
  56985. * Gets the view input component
  56986. */
  56987. get view(): NodeMaterialConnectionPoint;
  56988. /**
  56989. * Gets the rgb output component
  56990. */
  56991. get rgb(): NodeMaterialConnectionPoint;
  56992. /**
  56993. * Gets the r output component
  56994. */
  56995. get r(): NodeMaterialConnectionPoint;
  56996. /**
  56997. * Gets the g output component
  56998. */
  56999. get g(): NodeMaterialConnectionPoint;
  57000. /**
  57001. * Gets the b output component
  57002. */
  57003. get b(): NodeMaterialConnectionPoint;
  57004. autoConfigure(material: NodeMaterial): void;
  57005. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57006. isReady(): boolean;
  57007. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57008. private _injectVertexCode;
  57009. private _writeOutput;
  57010. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57011. protected _dumpPropertiesCode(): string;
  57012. serialize(): any;
  57013. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57014. }
  57015. }
  57016. declare module BABYLON {
  57017. /**
  57018. * Interface used to configure the node material editor
  57019. */
  57020. export interface INodeMaterialEditorOptions {
  57021. /** Define the URl to load node editor script */
  57022. editorURL?: string;
  57023. }
  57024. /** @hidden */
  57025. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57026. NORMAL: boolean;
  57027. TANGENT: boolean;
  57028. UV1: boolean;
  57029. /** BONES */
  57030. NUM_BONE_INFLUENCERS: number;
  57031. BonesPerMesh: number;
  57032. BONETEXTURE: boolean;
  57033. /** MORPH TARGETS */
  57034. MORPHTARGETS: boolean;
  57035. MORPHTARGETS_NORMAL: boolean;
  57036. MORPHTARGETS_TANGENT: boolean;
  57037. MORPHTARGETS_UV: boolean;
  57038. NUM_MORPH_INFLUENCERS: number;
  57039. /** IMAGE PROCESSING */
  57040. IMAGEPROCESSING: boolean;
  57041. VIGNETTE: boolean;
  57042. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57043. VIGNETTEBLENDMODEOPAQUE: boolean;
  57044. TONEMAPPING: boolean;
  57045. TONEMAPPING_ACES: boolean;
  57046. CONTRAST: boolean;
  57047. EXPOSURE: boolean;
  57048. COLORCURVES: boolean;
  57049. COLORGRADING: boolean;
  57050. COLORGRADING3D: boolean;
  57051. SAMPLER3DGREENDEPTH: boolean;
  57052. SAMPLER3DBGRMAP: boolean;
  57053. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57054. /** MISC. */
  57055. BUMPDIRECTUV: number;
  57056. constructor();
  57057. setValue(name: string, value: boolean): void;
  57058. }
  57059. /**
  57060. * Class used to configure NodeMaterial
  57061. */
  57062. export interface INodeMaterialOptions {
  57063. /**
  57064. * Defines if blocks should emit comments
  57065. */
  57066. emitComments: boolean;
  57067. }
  57068. /**
  57069. * Class used to create a node based material built by assembling shader blocks
  57070. */
  57071. export class NodeMaterial extends PushMaterial {
  57072. private static _BuildIdGenerator;
  57073. private _options;
  57074. private _vertexCompilationState;
  57075. private _fragmentCompilationState;
  57076. private _sharedData;
  57077. private _buildId;
  57078. private _buildWasSuccessful;
  57079. private _cachedWorldViewMatrix;
  57080. private _cachedWorldViewProjectionMatrix;
  57081. private _optimizers;
  57082. private _animationFrame;
  57083. /** Define the Url to load node editor script */
  57084. static EditorURL: string;
  57085. /** Define the Url to load snippets */
  57086. static SnippetUrl: string;
  57087. private BJSNODEMATERIALEDITOR;
  57088. /** Get the inspector from bundle or global */
  57089. private _getGlobalNodeMaterialEditor;
  57090. /**
  57091. * Gets or sets data used by visual editor
  57092. * @see https://nme.babylonjs.com
  57093. */
  57094. editorData: any;
  57095. /**
  57096. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  57097. */
  57098. ignoreAlpha: boolean;
  57099. /**
  57100. * Defines the maximum number of lights that can be used in the material
  57101. */
  57102. maxSimultaneousLights: number;
  57103. /**
  57104. * Observable raised when the material is built
  57105. */
  57106. onBuildObservable: Observable<NodeMaterial>;
  57107. /**
  57108. * Gets or sets the root nodes of the material vertex shader
  57109. */
  57110. _vertexOutputNodes: NodeMaterialBlock[];
  57111. /**
  57112. * Gets or sets the root nodes of the material fragment (pixel) shader
  57113. */
  57114. _fragmentOutputNodes: NodeMaterialBlock[];
  57115. /** Gets or sets options to control the node material overall behavior */
  57116. get options(): INodeMaterialOptions;
  57117. set options(options: INodeMaterialOptions);
  57118. /**
  57119. * Default configuration related to image processing available in the standard Material.
  57120. */
  57121. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57122. /**
  57123. * Gets the image processing configuration used either in this material.
  57124. */
  57125. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57126. /**
  57127. * Sets the Default image processing configuration used either in the this material.
  57128. *
  57129. * If sets to null, the scene one is in use.
  57130. */
  57131. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57132. /**
  57133. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57134. */
  57135. attachedBlocks: NodeMaterialBlock[];
  57136. /**
  57137. * Create a new node based material
  57138. * @param name defines the material name
  57139. * @param scene defines the hosting scene
  57140. * @param options defines creation option
  57141. */
  57142. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57143. /**
  57144. * Gets the current class name of the material e.g. "NodeMaterial"
  57145. * @returns the class name
  57146. */
  57147. getClassName(): string;
  57148. /**
  57149. * Keep track of the image processing observer to allow dispose and replace.
  57150. */
  57151. private _imageProcessingObserver;
  57152. /**
  57153. * Attaches a new image processing configuration to the Standard Material.
  57154. * @param configuration
  57155. */
  57156. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57157. /**
  57158. * Get a block by its name
  57159. * @param name defines the name of the block to retrieve
  57160. * @returns the required block or null if not found
  57161. */
  57162. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57163. /**
  57164. * Get a block by its name
  57165. * @param predicate defines the predicate used to find the good candidate
  57166. * @returns the required block or null if not found
  57167. */
  57168. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57169. /**
  57170. * Get an input block by its name
  57171. * @param predicate defines the predicate used to find the good candidate
  57172. * @returns the required input block or null if not found
  57173. */
  57174. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57175. /**
  57176. * Gets the list of input blocks attached to this material
  57177. * @returns an array of InputBlocks
  57178. */
  57179. getInputBlocks(): InputBlock[];
  57180. /**
  57181. * Adds a new optimizer to the list of optimizers
  57182. * @param optimizer defines the optimizers to add
  57183. * @returns the current material
  57184. */
  57185. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57186. /**
  57187. * Remove an optimizer from the list of optimizers
  57188. * @param optimizer defines the optimizers to remove
  57189. * @returns the current material
  57190. */
  57191. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57192. /**
  57193. * Add a new block to the list of output nodes
  57194. * @param node defines the node to add
  57195. * @returns the current material
  57196. */
  57197. addOutputNode(node: NodeMaterialBlock): this;
  57198. /**
  57199. * Remove a block from the list of root nodes
  57200. * @param node defines the node to remove
  57201. * @returns the current material
  57202. */
  57203. removeOutputNode(node: NodeMaterialBlock): this;
  57204. private _addVertexOutputNode;
  57205. private _removeVertexOutputNode;
  57206. private _addFragmentOutputNode;
  57207. private _removeFragmentOutputNode;
  57208. /**
  57209. * Specifies if the material will require alpha blending
  57210. * @returns a boolean specifying if alpha blending is needed
  57211. */
  57212. needAlphaBlending(): boolean;
  57213. /**
  57214. * Specifies if this material should be rendered in alpha test mode
  57215. * @returns a boolean specifying if an alpha test is needed.
  57216. */
  57217. needAlphaTesting(): boolean;
  57218. private _initializeBlock;
  57219. private _resetDualBlocks;
  57220. /**
  57221. * Remove a block from the current node material
  57222. * @param block defines the block to remove
  57223. */
  57224. removeBlock(block: NodeMaterialBlock): void;
  57225. /**
  57226. * Build the material and generates the inner effect
  57227. * @param verbose defines if the build should log activity
  57228. */
  57229. build(verbose?: boolean): void;
  57230. /**
  57231. * Runs an otpimization phase to try to improve the shader code
  57232. */
  57233. optimize(): void;
  57234. private _prepareDefinesForAttributes;
  57235. /**
  57236. * Get if the submesh is ready to be used and all its information available.
  57237. * Child classes can use it to update shaders
  57238. * @param mesh defines the mesh to check
  57239. * @param subMesh defines which submesh to check
  57240. * @param useInstances specifies that instances should be used
  57241. * @returns a boolean indicating that the submesh is ready or not
  57242. */
  57243. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57244. /**
  57245. * Get a string representing the shaders built by the current node graph
  57246. */
  57247. get compiledShaders(): string;
  57248. /**
  57249. * Binds the world matrix to the material
  57250. * @param world defines the world transformation matrix
  57251. */
  57252. bindOnlyWorldMatrix(world: Matrix): void;
  57253. /**
  57254. * Binds the submesh to this material by preparing the effect and shader to draw
  57255. * @param world defines the world transformation matrix
  57256. * @param mesh defines the mesh containing the submesh
  57257. * @param subMesh defines the submesh to bind the material to
  57258. */
  57259. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57260. /**
  57261. * Gets the active textures from the material
  57262. * @returns an array of textures
  57263. */
  57264. getActiveTextures(): BaseTexture[];
  57265. /**
  57266. * Gets the list of texture blocks
  57267. * @returns an array of texture blocks
  57268. */
  57269. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57270. /**
  57271. * Specifies if the material uses a texture
  57272. * @param texture defines the texture to check against the material
  57273. * @returns a boolean specifying if the material uses the texture
  57274. */
  57275. hasTexture(texture: BaseTexture): boolean;
  57276. /**
  57277. * Disposes the material
  57278. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57279. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57280. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57281. */
  57282. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57283. /** Creates the node editor window. */
  57284. private _createNodeEditor;
  57285. /**
  57286. * Launch the node material editor
  57287. * @param config Define the configuration of the editor
  57288. * @return a promise fulfilled when the node editor is visible
  57289. */
  57290. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57291. /**
  57292. * Clear the current material
  57293. */
  57294. clear(): void;
  57295. /**
  57296. * Clear the current material and set it to a default state
  57297. */
  57298. setToDefault(): void;
  57299. /**
  57300. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57301. * @param url defines the url to load from
  57302. * @returns a promise that will fullfil when the material is fully loaded
  57303. */
  57304. loadAsync(url: string): Promise<void>;
  57305. private _gatherBlocks;
  57306. /**
  57307. * Generate a string containing the code declaration required to create an equivalent of this material
  57308. * @returns a string
  57309. */
  57310. generateCode(): string;
  57311. /**
  57312. * Serializes this material in a JSON representation
  57313. * @returns the serialized material object
  57314. */
  57315. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57316. private _restoreConnections;
  57317. /**
  57318. * Clear the current graph and load a new one from a serialization object
  57319. * @param source defines the JSON representation of the material
  57320. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57321. */
  57322. loadFromSerialization(source: any, rootUrl?: string): void;
  57323. /**
  57324. * Creates a node material from parsed material data
  57325. * @param source defines the JSON representation of the material
  57326. * @param scene defines the hosting scene
  57327. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57328. * @returns a new node material
  57329. */
  57330. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57331. /**
  57332. * Creates a node material from a snippet saved in a remote file
  57333. * @param name defines the name of the material to create
  57334. * @param url defines the url to load from
  57335. * @param scene defines the hosting scene
  57336. * @returns a promise that will resolve to the new node material
  57337. */
  57338. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57339. /**
  57340. * Creates a node material from a snippet saved by the node material editor
  57341. * @param snippetId defines the snippet to load
  57342. * @param scene defines the hosting scene
  57343. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57344. * @returns a promise that will resolve to the new node material
  57345. */
  57346. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57347. /**
  57348. * Creates a new node material set to default basic configuration
  57349. * @param name defines the name of the material
  57350. * @param scene defines the hosting scene
  57351. * @returns a new NodeMaterial
  57352. */
  57353. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57354. }
  57355. }
  57356. declare module BABYLON {
  57357. /**
  57358. * Block used to read a texture from a sampler
  57359. */
  57360. export class TextureBlock extends NodeMaterialBlock {
  57361. private _defineName;
  57362. private _linearDefineName;
  57363. private _tempTextureRead;
  57364. private _samplerName;
  57365. private _transformedUVName;
  57366. private _textureTransformName;
  57367. private _textureInfoName;
  57368. private _mainUVName;
  57369. private _mainUVDefineName;
  57370. /**
  57371. * Gets or sets the texture associated with the node
  57372. */
  57373. texture: Nullable<Texture>;
  57374. /**
  57375. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57376. */
  57377. convertToGammaSpace: boolean;
  57378. /**
  57379. * Create a new TextureBlock
  57380. * @param name defines the block name
  57381. */
  57382. constructor(name: string);
  57383. /**
  57384. * Gets the current class name
  57385. * @returns the class name
  57386. */
  57387. getClassName(): string;
  57388. /**
  57389. * Gets the uv input component
  57390. */
  57391. get uv(): NodeMaterialConnectionPoint;
  57392. /**
  57393. * Gets the rgba output component
  57394. */
  57395. get rgba(): NodeMaterialConnectionPoint;
  57396. /**
  57397. * Gets the rgb output component
  57398. */
  57399. get rgb(): NodeMaterialConnectionPoint;
  57400. /**
  57401. * Gets the r output component
  57402. */
  57403. get r(): NodeMaterialConnectionPoint;
  57404. /**
  57405. * Gets the g output component
  57406. */
  57407. get g(): NodeMaterialConnectionPoint;
  57408. /**
  57409. * Gets the b output component
  57410. */
  57411. get b(): NodeMaterialConnectionPoint;
  57412. /**
  57413. * Gets the a output component
  57414. */
  57415. get a(): NodeMaterialConnectionPoint;
  57416. get target(): NodeMaterialBlockTargets;
  57417. autoConfigure(material: NodeMaterial): void;
  57418. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57419. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57420. isReady(): boolean;
  57421. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57422. private get _isMixed();
  57423. private _injectVertexCode;
  57424. private _writeTextureRead;
  57425. private _writeOutput;
  57426. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57427. protected _dumpPropertiesCode(): string;
  57428. serialize(): any;
  57429. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57430. }
  57431. }
  57432. declare module BABYLON {
  57433. /**
  57434. * Class used to store shared data between 2 NodeMaterialBuildState
  57435. */
  57436. export class NodeMaterialBuildStateSharedData {
  57437. /**
  57438. * Gets the list of emitted varyings
  57439. */
  57440. temps: string[];
  57441. /**
  57442. * Gets the list of emitted varyings
  57443. */
  57444. varyings: string[];
  57445. /**
  57446. * Gets the varying declaration string
  57447. */
  57448. varyingDeclaration: string;
  57449. /**
  57450. * Input blocks
  57451. */
  57452. inputBlocks: InputBlock[];
  57453. /**
  57454. * Input blocks
  57455. */
  57456. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57457. /**
  57458. * Bindable blocks (Blocks that need to set data to the effect)
  57459. */
  57460. bindableBlocks: NodeMaterialBlock[];
  57461. /**
  57462. * List of blocks that can provide a compilation fallback
  57463. */
  57464. blocksWithFallbacks: NodeMaterialBlock[];
  57465. /**
  57466. * List of blocks that can provide a define update
  57467. */
  57468. blocksWithDefines: NodeMaterialBlock[];
  57469. /**
  57470. * List of blocks that can provide a repeatable content
  57471. */
  57472. repeatableContentBlocks: NodeMaterialBlock[];
  57473. /**
  57474. * List of blocks that can provide a dynamic list of uniforms
  57475. */
  57476. dynamicUniformBlocks: NodeMaterialBlock[];
  57477. /**
  57478. * List of blocks that can block the isReady function for the material
  57479. */
  57480. blockingBlocks: NodeMaterialBlock[];
  57481. /**
  57482. * Gets the list of animated inputs
  57483. */
  57484. animatedInputs: InputBlock[];
  57485. /**
  57486. * Build Id used to avoid multiple recompilations
  57487. */
  57488. buildId: number;
  57489. /** List of emitted variables */
  57490. variableNames: {
  57491. [key: string]: number;
  57492. };
  57493. /** List of emitted defines */
  57494. defineNames: {
  57495. [key: string]: number;
  57496. };
  57497. /** Should emit comments? */
  57498. emitComments: boolean;
  57499. /** Emit build activity */
  57500. verbose: boolean;
  57501. /** Gets or sets the hosting scene */
  57502. scene: Scene;
  57503. /**
  57504. * Gets the compilation hints emitted at compilation time
  57505. */
  57506. hints: {
  57507. needWorldViewMatrix: boolean;
  57508. needWorldViewProjectionMatrix: boolean;
  57509. needAlphaBlending: boolean;
  57510. needAlphaTesting: boolean;
  57511. };
  57512. /**
  57513. * List of compilation checks
  57514. */
  57515. checks: {
  57516. emitVertex: boolean;
  57517. emitFragment: boolean;
  57518. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57519. };
  57520. /** Creates a new shared data */
  57521. constructor();
  57522. /**
  57523. * Emits console errors and exceptions if there is a failing check
  57524. */
  57525. emitErrors(): void;
  57526. }
  57527. }
  57528. declare module BABYLON {
  57529. /**
  57530. * Class used to store node based material build state
  57531. */
  57532. export class NodeMaterialBuildState {
  57533. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57534. supportUniformBuffers: boolean;
  57535. /**
  57536. * Gets the list of emitted attributes
  57537. */
  57538. attributes: string[];
  57539. /**
  57540. * Gets the list of emitted uniforms
  57541. */
  57542. uniforms: string[];
  57543. /**
  57544. * Gets the list of emitted constants
  57545. */
  57546. constants: string[];
  57547. /**
  57548. * Gets the list of emitted samplers
  57549. */
  57550. samplers: string[];
  57551. /**
  57552. * Gets the list of emitted functions
  57553. */
  57554. functions: {
  57555. [key: string]: string;
  57556. };
  57557. /**
  57558. * Gets the list of emitted extensions
  57559. */
  57560. extensions: {
  57561. [key: string]: string;
  57562. };
  57563. /**
  57564. * Gets the target of the compilation state
  57565. */
  57566. target: NodeMaterialBlockTargets;
  57567. /**
  57568. * Gets the list of emitted counters
  57569. */
  57570. counters: {
  57571. [key: string]: number;
  57572. };
  57573. /**
  57574. * Shared data between multiple NodeMaterialBuildState instances
  57575. */
  57576. sharedData: NodeMaterialBuildStateSharedData;
  57577. /** @hidden */
  57578. _vertexState: NodeMaterialBuildState;
  57579. /** @hidden */
  57580. _attributeDeclaration: string;
  57581. /** @hidden */
  57582. _uniformDeclaration: string;
  57583. /** @hidden */
  57584. _constantDeclaration: string;
  57585. /** @hidden */
  57586. _samplerDeclaration: string;
  57587. /** @hidden */
  57588. _varyingTransfer: string;
  57589. private _repeatableContentAnchorIndex;
  57590. /** @hidden */
  57591. _builtCompilationString: string;
  57592. /**
  57593. * Gets the emitted compilation strings
  57594. */
  57595. compilationString: string;
  57596. /**
  57597. * Finalize the compilation strings
  57598. * @param state defines the current compilation state
  57599. */
  57600. finalize(state: NodeMaterialBuildState): void;
  57601. /** @hidden */
  57602. get _repeatableContentAnchor(): string;
  57603. /** @hidden */
  57604. _getFreeVariableName(prefix: string): string;
  57605. /** @hidden */
  57606. _getFreeDefineName(prefix: string): string;
  57607. /** @hidden */
  57608. _excludeVariableName(name: string): void;
  57609. /** @hidden */
  57610. _emit2DSampler(name: string): void;
  57611. /** @hidden */
  57612. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57613. /** @hidden */
  57614. _emitExtension(name: string, extension: string): void;
  57615. /** @hidden */
  57616. _emitFunction(name: string, code: string, comments: string): void;
  57617. /** @hidden */
  57618. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57619. replaceStrings?: {
  57620. search: RegExp;
  57621. replace: string;
  57622. }[];
  57623. repeatKey?: string;
  57624. }): string;
  57625. /** @hidden */
  57626. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57627. repeatKey?: string;
  57628. removeAttributes?: boolean;
  57629. removeUniforms?: boolean;
  57630. removeVaryings?: boolean;
  57631. removeIfDef?: boolean;
  57632. replaceStrings?: {
  57633. search: RegExp;
  57634. replace: string;
  57635. }[];
  57636. }, storeKey?: string): void;
  57637. /** @hidden */
  57638. _registerTempVariable(name: string): boolean;
  57639. /** @hidden */
  57640. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57641. /** @hidden */
  57642. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57643. /** @hidden */
  57644. _emitFloat(value: number): string;
  57645. }
  57646. }
  57647. declare module BABYLON {
  57648. /**
  57649. * Defines a block that can be used inside a node based material
  57650. */
  57651. export class NodeMaterialBlock {
  57652. private _buildId;
  57653. private _buildTarget;
  57654. private _target;
  57655. private _isFinalMerger;
  57656. private _isInput;
  57657. protected _isUnique: boolean;
  57658. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57659. inputsAreExclusive: boolean;
  57660. /** @hidden */
  57661. _codeVariableName: string;
  57662. /** @hidden */
  57663. _inputs: NodeMaterialConnectionPoint[];
  57664. /** @hidden */
  57665. _outputs: NodeMaterialConnectionPoint[];
  57666. /** @hidden */
  57667. _preparationId: number;
  57668. /**
  57669. * Gets or sets the name of the block
  57670. */
  57671. name: string;
  57672. /**
  57673. * Gets or sets the unique id of the node
  57674. */
  57675. uniqueId: number;
  57676. /**
  57677. * Gets or sets the comments associated with this block
  57678. */
  57679. comments: string;
  57680. /**
  57681. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57682. */
  57683. get isUnique(): boolean;
  57684. /**
  57685. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57686. */
  57687. get isFinalMerger(): boolean;
  57688. /**
  57689. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57690. */
  57691. get isInput(): boolean;
  57692. /**
  57693. * Gets or sets the build Id
  57694. */
  57695. get buildId(): number;
  57696. set buildId(value: number);
  57697. /**
  57698. * Gets or sets the target of the block
  57699. */
  57700. get target(): NodeMaterialBlockTargets;
  57701. set target(value: NodeMaterialBlockTargets);
  57702. /**
  57703. * Gets the list of input points
  57704. */
  57705. get inputs(): NodeMaterialConnectionPoint[];
  57706. /** Gets the list of output points */
  57707. get outputs(): NodeMaterialConnectionPoint[];
  57708. /**
  57709. * Find an input by its name
  57710. * @param name defines the name of the input to look for
  57711. * @returns the input or null if not found
  57712. */
  57713. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57714. /**
  57715. * Find an output by its name
  57716. * @param name defines the name of the outputto look for
  57717. * @returns the output or null if not found
  57718. */
  57719. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57720. /**
  57721. * Creates a new NodeMaterialBlock
  57722. * @param name defines the block name
  57723. * @param target defines the target of that block (Vertex by default)
  57724. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57725. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57726. */
  57727. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57728. /**
  57729. * Initialize the block and prepare the context for build
  57730. * @param state defines the state that will be used for the build
  57731. */
  57732. initialize(state: NodeMaterialBuildState): void;
  57733. /**
  57734. * Bind data to effect. Will only be called for blocks with isBindable === true
  57735. * @param effect defines the effect to bind data to
  57736. * @param nodeMaterial defines the hosting NodeMaterial
  57737. * @param mesh defines the mesh that will be rendered
  57738. */
  57739. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57740. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57741. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57742. protected _writeFloat(value: number): string;
  57743. /**
  57744. * Gets the current class name e.g. "NodeMaterialBlock"
  57745. * @returns the class name
  57746. */
  57747. getClassName(): string;
  57748. /**
  57749. * Register a new input. Must be called inside a block constructor
  57750. * @param name defines the connection point name
  57751. * @param type defines the connection point type
  57752. * @param isOptional defines a boolean indicating that this input can be omitted
  57753. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57754. * @returns the current block
  57755. */
  57756. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57757. /**
  57758. * Register a new output. Must be called inside a block constructor
  57759. * @param name defines the connection point name
  57760. * @param type defines the connection point type
  57761. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57762. * @returns the current block
  57763. */
  57764. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57765. /**
  57766. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57767. * @param forOutput defines an optional connection point to check compatibility with
  57768. * @returns the first available input or null
  57769. */
  57770. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57771. /**
  57772. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57773. * @param forBlock defines an optional block to check compatibility with
  57774. * @returns the first available input or null
  57775. */
  57776. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57777. /**
  57778. * Gets the sibling of the given output
  57779. * @param current defines the current output
  57780. * @returns the next output in the list or null
  57781. */
  57782. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57783. /**
  57784. * Connect current block with another block
  57785. * @param other defines the block to connect with
  57786. * @param options define the various options to help pick the right connections
  57787. * @returns the current block
  57788. */
  57789. connectTo(other: NodeMaterialBlock, options?: {
  57790. input?: string;
  57791. output?: string;
  57792. outputSwizzle?: string;
  57793. }): this | undefined;
  57794. protected _buildBlock(state: NodeMaterialBuildState): void;
  57795. /**
  57796. * Add uniforms, samplers and uniform buffers at compilation time
  57797. * @param state defines the state to update
  57798. * @param nodeMaterial defines the node material requesting the update
  57799. * @param defines defines the material defines to update
  57800. * @param uniformBuffers defines the list of uniform buffer names
  57801. */
  57802. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57803. /**
  57804. * Add potential fallbacks if shader compilation fails
  57805. * @param mesh defines the mesh to be rendered
  57806. * @param fallbacks defines the current prioritized list of fallbacks
  57807. */
  57808. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57809. /**
  57810. * Initialize defines for shader compilation
  57811. * @param mesh defines the mesh to be rendered
  57812. * @param nodeMaterial defines the node material requesting the update
  57813. * @param defines defines the material defines to update
  57814. * @param useInstances specifies that instances should be used
  57815. */
  57816. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57817. /**
  57818. * Update defines for shader compilation
  57819. * @param mesh defines the mesh to be rendered
  57820. * @param nodeMaterial defines the node material requesting the update
  57821. * @param defines defines the material defines to update
  57822. * @param useInstances specifies that instances should be used
  57823. */
  57824. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57825. /**
  57826. * Lets the block try to connect some inputs automatically
  57827. * @param material defines the hosting NodeMaterial
  57828. */
  57829. autoConfigure(material: NodeMaterial): void;
  57830. /**
  57831. * Function called when a block is declared as repeatable content generator
  57832. * @param vertexShaderState defines the current compilation state for the vertex shader
  57833. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57834. * @param mesh defines the mesh to be rendered
  57835. * @param defines defines the material defines to update
  57836. */
  57837. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57838. /**
  57839. * Checks if the block is ready
  57840. * @param mesh defines the mesh to be rendered
  57841. * @param nodeMaterial defines the node material requesting the update
  57842. * @param defines defines the material defines to update
  57843. * @param useInstances specifies that instances should be used
  57844. * @returns true if the block is ready
  57845. */
  57846. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57847. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57848. private _processBuild;
  57849. /**
  57850. * Compile the current node and generate the shader code
  57851. * @param state defines the current compilation state (uniforms, samplers, current string)
  57852. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57853. * @returns true if already built
  57854. */
  57855. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57856. protected _inputRename(name: string): string;
  57857. protected _outputRename(name: string): string;
  57858. protected _dumpPropertiesCode(): string;
  57859. /** @hidden */
  57860. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57861. /** @hidden */
  57862. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57863. /**
  57864. * Clone the current block to a new identical block
  57865. * @param scene defines the hosting scene
  57866. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57867. * @returns a copy of the current block
  57868. */
  57869. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57870. /**
  57871. * Serializes this block in a JSON representation
  57872. * @returns the serialized block object
  57873. */
  57874. serialize(): any;
  57875. /** @hidden */
  57876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57877. /**
  57878. * Release resources
  57879. */
  57880. dispose(): void;
  57881. }
  57882. }
  57883. declare module BABYLON {
  57884. /**
  57885. * Enum defining the type of animations supported by InputBlock
  57886. */
  57887. export enum AnimatedInputBlockTypes {
  57888. /** No animation */
  57889. None = 0,
  57890. /** Time based animation. Will only work for floats */
  57891. Time = 1
  57892. }
  57893. }
  57894. declare module BABYLON {
  57895. /**
  57896. * Block used to expose an input value
  57897. */
  57898. export class InputBlock extends NodeMaterialBlock {
  57899. private _mode;
  57900. private _associatedVariableName;
  57901. private _storedValue;
  57902. private _valueCallback;
  57903. private _type;
  57904. private _animationType;
  57905. /** Gets or set a value used to limit the range of float values */
  57906. min: number;
  57907. /** Gets or set a value used to limit the range of float values */
  57908. max: number;
  57909. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57910. isBoolean: boolean;
  57911. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57912. matrixMode: number;
  57913. /** @hidden */
  57914. _systemValue: Nullable<NodeMaterialSystemValues>;
  57915. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57916. visibleInInspector: boolean;
  57917. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57918. isConstant: boolean;
  57919. /** Gets or sets the group to use to display this block in the Inspector */
  57920. groupInInspector: string;
  57921. /** Gets an observable raised when the value is changed */
  57922. onValueChangedObservable: Observable<InputBlock>;
  57923. /**
  57924. * Gets or sets the connection point type (default is float)
  57925. */
  57926. get type(): NodeMaterialBlockConnectionPointTypes;
  57927. /**
  57928. * Creates a new InputBlock
  57929. * @param name defines the block name
  57930. * @param target defines the target of that block (Vertex by default)
  57931. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57932. */
  57933. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57934. /**
  57935. * Gets the output component
  57936. */
  57937. get output(): NodeMaterialConnectionPoint;
  57938. /**
  57939. * Set the source of this connection point to a vertex attribute
  57940. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57941. * @returns the current connection point
  57942. */
  57943. setAsAttribute(attributeName?: string): InputBlock;
  57944. /**
  57945. * Set the source of this connection point to a system value
  57946. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57947. * @returns the current connection point
  57948. */
  57949. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57950. /**
  57951. * Gets or sets the value of that point.
  57952. * Please note that this value will be ignored if valueCallback is defined
  57953. */
  57954. get value(): any;
  57955. set value(value: any);
  57956. /**
  57957. * Gets or sets a callback used to get the value of that point.
  57958. * Please note that setting this value will force the connection point to ignore the value property
  57959. */
  57960. get valueCallback(): () => any;
  57961. set valueCallback(value: () => any);
  57962. /**
  57963. * Gets or sets the associated variable name in the shader
  57964. */
  57965. get associatedVariableName(): string;
  57966. set associatedVariableName(value: string);
  57967. /** Gets or sets the type of animation applied to the input */
  57968. get animationType(): AnimatedInputBlockTypes;
  57969. set animationType(value: AnimatedInputBlockTypes);
  57970. /**
  57971. * Gets a boolean indicating that this connection point not defined yet
  57972. */
  57973. get isUndefined(): boolean;
  57974. /**
  57975. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57976. * In this case the connection point name must be the name of the uniform to use.
  57977. * Can only be set on inputs
  57978. */
  57979. get isUniform(): boolean;
  57980. set isUniform(value: boolean);
  57981. /**
  57982. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57983. * In this case the connection point name must be the name of the attribute to use
  57984. * Can only be set on inputs
  57985. */
  57986. get isAttribute(): boolean;
  57987. set isAttribute(value: boolean);
  57988. /**
  57989. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57990. * Can only be set on exit points
  57991. */
  57992. get isVarying(): boolean;
  57993. set isVarying(value: boolean);
  57994. /**
  57995. * Gets a boolean indicating that the current connection point is a system value
  57996. */
  57997. get isSystemValue(): boolean;
  57998. /**
  57999. * Gets or sets the current well known value or null if not defined as a system value
  58000. */
  58001. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58002. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58003. /**
  58004. * Gets the current class name
  58005. * @returns the class name
  58006. */
  58007. getClassName(): string;
  58008. /**
  58009. * Animate the input if animationType !== None
  58010. * @param scene defines the rendering scene
  58011. */
  58012. animate(scene: Scene): void;
  58013. private _emitDefine;
  58014. initialize(state: NodeMaterialBuildState): void;
  58015. /**
  58016. * Set the input block to its default value (based on its type)
  58017. */
  58018. setDefaultValue(): void;
  58019. private _emitConstant;
  58020. private _emit;
  58021. /** @hidden */
  58022. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58023. /** @hidden */
  58024. _transmit(effect: Effect, scene: Scene): void;
  58025. protected _buildBlock(state: NodeMaterialBuildState): void;
  58026. protected _dumpPropertiesCode(): string;
  58027. dispose(): void;
  58028. serialize(): any;
  58029. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58030. }
  58031. }
  58032. declare module BABYLON {
  58033. /**
  58034. * Enum used to define the compatibility state between two connection points
  58035. */
  58036. export enum NodeMaterialConnectionPointCompatibilityStates {
  58037. /** Points are compatibles */
  58038. Compatible = 0,
  58039. /** Points are incompatible because of their types */
  58040. TypeIncompatible = 1,
  58041. /** Points are incompatible because of their targets (vertex vs fragment) */
  58042. TargetIncompatible = 2
  58043. }
  58044. /**
  58045. * Defines the direction of a connection point
  58046. */
  58047. export enum NodeMaterialConnectionPointDirection {
  58048. /** Input */
  58049. Input = 0,
  58050. /** Output */
  58051. Output = 1
  58052. }
  58053. /**
  58054. * Defines a connection point for a block
  58055. */
  58056. export class NodeMaterialConnectionPoint {
  58057. /** @hidden */
  58058. _ownerBlock: NodeMaterialBlock;
  58059. /** @hidden */
  58060. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58061. private _endpoints;
  58062. private _associatedVariableName;
  58063. private _direction;
  58064. /** @hidden */
  58065. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58066. /** @hidden */
  58067. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58068. private _type;
  58069. /** @hidden */
  58070. _enforceAssociatedVariableName: boolean;
  58071. /** Gets the direction of the point */
  58072. get direction(): NodeMaterialConnectionPointDirection;
  58073. /**
  58074. * Gets or sets the additional types supported by this connection point
  58075. */
  58076. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58077. /**
  58078. * Gets or sets the additional types excluded by this connection point
  58079. */
  58080. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58081. /**
  58082. * Observable triggered when this point is connected
  58083. */
  58084. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58085. /**
  58086. * Gets or sets the associated variable name in the shader
  58087. */
  58088. get associatedVariableName(): string;
  58089. set associatedVariableName(value: string);
  58090. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58091. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58092. /**
  58093. * Gets or sets the connection point type (default is float)
  58094. */
  58095. get type(): NodeMaterialBlockConnectionPointTypes;
  58096. set type(value: NodeMaterialBlockConnectionPointTypes);
  58097. /**
  58098. * Gets or sets the connection point name
  58099. */
  58100. name: string;
  58101. /**
  58102. * Gets or sets a boolean indicating that this connection point can be omitted
  58103. */
  58104. isOptional: boolean;
  58105. /**
  58106. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58107. */
  58108. define: string;
  58109. /** @hidden */
  58110. _prioritizeVertex: boolean;
  58111. private _target;
  58112. /** Gets or sets the target of that connection point */
  58113. get target(): NodeMaterialBlockTargets;
  58114. set target(value: NodeMaterialBlockTargets);
  58115. /**
  58116. * Gets a boolean indicating that the current point is connected
  58117. */
  58118. get isConnected(): boolean;
  58119. /**
  58120. * Gets a boolean indicating that the current point is connected to an input block
  58121. */
  58122. get isConnectedToInputBlock(): boolean;
  58123. /**
  58124. * Gets a the connected input block (if any)
  58125. */
  58126. get connectInputBlock(): Nullable<InputBlock>;
  58127. /** Get the other side of the connection (if any) */
  58128. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58129. /** Get the block that owns this connection point */
  58130. get ownerBlock(): NodeMaterialBlock;
  58131. /** Get the block connected on the other side of this connection (if any) */
  58132. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58133. /** Get the block connected on the endpoints of this connection (if any) */
  58134. get connectedBlocks(): Array<NodeMaterialBlock>;
  58135. /** Gets the list of connected endpoints */
  58136. get endpoints(): NodeMaterialConnectionPoint[];
  58137. /** Gets a boolean indicating if that output point is connected to at least one input */
  58138. get hasEndpoints(): boolean;
  58139. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58140. get isConnectedInVertexShader(): boolean;
  58141. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58142. get isConnectedInFragmentShader(): boolean;
  58143. /**
  58144. * Creates a new connection point
  58145. * @param name defines the connection point name
  58146. * @param ownerBlock defines the block hosting this connection point
  58147. * @param direction defines the direction of the connection point
  58148. */
  58149. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58150. /**
  58151. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58152. * @returns the class name
  58153. */
  58154. getClassName(): string;
  58155. /**
  58156. * Gets a boolean indicating if the current point can be connected to another point
  58157. * @param connectionPoint defines the other connection point
  58158. * @returns a boolean
  58159. */
  58160. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58161. /**
  58162. * Gets a number indicating if the current point can be connected to another point
  58163. * @param connectionPoint defines the other connection point
  58164. * @returns a number defining the compatibility state
  58165. */
  58166. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58167. /**
  58168. * Connect this point to another connection point
  58169. * @param connectionPoint defines the other connection point
  58170. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58171. * @returns the current connection point
  58172. */
  58173. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58174. /**
  58175. * Disconnect this point from one of his endpoint
  58176. * @param endpoint defines the other connection point
  58177. * @returns the current connection point
  58178. */
  58179. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58180. /**
  58181. * Serializes this point in a JSON representation
  58182. * @returns the serialized point object
  58183. */
  58184. serialize(): any;
  58185. /**
  58186. * Release resources
  58187. */
  58188. dispose(): void;
  58189. }
  58190. }
  58191. declare module BABYLON {
  58192. /**
  58193. * Block used to add support for vertex skinning (bones)
  58194. */
  58195. export class BonesBlock extends NodeMaterialBlock {
  58196. /**
  58197. * Creates a new BonesBlock
  58198. * @param name defines the block name
  58199. */
  58200. constructor(name: string);
  58201. /**
  58202. * Initialize the block and prepare the context for build
  58203. * @param state defines the state that will be used for the build
  58204. */
  58205. initialize(state: NodeMaterialBuildState): void;
  58206. /**
  58207. * Gets the current class name
  58208. * @returns the class name
  58209. */
  58210. getClassName(): string;
  58211. /**
  58212. * Gets the matrix indices input component
  58213. */
  58214. get matricesIndices(): NodeMaterialConnectionPoint;
  58215. /**
  58216. * Gets the matrix weights input component
  58217. */
  58218. get matricesWeights(): NodeMaterialConnectionPoint;
  58219. /**
  58220. * Gets the extra matrix indices input component
  58221. */
  58222. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58223. /**
  58224. * Gets the extra matrix weights input component
  58225. */
  58226. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58227. /**
  58228. * Gets the world input component
  58229. */
  58230. get world(): NodeMaterialConnectionPoint;
  58231. /**
  58232. * Gets the output component
  58233. */
  58234. get output(): NodeMaterialConnectionPoint;
  58235. autoConfigure(material: NodeMaterial): void;
  58236. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58237. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58238. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58239. protected _buildBlock(state: NodeMaterialBuildState): this;
  58240. }
  58241. }
  58242. declare module BABYLON {
  58243. /**
  58244. * Block used to add support for instances
  58245. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58246. */
  58247. export class InstancesBlock extends NodeMaterialBlock {
  58248. /**
  58249. * Creates a new InstancesBlock
  58250. * @param name defines the block name
  58251. */
  58252. constructor(name: string);
  58253. /**
  58254. * Gets the current class name
  58255. * @returns the class name
  58256. */
  58257. getClassName(): string;
  58258. /**
  58259. * Gets the first world row input component
  58260. */
  58261. get world0(): NodeMaterialConnectionPoint;
  58262. /**
  58263. * Gets the second world row input component
  58264. */
  58265. get world1(): NodeMaterialConnectionPoint;
  58266. /**
  58267. * Gets the third world row input component
  58268. */
  58269. get world2(): NodeMaterialConnectionPoint;
  58270. /**
  58271. * Gets the forth world row input component
  58272. */
  58273. get world3(): NodeMaterialConnectionPoint;
  58274. /**
  58275. * Gets the world input component
  58276. */
  58277. get world(): NodeMaterialConnectionPoint;
  58278. /**
  58279. * Gets the output component
  58280. */
  58281. get output(): NodeMaterialConnectionPoint;
  58282. /**
  58283. * Gets the isntanceID component
  58284. */
  58285. get instanceID(): NodeMaterialConnectionPoint;
  58286. autoConfigure(material: NodeMaterial): void;
  58287. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58288. protected _buildBlock(state: NodeMaterialBuildState): this;
  58289. }
  58290. }
  58291. declare module BABYLON {
  58292. /**
  58293. * Block used to add morph targets support to vertex shader
  58294. */
  58295. export class MorphTargetsBlock extends NodeMaterialBlock {
  58296. private _repeatableContentAnchor;
  58297. /**
  58298. * Create a new MorphTargetsBlock
  58299. * @param name defines the block name
  58300. */
  58301. constructor(name: string);
  58302. /**
  58303. * Gets the current class name
  58304. * @returns the class name
  58305. */
  58306. getClassName(): string;
  58307. /**
  58308. * Gets the position input component
  58309. */
  58310. get position(): NodeMaterialConnectionPoint;
  58311. /**
  58312. * Gets the normal input component
  58313. */
  58314. get normal(): NodeMaterialConnectionPoint;
  58315. /**
  58316. * Gets the tangent input component
  58317. */
  58318. get tangent(): NodeMaterialConnectionPoint;
  58319. /**
  58320. * Gets the tangent input component
  58321. */
  58322. get uv(): NodeMaterialConnectionPoint;
  58323. /**
  58324. * Gets the position output component
  58325. */
  58326. get positionOutput(): NodeMaterialConnectionPoint;
  58327. /**
  58328. * Gets the normal output component
  58329. */
  58330. get normalOutput(): NodeMaterialConnectionPoint;
  58331. /**
  58332. * Gets the tangent output component
  58333. */
  58334. get tangentOutput(): NodeMaterialConnectionPoint;
  58335. /**
  58336. * Gets the tangent output component
  58337. */
  58338. get uvOutput(): NodeMaterialConnectionPoint;
  58339. initialize(state: NodeMaterialBuildState): void;
  58340. autoConfigure(material: NodeMaterial): void;
  58341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58342. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58343. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58344. protected _buildBlock(state: NodeMaterialBuildState): this;
  58345. }
  58346. }
  58347. declare module BABYLON {
  58348. /**
  58349. * Block used to get data information from a light
  58350. */
  58351. export class LightInformationBlock extends NodeMaterialBlock {
  58352. private _lightDataUniformName;
  58353. private _lightColorUniformName;
  58354. private _lightTypeDefineName;
  58355. /**
  58356. * Gets or sets the light associated with this block
  58357. */
  58358. light: Nullable<Light>;
  58359. /**
  58360. * Creates a new LightInformationBlock
  58361. * @param name defines the block name
  58362. */
  58363. constructor(name: string);
  58364. /**
  58365. * Gets the current class name
  58366. * @returns the class name
  58367. */
  58368. getClassName(): string;
  58369. /**
  58370. * Gets the world position input component
  58371. */
  58372. get worldPosition(): NodeMaterialConnectionPoint;
  58373. /**
  58374. * Gets the direction output component
  58375. */
  58376. get direction(): NodeMaterialConnectionPoint;
  58377. /**
  58378. * Gets the direction output component
  58379. */
  58380. get color(): NodeMaterialConnectionPoint;
  58381. /**
  58382. * Gets the direction output component
  58383. */
  58384. get intensity(): NodeMaterialConnectionPoint;
  58385. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58386. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58387. protected _buildBlock(state: NodeMaterialBuildState): this;
  58388. serialize(): any;
  58389. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58390. }
  58391. }
  58392. declare module BABYLON {
  58393. /**
  58394. * Block used to add image processing support to fragment shader
  58395. */
  58396. export class ImageProcessingBlock extends NodeMaterialBlock {
  58397. /**
  58398. * Create a new ImageProcessingBlock
  58399. * @param name defines the block name
  58400. */
  58401. constructor(name: string);
  58402. /**
  58403. * Gets the current class name
  58404. * @returns the class name
  58405. */
  58406. getClassName(): string;
  58407. /**
  58408. * Gets the color input component
  58409. */
  58410. get color(): NodeMaterialConnectionPoint;
  58411. /**
  58412. * Gets the output component
  58413. */
  58414. get output(): NodeMaterialConnectionPoint;
  58415. /**
  58416. * Initialize the block and prepare the context for build
  58417. * @param state defines the state that will be used for the build
  58418. */
  58419. initialize(state: NodeMaterialBuildState): void;
  58420. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58421. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58422. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58423. protected _buildBlock(state: NodeMaterialBuildState): this;
  58424. }
  58425. }
  58426. declare module BABYLON {
  58427. /**
  58428. * Block used to pertub normals based on a normal map
  58429. */
  58430. export class PerturbNormalBlock extends NodeMaterialBlock {
  58431. private _tangentSpaceParameterName;
  58432. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58433. invertX: boolean;
  58434. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58435. invertY: boolean;
  58436. /**
  58437. * Create a new PerturbNormalBlock
  58438. * @param name defines the block name
  58439. */
  58440. constructor(name: string);
  58441. /**
  58442. * Gets the current class name
  58443. * @returns the class name
  58444. */
  58445. getClassName(): string;
  58446. /**
  58447. * Gets the world position input component
  58448. */
  58449. get worldPosition(): NodeMaterialConnectionPoint;
  58450. /**
  58451. * Gets the world normal input component
  58452. */
  58453. get worldNormal(): NodeMaterialConnectionPoint;
  58454. /**
  58455. * Gets the world tangent input component
  58456. */
  58457. get worldTangent(): NodeMaterialConnectionPoint;
  58458. /**
  58459. * Gets the uv input component
  58460. */
  58461. get uv(): NodeMaterialConnectionPoint;
  58462. /**
  58463. * Gets the normal map color input component
  58464. */
  58465. get normalMapColor(): NodeMaterialConnectionPoint;
  58466. /**
  58467. * Gets the strength input component
  58468. */
  58469. get strength(): NodeMaterialConnectionPoint;
  58470. /**
  58471. * Gets the output component
  58472. */
  58473. get output(): NodeMaterialConnectionPoint;
  58474. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58475. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58476. autoConfigure(material: NodeMaterial): void;
  58477. protected _buildBlock(state: NodeMaterialBuildState): this;
  58478. protected _dumpPropertiesCode(): string;
  58479. serialize(): any;
  58480. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58481. }
  58482. }
  58483. declare module BABYLON {
  58484. /**
  58485. * Block used to discard a pixel if a value is smaller than a cutoff
  58486. */
  58487. export class DiscardBlock extends NodeMaterialBlock {
  58488. /**
  58489. * Create a new DiscardBlock
  58490. * @param name defines the block name
  58491. */
  58492. constructor(name: string);
  58493. /**
  58494. * Gets the current class name
  58495. * @returns the class name
  58496. */
  58497. getClassName(): string;
  58498. /**
  58499. * Gets the color input component
  58500. */
  58501. get value(): NodeMaterialConnectionPoint;
  58502. /**
  58503. * Gets the cutoff input component
  58504. */
  58505. get cutoff(): NodeMaterialConnectionPoint;
  58506. protected _buildBlock(state: NodeMaterialBuildState): this;
  58507. }
  58508. }
  58509. declare module BABYLON {
  58510. /**
  58511. * Block used to test if the fragment shader is front facing
  58512. */
  58513. export class FrontFacingBlock extends NodeMaterialBlock {
  58514. /**
  58515. * Creates a new FrontFacingBlock
  58516. * @param name defines the block name
  58517. */
  58518. constructor(name: string);
  58519. /**
  58520. * Gets the current class name
  58521. * @returns the class name
  58522. */
  58523. getClassName(): string;
  58524. /**
  58525. * Gets the output component
  58526. */
  58527. get output(): NodeMaterialConnectionPoint;
  58528. protected _buildBlock(state: NodeMaterialBuildState): this;
  58529. }
  58530. }
  58531. declare module BABYLON {
  58532. /**
  58533. * Block used to get the derivative value on x and y of a given input
  58534. */
  58535. export class DerivativeBlock extends NodeMaterialBlock {
  58536. /**
  58537. * Create a new DerivativeBlock
  58538. * @param name defines the block name
  58539. */
  58540. constructor(name: string);
  58541. /**
  58542. * Gets the current class name
  58543. * @returns the class name
  58544. */
  58545. getClassName(): string;
  58546. /**
  58547. * Gets the input component
  58548. */
  58549. get input(): NodeMaterialConnectionPoint;
  58550. /**
  58551. * Gets the derivative output on x
  58552. */
  58553. get dx(): NodeMaterialConnectionPoint;
  58554. /**
  58555. * Gets the derivative output on y
  58556. */
  58557. get dy(): NodeMaterialConnectionPoint;
  58558. protected _buildBlock(state: NodeMaterialBuildState): this;
  58559. }
  58560. }
  58561. declare module BABYLON {
  58562. /**
  58563. * Block used to add support for scene fog
  58564. */
  58565. export class FogBlock extends NodeMaterialBlock {
  58566. private _fogDistanceName;
  58567. private _fogParameters;
  58568. /**
  58569. * Create a new FogBlock
  58570. * @param name defines the block name
  58571. */
  58572. constructor(name: string);
  58573. /**
  58574. * Gets the current class name
  58575. * @returns the class name
  58576. */
  58577. getClassName(): string;
  58578. /**
  58579. * Gets the world position input component
  58580. */
  58581. get worldPosition(): NodeMaterialConnectionPoint;
  58582. /**
  58583. * Gets the view input component
  58584. */
  58585. get view(): NodeMaterialConnectionPoint;
  58586. /**
  58587. * Gets the color input component
  58588. */
  58589. get input(): NodeMaterialConnectionPoint;
  58590. /**
  58591. * Gets the fog color input component
  58592. */
  58593. get fogColor(): NodeMaterialConnectionPoint;
  58594. /**
  58595. * Gets the output component
  58596. */
  58597. get output(): NodeMaterialConnectionPoint;
  58598. autoConfigure(material: NodeMaterial): void;
  58599. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58600. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58601. protected _buildBlock(state: NodeMaterialBuildState): this;
  58602. }
  58603. }
  58604. declare module BABYLON {
  58605. /**
  58606. * Block used to add light in the fragment shader
  58607. */
  58608. export class LightBlock extends NodeMaterialBlock {
  58609. private _lightId;
  58610. /**
  58611. * Gets or sets the light associated with this block
  58612. */
  58613. light: Nullable<Light>;
  58614. /**
  58615. * Create a new LightBlock
  58616. * @param name defines the block name
  58617. */
  58618. constructor(name: string);
  58619. /**
  58620. * Gets the current class name
  58621. * @returns the class name
  58622. */
  58623. getClassName(): string;
  58624. /**
  58625. * Gets the world position input component
  58626. */
  58627. get worldPosition(): NodeMaterialConnectionPoint;
  58628. /**
  58629. * Gets the world normal input component
  58630. */
  58631. get worldNormal(): NodeMaterialConnectionPoint;
  58632. /**
  58633. * Gets the camera (or eye) position component
  58634. */
  58635. get cameraPosition(): NodeMaterialConnectionPoint;
  58636. /**
  58637. * Gets the glossiness component
  58638. */
  58639. get glossiness(): NodeMaterialConnectionPoint;
  58640. /**
  58641. * Gets the glossinness power component
  58642. */
  58643. get glossPower(): NodeMaterialConnectionPoint;
  58644. /**
  58645. * Gets the diffuse color component
  58646. */
  58647. get diffuseColor(): NodeMaterialConnectionPoint;
  58648. /**
  58649. * Gets the specular color component
  58650. */
  58651. get specularColor(): NodeMaterialConnectionPoint;
  58652. /**
  58653. * Gets the diffuse output component
  58654. */
  58655. get diffuseOutput(): NodeMaterialConnectionPoint;
  58656. /**
  58657. * Gets the specular output component
  58658. */
  58659. get specularOutput(): NodeMaterialConnectionPoint;
  58660. /**
  58661. * Gets the shadow output component
  58662. */
  58663. get shadow(): NodeMaterialConnectionPoint;
  58664. autoConfigure(material: NodeMaterial): void;
  58665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58666. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58667. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58668. private _injectVertexCode;
  58669. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58670. serialize(): any;
  58671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58672. }
  58673. }
  58674. declare module BABYLON {
  58675. /**
  58676. * Block used to multiply 2 values
  58677. */
  58678. export class MultiplyBlock extends NodeMaterialBlock {
  58679. /**
  58680. * Creates a new MultiplyBlock
  58681. * @param name defines the block name
  58682. */
  58683. constructor(name: string);
  58684. /**
  58685. * Gets the current class name
  58686. * @returns the class name
  58687. */
  58688. getClassName(): string;
  58689. /**
  58690. * Gets the left operand input component
  58691. */
  58692. get left(): NodeMaterialConnectionPoint;
  58693. /**
  58694. * Gets the right operand input component
  58695. */
  58696. get right(): NodeMaterialConnectionPoint;
  58697. /**
  58698. * Gets the output component
  58699. */
  58700. get output(): NodeMaterialConnectionPoint;
  58701. protected _buildBlock(state: NodeMaterialBuildState): this;
  58702. }
  58703. }
  58704. declare module BABYLON {
  58705. /**
  58706. * Block used to add 2 vectors
  58707. */
  58708. export class AddBlock extends NodeMaterialBlock {
  58709. /**
  58710. * Creates a new AddBlock
  58711. * @param name defines the block name
  58712. */
  58713. constructor(name: string);
  58714. /**
  58715. * Gets the current class name
  58716. * @returns the class name
  58717. */
  58718. getClassName(): string;
  58719. /**
  58720. * Gets the left operand input component
  58721. */
  58722. get left(): NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the right operand input component
  58725. */
  58726. get right(): NodeMaterialConnectionPoint;
  58727. /**
  58728. * Gets the output component
  58729. */
  58730. get output(): NodeMaterialConnectionPoint;
  58731. protected _buildBlock(state: NodeMaterialBuildState): this;
  58732. }
  58733. }
  58734. declare module BABYLON {
  58735. /**
  58736. * Block used to scale a vector by a float
  58737. */
  58738. export class ScaleBlock extends NodeMaterialBlock {
  58739. /**
  58740. * Creates a new ScaleBlock
  58741. * @param name defines the block name
  58742. */
  58743. constructor(name: string);
  58744. /**
  58745. * Gets the current class name
  58746. * @returns the class name
  58747. */
  58748. getClassName(): string;
  58749. /**
  58750. * Gets the input component
  58751. */
  58752. get input(): NodeMaterialConnectionPoint;
  58753. /**
  58754. * Gets the factor input component
  58755. */
  58756. get factor(): NodeMaterialConnectionPoint;
  58757. /**
  58758. * Gets the output component
  58759. */
  58760. get output(): NodeMaterialConnectionPoint;
  58761. protected _buildBlock(state: NodeMaterialBuildState): this;
  58762. }
  58763. }
  58764. declare module BABYLON {
  58765. /**
  58766. * Block used to clamp a float
  58767. */
  58768. export class ClampBlock extends NodeMaterialBlock {
  58769. /** Gets or sets the minimum range */
  58770. minimum: number;
  58771. /** Gets or sets the maximum range */
  58772. maximum: number;
  58773. /**
  58774. * Creates a new ClampBlock
  58775. * @param name defines the block name
  58776. */
  58777. constructor(name: string);
  58778. /**
  58779. * Gets the current class name
  58780. * @returns the class name
  58781. */
  58782. getClassName(): string;
  58783. /**
  58784. * Gets the value input component
  58785. */
  58786. get value(): NodeMaterialConnectionPoint;
  58787. /**
  58788. * Gets the output component
  58789. */
  58790. get output(): NodeMaterialConnectionPoint;
  58791. protected _buildBlock(state: NodeMaterialBuildState): this;
  58792. protected _dumpPropertiesCode(): string;
  58793. serialize(): any;
  58794. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58795. }
  58796. }
  58797. declare module BABYLON {
  58798. /**
  58799. * Block used to apply a cross product between 2 vectors
  58800. */
  58801. export class CrossBlock extends NodeMaterialBlock {
  58802. /**
  58803. * Creates a new CrossBlock
  58804. * @param name defines the block name
  58805. */
  58806. constructor(name: string);
  58807. /**
  58808. * Gets the current class name
  58809. * @returns the class name
  58810. */
  58811. getClassName(): string;
  58812. /**
  58813. * Gets the left operand input component
  58814. */
  58815. get left(): NodeMaterialConnectionPoint;
  58816. /**
  58817. * Gets the right operand input component
  58818. */
  58819. get right(): NodeMaterialConnectionPoint;
  58820. /**
  58821. * Gets the output component
  58822. */
  58823. get output(): NodeMaterialConnectionPoint;
  58824. protected _buildBlock(state: NodeMaterialBuildState): this;
  58825. }
  58826. }
  58827. declare module BABYLON {
  58828. /**
  58829. * Block used to apply a dot product between 2 vectors
  58830. */
  58831. export class DotBlock extends NodeMaterialBlock {
  58832. /**
  58833. * Creates a new DotBlock
  58834. * @param name defines the block name
  58835. */
  58836. constructor(name: string);
  58837. /**
  58838. * Gets the current class name
  58839. * @returns the class name
  58840. */
  58841. getClassName(): string;
  58842. /**
  58843. * Gets the left operand input component
  58844. */
  58845. get left(): NodeMaterialConnectionPoint;
  58846. /**
  58847. * Gets the right operand input component
  58848. */
  58849. get right(): NodeMaterialConnectionPoint;
  58850. /**
  58851. * Gets the output component
  58852. */
  58853. get output(): NodeMaterialConnectionPoint;
  58854. protected _buildBlock(state: NodeMaterialBuildState): this;
  58855. }
  58856. }
  58857. declare module BABYLON {
  58858. /**
  58859. * Block used to remap a float from a range to a new one
  58860. */
  58861. export class RemapBlock extends NodeMaterialBlock {
  58862. /**
  58863. * Gets or sets the source range
  58864. */
  58865. sourceRange: Vector2;
  58866. /**
  58867. * Gets or sets the target range
  58868. */
  58869. targetRange: Vector2;
  58870. /**
  58871. * Creates a new RemapBlock
  58872. * @param name defines the block name
  58873. */
  58874. constructor(name: string);
  58875. /**
  58876. * Gets the current class name
  58877. * @returns the class name
  58878. */
  58879. getClassName(): string;
  58880. /**
  58881. * Gets the input component
  58882. */
  58883. get input(): NodeMaterialConnectionPoint;
  58884. /**
  58885. * Gets the source min input component
  58886. */
  58887. get sourceMin(): NodeMaterialConnectionPoint;
  58888. /**
  58889. * Gets the source max input component
  58890. */
  58891. get sourceMax(): NodeMaterialConnectionPoint;
  58892. /**
  58893. * Gets the target min input component
  58894. */
  58895. get targetMin(): NodeMaterialConnectionPoint;
  58896. /**
  58897. * Gets the target max input component
  58898. */
  58899. get targetMax(): NodeMaterialConnectionPoint;
  58900. /**
  58901. * Gets the output component
  58902. */
  58903. get output(): NodeMaterialConnectionPoint;
  58904. protected _buildBlock(state: NodeMaterialBuildState): this;
  58905. protected _dumpPropertiesCode(): string;
  58906. serialize(): any;
  58907. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58908. }
  58909. }
  58910. declare module BABYLON {
  58911. /**
  58912. * Block used to normalize a vector
  58913. */
  58914. export class NormalizeBlock extends NodeMaterialBlock {
  58915. /**
  58916. * Creates a new NormalizeBlock
  58917. * @param name defines the block name
  58918. */
  58919. constructor(name: string);
  58920. /**
  58921. * Gets the current class name
  58922. * @returns the class name
  58923. */
  58924. getClassName(): string;
  58925. /**
  58926. * Gets the input component
  58927. */
  58928. get input(): NodeMaterialConnectionPoint;
  58929. /**
  58930. * Gets the output component
  58931. */
  58932. get output(): NodeMaterialConnectionPoint;
  58933. protected _buildBlock(state: NodeMaterialBuildState): this;
  58934. }
  58935. }
  58936. declare module BABYLON {
  58937. /**
  58938. * Operations supported by the Trigonometry block
  58939. */
  58940. export enum TrigonometryBlockOperations {
  58941. /** Cos */
  58942. Cos = 0,
  58943. /** Sin */
  58944. Sin = 1,
  58945. /** Abs */
  58946. Abs = 2,
  58947. /** Exp */
  58948. Exp = 3,
  58949. /** Exp2 */
  58950. Exp2 = 4,
  58951. /** Round */
  58952. Round = 5,
  58953. /** Floor */
  58954. Floor = 6,
  58955. /** Ceiling */
  58956. Ceiling = 7,
  58957. /** Square root */
  58958. Sqrt = 8,
  58959. /** Log */
  58960. Log = 9,
  58961. /** Tangent */
  58962. Tan = 10,
  58963. /** Arc tangent */
  58964. ArcTan = 11,
  58965. /** Arc cosinus */
  58966. ArcCos = 12,
  58967. /** Arc sinus */
  58968. ArcSin = 13,
  58969. /** Fraction */
  58970. Fract = 14,
  58971. /** Sign */
  58972. Sign = 15,
  58973. /** To radians (from degrees) */
  58974. Radians = 16,
  58975. /** To degrees (from radians) */
  58976. Degrees = 17
  58977. }
  58978. /**
  58979. * Block used to apply trigonometry operation to floats
  58980. */
  58981. export class TrigonometryBlock extends NodeMaterialBlock {
  58982. /**
  58983. * Gets or sets the operation applied by the block
  58984. */
  58985. operation: TrigonometryBlockOperations;
  58986. /**
  58987. * Creates a new TrigonometryBlock
  58988. * @param name defines the block name
  58989. */
  58990. constructor(name: string);
  58991. /**
  58992. * Gets the current class name
  58993. * @returns the class name
  58994. */
  58995. getClassName(): string;
  58996. /**
  58997. * Gets the input component
  58998. */
  58999. get input(): NodeMaterialConnectionPoint;
  59000. /**
  59001. * Gets the output component
  59002. */
  59003. get output(): NodeMaterialConnectionPoint;
  59004. protected _buildBlock(state: NodeMaterialBuildState): this;
  59005. serialize(): any;
  59006. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59007. protected _dumpPropertiesCode(): string;
  59008. }
  59009. }
  59010. declare module BABYLON {
  59011. /**
  59012. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59013. */
  59014. export class ColorMergerBlock extends NodeMaterialBlock {
  59015. /**
  59016. * Create a new ColorMergerBlock
  59017. * @param name defines the block name
  59018. */
  59019. constructor(name: string);
  59020. /**
  59021. * Gets the current class name
  59022. * @returns the class name
  59023. */
  59024. getClassName(): string;
  59025. /**
  59026. * Gets the rgb component (input)
  59027. */
  59028. get rgbIn(): NodeMaterialConnectionPoint;
  59029. /**
  59030. * Gets the r component (input)
  59031. */
  59032. get r(): NodeMaterialConnectionPoint;
  59033. /**
  59034. * Gets the g component (input)
  59035. */
  59036. get g(): NodeMaterialConnectionPoint;
  59037. /**
  59038. * Gets the b component (input)
  59039. */
  59040. get b(): NodeMaterialConnectionPoint;
  59041. /**
  59042. * Gets the a component (input)
  59043. */
  59044. get a(): NodeMaterialConnectionPoint;
  59045. /**
  59046. * Gets the rgba component (output)
  59047. */
  59048. get rgba(): NodeMaterialConnectionPoint;
  59049. /**
  59050. * Gets the rgb component (output)
  59051. */
  59052. get rgbOut(): NodeMaterialConnectionPoint;
  59053. /**
  59054. * Gets the rgb component (output)
  59055. * @deprecated Please use rgbOut instead.
  59056. */
  59057. get rgb(): NodeMaterialConnectionPoint;
  59058. protected _buildBlock(state: NodeMaterialBuildState): this;
  59059. }
  59060. }
  59061. declare module BABYLON {
  59062. /**
  59063. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59064. */
  59065. export class VectorMergerBlock extends NodeMaterialBlock {
  59066. /**
  59067. * Create a new VectorMergerBlock
  59068. * @param name defines the block name
  59069. */
  59070. constructor(name: string);
  59071. /**
  59072. * Gets the current class name
  59073. * @returns the class name
  59074. */
  59075. getClassName(): string;
  59076. /**
  59077. * Gets the xyz component (input)
  59078. */
  59079. get xyzIn(): NodeMaterialConnectionPoint;
  59080. /**
  59081. * Gets the xy component (input)
  59082. */
  59083. get xyIn(): NodeMaterialConnectionPoint;
  59084. /**
  59085. * Gets the x component (input)
  59086. */
  59087. get x(): NodeMaterialConnectionPoint;
  59088. /**
  59089. * Gets the y component (input)
  59090. */
  59091. get y(): NodeMaterialConnectionPoint;
  59092. /**
  59093. * Gets the z component (input)
  59094. */
  59095. get z(): NodeMaterialConnectionPoint;
  59096. /**
  59097. * Gets the w component (input)
  59098. */
  59099. get w(): NodeMaterialConnectionPoint;
  59100. /**
  59101. * Gets the xyzw component (output)
  59102. */
  59103. get xyzw(): NodeMaterialConnectionPoint;
  59104. /**
  59105. * Gets the xyz component (output)
  59106. */
  59107. get xyzOut(): NodeMaterialConnectionPoint;
  59108. /**
  59109. * Gets the xy component (output)
  59110. */
  59111. get xyOut(): NodeMaterialConnectionPoint;
  59112. /**
  59113. * Gets the xy component (output)
  59114. * @deprecated Please use xyOut instead.
  59115. */
  59116. get xy(): NodeMaterialConnectionPoint;
  59117. /**
  59118. * Gets the xyz component (output)
  59119. * @deprecated Please use xyzOut instead.
  59120. */
  59121. get xyz(): NodeMaterialConnectionPoint;
  59122. protected _buildBlock(state: NodeMaterialBuildState): this;
  59123. }
  59124. }
  59125. declare module BABYLON {
  59126. /**
  59127. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59128. */
  59129. export class ColorSplitterBlock extends NodeMaterialBlock {
  59130. /**
  59131. * Create a new ColorSplitterBlock
  59132. * @param name defines the block name
  59133. */
  59134. constructor(name: string);
  59135. /**
  59136. * Gets the current class name
  59137. * @returns the class name
  59138. */
  59139. getClassName(): string;
  59140. /**
  59141. * Gets the rgba component (input)
  59142. */
  59143. get rgba(): NodeMaterialConnectionPoint;
  59144. /**
  59145. * Gets the rgb component (input)
  59146. */
  59147. get rgbIn(): NodeMaterialConnectionPoint;
  59148. /**
  59149. * Gets the rgb component (output)
  59150. */
  59151. get rgbOut(): NodeMaterialConnectionPoint;
  59152. /**
  59153. * Gets the r component (output)
  59154. */
  59155. get r(): NodeMaterialConnectionPoint;
  59156. /**
  59157. * Gets the g component (output)
  59158. */
  59159. get g(): NodeMaterialConnectionPoint;
  59160. /**
  59161. * Gets the b component (output)
  59162. */
  59163. get b(): NodeMaterialConnectionPoint;
  59164. /**
  59165. * Gets the a component (output)
  59166. */
  59167. get a(): NodeMaterialConnectionPoint;
  59168. protected _inputRename(name: string): string;
  59169. protected _outputRename(name: string): string;
  59170. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59171. }
  59172. }
  59173. declare module BABYLON {
  59174. /**
  59175. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59176. */
  59177. export class VectorSplitterBlock extends NodeMaterialBlock {
  59178. /**
  59179. * Create a new VectorSplitterBlock
  59180. * @param name defines the block name
  59181. */
  59182. constructor(name: string);
  59183. /**
  59184. * Gets the current class name
  59185. * @returns the class name
  59186. */
  59187. getClassName(): string;
  59188. /**
  59189. * Gets the xyzw component (input)
  59190. */
  59191. get xyzw(): NodeMaterialConnectionPoint;
  59192. /**
  59193. * Gets the xyz component (input)
  59194. */
  59195. get xyzIn(): NodeMaterialConnectionPoint;
  59196. /**
  59197. * Gets the xy component (input)
  59198. */
  59199. get xyIn(): NodeMaterialConnectionPoint;
  59200. /**
  59201. * Gets the xyz component (output)
  59202. */
  59203. get xyzOut(): NodeMaterialConnectionPoint;
  59204. /**
  59205. * Gets the xy component (output)
  59206. */
  59207. get xyOut(): NodeMaterialConnectionPoint;
  59208. /**
  59209. * Gets the x component (output)
  59210. */
  59211. get x(): NodeMaterialConnectionPoint;
  59212. /**
  59213. * Gets the y component (output)
  59214. */
  59215. get y(): NodeMaterialConnectionPoint;
  59216. /**
  59217. * Gets the z component (output)
  59218. */
  59219. get z(): NodeMaterialConnectionPoint;
  59220. /**
  59221. * Gets the w component (output)
  59222. */
  59223. get w(): NodeMaterialConnectionPoint;
  59224. protected _inputRename(name: string): string;
  59225. protected _outputRename(name: string): string;
  59226. protected _buildBlock(state: NodeMaterialBuildState): this;
  59227. }
  59228. }
  59229. declare module BABYLON {
  59230. /**
  59231. * Block used to lerp between 2 values
  59232. */
  59233. export class LerpBlock extends NodeMaterialBlock {
  59234. /**
  59235. * Creates a new LerpBlock
  59236. * @param name defines the block name
  59237. */
  59238. constructor(name: string);
  59239. /**
  59240. * Gets the current class name
  59241. * @returns the class name
  59242. */
  59243. getClassName(): string;
  59244. /**
  59245. * Gets the left operand input component
  59246. */
  59247. get left(): NodeMaterialConnectionPoint;
  59248. /**
  59249. * Gets the right operand input component
  59250. */
  59251. get right(): NodeMaterialConnectionPoint;
  59252. /**
  59253. * Gets the gradient operand input component
  59254. */
  59255. get gradient(): NodeMaterialConnectionPoint;
  59256. /**
  59257. * Gets the output component
  59258. */
  59259. get output(): NodeMaterialConnectionPoint;
  59260. protected _buildBlock(state: NodeMaterialBuildState): this;
  59261. }
  59262. }
  59263. declare module BABYLON {
  59264. /**
  59265. * Block used to divide 2 vectors
  59266. */
  59267. export class DivideBlock extends NodeMaterialBlock {
  59268. /**
  59269. * Creates a new DivideBlock
  59270. * @param name defines the block name
  59271. */
  59272. constructor(name: string);
  59273. /**
  59274. * Gets the current class name
  59275. * @returns the class name
  59276. */
  59277. getClassName(): string;
  59278. /**
  59279. * Gets the left operand input component
  59280. */
  59281. get left(): NodeMaterialConnectionPoint;
  59282. /**
  59283. * Gets the right operand input component
  59284. */
  59285. get right(): NodeMaterialConnectionPoint;
  59286. /**
  59287. * Gets the output component
  59288. */
  59289. get output(): NodeMaterialConnectionPoint;
  59290. protected _buildBlock(state: NodeMaterialBuildState): this;
  59291. }
  59292. }
  59293. declare module BABYLON {
  59294. /**
  59295. * Block used to subtract 2 vectors
  59296. */
  59297. export class SubtractBlock extends NodeMaterialBlock {
  59298. /**
  59299. * Creates a new SubtractBlock
  59300. * @param name defines the block name
  59301. */
  59302. constructor(name: string);
  59303. /**
  59304. * Gets the current class name
  59305. * @returns the class name
  59306. */
  59307. getClassName(): string;
  59308. /**
  59309. * Gets the left operand input component
  59310. */
  59311. get left(): NodeMaterialConnectionPoint;
  59312. /**
  59313. * Gets the right operand input component
  59314. */
  59315. get right(): NodeMaterialConnectionPoint;
  59316. /**
  59317. * Gets the output component
  59318. */
  59319. get output(): NodeMaterialConnectionPoint;
  59320. protected _buildBlock(state: NodeMaterialBuildState): this;
  59321. }
  59322. }
  59323. declare module BABYLON {
  59324. /**
  59325. * Block used to step a value
  59326. */
  59327. export class StepBlock extends NodeMaterialBlock {
  59328. /**
  59329. * Creates a new StepBlock
  59330. * @param name defines the block name
  59331. */
  59332. constructor(name: string);
  59333. /**
  59334. * Gets the current class name
  59335. * @returns the class name
  59336. */
  59337. getClassName(): string;
  59338. /**
  59339. * Gets the value operand input component
  59340. */
  59341. get value(): NodeMaterialConnectionPoint;
  59342. /**
  59343. * Gets the edge operand input component
  59344. */
  59345. get edge(): NodeMaterialConnectionPoint;
  59346. /**
  59347. * Gets the output component
  59348. */
  59349. get output(): NodeMaterialConnectionPoint;
  59350. protected _buildBlock(state: NodeMaterialBuildState): this;
  59351. }
  59352. }
  59353. declare module BABYLON {
  59354. /**
  59355. * Block used to get the opposite (1 - x) of a value
  59356. */
  59357. export class OneMinusBlock extends NodeMaterialBlock {
  59358. /**
  59359. * Creates a new OneMinusBlock
  59360. * @param name defines the block name
  59361. */
  59362. constructor(name: string);
  59363. /**
  59364. * Gets the current class name
  59365. * @returns the class name
  59366. */
  59367. getClassName(): string;
  59368. /**
  59369. * Gets the input component
  59370. */
  59371. get input(): NodeMaterialConnectionPoint;
  59372. /**
  59373. * Gets the output component
  59374. */
  59375. get output(): NodeMaterialConnectionPoint;
  59376. protected _buildBlock(state: NodeMaterialBuildState): this;
  59377. }
  59378. }
  59379. declare module BABYLON {
  59380. /**
  59381. * Block used to get the view direction
  59382. */
  59383. export class ViewDirectionBlock extends NodeMaterialBlock {
  59384. /**
  59385. * Creates a new ViewDirectionBlock
  59386. * @param name defines the block name
  59387. */
  59388. constructor(name: string);
  59389. /**
  59390. * Gets the current class name
  59391. * @returns the class name
  59392. */
  59393. getClassName(): string;
  59394. /**
  59395. * Gets the world position component
  59396. */
  59397. get worldPosition(): NodeMaterialConnectionPoint;
  59398. /**
  59399. * Gets the camera position component
  59400. */
  59401. get cameraPosition(): NodeMaterialConnectionPoint;
  59402. /**
  59403. * Gets the output component
  59404. */
  59405. get output(): NodeMaterialConnectionPoint;
  59406. autoConfigure(material: NodeMaterial): void;
  59407. protected _buildBlock(state: NodeMaterialBuildState): this;
  59408. }
  59409. }
  59410. declare module BABYLON {
  59411. /**
  59412. * Block used to compute fresnel value
  59413. */
  59414. export class FresnelBlock extends NodeMaterialBlock {
  59415. /**
  59416. * Create a new FresnelBlock
  59417. * @param name defines the block name
  59418. */
  59419. constructor(name: string);
  59420. /**
  59421. * Gets the current class name
  59422. * @returns the class name
  59423. */
  59424. getClassName(): string;
  59425. /**
  59426. * Gets the world normal input component
  59427. */
  59428. get worldNormal(): NodeMaterialConnectionPoint;
  59429. /**
  59430. * Gets the view direction input component
  59431. */
  59432. get viewDirection(): NodeMaterialConnectionPoint;
  59433. /**
  59434. * Gets the bias input component
  59435. */
  59436. get bias(): NodeMaterialConnectionPoint;
  59437. /**
  59438. * Gets the camera (or eye) position component
  59439. */
  59440. get power(): NodeMaterialConnectionPoint;
  59441. /**
  59442. * Gets the fresnel output component
  59443. */
  59444. get fresnel(): NodeMaterialConnectionPoint;
  59445. autoConfigure(material: NodeMaterial): void;
  59446. protected _buildBlock(state: NodeMaterialBuildState): this;
  59447. }
  59448. }
  59449. declare module BABYLON {
  59450. /**
  59451. * Block used to get the max of 2 values
  59452. */
  59453. export class MaxBlock extends NodeMaterialBlock {
  59454. /**
  59455. * Creates a new MaxBlock
  59456. * @param name defines the block name
  59457. */
  59458. constructor(name: string);
  59459. /**
  59460. * Gets the current class name
  59461. * @returns the class name
  59462. */
  59463. getClassName(): string;
  59464. /**
  59465. * Gets the left operand input component
  59466. */
  59467. get left(): NodeMaterialConnectionPoint;
  59468. /**
  59469. * Gets the right operand input component
  59470. */
  59471. get right(): NodeMaterialConnectionPoint;
  59472. /**
  59473. * Gets the output component
  59474. */
  59475. get output(): NodeMaterialConnectionPoint;
  59476. protected _buildBlock(state: NodeMaterialBuildState): this;
  59477. }
  59478. }
  59479. declare module BABYLON {
  59480. /**
  59481. * Block used to get the min of 2 values
  59482. */
  59483. export class MinBlock extends NodeMaterialBlock {
  59484. /**
  59485. * Creates a new MinBlock
  59486. * @param name defines the block name
  59487. */
  59488. constructor(name: string);
  59489. /**
  59490. * Gets the current class name
  59491. * @returns the class name
  59492. */
  59493. getClassName(): string;
  59494. /**
  59495. * Gets the left operand input component
  59496. */
  59497. get left(): NodeMaterialConnectionPoint;
  59498. /**
  59499. * Gets the right operand input component
  59500. */
  59501. get right(): NodeMaterialConnectionPoint;
  59502. /**
  59503. * Gets the output component
  59504. */
  59505. get output(): NodeMaterialConnectionPoint;
  59506. protected _buildBlock(state: NodeMaterialBuildState): this;
  59507. }
  59508. }
  59509. declare module BABYLON {
  59510. /**
  59511. * Block used to get the distance between 2 values
  59512. */
  59513. export class DistanceBlock extends NodeMaterialBlock {
  59514. /**
  59515. * Creates a new DistanceBlock
  59516. * @param name defines the block name
  59517. */
  59518. constructor(name: string);
  59519. /**
  59520. * Gets the current class name
  59521. * @returns the class name
  59522. */
  59523. getClassName(): string;
  59524. /**
  59525. * Gets the left operand input component
  59526. */
  59527. get left(): NodeMaterialConnectionPoint;
  59528. /**
  59529. * Gets the right operand input component
  59530. */
  59531. get right(): NodeMaterialConnectionPoint;
  59532. /**
  59533. * Gets the output component
  59534. */
  59535. get output(): NodeMaterialConnectionPoint;
  59536. protected _buildBlock(state: NodeMaterialBuildState): this;
  59537. }
  59538. }
  59539. declare module BABYLON {
  59540. /**
  59541. * Block used to get the length of a vector
  59542. */
  59543. export class LengthBlock extends NodeMaterialBlock {
  59544. /**
  59545. * Creates a new LengthBlock
  59546. * @param name defines the block name
  59547. */
  59548. constructor(name: string);
  59549. /**
  59550. * Gets the current class name
  59551. * @returns the class name
  59552. */
  59553. getClassName(): string;
  59554. /**
  59555. * Gets the value input component
  59556. */
  59557. get value(): NodeMaterialConnectionPoint;
  59558. /**
  59559. * Gets the output component
  59560. */
  59561. get output(): NodeMaterialConnectionPoint;
  59562. protected _buildBlock(state: NodeMaterialBuildState): this;
  59563. }
  59564. }
  59565. declare module BABYLON {
  59566. /**
  59567. * Block used to get negative version of a value (i.e. x * -1)
  59568. */
  59569. export class NegateBlock extends NodeMaterialBlock {
  59570. /**
  59571. * Creates a new NegateBlock
  59572. * @param name defines the block name
  59573. */
  59574. constructor(name: string);
  59575. /**
  59576. * Gets the current class name
  59577. * @returns the class name
  59578. */
  59579. getClassName(): string;
  59580. /**
  59581. * Gets the value input component
  59582. */
  59583. get value(): NodeMaterialConnectionPoint;
  59584. /**
  59585. * Gets the output component
  59586. */
  59587. get output(): NodeMaterialConnectionPoint;
  59588. protected _buildBlock(state: NodeMaterialBuildState): this;
  59589. }
  59590. }
  59591. declare module BABYLON {
  59592. /**
  59593. * Block used to get the value of the first parameter raised to the power of the second
  59594. */
  59595. export class PowBlock extends NodeMaterialBlock {
  59596. /**
  59597. * Creates a new PowBlock
  59598. * @param name defines the block name
  59599. */
  59600. constructor(name: string);
  59601. /**
  59602. * Gets the current class name
  59603. * @returns the class name
  59604. */
  59605. getClassName(): string;
  59606. /**
  59607. * Gets the value operand input component
  59608. */
  59609. get value(): NodeMaterialConnectionPoint;
  59610. /**
  59611. * Gets the power operand input component
  59612. */
  59613. get power(): NodeMaterialConnectionPoint;
  59614. /**
  59615. * Gets the output component
  59616. */
  59617. get output(): NodeMaterialConnectionPoint;
  59618. protected _buildBlock(state: NodeMaterialBuildState): this;
  59619. }
  59620. }
  59621. declare module BABYLON {
  59622. /**
  59623. * Block used to get a random number
  59624. */
  59625. export class RandomNumberBlock extends NodeMaterialBlock {
  59626. /**
  59627. * Creates a new RandomNumberBlock
  59628. * @param name defines the block name
  59629. */
  59630. constructor(name: string);
  59631. /**
  59632. * Gets the current class name
  59633. * @returns the class name
  59634. */
  59635. getClassName(): string;
  59636. /**
  59637. * Gets the seed input component
  59638. */
  59639. get seed(): NodeMaterialConnectionPoint;
  59640. /**
  59641. * Gets the output component
  59642. */
  59643. get output(): NodeMaterialConnectionPoint;
  59644. protected _buildBlock(state: NodeMaterialBuildState): this;
  59645. }
  59646. }
  59647. declare module BABYLON {
  59648. /**
  59649. * Block used to compute arc tangent of 2 values
  59650. */
  59651. export class ArcTan2Block extends NodeMaterialBlock {
  59652. /**
  59653. * Creates a new ArcTan2Block
  59654. * @param name defines the block name
  59655. */
  59656. constructor(name: string);
  59657. /**
  59658. * Gets the current class name
  59659. * @returns the class name
  59660. */
  59661. getClassName(): string;
  59662. /**
  59663. * Gets the x operand input component
  59664. */
  59665. get x(): NodeMaterialConnectionPoint;
  59666. /**
  59667. * Gets the y operand input component
  59668. */
  59669. get y(): NodeMaterialConnectionPoint;
  59670. /**
  59671. * Gets the output component
  59672. */
  59673. get output(): NodeMaterialConnectionPoint;
  59674. protected _buildBlock(state: NodeMaterialBuildState): this;
  59675. }
  59676. }
  59677. declare module BABYLON {
  59678. /**
  59679. * Block used to smooth step a value
  59680. */
  59681. export class SmoothStepBlock extends NodeMaterialBlock {
  59682. /**
  59683. * Creates a new SmoothStepBlock
  59684. * @param name defines the block name
  59685. */
  59686. constructor(name: string);
  59687. /**
  59688. * Gets the current class name
  59689. * @returns the class name
  59690. */
  59691. getClassName(): string;
  59692. /**
  59693. * Gets the value operand input component
  59694. */
  59695. get value(): NodeMaterialConnectionPoint;
  59696. /**
  59697. * Gets the first edge operand input component
  59698. */
  59699. get edge0(): NodeMaterialConnectionPoint;
  59700. /**
  59701. * Gets the second edge operand input component
  59702. */
  59703. get edge1(): NodeMaterialConnectionPoint;
  59704. /**
  59705. * Gets the output component
  59706. */
  59707. get output(): NodeMaterialConnectionPoint;
  59708. protected _buildBlock(state: NodeMaterialBuildState): this;
  59709. }
  59710. }
  59711. declare module BABYLON {
  59712. /**
  59713. * Block used to get the reciprocal (1 / x) of a value
  59714. */
  59715. export class ReciprocalBlock extends NodeMaterialBlock {
  59716. /**
  59717. * Creates a new ReciprocalBlock
  59718. * @param name defines the block name
  59719. */
  59720. constructor(name: string);
  59721. /**
  59722. * Gets the current class name
  59723. * @returns the class name
  59724. */
  59725. getClassName(): string;
  59726. /**
  59727. * Gets the input component
  59728. */
  59729. get input(): NodeMaterialConnectionPoint;
  59730. /**
  59731. * Gets the output component
  59732. */
  59733. get output(): NodeMaterialConnectionPoint;
  59734. protected _buildBlock(state: NodeMaterialBuildState): this;
  59735. }
  59736. }
  59737. declare module BABYLON {
  59738. /**
  59739. * Block used to replace a color by another one
  59740. */
  59741. export class ReplaceColorBlock extends NodeMaterialBlock {
  59742. /**
  59743. * Creates a new ReplaceColorBlock
  59744. * @param name defines the block name
  59745. */
  59746. constructor(name: string);
  59747. /**
  59748. * Gets the current class name
  59749. * @returns the class name
  59750. */
  59751. getClassName(): string;
  59752. /**
  59753. * Gets the value input component
  59754. */
  59755. get value(): NodeMaterialConnectionPoint;
  59756. /**
  59757. * Gets the reference input component
  59758. */
  59759. get reference(): NodeMaterialConnectionPoint;
  59760. /**
  59761. * Gets the distance input component
  59762. */
  59763. get distance(): NodeMaterialConnectionPoint;
  59764. /**
  59765. * Gets the replacement input component
  59766. */
  59767. get replacement(): NodeMaterialConnectionPoint;
  59768. /**
  59769. * Gets the output component
  59770. */
  59771. get output(): NodeMaterialConnectionPoint;
  59772. protected _buildBlock(state: NodeMaterialBuildState): this;
  59773. }
  59774. }
  59775. declare module BABYLON {
  59776. /**
  59777. * Block used to posterize a value
  59778. * @see https://en.wikipedia.org/wiki/Posterization
  59779. */
  59780. export class PosterizeBlock extends NodeMaterialBlock {
  59781. /**
  59782. * Creates a new PosterizeBlock
  59783. * @param name defines the block name
  59784. */
  59785. constructor(name: string);
  59786. /**
  59787. * Gets the current class name
  59788. * @returns the class name
  59789. */
  59790. getClassName(): string;
  59791. /**
  59792. * Gets the value input component
  59793. */
  59794. get value(): NodeMaterialConnectionPoint;
  59795. /**
  59796. * Gets the steps input component
  59797. */
  59798. get steps(): NodeMaterialConnectionPoint;
  59799. /**
  59800. * Gets the output component
  59801. */
  59802. get output(): NodeMaterialConnectionPoint;
  59803. protected _buildBlock(state: NodeMaterialBuildState): this;
  59804. }
  59805. }
  59806. declare module BABYLON {
  59807. /**
  59808. * Operations supported by the Wave block
  59809. */
  59810. export enum WaveBlockKind {
  59811. /** SawTooth */
  59812. SawTooth = 0,
  59813. /** Square */
  59814. Square = 1,
  59815. /** Triangle */
  59816. Triangle = 2
  59817. }
  59818. /**
  59819. * Block used to apply wave operation to floats
  59820. */
  59821. export class WaveBlock extends NodeMaterialBlock {
  59822. /**
  59823. * Gets or sets the kibnd of wave to be applied by the block
  59824. */
  59825. kind: WaveBlockKind;
  59826. /**
  59827. * Creates a new WaveBlock
  59828. * @param name defines the block name
  59829. */
  59830. constructor(name: string);
  59831. /**
  59832. * Gets the current class name
  59833. * @returns the class name
  59834. */
  59835. getClassName(): string;
  59836. /**
  59837. * Gets the input component
  59838. */
  59839. get input(): NodeMaterialConnectionPoint;
  59840. /**
  59841. * Gets the output component
  59842. */
  59843. get output(): NodeMaterialConnectionPoint;
  59844. protected _buildBlock(state: NodeMaterialBuildState): this;
  59845. serialize(): any;
  59846. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59847. }
  59848. }
  59849. declare module BABYLON {
  59850. /**
  59851. * Class used to store a color step for the GradientBlock
  59852. */
  59853. export class GradientBlockColorStep {
  59854. /**
  59855. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59856. */
  59857. step: number;
  59858. /**
  59859. * Gets or sets the color associated with this step
  59860. */
  59861. color: Color3;
  59862. /**
  59863. * Creates a new GradientBlockColorStep
  59864. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59865. * @param color defines the color associated with this step
  59866. */
  59867. constructor(
  59868. /**
  59869. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59870. */
  59871. step: number,
  59872. /**
  59873. * Gets or sets the color associated with this step
  59874. */
  59875. color: Color3);
  59876. }
  59877. /**
  59878. * Block used to return a color from a gradient based on an input value between 0 and 1
  59879. */
  59880. export class GradientBlock extends NodeMaterialBlock {
  59881. /**
  59882. * Gets or sets the list of color steps
  59883. */
  59884. colorSteps: GradientBlockColorStep[];
  59885. /**
  59886. * Creates a new GradientBlock
  59887. * @param name defines the block name
  59888. */
  59889. constructor(name: string);
  59890. /**
  59891. * Gets the current class name
  59892. * @returns the class name
  59893. */
  59894. getClassName(): string;
  59895. /**
  59896. * Gets the gradient input component
  59897. */
  59898. get gradient(): NodeMaterialConnectionPoint;
  59899. /**
  59900. * Gets the output component
  59901. */
  59902. get output(): NodeMaterialConnectionPoint;
  59903. private _writeColorConstant;
  59904. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59905. serialize(): any;
  59906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59907. protected _dumpPropertiesCode(): string;
  59908. }
  59909. }
  59910. declare module BABYLON {
  59911. /**
  59912. * Block used to normalize lerp between 2 values
  59913. */
  59914. export class NLerpBlock extends NodeMaterialBlock {
  59915. /**
  59916. * Creates a new NLerpBlock
  59917. * @param name defines the block name
  59918. */
  59919. constructor(name: string);
  59920. /**
  59921. * Gets the current class name
  59922. * @returns the class name
  59923. */
  59924. getClassName(): string;
  59925. /**
  59926. * Gets the left operand input component
  59927. */
  59928. get left(): NodeMaterialConnectionPoint;
  59929. /**
  59930. * Gets the right operand input component
  59931. */
  59932. get right(): NodeMaterialConnectionPoint;
  59933. /**
  59934. * Gets the gradient operand input component
  59935. */
  59936. get gradient(): NodeMaterialConnectionPoint;
  59937. /**
  59938. * Gets the output component
  59939. */
  59940. get output(): NodeMaterialConnectionPoint;
  59941. protected _buildBlock(state: NodeMaterialBuildState): this;
  59942. }
  59943. }
  59944. declare module BABYLON {
  59945. /**
  59946. * block used to Generate a Worley Noise 3D Noise Pattern
  59947. */
  59948. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59949. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59950. manhattanDistance: boolean;
  59951. /**
  59952. * Creates a new WorleyNoise3DBlock
  59953. * @param name defines the block name
  59954. */
  59955. constructor(name: string);
  59956. /**
  59957. * Gets the current class name
  59958. * @returns the class name
  59959. */
  59960. getClassName(): string;
  59961. /**
  59962. * Gets the seed input component
  59963. */
  59964. get seed(): NodeMaterialConnectionPoint;
  59965. /**
  59966. * Gets the jitter input component
  59967. */
  59968. get jitter(): NodeMaterialConnectionPoint;
  59969. /**
  59970. * Gets the output component
  59971. */
  59972. get output(): NodeMaterialConnectionPoint;
  59973. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59974. /**
  59975. * Exposes the properties to the UI?
  59976. */
  59977. protected _dumpPropertiesCode(): string;
  59978. /**
  59979. * Exposes the properties to the Seralize?
  59980. */
  59981. serialize(): any;
  59982. /**
  59983. * Exposes the properties to the deseralize?
  59984. */
  59985. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59986. }
  59987. }
  59988. declare module BABYLON {
  59989. /**
  59990. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59991. */
  59992. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59993. /**
  59994. * Creates a new SimplexPerlin3DBlock
  59995. * @param name defines the block name
  59996. */
  59997. constructor(name: string);
  59998. /**
  59999. * Gets the current class name
  60000. * @returns the class name
  60001. */
  60002. getClassName(): string;
  60003. /**
  60004. * Gets the seed operand input component
  60005. */
  60006. get seed(): NodeMaterialConnectionPoint;
  60007. /**
  60008. * Gets the output component
  60009. */
  60010. get output(): NodeMaterialConnectionPoint;
  60011. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60012. }
  60013. }
  60014. declare module BABYLON {
  60015. /**
  60016. * Block used to blend normals
  60017. */
  60018. export class NormalBlendBlock extends NodeMaterialBlock {
  60019. /**
  60020. * Creates a new NormalBlendBlock
  60021. * @param name defines the block name
  60022. */
  60023. constructor(name: string);
  60024. /**
  60025. * Gets the current class name
  60026. * @returns the class name
  60027. */
  60028. getClassName(): string;
  60029. /**
  60030. * Gets the first input component
  60031. */
  60032. get normalMap0(): NodeMaterialConnectionPoint;
  60033. /**
  60034. * Gets the second input component
  60035. */
  60036. get normalMap1(): NodeMaterialConnectionPoint;
  60037. /**
  60038. * Gets the output component
  60039. */
  60040. get output(): NodeMaterialConnectionPoint;
  60041. protected _buildBlock(state: NodeMaterialBuildState): this;
  60042. }
  60043. }
  60044. declare module BABYLON {
  60045. /**
  60046. * Block used to rotate a 2d vector by a given angle
  60047. */
  60048. export class Rotate2dBlock extends NodeMaterialBlock {
  60049. /**
  60050. * Creates a new Rotate2dBlock
  60051. * @param name defines the block name
  60052. */
  60053. constructor(name: string);
  60054. /**
  60055. * Gets the current class name
  60056. * @returns the class name
  60057. */
  60058. getClassName(): string;
  60059. /**
  60060. * Gets the input vector
  60061. */
  60062. get input(): NodeMaterialConnectionPoint;
  60063. /**
  60064. * Gets the input angle
  60065. */
  60066. get angle(): NodeMaterialConnectionPoint;
  60067. /**
  60068. * Gets the output component
  60069. */
  60070. get output(): NodeMaterialConnectionPoint;
  60071. autoConfigure(material: NodeMaterial): void;
  60072. protected _buildBlock(state: NodeMaterialBuildState): this;
  60073. }
  60074. }
  60075. declare module BABYLON {
  60076. /**
  60077. * Block used to get the reflected vector from a direction and a normal
  60078. */
  60079. export class ReflectBlock extends NodeMaterialBlock {
  60080. /**
  60081. * Creates a new ReflectBlock
  60082. * @param name defines the block name
  60083. */
  60084. constructor(name: string);
  60085. /**
  60086. * Gets the current class name
  60087. * @returns the class name
  60088. */
  60089. getClassName(): string;
  60090. /**
  60091. * Gets the incident component
  60092. */
  60093. get incident(): NodeMaterialConnectionPoint;
  60094. /**
  60095. * Gets the normal component
  60096. */
  60097. get normal(): NodeMaterialConnectionPoint;
  60098. /**
  60099. * Gets the output component
  60100. */
  60101. get output(): NodeMaterialConnectionPoint;
  60102. protected _buildBlock(state: NodeMaterialBuildState): this;
  60103. }
  60104. }
  60105. declare module BABYLON {
  60106. /**
  60107. * Block used to get the refracted vector from a direction and a normal
  60108. */
  60109. export class RefractBlock extends NodeMaterialBlock {
  60110. /**
  60111. * Creates a new RefractBlock
  60112. * @param name defines the block name
  60113. */
  60114. constructor(name: string);
  60115. /**
  60116. * Gets the current class name
  60117. * @returns the class name
  60118. */
  60119. getClassName(): string;
  60120. /**
  60121. * Gets the incident component
  60122. */
  60123. get incident(): NodeMaterialConnectionPoint;
  60124. /**
  60125. * Gets the normal component
  60126. */
  60127. get normal(): NodeMaterialConnectionPoint;
  60128. /**
  60129. * Gets the index of refraction component
  60130. */
  60131. get ior(): NodeMaterialConnectionPoint;
  60132. /**
  60133. * Gets the output component
  60134. */
  60135. get output(): NodeMaterialConnectionPoint;
  60136. protected _buildBlock(state: NodeMaterialBuildState): this;
  60137. }
  60138. }
  60139. declare module BABYLON {
  60140. /**
  60141. * Block used to desaturate a color
  60142. */
  60143. export class DesaturateBlock extends NodeMaterialBlock {
  60144. /**
  60145. * Creates a new DesaturateBlock
  60146. * @param name defines the block name
  60147. */
  60148. constructor(name: string);
  60149. /**
  60150. * Gets the current class name
  60151. * @returns the class name
  60152. */
  60153. getClassName(): string;
  60154. /**
  60155. * Gets the color operand input component
  60156. */
  60157. get color(): NodeMaterialConnectionPoint;
  60158. /**
  60159. * Gets the level operand input component
  60160. */
  60161. get level(): NodeMaterialConnectionPoint;
  60162. /**
  60163. * Gets the output component
  60164. */
  60165. get output(): NodeMaterialConnectionPoint;
  60166. protected _buildBlock(state: NodeMaterialBuildState): this;
  60167. }
  60168. }
  60169. declare module BABYLON {
  60170. /**
  60171. * Effect Render Options
  60172. */
  60173. export interface IEffectRendererOptions {
  60174. /**
  60175. * Defines the vertices positions.
  60176. */
  60177. positions?: number[];
  60178. /**
  60179. * Defines the indices.
  60180. */
  60181. indices?: number[];
  60182. }
  60183. /**
  60184. * Helper class to render one or more effects
  60185. */
  60186. export class EffectRenderer {
  60187. private engine;
  60188. private static _DefaultOptions;
  60189. private _vertexBuffers;
  60190. private _indexBuffer;
  60191. private _ringBufferIndex;
  60192. private _ringScreenBuffer;
  60193. private _fullscreenViewport;
  60194. private _getNextFrameBuffer;
  60195. /**
  60196. * Creates an effect renderer
  60197. * @param engine the engine to use for rendering
  60198. * @param options defines the options of the effect renderer
  60199. */
  60200. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60201. /**
  60202. * Sets the current viewport in normalized coordinates 0-1
  60203. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60204. */
  60205. setViewport(viewport?: Viewport): void;
  60206. /**
  60207. * Binds the embedded attributes buffer to the effect.
  60208. * @param effect Defines the effect to bind the attributes for
  60209. */
  60210. bindBuffers(effect: Effect): void;
  60211. /**
  60212. * Sets the current effect wrapper to use during draw.
  60213. * The effect needs to be ready before calling this api.
  60214. * This also sets the default full screen position attribute.
  60215. * @param effectWrapper Defines the effect to draw with
  60216. */
  60217. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60218. /**
  60219. * Draws a full screen quad.
  60220. */
  60221. draw(): void;
  60222. /**
  60223. * renders one or more effects to a specified texture
  60224. * @param effectWrappers list of effects to renderer
  60225. * @param outputTexture texture to draw to, if null it will render to the screen
  60226. */
  60227. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60228. /**
  60229. * Disposes of the effect renderer
  60230. */
  60231. dispose(): void;
  60232. }
  60233. /**
  60234. * Options to create an EffectWrapper
  60235. */
  60236. interface EffectWrapperCreationOptions {
  60237. /**
  60238. * Engine to use to create the effect
  60239. */
  60240. engine: ThinEngine;
  60241. /**
  60242. * Fragment shader for the effect
  60243. */
  60244. fragmentShader: string;
  60245. /**
  60246. * Vertex shader for the effect
  60247. */
  60248. vertexShader?: string;
  60249. /**
  60250. * Attributes to use in the shader
  60251. */
  60252. attributeNames?: Array<string>;
  60253. /**
  60254. * Uniforms to use in the shader
  60255. */
  60256. uniformNames?: Array<string>;
  60257. /**
  60258. * Texture sampler names to use in the shader
  60259. */
  60260. samplerNames?: Array<string>;
  60261. /**
  60262. * The friendly name of the effect displayed in Spector.
  60263. */
  60264. name?: string;
  60265. }
  60266. /**
  60267. * Wraps an effect to be used for rendering
  60268. */
  60269. export class EffectWrapper {
  60270. /**
  60271. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60272. */
  60273. onApplyObservable: Observable<{}>;
  60274. /**
  60275. * The underlying effect
  60276. */
  60277. effect: Effect;
  60278. /**
  60279. * Creates an effect to be renderer
  60280. * @param creationOptions options to create the effect
  60281. */
  60282. constructor(creationOptions: EffectWrapperCreationOptions);
  60283. /**
  60284. * Disposes of the effect wrapper
  60285. */
  60286. dispose(): void;
  60287. }
  60288. }
  60289. declare module BABYLON {
  60290. /**
  60291. * Helper class to push actions to a pool of workers.
  60292. */
  60293. export class WorkerPool implements IDisposable {
  60294. private _workerInfos;
  60295. private _pendingActions;
  60296. /**
  60297. * Constructor
  60298. * @param workers Array of workers to use for actions
  60299. */
  60300. constructor(workers: Array<Worker>);
  60301. /**
  60302. * Terminates all workers and clears any pending actions.
  60303. */
  60304. dispose(): void;
  60305. /**
  60306. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60307. * pended until a worker has completed its action.
  60308. * @param action The action to perform. Call onComplete when the action is complete.
  60309. */
  60310. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60311. private _execute;
  60312. }
  60313. }
  60314. declare module BABYLON {
  60315. /**
  60316. * Configuration for Draco compression
  60317. */
  60318. export interface IDracoCompressionConfiguration {
  60319. /**
  60320. * Configuration for the decoder.
  60321. */
  60322. decoder: {
  60323. /**
  60324. * The url to the WebAssembly module.
  60325. */
  60326. wasmUrl?: string;
  60327. /**
  60328. * The url to the WebAssembly binary.
  60329. */
  60330. wasmBinaryUrl?: string;
  60331. /**
  60332. * The url to the fallback JavaScript module.
  60333. */
  60334. fallbackUrl?: string;
  60335. };
  60336. }
  60337. /**
  60338. * Draco compression (https://google.github.io/draco/)
  60339. *
  60340. * This class wraps the Draco module.
  60341. *
  60342. * **Encoder**
  60343. *
  60344. * The encoder is not currently implemented.
  60345. *
  60346. * **Decoder**
  60347. *
  60348. * 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.
  60349. *
  60350. * To update the configuration, use the following code:
  60351. * ```javascript
  60352. * DracoCompression.Configuration = {
  60353. * decoder: {
  60354. * wasmUrl: "<url to the WebAssembly library>",
  60355. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60356. * fallbackUrl: "<url to the fallback JavaScript library>",
  60357. * }
  60358. * };
  60359. * ```
  60360. *
  60361. * 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.
  60362. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60363. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60364. *
  60365. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60366. * ```javascript
  60367. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60368. * ```
  60369. *
  60370. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60371. */
  60372. export class DracoCompression implements IDisposable {
  60373. private _workerPoolPromise?;
  60374. private _decoderModulePromise?;
  60375. /**
  60376. * The configuration. Defaults to the following urls:
  60377. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60378. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60379. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60380. */
  60381. static Configuration: IDracoCompressionConfiguration;
  60382. /**
  60383. * Returns true if the decoder configuration is available.
  60384. */
  60385. static get DecoderAvailable(): boolean;
  60386. /**
  60387. * Default number of workers to create when creating the draco compression object.
  60388. */
  60389. static DefaultNumWorkers: number;
  60390. private static GetDefaultNumWorkers;
  60391. private static _Default;
  60392. /**
  60393. * Default instance for the draco compression object.
  60394. */
  60395. static get Default(): DracoCompression;
  60396. /**
  60397. * Constructor
  60398. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60399. */
  60400. constructor(numWorkers?: number);
  60401. /**
  60402. * Stop all async operations and release resources.
  60403. */
  60404. dispose(): void;
  60405. /**
  60406. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60407. * @returns a promise that resolves when ready
  60408. */
  60409. whenReadyAsync(): Promise<void>;
  60410. /**
  60411. * Decode Draco compressed mesh data to vertex data.
  60412. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60413. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60414. * @returns A promise that resolves with the decoded vertex data
  60415. */
  60416. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60417. [kind: string]: number;
  60418. }): Promise<VertexData>;
  60419. }
  60420. }
  60421. declare module BABYLON {
  60422. /**
  60423. * Class for building Constructive Solid Geometry
  60424. */
  60425. export class CSG {
  60426. private polygons;
  60427. /**
  60428. * The world matrix
  60429. */
  60430. matrix: Matrix;
  60431. /**
  60432. * Stores the position
  60433. */
  60434. position: Vector3;
  60435. /**
  60436. * Stores the rotation
  60437. */
  60438. rotation: Vector3;
  60439. /**
  60440. * Stores the rotation quaternion
  60441. */
  60442. rotationQuaternion: Nullable<Quaternion>;
  60443. /**
  60444. * Stores the scaling vector
  60445. */
  60446. scaling: Vector3;
  60447. /**
  60448. * Convert the Mesh to CSG
  60449. * @param mesh The Mesh to convert to CSG
  60450. * @returns A new CSG from the Mesh
  60451. */
  60452. static FromMesh(mesh: Mesh): CSG;
  60453. /**
  60454. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60455. * @param polygons Polygons used to construct a CSG solid
  60456. */
  60457. private static FromPolygons;
  60458. /**
  60459. * Clones, or makes a deep copy, of the CSG
  60460. * @returns A new CSG
  60461. */
  60462. clone(): CSG;
  60463. /**
  60464. * Unions this CSG with another CSG
  60465. * @param csg The CSG to union against this CSG
  60466. * @returns The unioned CSG
  60467. */
  60468. union(csg: CSG): CSG;
  60469. /**
  60470. * Unions this CSG with another CSG in place
  60471. * @param csg The CSG to union against this CSG
  60472. */
  60473. unionInPlace(csg: CSG): void;
  60474. /**
  60475. * Subtracts this CSG with another CSG
  60476. * @param csg The CSG to subtract against this CSG
  60477. * @returns A new CSG
  60478. */
  60479. subtract(csg: CSG): CSG;
  60480. /**
  60481. * Subtracts this CSG with another CSG in place
  60482. * @param csg The CSG to subtact against this CSG
  60483. */
  60484. subtractInPlace(csg: CSG): void;
  60485. /**
  60486. * Intersect this CSG with another CSG
  60487. * @param csg The CSG to intersect against this CSG
  60488. * @returns A new CSG
  60489. */
  60490. intersect(csg: CSG): CSG;
  60491. /**
  60492. * Intersects this CSG with another CSG in place
  60493. * @param csg The CSG to intersect against this CSG
  60494. */
  60495. intersectInPlace(csg: CSG): void;
  60496. /**
  60497. * Return a new CSG solid with solid and empty space switched. This solid is
  60498. * not modified.
  60499. * @returns A new CSG solid with solid and empty space switched
  60500. */
  60501. inverse(): CSG;
  60502. /**
  60503. * Inverses the CSG in place
  60504. */
  60505. inverseInPlace(): void;
  60506. /**
  60507. * This is used to keep meshes transformations so they can be restored
  60508. * when we build back a Babylon Mesh
  60509. * NB : All CSG operations are performed in world coordinates
  60510. * @param csg The CSG to copy the transform attributes from
  60511. * @returns This CSG
  60512. */
  60513. copyTransformAttributes(csg: CSG): CSG;
  60514. /**
  60515. * Build Raw mesh from CSG
  60516. * Coordinates here are in world space
  60517. * @param name The name of the mesh geometry
  60518. * @param scene The Scene
  60519. * @param keepSubMeshes Specifies if the submeshes should be kept
  60520. * @returns A new Mesh
  60521. */
  60522. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60523. /**
  60524. * Build Mesh from CSG taking material and transforms into account
  60525. * @param name The name of the Mesh
  60526. * @param material The material of the Mesh
  60527. * @param scene The Scene
  60528. * @param keepSubMeshes Specifies if submeshes should be kept
  60529. * @returns The new Mesh
  60530. */
  60531. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60532. }
  60533. }
  60534. declare module BABYLON {
  60535. /**
  60536. * Class used to create a trail following a mesh
  60537. */
  60538. export class TrailMesh extends Mesh {
  60539. private _generator;
  60540. private _autoStart;
  60541. private _running;
  60542. private _diameter;
  60543. private _length;
  60544. private _sectionPolygonPointsCount;
  60545. private _sectionVectors;
  60546. private _sectionNormalVectors;
  60547. private _beforeRenderObserver;
  60548. /**
  60549. * @constructor
  60550. * @param name The value used by scene.getMeshByName() to do a lookup.
  60551. * @param generator The mesh or transform node to generate a trail.
  60552. * @param scene The scene to add this mesh to.
  60553. * @param diameter Diameter of trailing mesh. Default is 1.
  60554. * @param length Length of trailing mesh. Default is 60.
  60555. * @param autoStart Automatically start trailing mesh. Default true.
  60556. */
  60557. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60558. /**
  60559. * "TrailMesh"
  60560. * @returns "TrailMesh"
  60561. */
  60562. getClassName(): string;
  60563. private _createMesh;
  60564. /**
  60565. * Start trailing mesh.
  60566. */
  60567. start(): void;
  60568. /**
  60569. * Stop trailing mesh.
  60570. */
  60571. stop(): void;
  60572. /**
  60573. * Update trailing mesh geometry.
  60574. */
  60575. update(): void;
  60576. /**
  60577. * Returns a new TrailMesh object.
  60578. * @param name is a string, the name given to the new mesh
  60579. * @param newGenerator use new generator object for cloned trail mesh
  60580. * @returns a new mesh
  60581. */
  60582. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60583. /**
  60584. * Serializes this trail mesh
  60585. * @param serializationObject object to write serialization to
  60586. */
  60587. serialize(serializationObject: any): void;
  60588. /**
  60589. * Parses a serialized trail mesh
  60590. * @param parsedMesh the serialized mesh
  60591. * @param scene the scene to create the trail mesh in
  60592. * @returns the created trail mesh
  60593. */
  60594. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60595. }
  60596. }
  60597. declare module BABYLON {
  60598. /**
  60599. * Class containing static functions to help procedurally build meshes
  60600. */
  60601. export class TiledBoxBuilder {
  60602. /**
  60603. * Creates a box mesh
  60604. * 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)
  60605. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60607. * * 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
  60608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60609. * @param name defines the name of the mesh
  60610. * @param options defines the options used to create the mesh
  60611. * @param scene defines the hosting scene
  60612. * @returns the box mesh
  60613. */
  60614. static CreateTiledBox(name: string, options: {
  60615. pattern?: number;
  60616. width?: number;
  60617. height?: number;
  60618. depth?: number;
  60619. tileSize?: number;
  60620. tileWidth?: number;
  60621. tileHeight?: number;
  60622. alignHorizontal?: number;
  60623. alignVertical?: number;
  60624. faceUV?: Vector4[];
  60625. faceColors?: Color4[];
  60626. sideOrientation?: number;
  60627. updatable?: boolean;
  60628. }, scene?: Nullable<Scene>): Mesh;
  60629. }
  60630. }
  60631. declare module BABYLON {
  60632. /**
  60633. * Class containing static functions to help procedurally build meshes
  60634. */
  60635. export class TorusKnotBuilder {
  60636. /**
  60637. * Creates a torus knot mesh
  60638. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60639. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60640. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60641. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60643. * * 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
  60644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60645. * @param name defines the name of the mesh
  60646. * @param options defines the options used to create the mesh
  60647. * @param scene defines the hosting scene
  60648. * @returns the torus knot mesh
  60649. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60650. */
  60651. static CreateTorusKnot(name: string, options: {
  60652. radius?: number;
  60653. tube?: number;
  60654. radialSegments?: number;
  60655. tubularSegments?: number;
  60656. p?: number;
  60657. q?: number;
  60658. updatable?: boolean;
  60659. sideOrientation?: number;
  60660. frontUVs?: Vector4;
  60661. backUVs?: Vector4;
  60662. }, scene: any): Mesh;
  60663. }
  60664. }
  60665. declare module BABYLON {
  60666. /**
  60667. * Polygon
  60668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60669. */
  60670. export class Polygon {
  60671. /**
  60672. * Creates a rectangle
  60673. * @param xmin bottom X coord
  60674. * @param ymin bottom Y coord
  60675. * @param xmax top X coord
  60676. * @param ymax top Y coord
  60677. * @returns points that make the resulting rectation
  60678. */
  60679. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60680. /**
  60681. * Creates a circle
  60682. * @param radius radius of circle
  60683. * @param cx scale in x
  60684. * @param cy scale in y
  60685. * @param numberOfSides number of sides that make up the circle
  60686. * @returns points that make the resulting circle
  60687. */
  60688. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60689. /**
  60690. * Creates a polygon from input string
  60691. * @param input Input polygon data
  60692. * @returns the parsed points
  60693. */
  60694. static Parse(input: string): Vector2[];
  60695. /**
  60696. * Starts building a polygon from x and y coordinates
  60697. * @param x x coordinate
  60698. * @param y y coordinate
  60699. * @returns the started path2
  60700. */
  60701. static StartingAt(x: number, y: number): Path2;
  60702. }
  60703. /**
  60704. * Builds a polygon
  60705. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60706. */
  60707. export class PolygonMeshBuilder {
  60708. private _points;
  60709. private _outlinepoints;
  60710. private _holes;
  60711. private _name;
  60712. private _scene;
  60713. private _epoints;
  60714. private _eholes;
  60715. private _addToepoint;
  60716. /**
  60717. * Babylon reference to the earcut plugin.
  60718. */
  60719. bjsEarcut: any;
  60720. /**
  60721. * Creates a PolygonMeshBuilder
  60722. * @param name name of the builder
  60723. * @param contours Path of the polygon
  60724. * @param scene scene to add to when creating the mesh
  60725. * @param earcutInjection can be used to inject your own earcut reference
  60726. */
  60727. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60728. /**
  60729. * Adds a whole within the polygon
  60730. * @param hole Array of points defining the hole
  60731. * @returns this
  60732. */
  60733. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60734. /**
  60735. * Creates the polygon
  60736. * @param updatable If the mesh should be updatable
  60737. * @param depth The depth of the mesh created
  60738. * @returns the created mesh
  60739. */
  60740. build(updatable?: boolean, depth?: number): Mesh;
  60741. /**
  60742. * Creates the polygon
  60743. * @param depth The depth of the mesh created
  60744. * @returns the created VertexData
  60745. */
  60746. buildVertexData(depth?: number): VertexData;
  60747. /**
  60748. * Adds a side to the polygon
  60749. * @param positions points that make the polygon
  60750. * @param normals normals of the polygon
  60751. * @param uvs uvs of the polygon
  60752. * @param indices indices of the polygon
  60753. * @param bounds bounds of the polygon
  60754. * @param points points of the polygon
  60755. * @param depth depth of the polygon
  60756. * @param flip flip of the polygon
  60757. */
  60758. private addSide;
  60759. }
  60760. }
  60761. declare module BABYLON {
  60762. /**
  60763. * Class containing static functions to help procedurally build meshes
  60764. */
  60765. export class PolygonBuilder {
  60766. /**
  60767. * Creates a polygon mesh
  60768. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60769. * * 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
  60770. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60772. * * 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)
  60773. * * Remember you can only change the shape positions, not their number when updating a polygon
  60774. * @param name defines the name of the mesh
  60775. * @param options defines the options used to create the mesh
  60776. * @param scene defines the hosting scene
  60777. * @param earcutInjection can be used to inject your own earcut reference
  60778. * @returns the polygon mesh
  60779. */
  60780. static CreatePolygon(name: string, options: {
  60781. shape: Vector3[];
  60782. holes?: Vector3[][];
  60783. depth?: number;
  60784. faceUV?: Vector4[];
  60785. faceColors?: Color4[];
  60786. updatable?: boolean;
  60787. sideOrientation?: number;
  60788. frontUVs?: Vector4;
  60789. backUVs?: Vector4;
  60790. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60791. /**
  60792. * Creates an extruded polygon mesh, with depth in the Y direction.
  60793. * * 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)
  60794. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60795. * @param name defines the name of the mesh
  60796. * @param options defines the options used to create the mesh
  60797. * @param scene defines the hosting scene
  60798. * @param earcutInjection can be used to inject your own earcut reference
  60799. * @returns the polygon mesh
  60800. */
  60801. static ExtrudePolygon(name: string, options: {
  60802. shape: Vector3[];
  60803. holes?: Vector3[][];
  60804. depth?: number;
  60805. faceUV?: Vector4[];
  60806. faceColors?: Color4[];
  60807. updatable?: boolean;
  60808. sideOrientation?: number;
  60809. frontUVs?: Vector4;
  60810. backUVs?: Vector4;
  60811. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60812. }
  60813. }
  60814. declare module BABYLON {
  60815. /**
  60816. * Class containing static functions to help procedurally build meshes
  60817. */
  60818. export class LatheBuilder {
  60819. /**
  60820. * Creates lathe mesh.
  60821. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60822. * * 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
  60823. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60824. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60825. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60826. * * 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
  60827. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60828. * * 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
  60829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60830. * * 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
  60831. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60833. * @param name defines the name of the mesh
  60834. * @param options defines the options used to create the mesh
  60835. * @param scene defines the hosting scene
  60836. * @returns the lathe mesh
  60837. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60838. */
  60839. static CreateLathe(name: string, options: {
  60840. shape: Vector3[];
  60841. radius?: number;
  60842. tessellation?: number;
  60843. clip?: number;
  60844. arc?: number;
  60845. closed?: boolean;
  60846. updatable?: boolean;
  60847. sideOrientation?: number;
  60848. frontUVs?: Vector4;
  60849. backUVs?: Vector4;
  60850. cap?: number;
  60851. invertUV?: boolean;
  60852. }, scene?: Nullable<Scene>): Mesh;
  60853. }
  60854. }
  60855. declare module BABYLON {
  60856. /**
  60857. * Class containing static functions to help procedurally build meshes
  60858. */
  60859. export class TiledPlaneBuilder {
  60860. /**
  60861. * Creates a tiled plane mesh
  60862. * * The parameter `pattern` will, depending on value, do nothing or
  60863. * * * flip (reflect about central vertical) alternate tiles across and up
  60864. * * * flip every tile on alternate rows
  60865. * * * rotate (180 degs) alternate tiles across and up
  60866. * * * rotate every tile on alternate rows
  60867. * * * flip and rotate alternate tiles across and up
  60868. * * * flip and rotate every tile on alternate rows
  60869. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60870. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60871. * * 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
  60872. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60873. * * 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)
  60874. * * 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)
  60875. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60876. * @param name defines the name of the mesh
  60877. * @param options defines the options used to create the mesh
  60878. * @param scene defines the hosting scene
  60879. * @returns the box mesh
  60880. */
  60881. static CreateTiledPlane(name: string, options: {
  60882. pattern?: number;
  60883. tileSize?: number;
  60884. tileWidth?: number;
  60885. tileHeight?: number;
  60886. size?: number;
  60887. width?: number;
  60888. height?: number;
  60889. alignHorizontal?: number;
  60890. alignVertical?: number;
  60891. sideOrientation?: number;
  60892. frontUVs?: Vector4;
  60893. backUVs?: Vector4;
  60894. updatable?: boolean;
  60895. }, scene?: Nullable<Scene>): Mesh;
  60896. }
  60897. }
  60898. declare module BABYLON {
  60899. /**
  60900. * Class containing static functions to help procedurally build meshes
  60901. */
  60902. export class TubeBuilder {
  60903. /**
  60904. * Creates a tube mesh.
  60905. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60906. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60907. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60908. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60909. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60910. * * 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)
  60911. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60912. * * 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
  60913. * * 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
  60914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60915. * * 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
  60916. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60918. * @param name defines the name of the mesh
  60919. * @param options defines the options used to create the mesh
  60920. * @param scene defines the hosting scene
  60921. * @returns the tube mesh
  60922. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60923. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60924. */
  60925. static CreateTube(name: string, options: {
  60926. path: Vector3[];
  60927. radius?: number;
  60928. tessellation?: number;
  60929. radiusFunction?: {
  60930. (i: number, distance: number): number;
  60931. };
  60932. cap?: number;
  60933. arc?: number;
  60934. updatable?: boolean;
  60935. sideOrientation?: number;
  60936. frontUVs?: Vector4;
  60937. backUVs?: Vector4;
  60938. instance?: Mesh;
  60939. invertUV?: boolean;
  60940. }, scene?: Nullable<Scene>): Mesh;
  60941. }
  60942. }
  60943. declare module BABYLON {
  60944. /**
  60945. * Class containing static functions to help procedurally build meshes
  60946. */
  60947. export class IcoSphereBuilder {
  60948. /**
  60949. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60950. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60951. * * 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`)
  60952. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60953. * * 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
  60954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60955. * * 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
  60956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60957. * @param name defines the name of the mesh
  60958. * @param options defines the options used to create the mesh
  60959. * @param scene defines the hosting scene
  60960. * @returns the icosahedron mesh
  60961. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60962. */
  60963. static CreateIcoSphere(name: string, options: {
  60964. radius?: number;
  60965. radiusX?: number;
  60966. radiusY?: number;
  60967. radiusZ?: number;
  60968. flat?: boolean;
  60969. subdivisions?: number;
  60970. sideOrientation?: number;
  60971. frontUVs?: Vector4;
  60972. backUVs?: Vector4;
  60973. updatable?: boolean;
  60974. }, scene?: Nullable<Scene>): Mesh;
  60975. }
  60976. }
  60977. declare module BABYLON {
  60978. /**
  60979. * Class containing static functions to help procedurally build meshes
  60980. */
  60981. export class DecalBuilder {
  60982. /**
  60983. * Creates a decal mesh.
  60984. * 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
  60985. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60986. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60987. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60988. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60989. * @param name defines the name of the mesh
  60990. * @param sourceMesh defines the mesh where the decal must be applied
  60991. * @param options defines the options used to create the mesh
  60992. * @param scene defines the hosting scene
  60993. * @returns the decal mesh
  60994. * @see https://doc.babylonjs.com/how_to/decals
  60995. */
  60996. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60997. position?: Vector3;
  60998. normal?: Vector3;
  60999. size?: Vector3;
  61000. angle?: number;
  61001. }): Mesh;
  61002. }
  61003. }
  61004. declare module BABYLON {
  61005. /**
  61006. * Class containing static functions to help procedurally build meshes
  61007. */
  61008. export class MeshBuilder {
  61009. /**
  61010. * Creates a box mesh
  61011. * * The parameter `size` sets the size (float) of each box side (default 1)
  61012. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61013. * * 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)
  61014. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61016. * * 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
  61017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61018. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61019. * @param name defines the name of the mesh
  61020. * @param options defines the options used to create the mesh
  61021. * @param scene defines the hosting scene
  61022. * @returns the box mesh
  61023. */
  61024. static CreateBox(name: string, options: {
  61025. size?: number;
  61026. width?: number;
  61027. height?: number;
  61028. depth?: number;
  61029. faceUV?: Vector4[];
  61030. faceColors?: Color4[];
  61031. sideOrientation?: number;
  61032. frontUVs?: Vector4;
  61033. backUVs?: Vector4;
  61034. updatable?: boolean;
  61035. }, scene?: Nullable<Scene>): Mesh;
  61036. /**
  61037. * Creates a tiled box mesh
  61038. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61040. * @param name defines the name of the mesh
  61041. * @param options defines the options used to create the mesh
  61042. * @param scene defines the hosting scene
  61043. * @returns the tiled box mesh
  61044. */
  61045. static CreateTiledBox(name: string, options: {
  61046. pattern?: number;
  61047. size?: number;
  61048. width?: number;
  61049. height?: number;
  61050. depth: number;
  61051. tileSize?: number;
  61052. tileWidth?: number;
  61053. tileHeight?: number;
  61054. faceUV?: Vector4[];
  61055. faceColors?: Color4[];
  61056. alignHorizontal?: number;
  61057. alignVertical?: number;
  61058. sideOrientation?: number;
  61059. updatable?: boolean;
  61060. }, scene?: Nullable<Scene>): Mesh;
  61061. /**
  61062. * Creates a sphere mesh
  61063. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61064. * * 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`)
  61065. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61066. * * 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
  61067. * * 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)
  61068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61069. * * 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
  61070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61071. * @param name defines the name of the mesh
  61072. * @param options defines the options used to create the mesh
  61073. * @param scene defines the hosting scene
  61074. * @returns the sphere mesh
  61075. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61076. */
  61077. static CreateSphere(name: string, options: {
  61078. segments?: number;
  61079. diameter?: number;
  61080. diameterX?: number;
  61081. diameterY?: number;
  61082. diameterZ?: number;
  61083. arc?: number;
  61084. slice?: number;
  61085. sideOrientation?: number;
  61086. frontUVs?: Vector4;
  61087. backUVs?: Vector4;
  61088. updatable?: boolean;
  61089. }, scene?: Nullable<Scene>): Mesh;
  61090. /**
  61091. * Creates a plane polygonal mesh. By default, this is a disc
  61092. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61093. * * 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
  61094. * * 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
  61095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61096. * * 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
  61097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61098. * @param name defines the name of the mesh
  61099. * @param options defines the options used to create the mesh
  61100. * @param scene defines the hosting scene
  61101. * @returns the plane polygonal mesh
  61102. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61103. */
  61104. static CreateDisc(name: string, options: {
  61105. radius?: number;
  61106. tessellation?: number;
  61107. arc?: number;
  61108. updatable?: boolean;
  61109. sideOrientation?: number;
  61110. frontUVs?: Vector4;
  61111. backUVs?: Vector4;
  61112. }, scene?: Nullable<Scene>): Mesh;
  61113. /**
  61114. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61115. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61116. * * 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`)
  61117. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61118. * * 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
  61119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61120. * * 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
  61121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61122. * @param name defines the name of the mesh
  61123. * @param options defines the options used to create the mesh
  61124. * @param scene defines the hosting scene
  61125. * @returns the icosahedron mesh
  61126. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61127. */
  61128. static CreateIcoSphere(name: string, options: {
  61129. radius?: number;
  61130. radiusX?: number;
  61131. radiusY?: number;
  61132. radiusZ?: number;
  61133. flat?: boolean;
  61134. subdivisions?: number;
  61135. sideOrientation?: number;
  61136. frontUVs?: Vector4;
  61137. backUVs?: Vector4;
  61138. updatable?: boolean;
  61139. }, scene?: Nullable<Scene>): Mesh;
  61140. /**
  61141. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61142. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61143. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61144. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61145. * * 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
  61146. * * 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
  61147. * * 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
  61148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61149. * * 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
  61150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61151. * * 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
  61152. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61153. * * 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
  61154. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61156. * @param name defines the name of the mesh
  61157. * @param options defines the options used to create the mesh
  61158. * @param scene defines the hosting scene
  61159. * @returns the ribbon mesh
  61160. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61161. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61162. */
  61163. static CreateRibbon(name: string, options: {
  61164. pathArray: Vector3[][];
  61165. closeArray?: boolean;
  61166. closePath?: boolean;
  61167. offset?: number;
  61168. updatable?: boolean;
  61169. sideOrientation?: number;
  61170. frontUVs?: Vector4;
  61171. backUVs?: Vector4;
  61172. instance?: Mesh;
  61173. invertUV?: boolean;
  61174. uvs?: Vector2[];
  61175. colors?: Color4[];
  61176. }, scene?: Nullable<Scene>): Mesh;
  61177. /**
  61178. * Creates a cylinder or a cone mesh
  61179. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61180. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61181. * * 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.
  61182. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61183. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61184. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61185. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61186. * * 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).
  61187. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61188. * * 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).
  61189. * * 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
  61190. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61191. * * 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
  61192. * * 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.
  61193. * * If `enclose` is false, a ring surface is one element.
  61194. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61195. * * 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
  61196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61197. * * 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
  61198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61199. * @param name defines the name of the mesh
  61200. * @param options defines the options used to create the mesh
  61201. * @param scene defines the hosting scene
  61202. * @returns the cylinder mesh
  61203. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61204. */
  61205. static CreateCylinder(name: string, options: {
  61206. height?: number;
  61207. diameterTop?: number;
  61208. diameterBottom?: number;
  61209. diameter?: number;
  61210. tessellation?: number;
  61211. subdivisions?: number;
  61212. arc?: number;
  61213. faceColors?: Color4[];
  61214. faceUV?: Vector4[];
  61215. updatable?: boolean;
  61216. hasRings?: boolean;
  61217. enclose?: boolean;
  61218. cap?: number;
  61219. sideOrientation?: number;
  61220. frontUVs?: Vector4;
  61221. backUVs?: Vector4;
  61222. }, scene?: Nullable<Scene>): Mesh;
  61223. /**
  61224. * Creates a torus mesh
  61225. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61226. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61227. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61229. * * 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
  61230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61231. * @param name defines the name of the mesh
  61232. * @param options defines the options used to create the mesh
  61233. * @param scene defines the hosting scene
  61234. * @returns the torus mesh
  61235. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61236. */
  61237. static CreateTorus(name: string, options: {
  61238. diameter?: number;
  61239. thickness?: number;
  61240. tessellation?: number;
  61241. updatable?: boolean;
  61242. sideOrientation?: number;
  61243. frontUVs?: Vector4;
  61244. backUVs?: Vector4;
  61245. }, scene?: Nullable<Scene>): Mesh;
  61246. /**
  61247. * Creates a torus knot mesh
  61248. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61249. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61250. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61251. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61253. * * 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
  61254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61255. * @param name defines the name of the mesh
  61256. * @param options defines the options used to create the mesh
  61257. * @param scene defines the hosting scene
  61258. * @returns the torus knot mesh
  61259. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61260. */
  61261. static CreateTorusKnot(name: string, options: {
  61262. radius?: number;
  61263. tube?: number;
  61264. radialSegments?: number;
  61265. tubularSegments?: number;
  61266. p?: number;
  61267. q?: number;
  61268. updatable?: boolean;
  61269. sideOrientation?: number;
  61270. frontUVs?: Vector4;
  61271. backUVs?: Vector4;
  61272. }, scene?: Nullable<Scene>): Mesh;
  61273. /**
  61274. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61275. * * 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
  61276. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61277. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61278. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61279. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61280. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61281. * * 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
  61282. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61284. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61285. * @param name defines the name of the new line system
  61286. * @param options defines the options used to create the line system
  61287. * @param scene defines the hosting scene
  61288. * @returns a new line system mesh
  61289. */
  61290. static CreateLineSystem(name: string, options: {
  61291. lines: Vector3[][];
  61292. updatable?: boolean;
  61293. instance?: Nullable<LinesMesh>;
  61294. colors?: Nullable<Color4[][]>;
  61295. useVertexAlpha?: boolean;
  61296. }, scene: Nullable<Scene>): LinesMesh;
  61297. /**
  61298. * Creates a line mesh
  61299. * 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
  61300. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61301. * * The parameter `points` is an array successive Vector3
  61302. * * 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
  61303. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61304. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61305. * * When updating an instance, remember that only point positions can change, not the number of points
  61306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61308. * @param name defines the name of the new line system
  61309. * @param options defines the options used to create the line system
  61310. * @param scene defines the hosting scene
  61311. * @returns a new line mesh
  61312. */
  61313. static CreateLines(name: string, options: {
  61314. points: Vector3[];
  61315. updatable?: boolean;
  61316. instance?: Nullable<LinesMesh>;
  61317. colors?: Color4[];
  61318. useVertexAlpha?: boolean;
  61319. }, scene?: Nullable<Scene>): LinesMesh;
  61320. /**
  61321. * Creates a dashed line mesh
  61322. * * 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
  61323. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61324. * * The parameter `points` is an array successive Vector3
  61325. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61326. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61327. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61328. * * 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
  61329. * * When updating an instance, remember that only point positions can change, not the number of points
  61330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61331. * @param name defines the name of the mesh
  61332. * @param options defines the options used to create the mesh
  61333. * @param scene defines the hosting scene
  61334. * @returns the dashed line mesh
  61335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61336. */
  61337. static CreateDashedLines(name: string, options: {
  61338. points: Vector3[];
  61339. dashSize?: number;
  61340. gapSize?: number;
  61341. dashNb?: number;
  61342. updatable?: boolean;
  61343. instance?: LinesMesh;
  61344. }, scene?: Nullable<Scene>): LinesMesh;
  61345. /**
  61346. * 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.
  61347. * * 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.
  61348. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61349. * * 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.
  61350. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61351. * * 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
  61352. * * 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
  61353. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61355. * * 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
  61356. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61358. * @param name defines the name of the mesh
  61359. * @param options defines the options used to create the mesh
  61360. * @param scene defines the hosting scene
  61361. * @returns the extruded shape mesh
  61362. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61364. */
  61365. static ExtrudeShape(name: string, options: {
  61366. shape: Vector3[];
  61367. path: Vector3[];
  61368. scale?: number;
  61369. rotation?: number;
  61370. cap?: number;
  61371. updatable?: boolean;
  61372. sideOrientation?: number;
  61373. frontUVs?: Vector4;
  61374. backUVs?: Vector4;
  61375. instance?: Mesh;
  61376. invertUV?: boolean;
  61377. }, scene?: Nullable<Scene>): Mesh;
  61378. /**
  61379. * Creates an custom extruded shape mesh.
  61380. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61381. * * 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.
  61382. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61383. * * 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
  61384. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61385. * * 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
  61386. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61387. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61388. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61389. * * 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
  61390. * * 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
  61391. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61393. * * 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
  61394. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61396. * @param name defines the name of the mesh
  61397. * @param options defines the options used to create the mesh
  61398. * @param scene defines the hosting scene
  61399. * @returns the custom extruded shape mesh
  61400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61401. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61403. */
  61404. static ExtrudeShapeCustom(name: string, options: {
  61405. shape: Vector3[];
  61406. path: Vector3[];
  61407. scaleFunction?: any;
  61408. rotationFunction?: any;
  61409. ribbonCloseArray?: boolean;
  61410. ribbonClosePath?: boolean;
  61411. cap?: number;
  61412. updatable?: boolean;
  61413. sideOrientation?: number;
  61414. frontUVs?: Vector4;
  61415. backUVs?: Vector4;
  61416. instance?: Mesh;
  61417. invertUV?: boolean;
  61418. }, scene?: Nullable<Scene>): Mesh;
  61419. /**
  61420. * Creates lathe mesh.
  61421. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61422. * * 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
  61423. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61424. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61425. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61426. * * 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
  61427. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61428. * * 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
  61429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61430. * * 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
  61431. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61433. * @param name defines the name of the mesh
  61434. * @param options defines the options used to create the mesh
  61435. * @param scene defines the hosting scene
  61436. * @returns the lathe mesh
  61437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61438. */
  61439. static CreateLathe(name: string, options: {
  61440. shape: Vector3[];
  61441. radius?: number;
  61442. tessellation?: number;
  61443. clip?: number;
  61444. arc?: number;
  61445. closed?: boolean;
  61446. updatable?: boolean;
  61447. sideOrientation?: number;
  61448. frontUVs?: Vector4;
  61449. backUVs?: Vector4;
  61450. cap?: number;
  61451. invertUV?: boolean;
  61452. }, scene?: Nullable<Scene>): Mesh;
  61453. /**
  61454. * Creates a tiled plane mesh
  61455. * * You can set a limited pattern arrangement with the tiles
  61456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61457. * * 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
  61458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61459. * @param name defines the name of the mesh
  61460. * @param options defines the options used to create the mesh
  61461. * @param scene defines the hosting scene
  61462. * @returns the plane mesh
  61463. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61464. */
  61465. static CreateTiledPlane(name: string, options: {
  61466. pattern?: number;
  61467. tileSize?: number;
  61468. tileWidth?: number;
  61469. tileHeight?: number;
  61470. size?: number;
  61471. width?: number;
  61472. height?: number;
  61473. alignHorizontal?: number;
  61474. alignVertical?: number;
  61475. sideOrientation?: number;
  61476. frontUVs?: Vector4;
  61477. backUVs?: Vector4;
  61478. updatable?: boolean;
  61479. }, scene?: Nullable<Scene>): Mesh;
  61480. /**
  61481. * Creates a plane mesh
  61482. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61483. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61484. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61486. * * 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
  61487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61488. * @param name defines the name of the mesh
  61489. * @param options defines the options used to create the mesh
  61490. * @param scene defines the hosting scene
  61491. * @returns the plane mesh
  61492. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61493. */
  61494. static CreatePlane(name: string, options: {
  61495. size?: number;
  61496. width?: number;
  61497. height?: number;
  61498. sideOrientation?: number;
  61499. frontUVs?: Vector4;
  61500. backUVs?: Vector4;
  61501. updatable?: boolean;
  61502. sourcePlane?: Plane;
  61503. }, scene?: Nullable<Scene>): Mesh;
  61504. /**
  61505. * Creates a ground mesh
  61506. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61507. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61509. * @param name defines the name of the mesh
  61510. * @param options defines the options used to create the mesh
  61511. * @param scene defines the hosting scene
  61512. * @returns the ground mesh
  61513. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61514. */
  61515. static CreateGround(name: string, options: {
  61516. width?: number;
  61517. height?: number;
  61518. subdivisions?: number;
  61519. subdivisionsX?: number;
  61520. subdivisionsY?: number;
  61521. updatable?: boolean;
  61522. }, scene?: Nullable<Scene>): Mesh;
  61523. /**
  61524. * Creates a tiled ground mesh
  61525. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61526. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61527. * * 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
  61528. * * 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
  61529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61530. * @param name defines the name of the mesh
  61531. * @param options defines the options used to create the mesh
  61532. * @param scene defines the hosting scene
  61533. * @returns the tiled ground mesh
  61534. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61535. */
  61536. static CreateTiledGround(name: string, options: {
  61537. xmin: number;
  61538. zmin: number;
  61539. xmax: number;
  61540. zmax: number;
  61541. subdivisions?: {
  61542. w: number;
  61543. h: number;
  61544. };
  61545. precision?: {
  61546. w: number;
  61547. h: number;
  61548. };
  61549. updatable?: boolean;
  61550. }, scene?: Nullable<Scene>): Mesh;
  61551. /**
  61552. * Creates a ground mesh from a height map
  61553. * * The parameter `url` sets the URL of the height map image resource.
  61554. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61555. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61556. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61557. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61558. * * 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.
  61559. * * 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).
  61560. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61562. * @param name defines the name of the mesh
  61563. * @param url defines the url to the height map
  61564. * @param options defines the options used to create the mesh
  61565. * @param scene defines the hosting scene
  61566. * @returns the ground mesh
  61567. * @see https://doc.babylonjs.com/babylon101/height_map
  61568. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61569. */
  61570. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61571. width?: number;
  61572. height?: number;
  61573. subdivisions?: number;
  61574. minHeight?: number;
  61575. maxHeight?: number;
  61576. colorFilter?: Color3;
  61577. alphaFilter?: number;
  61578. updatable?: boolean;
  61579. onReady?: (mesh: GroundMesh) => void;
  61580. }, scene?: Nullable<Scene>): GroundMesh;
  61581. /**
  61582. * Creates a polygon mesh
  61583. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61584. * * 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
  61585. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61587. * * 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)
  61588. * * Remember you can only change the shape positions, not their number when updating a polygon
  61589. * @param name defines the name of the mesh
  61590. * @param options defines the options used to create the mesh
  61591. * @param scene defines the hosting scene
  61592. * @param earcutInjection can be used to inject your own earcut reference
  61593. * @returns the polygon mesh
  61594. */
  61595. static CreatePolygon(name: string, options: {
  61596. shape: Vector3[];
  61597. holes?: Vector3[][];
  61598. depth?: number;
  61599. faceUV?: Vector4[];
  61600. faceColors?: Color4[];
  61601. updatable?: boolean;
  61602. sideOrientation?: number;
  61603. frontUVs?: Vector4;
  61604. backUVs?: Vector4;
  61605. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61606. /**
  61607. * Creates an extruded polygon mesh, with depth in the Y direction.
  61608. * * 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)
  61609. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61610. * @param name defines the name of the mesh
  61611. * @param options defines the options used to create the mesh
  61612. * @param scene defines the hosting scene
  61613. * @param earcutInjection can be used to inject your own earcut reference
  61614. * @returns the polygon mesh
  61615. */
  61616. static ExtrudePolygon(name: string, options: {
  61617. shape: Vector3[];
  61618. holes?: Vector3[][];
  61619. depth?: number;
  61620. faceUV?: Vector4[];
  61621. faceColors?: Color4[];
  61622. updatable?: boolean;
  61623. sideOrientation?: number;
  61624. frontUVs?: Vector4;
  61625. backUVs?: Vector4;
  61626. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61627. /**
  61628. * Creates a tube mesh.
  61629. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61630. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61631. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61632. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61633. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61634. * * 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)
  61635. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61636. * * 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
  61637. * * 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
  61638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61639. * * 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
  61640. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61642. * @param name defines the name of the mesh
  61643. * @param options defines the options used to create the mesh
  61644. * @param scene defines the hosting scene
  61645. * @returns the tube mesh
  61646. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61647. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61648. */
  61649. static CreateTube(name: string, options: {
  61650. path: Vector3[];
  61651. radius?: number;
  61652. tessellation?: number;
  61653. radiusFunction?: {
  61654. (i: number, distance: number): number;
  61655. };
  61656. cap?: number;
  61657. arc?: number;
  61658. updatable?: boolean;
  61659. sideOrientation?: number;
  61660. frontUVs?: Vector4;
  61661. backUVs?: Vector4;
  61662. instance?: Mesh;
  61663. invertUV?: boolean;
  61664. }, scene?: Nullable<Scene>): Mesh;
  61665. /**
  61666. * Creates a polyhedron mesh
  61667. * * 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
  61668. * * The parameter `size` (positive float, default 1) sets the polygon size
  61669. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61670. * * 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`
  61671. * * 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
  61672. * * 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)`)
  61673. * * 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
  61674. * * 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
  61675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61676. * * 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
  61677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61678. * @param name defines the name of the mesh
  61679. * @param options defines the options used to create the mesh
  61680. * @param scene defines the hosting scene
  61681. * @returns the polyhedron mesh
  61682. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61683. */
  61684. static CreatePolyhedron(name: string, options: {
  61685. type?: number;
  61686. size?: number;
  61687. sizeX?: number;
  61688. sizeY?: number;
  61689. sizeZ?: number;
  61690. custom?: any;
  61691. faceUV?: Vector4[];
  61692. faceColors?: Color4[];
  61693. flat?: boolean;
  61694. updatable?: boolean;
  61695. sideOrientation?: number;
  61696. frontUVs?: Vector4;
  61697. backUVs?: Vector4;
  61698. }, scene?: Nullable<Scene>): Mesh;
  61699. /**
  61700. * Creates a decal mesh.
  61701. * 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
  61702. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61703. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61704. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61705. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61706. * @param name defines the name of the mesh
  61707. * @param sourceMesh defines the mesh where the decal must be applied
  61708. * @param options defines the options used to create the mesh
  61709. * @param scene defines the hosting scene
  61710. * @returns the decal mesh
  61711. * @see https://doc.babylonjs.com/how_to/decals
  61712. */
  61713. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61714. position?: Vector3;
  61715. normal?: Vector3;
  61716. size?: Vector3;
  61717. angle?: number;
  61718. }): Mesh;
  61719. }
  61720. }
  61721. declare module BABYLON {
  61722. /**
  61723. * A simplifier interface for future simplification implementations
  61724. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61725. */
  61726. export interface ISimplifier {
  61727. /**
  61728. * Simplification of a given mesh according to the given settings.
  61729. * Since this requires computation, it is assumed that the function runs async.
  61730. * @param settings The settings of the simplification, including quality and distance
  61731. * @param successCallback A callback that will be called after the mesh was simplified.
  61732. * @param errorCallback in case of an error, this callback will be called. optional.
  61733. */
  61734. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61735. }
  61736. /**
  61737. * Expected simplification settings.
  61738. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61739. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61740. */
  61741. export interface ISimplificationSettings {
  61742. /**
  61743. * Gets or sets the expected quality
  61744. */
  61745. quality: number;
  61746. /**
  61747. * Gets or sets the distance when this optimized version should be used
  61748. */
  61749. distance: number;
  61750. /**
  61751. * Gets an already optimized mesh
  61752. */
  61753. optimizeMesh?: boolean;
  61754. }
  61755. /**
  61756. * Class used to specify simplification options
  61757. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61758. */
  61759. export class SimplificationSettings implements ISimplificationSettings {
  61760. /** expected quality */
  61761. quality: number;
  61762. /** distance when this optimized version should be used */
  61763. distance: number;
  61764. /** already optimized mesh */
  61765. optimizeMesh?: boolean | undefined;
  61766. /**
  61767. * Creates a SimplificationSettings
  61768. * @param quality expected quality
  61769. * @param distance distance when this optimized version should be used
  61770. * @param optimizeMesh already optimized mesh
  61771. */
  61772. constructor(
  61773. /** expected quality */
  61774. quality: number,
  61775. /** distance when this optimized version should be used */
  61776. distance: number,
  61777. /** already optimized mesh */
  61778. optimizeMesh?: boolean | undefined);
  61779. }
  61780. /**
  61781. * Interface used to define a simplification task
  61782. */
  61783. export interface ISimplificationTask {
  61784. /**
  61785. * Array of settings
  61786. */
  61787. settings: Array<ISimplificationSettings>;
  61788. /**
  61789. * Simplification type
  61790. */
  61791. simplificationType: SimplificationType;
  61792. /**
  61793. * Mesh to simplify
  61794. */
  61795. mesh: Mesh;
  61796. /**
  61797. * Callback called on success
  61798. */
  61799. successCallback?: () => void;
  61800. /**
  61801. * Defines if parallel processing can be used
  61802. */
  61803. parallelProcessing: boolean;
  61804. }
  61805. /**
  61806. * Queue used to order the simplification tasks
  61807. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61808. */
  61809. export class SimplificationQueue {
  61810. private _simplificationArray;
  61811. /**
  61812. * Gets a boolean indicating that the process is still running
  61813. */
  61814. running: boolean;
  61815. /**
  61816. * Creates a new queue
  61817. */
  61818. constructor();
  61819. /**
  61820. * Adds a new simplification task
  61821. * @param task defines a task to add
  61822. */
  61823. addTask(task: ISimplificationTask): void;
  61824. /**
  61825. * Execute next task
  61826. */
  61827. executeNext(): void;
  61828. /**
  61829. * Execute a simplification task
  61830. * @param task defines the task to run
  61831. */
  61832. runSimplification(task: ISimplificationTask): void;
  61833. private getSimplifier;
  61834. }
  61835. /**
  61836. * The implemented types of simplification
  61837. * At the moment only Quadratic Error Decimation is implemented
  61838. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61839. */
  61840. export enum SimplificationType {
  61841. /** Quadratic error decimation */
  61842. QUADRATIC = 0
  61843. }
  61844. /**
  61845. * An implementation of the Quadratic Error simplification algorithm.
  61846. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  61847. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  61848. * @author RaananW
  61849. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61850. */
  61851. export class QuadraticErrorSimplification implements ISimplifier {
  61852. private _mesh;
  61853. private triangles;
  61854. private vertices;
  61855. private references;
  61856. private _reconstructedMesh;
  61857. /** Gets or sets the number pf sync interations */
  61858. syncIterations: number;
  61859. /** Gets or sets the aggressiveness of the simplifier */
  61860. aggressiveness: number;
  61861. /** Gets or sets the number of allowed iterations for decimation */
  61862. decimationIterations: number;
  61863. /** Gets or sets the espilon to use for bounding box computation */
  61864. boundingBoxEpsilon: number;
  61865. /**
  61866. * Creates a new QuadraticErrorSimplification
  61867. * @param _mesh defines the target mesh
  61868. */
  61869. constructor(_mesh: Mesh);
  61870. /**
  61871. * Simplification of a given mesh according to the given settings.
  61872. * Since this requires computation, it is assumed that the function runs async.
  61873. * @param settings The settings of the simplification, including quality and distance
  61874. * @param successCallback A callback that will be called after the mesh was simplified.
  61875. */
  61876. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  61877. private runDecimation;
  61878. private initWithMesh;
  61879. private init;
  61880. private reconstructMesh;
  61881. private initDecimatedMesh;
  61882. private isFlipped;
  61883. private updateTriangles;
  61884. private identifyBorder;
  61885. private updateMesh;
  61886. private vertexError;
  61887. private calculateError;
  61888. }
  61889. }
  61890. declare module BABYLON {
  61891. interface Scene {
  61892. /** @hidden (Backing field) */
  61893. _simplificationQueue: SimplificationQueue;
  61894. /**
  61895. * Gets or sets the simplification queue attached to the scene
  61896. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61897. */
  61898. simplificationQueue: SimplificationQueue;
  61899. }
  61900. interface Mesh {
  61901. /**
  61902. * Simplify the mesh according to the given array of settings.
  61903. * Function will return immediately and will simplify async
  61904. * @param settings a collection of simplification settings
  61905. * @param parallelProcessing should all levels calculate parallel or one after the other
  61906. * @param simplificationType the type of simplification to run
  61907. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61908. * @returns the current mesh
  61909. */
  61910. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61911. }
  61912. /**
  61913. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61914. * created in a scene
  61915. */
  61916. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61917. /**
  61918. * The component name helpfull to identify the component in the list of scene components.
  61919. */
  61920. readonly name: string;
  61921. /**
  61922. * The scene the component belongs to.
  61923. */
  61924. scene: Scene;
  61925. /**
  61926. * Creates a new instance of the component for the given scene
  61927. * @param scene Defines the scene to register the component in
  61928. */
  61929. constructor(scene: Scene);
  61930. /**
  61931. * Registers the component in a given scene
  61932. */
  61933. register(): void;
  61934. /**
  61935. * Rebuilds the elements related to this component in case of
  61936. * context lost for instance.
  61937. */
  61938. rebuild(): void;
  61939. /**
  61940. * Disposes the component and the associated ressources
  61941. */
  61942. dispose(): void;
  61943. private _beforeCameraUpdate;
  61944. }
  61945. }
  61946. declare module BABYLON {
  61947. /**
  61948. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61949. */
  61950. export interface INavigationEnginePlugin {
  61951. /**
  61952. * plugin name
  61953. */
  61954. name: string;
  61955. /**
  61956. * Creates a navigation mesh
  61957. * @param meshes array of all the geometry used to compute the navigatio mesh
  61958. * @param parameters bunch of parameters used to filter geometry
  61959. */
  61960. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61961. /**
  61962. * Create a navigation mesh debug mesh
  61963. * @param scene is where the mesh will be added
  61964. * @returns debug display mesh
  61965. */
  61966. createDebugNavMesh(scene: Scene): Mesh;
  61967. /**
  61968. * Get a navigation mesh constrained position, closest to the parameter position
  61969. * @param position world position
  61970. * @returns the closest point to position constrained by the navigation mesh
  61971. */
  61972. getClosestPoint(position: Vector3): Vector3;
  61973. /**
  61974. * Get a navigation mesh constrained position, within a particular radius
  61975. * @param position world position
  61976. * @param maxRadius the maximum distance to the constrained world position
  61977. * @returns the closest point to position constrained by the navigation mesh
  61978. */
  61979. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61980. /**
  61981. * Compute the final position from a segment made of destination-position
  61982. * @param position world position
  61983. * @param destination world position
  61984. * @returns the resulting point along the navmesh
  61985. */
  61986. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61987. /**
  61988. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61989. * @param start world position
  61990. * @param end world position
  61991. * @returns array containing world position composing the path
  61992. */
  61993. computePath(start: Vector3, end: Vector3): Vector3[];
  61994. /**
  61995. * If this plugin is supported
  61996. * @returns true if plugin is supported
  61997. */
  61998. isSupported(): boolean;
  61999. /**
  62000. * Create a new Crowd so you can add agents
  62001. * @param maxAgents the maximum agent count in the crowd
  62002. * @param maxAgentRadius the maximum radius an agent can have
  62003. * @param scene to attach the crowd to
  62004. * @returns the crowd you can add agents to
  62005. */
  62006. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62007. /**
  62008. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62009. * The queries will try to find a solution within those bounds
  62010. * default is (1,1,1)
  62011. * @param extent x,y,z value that define the extent around the queries point of reference
  62012. */
  62013. setDefaultQueryExtent(extent: Vector3): void;
  62014. /**
  62015. * Get the Bounding box extent specified by setDefaultQueryExtent
  62016. * @returns the box extent values
  62017. */
  62018. getDefaultQueryExtent(): Vector3;
  62019. /**
  62020. * Release all resources
  62021. */
  62022. dispose(): void;
  62023. }
  62024. /**
  62025. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62026. */
  62027. export interface ICrowd {
  62028. /**
  62029. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62030. * You can attach anything to that node. The node position is updated in the scene update tick.
  62031. * @param pos world position that will be constrained by the navigation mesh
  62032. * @param parameters agent parameters
  62033. * @param transform hooked to the agent that will be update by the scene
  62034. * @returns agent index
  62035. */
  62036. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62037. /**
  62038. * Returns the agent position in world space
  62039. * @param index agent index returned by addAgent
  62040. * @returns world space position
  62041. */
  62042. getAgentPosition(index: number): Vector3;
  62043. /**
  62044. * Gets the agent velocity in world space
  62045. * @param index agent index returned by addAgent
  62046. * @returns world space velocity
  62047. */
  62048. getAgentVelocity(index: number): Vector3;
  62049. /**
  62050. * remove a particular agent previously created
  62051. * @param index agent index returned by addAgent
  62052. */
  62053. removeAgent(index: number): void;
  62054. /**
  62055. * get the list of all agents attached to this crowd
  62056. * @returns list of agent indices
  62057. */
  62058. getAgents(): number[];
  62059. /**
  62060. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62061. * @param deltaTime in seconds
  62062. */
  62063. update(deltaTime: number): void;
  62064. /**
  62065. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62066. * @param index agent index returned by addAgent
  62067. * @param destination targeted world position
  62068. */
  62069. agentGoto(index: number, destination: Vector3): void;
  62070. /**
  62071. * Teleport the agent to a new position
  62072. * @param index agent index returned by addAgent
  62073. * @param destination targeted world position
  62074. */
  62075. agentTeleport(index: number, destination: Vector3): void;
  62076. /**
  62077. * Update agent parameters
  62078. * @param index agent index returned by addAgent
  62079. * @param parameters agent parameters
  62080. */
  62081. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62082. /**
  62083. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62084. * The queries will try to find a solution within those bounds
  62085. * default is (1,1,1)
  62086. * @param extent x,y,z value that define the extent around the queries point of reference
  62087. */
  62088. setDefaultQueryExtent(extent: Vector3): void;
  62089. /**
  62090. * Get the Bounding box extent specified by setDefaultQueryExtent
  62091. * @returns the box extent values
  62092. */
  62093. getDefaultQueryExtent(): Vector3;
  62094. /**
  62095. * Release all resources
  62096. */
  62097. dispose(): void;
  62098. }
  62099. /**
  62100. * Configures an agent
  62101. */
  62102. export interface IAgentParameters {
  62103. /**
  62104. * Agent radius. [Limit: >= 0]
  62105. */
  62106. radius: number;
  62107. /**
  62108. * Agent height. [Limit: > 0]
  62109. */
  62110. height: number;
  62111. /**
  62112. * Maximum allowed acceleration. [Limit: >= 0]
  62113. */
  62114. maxAcceleration: number;
  62115. /**
  62116. * Maximum allowed speed. [Limit: >= 0]
  62117. */
  62118. maxSpeed: number;
  62119. /**
  62120. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62121. */
  62122. collisionQueryRange: number;
  62123. /**
  62124. * The path visibility optimization range. [Limit: > 0]
  62125. */
  62126. pathOptimizationRange: number;
  62127. /**
  62128. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62129. */
  62130. separationWeight: number;
  62131. }
  62132. /**
  62133. * Configures the navigation mesh creation
  62134. */
  62135. export interface INavMeshParameters {
  62136. /**
  62137. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62138. */
  62139. cs: number;
  62140. /**
  62141. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62142. */
  62143. ch: number;
  62144. /**
  62145. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62146. */
  62147. walkableSlopeAngle: number;
  62148. /**
  62149. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62150. * be considered walkable. [Limit: >= 3] [Units: vx]
  62151. */
  62152. walkableHeight: number;
  62153. /**
  62154. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62155. */
  62156. walkableClimb: number;
  62157. /**
  62158. * The distance to erode/shrink the walkable area of the heightfield away from
  62159. * obstructions. [Limit: >=0] [Units: vx]
  62160. */
  62161. walkableRadius: number;
  62162. /**
  62163. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62164. */
  62165. maxEdgeLen: number;
  62166. /**
  62167. * The maximum distance a simplfied contour's border edges should deviate
  62168. * the original raw contour. [Limit: >=0] [Units: vx]
  62169. */
  62170. maxSimplificationError: number;
  62171. /**
  62172. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62173. */
  62174. minRegionArea: number;
  62175. /**
  62176. * Any regions with a span count smaller than this value will, if possible,
  62177. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62178. */
  62179. mergeRegionArea: number;
  62180. /**
  62181. * The maximum number of vertices allowed for polygons generated during the
  62182. * contour to polygon conversion process. [Limit: >= 3]
  62183. */
  62184. maxVertsPerPoly: number;
  62185. /**
  62186. * Sets the sampling distance to use when generating the detail mesh.
  62187. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62188. */
  62189. detailSampleDist: number;
  62190. /**
  62191. * The maximum distance the detail mesh surface should deviate from heightfield
  62192. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62193. */
  62194. detailSampleMaxError: number;
  62195. }
  62196. }
  62197. declare module BABYLON {
  62198. /**
  62199. * RecastJS navigation plugin
  62200. */
  62201. export class RecastJSPlugin implements INavigationEnginePlugin {
  62202. /**
  62203. * Reference to the Recast library
  62204. */
  62205. bjsRECAST: any;
  62206. /**
  62207. * plugin name
  62208. */
  62209. name: string;
  62210. /**
  62211. * the first navmesh created. We might extend this to support multiple navmeshes
  62212. */
  62213. navMesh: any;
  62214. /**
  62215. * Initializes the recastJS plugin
  62216. * @param recastInjection can be used to inject your own recast reference
  62217. */
  62218. constructor(recastInjection?: any);
  62219. /**
  62220. * Creates a navigation mesh
  62221. * @param meshes array of all the geometry used to compute the navigatio mesh
  62222. * @param parameters bunch of parameters used to filter geometry
  62223. */
  62224. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62225. /**
  62226. * Create a navigation mesh debug mesh
  62227. * @param scene is where the mesh will be added
  62228. * @returns debug display mesh
  62229. */
  62230. createDebugNavMesh(scene: Scene): Mesh;
  62231. /**
  62232. * Get a navigation mesh constrained position, closest to the parameter position
  62233. * @param position world position
  62234. * @returns the closest point to position constrained by the navigation mesh
  62235. */
  62236. getClosestPoint(position: Vector3): Vector3;
  62237. /**
  62238. * Get a navigation mesh constrained position, within a particular radius
  62239. * @param position world position
  62240. * @param maxRadius the maximum distance to the constrained world position
  62241. * @returns the closest point to position constrained by the navigation mesh
  62242. */
  62243. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62244. /**
  62245. * Compute the final position from a segment made of destination-position
  62246. * @param position world position
  62247. * @param destination world position
  62248. * @returns the resulting point along the navmesh
  62249. */
  62250. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62251. /**
  62252. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62253. * @param start world position
  62254. * @param end world position
  62255. * @returns array containing world position composing the path
  62256. */
  62257. computePath(start: Vector3, end: Vector3): Vector3[];
  62258. /**
  62259. * Create a new Crowd so you can add agents
  62260. * @param maxAgents the maximum agent count in the crowd
  62261. * @param maxAgentRadius the maximum radius an agent can have
  62262. * @param scene to attach the crowd to
  62263. * @returns the crowd you can add agents to
  62264. */
  62265. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62266. /**
  62267. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62268. * The queries will try to find a solution within those bounds
  62269. * default is (1,1,1)
  62270. * @param extent x,y,z value that define the extent around the queries point of reference
  62271. */
  62272. setDefaultQueryExtent(extent: Vector3): void;
  62273. /**
  62274. * Get the Bounding box extent specified by setDefaultQueryExtent
  62275. * @returns the box extent values
  62276. */
  62277. getDefaultQueryExtent(): Vector3;
  62278. /**
  62279. * Disposes
  62280. */
  62281. dispose(): void;
  62282. /**
  62283. * If this plugin is supported
  62284. * @returns true if plugin is supported
  62285. */
  62286. isSupported(): boolean;
  62287. }
  62288. /**
  62289. * Recast detour crowd implementation
  62290. */
  62291. export class RecastJSCrowd implements ICrowd {
  62292. /**
  62293. * Recast/detour plugin
  62294. */
  62295. bjsRECASTPlugin: RecastJSPlugin;
  62296. /**
  62297. * Link to the detour crowd
  62298. */
  62299. recastCrowd: any;
  62300. /**
  62301. * One transform per agent
  62302. */
  62303. transforms: TransformNode[];
  62304. /**
  62305. * All agents created
  62306. */
  62307. agents: number[];
  62308. /**
  62309. * Link to the scene is kept to unregister the crowd from the scene
  62310. */
  62311. private _scene;
  62312. /**
  62313. * Observer for crowd updates
  62314. */
  62315. private _onBeforeAnimationsObserver;
  62316. /**
  62317. * Constructor
  62318. * @param plugin recastJS plugin
  62319. * @param maxAgents the maximum agent count in the crowd
  62320. * @param maxAgentRadius the maximum radius an agent can have
  62321. * @param scene to attach the crowd to
  62322. * @returns the crowd you can add agents to
  62323. */
  62324. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62325. /**
  62326. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62327. * You can attach anything to that node. The node position is updated in the scene update tick.
  62328. * @param pos world position that will be constrained by the navigation mesh
  62329. * @param parameters agent parameters
  62330. * @param transform hooked to the agent that will be update by the scene
  62331. * @returns agent index
  62332. */
  62333. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62334. /**
  62335. * Returns the agent position in world space
  62336. * @param index agent index returned by addAgent
  62337. * @returns world space position
  62338. */
  62339. getAgentPosition(index: number): Vector3;
  62340. /**
  62341. * Returns the agent velocity in world space
  62342. * @param index agent index returned by addAgent
  62343. * @returns world space velocity
  62344. */
  62345. getAgentVelocity(index: number): Vector3;
  62346. /**
  62347. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62348. * @param index agent index returned by addAgent
  62349. * @param destination targeted world position
  62350. */
  62351. agentGoto(index: number, destination: Vector3): void;
  62352. /**
  62353. * Teleport the agent to a new position
  62354. * @param index agent index returned by addAgent
  62355. * @param destination targeted world position
  62356. */
  62357. agentTeleport(index: number, destination: Vector3): void;
  62358. /**
  62359. * Update agent parameters
  62360. * @param index agent index returned by addAgent
  62361. * @param parameters agent parameters
  62362. */
  62363. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62364. /**
  62365. * remove a particular agent previously created
  62366. * @param index agent index returned by addAgent
  62367. */
  62368. removeAgent(index: number): void;
  62369. /**
  62370. * get the list of all agents attached to this crowd
  62371. * @returns list of agent indices
  62372. */
  62373. getAgents(): number[];
  62374. /**
  62375. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62376. * @param deltaTime in seconds
  62377. */
  62378. update(deltaTime: number): void;
  62379. /**
  62380. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62381. * The queries will try to find a solution within those bounds
  62382. * default is (1,1,1)
  62383. * @param extent x,y,z value that define the extent around the queries point of reference
  62384. */
  62385. setDefaultQueryExtent(extent: Vector3): void;
  62386. /**
  62387. * Get the Bounding box extent specified by setDefaultQueryExtent
  62388. * @returns the box extent values
  62389. */
  62390. getDefaultQueryExtent(): Vector3;
  62391. /**
  62392. * Release all resources
  62393. */
  62394. dispose(): void;
  62395. }
  62396. }
  62397. declare module BABYLON {
  62398. /**
  62399. * Class used to enable access to IndexedDB
  62400. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62401. */
  62402. export class Database implements IOfflineProvider {
  62403. private _callbackManifestChecked;
  62404. private _currentSceneUrl;
  62405. private _db;
  62406. private _enableSceneOffline;
  62407. private _enableTexturesOffline;
  62408. private _manifestVersionFound;
  62409. private _mustUpdateRessources;
  62410. private _hasReachedQuota;
  62411. private _isSupported;
  62412. private _idbFactory;
  62413. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62414. private static IsUASupportingBlobStorage;
  62415. /**
  62416. * Gets a boolean indicating if Database storate is enabled (off by default)
  62417. */
  62418. static IDBStorageEnabled: boolean;
  62419. /**
  62420. * Gets a boolean indicating if scene must be saved in the database
  62421. */
  62422. get enableSceneOffline(): boolean;
  62423. /**
  62424. * Gets a boolean indicating if textures must be saved in the database
  62425. */
  62426. get enableTexturesOffline(): boolean;
  62427. /**
  62428. * Creates a new Database
  62429. * @param urlToScene defines the url to load the scene
  62430. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62431. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62432. */
  62433. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62434. private static _ParseURL;
  62435. private static _ReturnFullUrlLocation;
  62436. private _checkManifestFile;
  62437. /**
  62438. * Open the database and make it available
  62439. * @param successCallback defines the callback to call on success
  62440. * @param errorCallback defines the callback to call on error
  62441. */
  62442. open(successCallback: () => void, errorCallback: () => void): void;
  62443. /**
  62444. * Loads an image from the database
  62445. * @param url defines the url to load from
  62446. * @param image defines the target DOM image
  62447. */
  62448. loadImage(url: string, image: HTMLImageElement): void;
  62449. private _loadImageFromDBAsync;
  62450. private _saveImageIntoDBAsync;
  62451. private _checkVersionFromDB;
  62452. private _loadVersionFromDBAsync;
  62453. private _saveVersionIntoDBAsync;
  62454. /**
  62455. * Loads a file from database
  62456. * @param url defines the URL to load from
  62457. * @param sceneLoaded defines a callback to call on success
  62458. * @param progressCallBack defines a callback to call when progress changed
  62459. * @param errorCallback defines a callback to call on error
  62460. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62461. */
  62462. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62463. private _loadFileAsync;
  62464. private _saveFileAsync;
  62465. /**
  62466. * Validates if xhr data is correct
  62467. * @param xhr defines the request to validate
  62468. * @param dataType defines the expected data type
  62469. * @returns true if data is correct
  62470. */
  62471. private static _ValidateXHRData;
  62472. }
  62473. }
  62474. declare module BABYLON {
  62475. /** @hidden */
  62476. export var gpuUpdateParticlesPixelShader: {
  62477. name: string;
  62478. shader: string;
  62479. };
  62480. }
  62481. declare module BABYLON {
  62482. /** @hidden */
  62483. export var gpuUpdateParticlesVertexShader: {
  62484. name: string;
  62485. shader: string;
  62486. };
  62487. }
  62488. declare module BABYLON {
  62489. /** @hidden */
  62490. export var clipPlaneFragmentDeclaration2: {
  62491. name: string;
  62492. shader: string;
  62493. };
  62494. }
  62495. declare module BABYLON {
  62496. /** @hidden */
  62497. export var gpuRenderParticlesPixelShader: {
  62498. name: string;
  62499. shader: string;
  62500. };
  62501. }
  62502. declare module BABYLON {
  62503. /** @hidden */
  62504. export var clipPlaneVertexDeclaration2: {
  62505. name: string;
  62506. shader: string;
  62507. };
  62508. }
  62509. declare module BABYLON {
  62510. /** @hidden */
  62511. export var gpuRenderParticlesVertexShader: {
  62512. name: string;
  62513. shader: string;
  62514. };
  62515. }
  62516. declare module BABYLON {
  62517. /**
  62518. * This represents a GPU particle system in Babylon
  62519. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62520. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62521. */
  62522. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62523. /**
  62524. * The layer mask we are rendering the particles through.
  62525. */
  62526. layerMask: number;
  62527. private _capacity;
  62528. private _activeCount;
  62529. private _currentActiveCount;
  62530. private _accumulatedCount;
  62531. private _renderEffect;
  62532. private _updateEffect;
  62533. private _buffer0;
  62534. private _buffer1;
  62535. private _spriteBuffer;
  62536. private _updateVAO;
  62537. private _renderVAO;
  62538. private _targetIndex;
  62539. private _sourceBuffer;
  62540. private _targetBuffer;
  62541. private _engine;
  62542. private _currentRenderId;
  62543. private _started;
  62544. private _stopped;
  62545. private _timeDelta;
  62546. private _randomTexture;
  62547. private _randomTexture2;
  62548. private _attributesStrideSize;
  62549. private _updateEffectOptions;
  62550. private _randomTextureSize;
  62551. private _actualFrame;
  62552. private readonly _rawTextureWidth;
  62553. /**
  62554. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62555. */
  62556. static get IsSupported(): boolean;
  62557. /**
  62558. * An event triggered when the system is disposed.
  62559. */
  62560. onDisposeObservable: Observable<GPUParticleSystem>;
  62561. /**
  62562. * Gets the maximum number of particles active at the same time.
  62563. * @returns The max number of active particles.
  62564. */
  62565. getCapacity(): number;
  62566. /**
  62567. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62568. * to override the particles.
  62569. */
  62570. forceDepthWrite: boolean;
  62571. /**
  62572. * Gets or set the number of active particles
  62573. */
  62574. get activeParticleCount(): number;
  62575. set activeParticleCount(value: number);
  62576. private _preWarmDone;
  62577. /**
  62578. * Specifies if the particles are updated in emitter local space or world space.
  62579. * This is always false for GPU particles
  62580. */
  62581. get isLocal(): boolean;
  62582. set isLocal(value: boolean);
  62583. /**
  62584. * Is this system ready to be used/rendered
  62585. * @return true if the system is ready
  62586. */
  62587. isReady(): boolean;
  62588. /**
  62589. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62590. * @returns True if it has been started, otherwise false.
  62591. */
  62592. isStarted(): boolean;
  62593. /**
  62594. * Starts the particle system and begins to emit
  62595. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62596. */
  62597. start(delay?: number): void;
  62598. /**
  62599. * Stops the particle system.
  62600. */
  62601. stop(): void;
  62602. /**
  62603. * Remove all active particles
  62604. */
  62605. reset(): void;
  62606. /**
  62607. * Returns the string "GPUParticleSystem"
  62608. * @returns a string containing the class name
  62609. */
  62610. getClassName(): string;
  62611. private _colorGradientsTexture;
  62612. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62613. /**
  62614. * Adds a new color gradient
  62615. * @param gradient defines the gradient to use (between 0 and 1)
  62616. * @param color1 defines the color to affect to the specified gradient
  62617. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62618. * @returns the current particle system
  62619. */
  62620. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62621. /**
  62622. * Remove a specific color gradient
  62623. * @param gradient defines the gradient to remove
  62624. * @returns the current particle system
  62625. */
  62626. removeColorGradient(gradient: number): GPUParticleSystem;
  62627. private _angularSpeedGradientsTexture;
  62628. private _sizeGradientsTexture;
  62629. private _velocityGradientsTexture;
  62630. private _limitVelocityGradientsTexture;
  62631. private _dragGradientsTexture;
  62632. private _addFactorGradient;
  62633. /**
  62634. * Adds a new size gradient
  62635. * @param gradient defines the gradient to use (between 0 and 1)
  62636. * @param factor defines the size factor to affect to the specified gradient
  62637. * @returns the current particle system
  62638. */
  62639. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62640. /**
  62641. * Remove a specific size gradient
  62642. * @param gradient defines the gradient to remove
  62643. * @returns the current particle system
  62644. */
  62645. removeSizeGradient(gradient: number): GPUParticleSystem;
  62646. /**
  62647. * Adds a new angular speed gradient
  62648. * @param gradient defines the gradient to use (between 0 and 1)
  62649. * @param factor defines the angular speed to affect to the specified gradient
  62650. * @returns the current particle system
  62651. */
  62652. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62653. /**
  62654. * Remove a specific angular speed gradient
  62655. * @param gradient defines the gradient to remove
  62656. * @returns the current particle system
  62657. */
  62658. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62659. /**
  62660. * Adds a new velocity gradient
  62661. * @param gradient defines the gradient to use (between 0 and 1)
  62662. * @param factor defines the velocity to affect to the specified gradient
  62663. * @returns the current particle system
  62664. */
  62665. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62666. /**
  62667. * Remove a specific velocity gradient
  62668. * @param gradient defines the gradient to remove
  62669. * @returns the current particle system
  62670. */
  62671. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62672. /**
  62673. * Adds a new limit velocity gradient
  62674. * @param gradient defines the gradient to use (between 0 and 1)
  62675. * @param factor defines the limit velocity value to affect to the specified gradient
  62676. * @returns the current particle system
  62677. */
  62678. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62679. /**
  62680. * Remove a specific limit velocity gradient
  62681. * @param gradient defines the gradient to remove
  62682. * @returns the current particle system
  62683. */
  62684. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62685. /**
  62686. * Adds a new drag gradient
  62687. * @param gradient defines the gradient to use (between 0 and 1)
  62688. * @param factor defines the drag value to affect to the specified gradient
  62689. * @returns the current particle system
  62690. */
  62691. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62692. /**
  62693. * Remove a specific drag gradient
  62694. * @param gradient defines the gradient to remove
  62695. * @returns the current particle system
  62696. */
  62697. removeDragGradient(gradient: number): GPUParticleSystem;
  62698. /**
  62699. * Not supported by GPUParticleSystem
  62700. * @param gradient defines the gradient to use (between 0 and 1)
  62701. * @param factor defines the emit rate value to affect to the specified gradient
  62702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62703. * @returns the current particle system
  62704. */
  62705. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62706. /**
  62707. * Not supported by GPUParticleSystem
  62708. * @param gradient defines the gradient to remove
  62709. * @returns the current particle system
  62710. */
  62711. removeEmitRateGradient(gradient: number): IParticleSystem;
  62712. /**
  62713. * Not supported by GPUParticleSystem
  62714. * @param gradient defines the gradient to use (between 0 and 1)
  62715. * @param factor defines the start size value to affect to the specified gradient
  62716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62717. * @returns the current particle system
  62718. */
  62719. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62720. /**
  62721. * Not supported by GPUParticleSystem
  62722. * @param gradient defines the gradient to remove
  62723. * @returns the current particle system
  62724. */
  62725. removeStartSizeGradient(gradient: number): IParticleSystem;
  62726. /**
  62727. * Not supported by GPUParticleSystem
  62728. * @param gradient defines the gradient to use (between 0 and 1)
  62729. * @param min defines the color remap minimal range
  62730. * @param max defines the color remap maximal range
  62731. * @returns the current particle system
  62732. */
  62733. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62734. /**
  62735. * Not supported by GPUParticleSystem
  62736. * @param gradient defines the gradient to remove
  62737. * @returns the current particle system
  62738. */
  62739. removeColorRemapGradient(): IParticleSystem;
  62740. /**
  62741. * Not supported by GPUParticleSystem
  62742. * @param gradient defines the gradient to use (between 0 and 1)
  62743. * @param min defines the alpha remap minimal range
  62744. * @param max defines the alpha remap maximal range
  62745. * @returns the current particle system
  62746. */
  62747. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62748. /**
  62749. * Not supported by GPUParticleSystem
  62750. * @param gradient defines the gradient to remove
  62751. * @returns the current particle system
  62752. */
  62753. removeAlphaRemapGradient(): IParticleSystem;
  62754. /**
  62755. * Not supported by GPUParticleSystem
  62756. * @param gradient defines the gradient to use (between 0 and 1)
  62757. * @param color defines the color to affect to the specified gradient
  62758. * @returns the current particle system
  62759. */
  62760. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62761. /**
  62762. * Not supported by GPUParticleSystem
  62763. * @param gradient defines the gradient to remove
  62764. * @returns the current particle system
  62765. */
  62766. removeRampGradient(): IParticleSystem;
  62767. /**
  62768. * Not supported by GPUParticleSystem
  62769. * @returns the list of ramp gradients
  62770. */
  62771. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62772. /**
  62773. * Not supported by GPUParticleSystem
  62774. * Gets or sets a boolean indicating that ramp gradients must be used
  62775. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62776. */
  62777. get useRampGradients(): boolean;
  62778. set useRampGradients(value: boolean);
  62779. /**
  62780. * Not supported by GPUParticleSystem
  62781. * @param gradient defines the gradient to use (between 0 and 1)
  62782. * @param factor defines the life time factor to affect to the specified gradient
  62783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62784. * @returns the current particle system
  62785. */
  62786. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62787. /**
  62788. * Not supported by GPUParticleSystem
  62789. * @param gradient defines the gradient to remove
  62790. * @returns the current particle system
  62791. */
  62792. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62793. /**
  62794. * Instantiates a GPU particle system.
  62795. * 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.
  62796. * @param name The name of the particle system
  62797. * @param options The options used to create the system
  62798. * @param scene The scene the particle system belongs to
  62799. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62800. */
  62801. constructor(name: string, options: Partial<{
  62802. capacity: number;
  62803. randomTextureSize: number;
  62804. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62805. protected _reset(): void;
  62806. private _createUpdateVAO;
  62807. private _createRenderVAO;
  62808. private _initialize;
  62809. /** @hidden */
  62810. _recreateUpdateEffect(): void;
  62811. /** @hidden */
  62812. _recreateRenderEffect(): void;
  62813. /**
  62814. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62815. * @param preWarm defines if we are in the pre-warmimg phase
  62816. */
  62817. animate(preWarm?: boolean): void;
  62818. private _createFactorGradientTexture;
  62819. private _createSizeGradientTexture;
  62820. private _createAngularSpeedGradientTexture;
  62821. private _createVelocityGradientTexture;
  62822. private _createLimitVelocityGradientTexture;
  62823. private _createDragGradientTexture;
  62824. private _createColorGradientTexture;
  62825. /**
  62826. * Renders the particle system in its current state
  62827. * @param preWarm defines if the system should only update the particles but not render them
  62828. * @returns the current number of particles
  62829. */
  62830. render(preWarm?: boolean): number;
  62831. /**
  62832. * Rebuilds the particle system
  62833. */
  62834. rebuild(): void;
  62835. private _releaseBuffers;
  62836. private _releaseVAOs;
  62837. /**
  62838. * Disposes the particle system and free the associated resources
  62839. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62840. */
  62841. dispose(disposeTexture?: boolean): void;
  62842. /**
  62843. * Clones the particle system.
  62844. * @param name The name of the cloned object
  62845. * @param newEmitter The new emitter to use
  62846. * @returns the cloned particle system
  62847. */
  62848. clone(name: string, newEmitter: any): GPUParticleSystem;
  62849. /**
  62850. * Serializes the particle system to a JSON object.
  62851. * @returns the JSON object
  62852. */
  62853. serialize(): any;
  62854. /**
  62855. * Parses a JSON object to create a GPU particle system.
  62856. * @param parsedParticleSystem The JSON object to parse
  62857. * @param scene The scene to create the particle system in
  62858. * @param rootUrl The root url to use to load external dependencies like texture
  62859. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62860. * @returns the parsed GPU particle system
  62861. */
  62862. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62863. }
  62864. }
  62865. declare module BABYLON {
  62866. /**
  62867. * Represents a set of particle systems working together to create a specific effect
  62868. */
  62869. export class ParticleSystemSet implements IDisposable {
  62870. /**
  62871. * Gets or sets base Assets URL
  62872. */
  62873. static BaseAssetsUrl: string;
  62874. private _emitterCreationOptions;
  62875. private _emitterNode;
  62876. /**
  62877. * Gets the particle system list
  62878. */
  62879. systems: IParticleSystem[];
  62880. /**
  62881. * Gets the emitter node used with this set
  62882. */
  62883. get emitterNode(): Nullable<TransformNode>;
  62884. /**
  62885. * Creates a new emitter mesh as a sphere
  62886. * @param options defines the options used to create the sphere
  62887. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62888. * @param scene defines the hosting scene
  62889. */
  62890. setEmitterAsSphere(options: {
  62891. diameter: number;
  62892. segments: number;
  62893. color: Color3;
  62894. }, renderingGroupId: number, scene: Scene): void;
  62895. /**
  62896. * Starts all particle systems of the set
  62897. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62898. */
  62899. start(emitter?: AbstractMesh): void;
  62900. /**
  62901. * Release all associated resources
  62902. */
  62903. dispose(): void;
  62904. /**
  62905. * Serialize the set into a JSON compatible object
  62906. * @returns a JSON compatible representation of the set
  62907. */
  62908. serialize(): any;
  62909. /**
  62910. * Parse a new ParticleSystemSet from a serialized source
  62911. * @param data defines a JSON compatible representation of the set
  62912. * @param scene defines the hosting scene
  62913. * @param gpu defines if we want GPU particles or CPU particles
  62914. * @returns a new ParticleSystemSet
  62915. */
  62916. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62917. }
  62918. }
  62919. declare module BABYLON {
  62920. /**
  62921. * This class is made for on one-liner static method to help creating particle system set.
  62922. */
  62923. export class ParticleHelper {
  62924. /**
  62925. * Gets or sets base Assets URL
  62926. */
  62927. static BaseAssetsUrl: string;
  62928. /**
  62929. * Create a default particle system that you can tweak
  62930. * @param emitter defines the emitter to use
  62931. * @param capacity defines the system capacity (default is 500 particles)
  62932. * @param scene defines the hosting scene
  62933. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62934. * @returns the new Particle system
  62935. */
  62936. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62937. /**
  62938. * This is the main static method (one-liner) of this helper to create different particle systems
  62939. * @param type This string represents the type to the particle system to create
  62940. * @param scene The scene where the particle system should live
  62941. * @param gpu If the system will use gpu
  62942. * @returns the ParticleSystemSet created
  62943. */
  62944. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62945. /**
  62946. * Static function used to export a particle system to a ParticleSystemSet variable.
  62947. * Please note that the emitter shape is not exported
  62948. * @param systems defines the particle systems to export
  62949. * @returns the created particle system set
  62950. */
  62951. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62952. }
  62953. }
  62954. declare module BABYLON {
  62955. interface Engine {
  62956. /**
  62957. * Create an effect to use with particle systems.
  62958. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62959. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62960. * @param uniformsNames defines a list of attribute names
  62961. * @param samplers defines an array of string used to represent textures
  62962. * @param defines defines the string containing the defines to use to compile the shaders
  62963. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62964. * @param onCompiled defines a function to call when the effect creation is successful
  62965. * @param onError defines a function to call when the effect creation has failed
  62966. * @returns the new Effect
  62967. */
  62968. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62969. }
  62970. interface Mesh {
  62971. /**
  62972. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62973. * @returns an array of IParticleSystem
  62974. */
  62975. getEmittedParticleSystems(): IParticleSystem[];
  62976. /**
  62977. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62978. * @returns an array of IParticleSystem
  62979. */
  62980. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62981. }
  62982. /**
  62983. * @hidden
  62984. */
  62985. export var _IDoNeedToBeInTheBuild: number;
  62986. }
  62987. declare module BABYLON {
  62988. /** Defines the 4 color options */
  62989. export enum PointColor {
  62990. /** color value */
  62991. Color = 2,
  62992. /** uv value */
  62993. UV = 1,
  62994. /** random value */
  62995. Random = 0,
  62996. /** stated value */
  62997. Stated = 3
  62998. }
  62999. /**
  63000. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63001. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  63002. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63003. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63004. *
  63005. * Full documentation here : TO BE ENTERED
  63006. */
  63007. export class PointsCloudSystem implements IDisposable {
  63008. /**
  63009. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63010. * Example : var p = SPS.particles[i];
  63011. */
  63012. particles: CloudPoint[];
  63013. /**
  63014. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63015. */
  63016. nbParticles: number;
  63017. /**
  63018. * This a counter for your own usage. It's not set by any SPS functions.
  63019. */
  63020. counter: number;
  63021. /**
  63022. * The PCS name. This name is also given to the underlying mesh.
  63023. */
  63024. name: string;
  63025. /**
  63026. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63027. */
  63028. mesh: Mesh;
  63029. /**
  63030. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63031. * Please read :
  63032. */
  63033. vars: any;
  63034. /**
  63035. * @hidden
  63036. */
  63037. _size: number;
  63038. private _scene;
  63039. private _promises;
  63040. private _positions;
  63041. private _indices;
  63042. private _normals;
  63043. private _colors;
  63044. private _uvs;
  63045. private _indices32;
  63046. private _positions32;
  63047. private _colors32;
  63048. private _uvs32;
  63049. private _updatable;
  63050. private _isVisibilityBoxLocked;
  63051. private _alwaysVisible;
  63052. private _groups;
  63053. private _groupCounter;
  63054. private _computeParticleColor;
  63055. private _computeParticleTexture;
  63056. private _computeParticleRotation;
  63057. private _computeBoundingBox;
  63058. private _isReady;
  63059. /**
  63060. * Creates a PCS (Points Cloud System) object
  63061. * @param name (String) is the PCS name, this will be the underlying mesh name
  63062. * @param pointSize (number) is the size for each point
  63063. * @param scene (Scene) is the scene in which the PCS is added
  63064. * @param options defines the options of the PCS e.g.
  63065. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63066. */
  63067. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63068. updatable?: boolean;
  63069. });
  63070. /**
  63071. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63072. * If no points were added to the PCS, the returned mesh is just a single point.
  63073. * @returns a promise for the created mesh
  63074. */
  63075. buildMeshAsync(): Promise<Mesh>;
  63076. /**
  63077. * @hidden
  63078. */
  63079. private _buildMesh;
  63080. private _addParticle;
  63081. private _randomUnitVector;
  63082. private _getColorIndicesForCoord;
  63083. private _setPointsColorOrUV;
  63084. private _colorFromTexture;
  63085. private _calculateDensity;
  63086. /**
  63087. * Adds points to the PCS in random positions within a unit sphere
  63088. * @param nb (positive integer) the number of particles to be created from this model
  63089. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63090. * @returns the number of groups in the system
  63091. */
  63092. addPoints(nb: number, pointFunction?: any): number;
  63093. /**
  63094. * Adds points to the PCS from the surface of the model shape
  63095. * @param mesh is any Mesh object that will be used as a surface model for the points
  63096. * @param nb (positive integer) the number of particles to be created from this model
  63097. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63098. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63099. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63100. * @returns the number of groups in the system
  63101. */
  63102. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63103. /**
  63104. * Adds points to the PCS inside the model shape
  63105. * @param mesh is any Mesh object that will be used as a surface model for the points
  63106. * @param nb (positive integer) the number of particles to be created from this model
  63107. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63108. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63109. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63110. * @returns the number of groups in the system
  63111. */
  63112. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63113. /**
  63114. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63115. * This method calls `updateParticle()` for each particle of the SPS.
  63116. * For an animated SPS, it is usually called within the render loop.
  63117. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63118. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63119. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63120. * @returns the PCS.
  63121. */
  63122. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63123. /**
  63124. * Disposes the PCS.
  63125. */
  63126. dispose(): void;
  63127. /**
  63128. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63129. * doc :
  63130. * @returns the PCS.
  63131. */
  63132. refreshVisibleSize(): PointsCloudSystem;
  63133. /**
  63134. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63135. * @param size the size (float) of the visibility box
  63136. * note : this doesn't lock the PCS mesh bounding box.
  63137. * doc :
  63138. */
  63139. setVisibilityBox(size: number): void;
  63140. /**
  63141. * Gets whether the PCS is always visible or not
  63142. * doc :
  63143. */
  63144. get isAlwaysVisible(): boolean;
  63145. /**
  63146. * Sets the PCS as always visible or not
  63147. * doc :
  63148. */
  63149. set isAlwaysVisible(val: boolean);
  63150. /**
  63151. * Tells to `setParticles()` to compute the particle rotations or not
  63152. * Default value : false. The PCS is faster when it's set to false
  63153. * Note : particle rotations are only applied to parent particles
  63154. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63155. */
  63156. set computeParticleRotation(val: boolean);
  63157. /**
  63158. * Tells to `setParticles()` to compute the particle colors or not.
  63159. * Default value : true. The PCS is faster when it's set to false.
  63160. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63161. */
  63162. set computeParticleColor(val: boolean);
  63163. set computeParticleTexture(val: boolean);
  63164. /**
  63165. * Gets if `setParticles()` computes the particle colors or not.
  63166. * Default value : false. The PCS is faster when it's set to false.
  63167. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63168. */
  63169. get computeParticleColor(): boolean;
  63170. /**
  63171. * Gets if `setParticles()` computes the particle textures or not.
  63172. * Default value : false. The PCS is faster when it's set to false.
  63173. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63174. */
  63175. get computeParticleTexture(): boolean;
  63176. /**
  63177. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63178. */
  63179. set computeBoundingBox(val: boolean);
  63180. /**
  63181. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63182. */
  63183. get computeBoundingBox(): boolean;
  63184. /**
  63185. * This function does nothing. It may be overwritten to set all the particle first values.
  63186. * The PCS doesn't call this function, you may have to call it by your own.
  63187. * doc :
  63188. */
  63189. initParticles(): void;
  63190. /**
  63191. * This function does nothing. It may be overwritten to recycle a particle
  63192. * The PCS doesn't call this function, you can to call it
  63193. * doc :
  63194. * @param particle The particle to recycle
  63195. * @returns the recycled particle
  63196. */
  63197. recycleParticle(particle: CloudPoint): CloudPoint;
  63198. /**
  63199. * Updates a particle : this function should be overwritten by the user.
  63200. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63201. * doc :
  63202. * @example : just set a particle position or velocity and recycle conditions
  63203. * @param particle The particle to update
  63204. * @returns the updated particle
  63205. */
  63206. updateParticle(particle: CloudPoint): CloudPoint;
  63207. /**
  63208. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63209. * This does nothing and may be overwritten by the user.
  63210. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63211. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63212. * @param update the boolean update value actually passed to setParticles()
  63213. */
  63214. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63215. /**
  63216. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63217. * This will be passed three parameters.
  63218. * This does nothing and may be overwritten by the user.
  63219. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63220. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63221. * @param update the boolean update value actually passed to setParticles()
  63222. */
  63223. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63224. }
  63225. }
  63226. declare module BABYLON {
  63227. /**
  63228. * Represents one particle of a points cloud system.
  63229. */
  63230. export class CloudPoint {
  63231. /**
  63232. * particle global index
  63233. */
  63234. idx: number;
  63235. /**
  63236. * The color of the particle
  63237. */
  63238. color: Nullable<Color4>;
  63239. /**
  63240. * The world space position of the particle.
  63241. */
  63242. position: Vector3;
  63243. /**
  63244. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63245. */
  63246. rotation: Vector3;
  63247. /**
  63248. * The world space rotation quaternion of the particle.
  63249. */
  63250. rotationQuaternion: Nullable<Quaternion>;
  63251. /**
  63252. * The uv of the particle.
  63253. */
  63254. uv: Nullable<Vector2>;
  63255. /**
  63256. * The current speed of the particle.
  63257. */
  63258. velocity: Vector3;
  63259. /**
  63260. * The pivot point in the particle local space.
  63261. */
  63262. pivot: Vector3;
  63263. /**
  63264. * Must the particle be translated from its pivot point in its local space ?
  63265. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63266. * Default : false
  63267. */
  63268. translateFromPivot: boolean;
  63269. /**
  63270. * Index of this particle in the global "positions" array (Internal use)
  63271. * @hidden
  63272. */
  63273. _pos: number;
  63274. /**
  63275. * @hidden Index of this particle in the global "indices" array (Internal use)
  63276. */
  63277. _ind: number;
  63278. /**
  63279. * Group this particle belongs to
  63280. */
  63281. _group: PointsGroup;
  63282. /**
  63283. * Group id of this particle
  63284. */
  63285. groupId: number;
  63286. /**
  63287. * Index of the particle in its group id (Internal use)
  63288. */
  63289. idxInGroup: number;
  63290. /**
  63291. * @hidden Particle BoundingInfo object (Internal use)
  63292. */
  63293. _boundingInfo: BoundingInfo;
  63294. /**
  63295. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63296. */
  63297. _pcs: PointsCloudSystem;
  63298. /**
  63299. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63300. */
  63301. _stillInvisible: boolean;
  63302. /**
  63303. * @hidden Last computed particle rotation matrix
  63304. */
  63305. _rotationMatrix: number[];
  63306. /**
  63307. * Parent particle Id, if any.
  63308. * Default null.
  63309. */
  63310. parentId: Nullable<number>;
  63311. /**
  63312. * @hidden Internal global position in the PCS.
  63313. */
  63314. _globalPosition: Vector3;
  63315. /**
  63316. * Creates a Point Cloud object.
  63317. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63318. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63319. * @param group (PointsGroup) is the group the particle belongs to
  63320. * @param groupId (integer) is the group identifier in the PCS.
  63321. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63322. * @param pcs defines the PCS it is associated to
  63323. */
  63324. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63325. /**
  63326. * get point size
  63327. */
  63328. get size(): Vector3;
  63329. /**
  63330. * Set point size
  63331. */
  63332. set size(scale: Vector3);
  63333. /**
  63334. * Legacy support, changed quaternion to rotationQuaternion
  63335. */
  63336. get quaternion(): Nullable<Quaternion>;
  63337. /**
  63338. * Legacy support, changed quaternion to rotationQuaternion
  63339. */
  63340. set quaternion(q: Nullable<Quaternion>);
  63341. /**
  63342. * Returns a boolean. True if the particle intersects a mesh, else false
  63343. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63344. * @param target is the object (point or mesh) what the intersection is computed against
  63345. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63346. * @returns true if it intersects
  63347. */
  63348. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63349. /**
  63350. * get the rotation matrix of the particle
  63351. * @hidden
  63352. */
  63353. getRotationMatrix(m: Matrix): void;
  63354. }
  63355. /**
  63356. * Represents a group of points in a points cloud system
  63357. * * PCS internal tool, don't use it manually.
  63358. */
  63359. export class PointsGroup {
  63360. /**
  63361. * The group id
  63362. * @hidden
  63363. */
  63364. groupID: number;
  63365. /**
  63366. * image data for group (internal use)
  63367. * @hidden
  63368. */
  63369. _groupImageData: Nullable<ArrayBufferView>;
  63370. /**
  63371. * Image Width (internal use)
  63372. * @hidden
  63373. */
  63374. _groupImgWidth: number;
  63375. /**
  63376. * Image Height (internal use)
  63377. * @hidden
  63378. */
  63379. _groupImgHeight: number;
  63380. /**
  63381. * Custom position function (internal use)
  63382. * @hidden
  63383. */
  63384. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63385. /**
  63386. * density per facet for surface points
  63387. * @hidden
  63388. */
  63389. _groupDensity: number[];
  63390. /**
  63391. * Only when points are colored by texture carries pointer to texture list array
  63392. * @hidden
  63393. */
  63394. _textureNb: number;
  63395. /**
  63396. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63397. * PCS internal tool, don't use it manually.
  63398. * @hidden
  63399. */
  63400. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63401. }
  63402. }
  63403. declare module BABYLON {
  63404. interface Scene {
  63405. /** @hidden (Backing field) */
  63406. _physicsEngine: Nullable<IPhysicsEngine>;
  63407. /** @hidden */
  63408. _physicsTimeAccumulator: number;
  63409. /**
  63410. * Gets the current physics engine
  63411. * @returns a IPhysicsEngine or null if none attached
  63412. */
  63413. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63414. /**
  63415. * Enables physics to the current scene
  63416. * @param gravity defines the scene's gravity for the physics engine
  63417. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63418. * @return a boolean indicating if the physics engine was initialized
  63419. */
  63420. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63421. /**
  63422. * Disables and disposes the physics engine associated with the scene
  63423. */
  63424. disablePhysicsEngine(): void;
  63425. /**
  63426. * Gets a boolean indicating if there is an active physics engine
  63427. * @returns a boolean indicating if there is an active physics engine
  63428. */
  63429. isPhysicsEnabled(): boolean;
  63430. /**
  63431. * Deletes a physics compound impostor
  63432. * @param compound defines the compound to delete
  63433. */
  63434. deleteCompoundImpostor(compound: any): void;
  63435. /**
  63436. * An event triggered when physic simulation is about to be run
  63437. */
  63438. onBeforePhysicsObservable: Observable<Scene>;
  63439. /**
  63440. * An event triggered when physic simulation has been done
  63441. */
  63442. onAfterPhysicsObservable: Observable<Scene>;
  63443. }
  63444. interface AbstractMesh {
  63445. /** @hidden */
  63446. _physicsImpostor: Nullable<PhysicsImpostor>;
  63447. /**
  63448. * Gets or sets impostor used for physic simulation
  63449. * @see http://doc.babylonjs.com/features/physics_engine
  63450. */
  63451. physicsImpostor: Nullable<PhysicsImpostor>;
  63452. /**
  63453. * Gets the current physics impostor
  63454. * @see http://doc.babylonjs.com/features/physics_engine
  63455. * @returns a physics impostor or null
  63456. */
  63457. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63458. /** Apply a physic impulse to the mesh
  63459. * @param force defines the force to apply
  63460. * @param contactPoint defines where to apply the force
  63461. * @returns the current mesh
  63462. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63463. */
  63464. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63465. /**
  63466. * Creates a physic joint between two meshes
  63467. * @param otherMesh defines the other mesh to use
  63468. * @param pivot1 defines the pivot to use on this mesh
  63469. * @param pivot2 defines the pivot to use on the other mesh
  63470. * @param options defines additional options (can be plugin dependent)
  63471. * @returns the current mesh
  63472. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63473. */
  63474. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63475. /** @hidden */
  63476. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63477. }
  63478. /**
  63479. * Defines the physics engine scene component responsible to manage a physics engine
  63480. */
  63481. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63482. /**
  63483. * The component name helpful to identify the component in the list of scene components.
  63484. */
  63485. readonly name: string;
  63486. /**
  63487. * The scene the component belongs to.
  63488. */
  63489. scene: Scene;
  63490. /**
  63491. * Creates a new instance of the component for the given scene
  63492. * @param scene Defines the scene to register the component in
  63493. */
  63494. constructor(scene: Scene);
  63495. /**
  63496. * Registers the component in a given scene
  63497. */
  63498. register(): void;
  63499. /**
  63500. * Rebuilds the elements related to this component in case of
  63501. * context lost for instance.
  63502. */
  63503. rebuild(): void;
  63504. /**
  63505. * Disposes the component and the associated ressources
  63506. */
  63507. dispose(): void;
  63508. }
  63509. }
  63510. declare module BABYLON {
  63511. /**
  63512. * A helper for physics simulations
  63513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63514. */
  63515. export class PhysicsHelper {
  63516. private _scene;
  63517. private _physicsEngine;
  63518. /**
  63519. * Initializes the Physics helper
  63520. * @param scene Babylon.js scene
  63521. */
  63522. constructor(scene: Scene);
  63523. /**
  63524. * Applies a radial explosion impulse
  63525. * @param origin the origin of the explosion
  63526. * @param radiusOrEventOptions the radius or the options of radial explosion
  63527. * @param strength the explosion strength
  63528. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63529. * @returns A physics radial explosion event, or null
  63530. */
  63531. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63532. /**
  63533. * Applies a radial explosion force
  63534. * @param origin the origin of the explosion
  63535. * @param radiusOrEventOptions the radius or the options of radial explosion
  63536. * @param strength the explosion strength
  63537. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63538. * @returns A physics radial explosion event, or null
  63539. */
  63540. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63541. /**
  63542. * Creates a gravitational field
  63543. * @param origin the origin of the explosion
  63544. * @param radiusOrEventOptions the radius or the options of radial explosion
  63545. * @param strength the explosion strength
  63546. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63547. * @returns A physics gravitational field event, or null
  63548. */
  63549. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63550. /**
  63551. * Creates a physics updraft event
  63552. * @param origin the origin of the updraft
  63553. * @param radiusOrEventOptions the radius or the options of the updraft
  63554. * @param strength the strength of the updraft
  63555. * @param height the height of the updraft
  63556. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63557. * @returns A physics updraft event, or null
  63558. */
  63559. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63560. /**
  63561. * Creates a physics vortex event
  63562. * @param origin the of the vortex
  63563. * @param radiusOrEventOptions the radius or the options of the vortex
  63564. * @param strength the strength of the vortex
  63565. * @param height the height of the vortex
  63566. * @returns a Physics vortex event, or null
  63567. * A physics vortex event or null
  63568. */
  63569. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63570. }
  63571. /**
  63572. * Represents a physics radial explosion event
  63573. */
  63574. class PhysicsRadialExplosionEvent {
  63575. private _scene;
  63576. private _options;
  63577. private _sphere;
  63578. private _dataFetched;
  63579. /**
  63580. * Initializes a radial explosioin event
  63581. * @param _scene BabylonJS scene
  63582. * @param _options The options for the vortex event
  63583. */
  63584. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63585. /**
  63586. * Returns the data related to the radial explosion event (sphere).
  63587. * @returns The radial explosion event data
  63588. */
  63589. getData(): PhysicsRadialExplosionEventData;
  63590. /**
  63591. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63592. * @param impostor A physics imposter
  63593. * @param origin the origin of the explosion
  63594. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63595. */
  63596. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63597. /**
  63598. * Triggers affecterd impostors callbacks
  63599. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63600. */
  63601. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63602. /**
  63603. * Disposes the sphere.
  63604. * @param force Specifies if the sphere should be disposed by force
  63605. */
  63606. dispose(force?: boolean): void;
  63607. /*** Helpers ***/
  63608. private _prepareSphere;
  63609. private _intersectsWithSphere;
  63610. }
  63611. /**
  63612. * Represents a gravitational field event
  63613. */
  63614. class PhysicsGravitationalFieldEvent {
  63615. private _physicsHelper;
  63616. private _scene;
  63617. private _origin;
  63618. private _options;
  63619. private _tickCallback;
  63620. private _sphere;
  63621. private _dataFetched;
  63622. /**
  63623. * Initializes the physics gravitational field event
  63624. * @param _physicsHelper A physics helper
  63625. * @param _scene BabylonJS scene
  63626. * @param _origin The origin position of the gravitational field event
  63627. * @param _options The options for the vortex event
  63628. */
  63629. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63630. /**
  63631. * Returns the data related to the gravitational field event (sphere).
  63632. * @returns A gravitational field event
  63633. */
  63634. getData(): PhysicsGravitationalFieldEventData;
  63635. /**
  63636. * Enables the gravitational field.
  63637. */
  63638. enable(): void;
  63639. /**
  63640. * Disables the gravitational field.
  63641. */
  63642. disable(): void;
  63643. /**
  63644. * Disposes the sphere.
  63645. * @param force The force to dispose from the gravitational field event
  63646. */
  63647. dispose(force?: boolean): void;
  63648. private _tick;
  63649. }
  63650. /**
  63651. * Represents a physics updraft event
  63652. */
  63653. class PhysicsUpdraftEvent {
  63654. private _scene;
  63655. private _origin;
  63656. private _options;
  63657. private _physicsEngine;
  63658. private _originTop;
  63659. private _originDirection;
  63660. private _tickCallback;
  63661. private _cylinder;
  63662. private _cylinderPosition;
  63663. private _dataFetched;
  63664. /**
  63665. * Initializes the physics updraft event
  63666. * @param _scene BabylonJS scene
  63667. * @param _origin The origin position of the updraft
  63668. * @param _options The options for the updraft event
  63669. */
  63670. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63671. /**
  63672. * Returns the data related to the updraft event (cylinder).
  63673. * @returns A physics updraft event
  63674. */
  63675. getData(): PhysicsUpdraftEventData;
  63676. /**
  63677. * Enables the updraft.
  63678. */
  63679. enable(): void;
  63680. /**
  63681. * Disables the updraft.
  63682. */
  63683. disable(): void;
  63684. /**
  63685. * Disposes the cylinder.
  63686. * @param force Specifies if the updraft should be disposed by force
  63687. */
  63688. dispose(force?: boolean): void;
  63689. private getImpostorHitData;
  63690. private _tick;
  63691. /*** Helpers ***/
  63692. private _prepareCylinder;
  63693. private _intersectsWithCylinder;
  63694. }
  63695. /**
  63696. * Represents a physics vortex event
  63697. */
  63698. class PhysicsVortexEvent {
  63699. private _scene;
  63700. private _origin;
  63701. private _options;
  63702. private _physicsEngine;
  63703. private _originTop;
  63704. private _tickCallback;
  63705. private _cylinder;
  63706. private _cylinderPosition;
  63707. private _dataFetched;
  63708. /**
  63709. * Initializes the physics vortex event
  63710. * @param _scene The BabylonJS scene
  63711. * @param _origin The origin position of the vortex
  63712. * @param _options The options for the vortex event
  63713. */
  63714. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63715. /**
  63716. * Returns the data related to the vortex event (cylinder).
  63717. * @returns The physics vortex event data
  63718. */
  63719. getData(): PhysicsVortexEventData;
  63720. /**
  63721. * Enables the vortex.
  63722. */
  63723. enable(): void;
  63724. /**
  63725. * Disables the cortex.
  63726. */
  63727. disable(): void;
  63728. /**
  63729. * Disposes the sphere.
  63730. * @param force
  63731. */
  63732. dispose(force?: boolean): void;
  63733. private getImpostorHitData;
  63734. private _tick;
  63735. /*** Helpers ***/
  63736. private _prepareCylinder;
  63737. private _intersectsWithCylinder;
  63738. }
  63739. /**
  63740. * Options fot the radial explosion event
  63741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63742. */
  63743. export class PhysicsRadialExplosionEventOptions {
  63744. /**
  63745. * The radius of the sphere for the radial explosion.
  63746. */
  63747. radius: number;
  63748. /**
  63749. * The strenth of the explosion.
  63750. */
  63751. strength: number;
  63752. /**
  63753. * The strenght of the force in correspondence to the distance of the affected object
  63754. */
  63755. falloff: PhysicsRadialImpulseFalloff;
  63756. /**
  63757. * Sphere options for the radial explosion.
  63758. */
  63759. sphere: {
  63760. segments: number;
  63761. diameter: number;
  63762. };
  63763. /**
  63764. * Sphere options for the radial explosion.
  63765. */
  63766. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63767. }
  63768. /**
  63769. * Options fot the updraft event
  63770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63771. */
  63772. export class PhysicsUpdraftEventOptions {
  63773. /**
  63774. * The radius of the cylinder for the vortex
  63775. */
  63776. radius: number;
  63777. /**
  63778. * The strenth of the updraft.
  63779. */
  63780. strength: number;
  63781. /**
  63782. * The height of the cylinder for the updraft.
  63783. */
  63784. height: number;
  63785. /**
  63786. * The mode for the the updraft.
  63787. */
  63788. updraftMode: PhysicsUpdraftMode;
  63789. }
  63790. /**
  63791. * Options fot the vortex event
  63792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63793. */
  63794. export class PhysicsVortexEventOptions {
  63795. /**
  63796. * The radius of the cylinder for the vortex
  63797. */
  63798. radius: number;
  63799. /**
  63800. * The strenth of the vortex.
  63801. */
  63802. strength: number;
  63803. /**
  63804. * The height of the cylinder for the vortex.
  63805. */
  63806. height: number;
  63807. /**
  63808. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63809. */
  63810. centripetalForceThreshold: number;
  63811. /**
  63812. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63813. */
  63814. centripetalForceMultiplier: number;
  63815. /**
  63816. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63817. */
  63818. centrifugalForceMultiplier: number;
  63819. /**
  63820. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63821. */
  63822. updraftForceMultiplier: number;
  63823. }
  63824. /**
  63825. * The strenght of the force in correspondence to the distance of the affected object
  63826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63827. */
  63828. export enum PhysicsRadialImpulseFalloff {
  63829. /** Defines that impulse is constant in strength across it's whole radius */
  63830. Constant = 0,
  63831. /** Defines that impulse gets weaker if it's further from the origin */
  63832. Linear = 1
  63833. }
  63834. /**
  63835. * The strength of the force in correspondence to the distance of the affected object
  63836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63837. */
  63838. export enum PhysicsUpdraftMode {
  63839. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63840. Center = 0,
  63841. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63842. Perpendicular = 1
  63843. }
  63844. /**
  63845. * Interface for a physics hit data
  63846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63847. */
  63848. export interface PhysicsHitData {
  63849. /**
  63850. * The force applied at the contact point
  63851. */
  63852. force: Vector3;
  63853. /**
  63854. * The contact point
  63855. */
  63856. contactPoint: Vector3;
  63857. /**
  63858. * The distance from the origin to the contact point
  63859. */
  63860. distanceFromOrigin: number;
  63861. }
  63862. /**
  63863. * Interface for radial explosion event data
  63864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63865. */
  63866. export interface PhysicsRadialExplosionEventData {
  63867. /**
  63868. * A sphere used for the radial explosion event
  63869. */
  63870. sphere: Mesh;
  63871. }
  63872. /**
  63873. * Interface for gravitational field event data
  63874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63875. */
  63876. export interface PhysicsGravitationalFieldEventData {
  63877. /**
  63878. * A sphere mesh used for the gravitational field event
  63879. */
  63880. sphere: Mesh;
  63881. }
  63882. /**
  63883. * Interface for updraft event data
  63884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63885. */
  63886. export interface PhysicsUpdraftEventData {
  63887. /**
  63888. * A cylinder used for the updraft event
  63889. */
  63890. cylinder: Mesh;
  63891. }
  63892. /**
  63893. * Interface for vortex event data
  63894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63895. */
  63896. export interface PhysicsVortexEventData {
  63897. /**
  63898. * A cylinder used for the vortex event
  63899. */
  63900. cylinder: Mesh;
  63901. }
  63902. /**
  63903. * Interface for an affected physics impostor
  63904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63905. */
  63906. export interface PhysicsAffectedImpostorWithData {
  63907. /**
  63908. * The impostor affected by the effect
  63909. */
  63910. impostor: PhysicsImpostor;
  63911. /**
  63912. * The data about the hit/horce from the explosion
  63913. */
  63914. hitData: PhysicsHitData;
  63915. }
  63916. }
  63917. declare module BABYLON {
  63918. /** @hidden */
  63919. export var blackAndWhitePixelShader: {
  63920. name: string;
  63921. shader: string;
  63922. };
  63923. }
  63924. declare module BABYLON {
  63925. /**
  63926. * Post process used to render in black and white
  63927. */
  63928. export class BlackAndWhitePostProcess extends PostProcess {
  63929. /**
  63930. * Linear about to convert he result to black and white (default: 1)
  63931. */
  63932. degree: number;
  63933. /**
  63934. * Creates a black and white post process
  63935. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63936. * @param name The name of the effect.
  63937. * @param options The required width/height ratio to downsize to before computing the render pass.
  63938. * @param camera The camera to apply the render pass to.
  63939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63940. * @param engine The engine which the post process will be applied. (default: current engine)
  63941. * @param reusable If the post process can be reused on the same frame. (default: false)
  63942. */
  63943. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63944. }
  63945. }
  63946. declare module BABYLON {
  63947. /**
  63948. * This represents a set of one or more post processes in Babylon.
  63949. * A post process can be used to apply a shader to a texture after it is rendered.
  63950. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63951. */
  63952. export class PostProcessRenderEffect {
  63953. private _postProcesses;
  63954. private _getPostProcesses;
  63955. private _singleInstance;
  63956. private _cameras;
  63957. private _indicesForCamera;
  63958. /**
  63959. * Name of the effect
  63960. * @hidden
  63961. */
  63962. _name: string;
  63963. /**
  63964. * Instantiates a post process render effect.
  63965. * A post process can be used to apply a shader to a texture after it is rendered.
  63966. * @param engine The engine the effect is tied to
  63967. * @param name The name of the effect
  63968. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63969. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63970. */
  63971. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63972. /**
  63973. * Checks if all the post processes in the effect are supported.
  63974. */
  63975. get isSupported(): boolean;
  63976. /**
  63977. * Updates the current state of the effect
  63978. * @hidden
  63979. */
  63980. _update(): void;
  63981. /**
  63982. * Attaches the effect on cameras
  63983. * @param cameras The camera to attach to.
  63984. * @hidden
  63985. */
  63986. _attachCameras(cameras: Camera): void;
  63987. /**
  63988. * Attaches the effect on cameras
  63989. * @param cameras The camera to attach to.
  63990. * @hidden
  63991. */
  63992. _attachCameras(cameras: Camera[]): void;
  63993. /**
  63994. * Detaches the effect on cameras
  63995. * @param cameras The camera to detatch from.
  63996. * @hidden
  63997. */
  63998. _detachCameras(cameras: Camera): void;
  63999. /**
  64000. * Detatches the effect on cameras
  64001. * @param cameras The camera to detatch from.
  64002. * @hidden
  64003. */
  64004. _detachCameras(cameras: Camera[]): void;
  64005. /**
  64006. * Enables the effect on given cameras
  64007. * @param cameras The camera to enable.
  64008. * @hidden
  64009. */
  64010. _enable(cameras: Camera): void;
  64011. /**
  64012. * Enables the effect on given cameras
  64013. * @param cameras The camera to enable.
  64014. * @hidden
  64015. */
  64016. _enable(cameras: Nullable<Camera[]>): void;
  64017. /**
  64018. * Disables the effect on the given cameras
  64019. * @param cameras The camera to disable.
  64020. * @hidden
  64021. */
  64022. _disable(cameras: Camera): void;
  64023. /**
  64024. * Disables the effect on the given cameras
  64025. * @param cameras The camera to disable.
  64026. * @hidden
  64027. */
  64028. _disable(cameras: Nullable<Camera[]>): void;
  64029. /**
  64030. * Gets a list of the post processes contained in the effect.
  64031. * @param camera The camera to get the post processes on.
  64032. * @returns The list of the post processes in the effect.
  64033. */
  64034. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64035. }
  64036. }
  64037. declare module BABYLON {
  64038. /** @hidden */
  64039. export var extractHighlightsPixelShader: {
  64040. name: string;
  64041. shader: string;
  64042. };
  64043. }
  64044. declare module BABYLON {
  64045. /**
  64046. * 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.
  64047. */
  64048. export class ExtractHighlightsPostProcess extends PostProcess {
  64049. /**
  64050. * The luminance threshold, pixels below this value will be set to black.
  64051. */
  64052. threshold: number;
  64053. /** @hidden */
  64054. _exposure: number;
  64055. /**
  64056. * Post process which has the input texture to be used when performing highlight extraction
  64057. * @hidden
  64058. */
  64059. _inputPostProcess: Nullable<PostProcess>;
  64060. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64061. }
  64062. }
  64063. declare module BABYLON {
  64064. /** @hidden */
  64065. export var bloomMergePixelShader: {
  64066. name: string;
  64067. shader: string;
  64068. };
  64069. }
  64070. declare module BABYLON {
  64071. /**
  64072. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64073. */
  64074. export class BloomMergePostProcess extends PostProcess {
  64075. /** Weight of the bloom to be added to the original input. */
  64076. weight: number;
  64077. /**
  64078. * Creates a new instance of @see BloomMergePostProcess
  64079. * @param name The name of the effect.
  64080. * @param originalFromInput Post process which's input will be used for the merge.
  64081. * @param blurred Blurred highlights post process which's output will be used.
  64082. * @param weight Weight of the bloom to be added to the original input.
  64083. * @param options The required width/height ratio to downsize to before computing the render pass.
  64084. * @param camera The camera to apply the render pass to.
  64085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64086. * @param engine The engine which the post process will be applied. (default: current engine)
  64087. * @param reusable If the post process can be reused on the same frame. (default: false)
  64088. * @param textureType Type of textures used when performing the post process. (default: 0)
  64089. * @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)
  64090. */
  64091. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64092. /** Weight of the bloom to be added to the original input. */
  64093. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64094. }
  64095. }
  64096. declare module BABYLON {
  64097. /**
  64098. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64099. */
  64100. export class BloomEffect extends PostProcessRenderEffect {
  64101. private bloomScale;
  64102. /**
  64103. * @hidden Internal
  64104. */
  64105. _effects: Array<PostProcess>;
  64106. /**
  64107. * @hidden Internal
  64108. */
  64109. _downscale: ExtractHighlightsPostProcess;
  64110. private _blurX;
  64111. private _blurY;
  64112. private _merge;
  64113. /**
  64114. * The luminance threshold to find bright areas of the image to bloom.
  64115. */
  64116. get threshold(): number;
  64117. set threshold(value: number);
  64118. /**
  64119. * The strength of the bloom.
  64120. */
  64121. get weight(): number;
  64122. set weight(value: number);
  64123. /**
  64124. * Specifies the size of the bloom blur kernel, relative to the final output size
  64125. */
  64126. get kernel(): number;
  64127. set kernel(value: number);
  64128. /**
  64129. * Creates a new instance of @see BloomEffect
  64130. * @param scene The scene the effect belongs to.
  64131. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64132. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64133. * @param bloomWeight The the strength of bloom.
  64134. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64135. * @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)
  64136. */
  64137. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64138. /**
  64139. * Disposes each of the internal effects for a given camera.
  64140. * @param camera The camera to dispose the effect on.
  64141. */
  64142. disposeEffects(camera: Camera): void;
  64143. /**
  64144. * @hidden Internal
  64145. */
  64146. _updateEffects(): void;
  64147. /**
  64148. * Internal
  64149. * @returns if all the contained post processes are ready.
  64150. * @hidden
  64151. */
  64152. _isReady(): boolean;
  64153. }
  64154. }
  64155. declare module BABYLON {
  64156. /** @hidden */
  64157. export var chromaticAberrationPixelShader: {
  64158. name: string;
  64159. shader: string;
  64160. };
  64161. }
  64162. declare module BABYLON {
  64163. /**
  64164. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64165. */
  64166. export class ChromaticAberrationPostProcess extends PostProcess {
  64167. /**
  64168. * The amount of seperation of rgb channels (default: 30)
  64169. */
  64170. aberrationAmount: number;
  64171. /**
  64172. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64173. */
  64174. radialIntensity: number;
  64175. /**
  64176. * 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))
  64177. */
  64178. direction: Vector2;
  64179. /**
  64180. * 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))
  64181. */
  64182. centerPosition: Vector2;
  64183. /**
  64184. * Creates a new instance ChromaticAberrationPostProcess
  64185. * @param name The name of the effect.
  64186. * @param screenWidth The width of the screen to apply the effect on.
  64187. * @param screenHeight The height of the screen to apply the effect on.
  64188. * @param options The required width/height ratio to downsize to before computing the render pass.
  64189. * @param camera The camera to apply the render pass to.
  64190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64191. * @param engine The engine which the post process will be applied. (default: current engine)
  64192. * @param reusable If the post process can be reused on the same frame. (default: false)
  64193. * @param textureType Type of textures used when performing the post process. (default: 0)
  64194. * @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)
  64195. */
  64196. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64197. }
  64198. }
  64199. declare module BABYLON {
  64200. /** @hidden */
  64201. export var circleOfConfusionPixelShader: {
  64202. name: string;
  64203. shader: string;
  64204. };
  64205. }
  64206. declare module BABYLON {
  64207. /**
  64208. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64209. */
  64210. export class CircleOfConfusionPostProcess extends PostProcess {
  64211. /**
  64212. * 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.
  64213. */
  64214. lensSize: number;
  64215. /**
  64216. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64217. */
  64218. fStop: number;
  64219. /**
  64220. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64221. */
  64222. focusDistance: number;
  64223. /**
  64224. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64225. */
  64226. focalLength: number;
  64227. private _depthTexture;
  64228. /**
  64229. * Creates a new instance CircleOfConfusionPostProcess
  64230. * @param name The name of the effect.
  64231. * @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.
  64232. * @param options The required width/height ratio to downsize to before computing the render pass.
  64233. * @param camera The camera to apply the render pass to.
  64234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64235. * @param engine The engine which the post process will be applied. (default: current engine)
  64236. * @param reusable If the post process can be reused on the same frame. (default: false)
  64237. * @param textureType Type of textures used when performing the post process. (default: 0)
  64238. * @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)
  64239. */
  64240. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64241. /**
  64242. * 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.
  64243. */
  64244. set depthTexture(value: RenderTargetTexture);
  64245. }
  64246. }
  64247. declare module BABYLON {
  64248. /** @hidden */
  64249. export var colorCorrectionPixelShader: {
  64250. name: string;
  64251. shader: string;
  64252. };
  64253. }
  64254. declare module BABYLON {
  64255. /**
  64256. *
  64257. * This post-process allows the modification of rendered colors by using
  64258. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64259. *
  64260. * The object needs to be provided an url to a texture containing the color
  64261. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64262. * Use an image editing software to tweak the LUT to match your needs.
  64263. *
  64264. * For an example of a color LUT, see here:
  64265. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64266. * For explanations on color grading, see here:
  64267. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64268. *
  64269. */
  64270. export class ColorCorrectionPostProcess extends PostProcess {
  64271. private _colorTableTexture;
  64272. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64273. }
  64274. }
  64275. declare module BABYLON {
  64276. /** @hidden */
  64277. export var convolutionPixelShader: {
  64278. name: string;
  64279. shader: string;
  64280. };
  64281. }
  64282. declare module BABYLON {
  64283. /**
  64284. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64285. * input texture to perform effects such as edge detection or sharpening
  64286. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64287. */
  64288. export class ConvolutionPostProcess extends PostProcess {
  64289. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64290. kernel: number[];
  64291. /**
  64292. * Creates a new instance ConvolutionPostProcess
  64293. * @param name The name of the effect.
  64294. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64295. * @param options The required width/height ratio to downsize to before computing the render pass.
  64296. * @param camera The camera to apply the render pass to.
  64297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64298. * @param engine The engine which the post process will be applied. (default: current engine)
  64299. * @param reusable If the post process can be reused on the same frame. (default: false)
  64300. * @param textureType Type of textures used when performing the post process. (default: 0)
  64301. */
  64302. constructor(name: string,
  64303. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64304. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64305. /**
  64306. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64307. */
  64308. static EdgeDetect0Kernel: number[];
  64309. /**
  64310. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64311. */
  64312. static EdgeDetect1Kernel: number[];
  64313. /**
  64314. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64315. */
  64316. static EdgeDetect2Kernel: number[];
  64317. /**
  64318. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64319. */
  64320. static SharpenKernel: number[];
  64321. /**
  64322. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64323. */
  64324. static EmbossKernel: number[];
  64325. /**
  64326. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64327. */
  64328. static GaussianKernel: number[];
  64329. }
  64330. }
  64331. declare module BABYLON {
  64332. /**
  64333. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64334. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64335. * based on samples that have a large difference in distance than the center pixel.
  64336. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64337. */
  64338. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64339. direction: Vector2;
  64340. /**
  64341. * Creates a new instance CircleOfConfusionPostProcess
  64342. * @param name The name of the effect.
  64343. * @param scene The scene the effect belongs to.
  64344. * @param direction The direction the blur should be applied.
  64345. * @param kernel The size of the kernel used to blur.
  64346. * @param options The required width/height ratio to downsize to before computing the render pass.
  64347. * @param camera The camera to apply the render pass to.
  64348. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64349. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64351. * @param engine The engine which the post process will be applied. (default: current engine)
  64352. * @param reusable If the post process can be reused on the same frame. (default: false)
  64353. * @param textureType Type of textures used when performing the post process. (default: 0)
  64354. * @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)
  64355. */
  64356. 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);
  64357. }
  64358. }
  64359. declare module BABYLON {
  64360. /** @hidden */
  64361. export var depthOfFieldMergePixelShader: {
  64362. name: string;
  64363. shader: string;
  64364. };
  64365. }
  64366. declare module BABYLON {
  64367. /**
  64368. * Options to be set when merging outputs from the default pipeline.
  64369. */
  64370. export class DepthOfFieldMergePostProcessOptions {
  64371. /**
  64372. * The original image to merge on top of
  64373. */
  64374. originalFromInput: PostProcess;
  64375. /**
  64376. * Parameters to perform the merge of the depth of field effect
  64377. */
  64378. depthOfField?: {
  64379. circleOfConfusion: PostProcess;
  64380. blurSteps: Array<PostProcess>;
  64381. };
  64382. /**
  64383. * Parameters to perform the merge of bloom effect
  64384. */
  64385. bloom?: {
  64386. blurred: PostProcess;
  64387. weight: number;
  64388. };
  64389. }
  64390. /**
  64391. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64392. */
  64393. export class DepthOfFieldMergePostProcess extends PostProcess {
  64394. private blurSteps;
  64395. /**
  64396. * Creates a new instance of DepthOfFieldMergePostProcess
  64397. * @param name The name of the effect.
  64398. * @param originalFromInput Post process which's input will be used for the merge.
  64399. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64400. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64401. * @param options The required width/height ratio to downsize to before computing the render pass.
  64402. * @param camera The camera to apply the render pass to.
  64403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64404. * @param engine The engine which the post process will be applied. (default: current engine)
  64405. * @param reusable If the post process can be reused on the same frame. (default: false)
  64406. * @param textureType Type of textures used when performing the post process. (default: 0)
  64407. * @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)
  64408. */
  64409. 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);
  64410. /**
  64411. * Updates the effect with the current post process compile time values and recompiles the shader.
  64412. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64413. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64414. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64415. * @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
  64416. * @param onCompiled Called when the shader has been compiled.
  64417. * @param onError Called if there is an error when compiling a shader.
  64418. */
  64419. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64420. }
  64421. }
  64422. declare module BABYLON {
  64423. /**
  64424. * Specifies the level of max blur that should be applied when using the depth of field effect
  64425. */
  64426. export enum DepthOfFieldEffectBlurLevel {
  64427. /**
  64428. * Subtle blur
  64429. */
  64430. Low = 0,
  64431. /**
  64432. * Medium blur
  64433. */
  64434. Medium = 1,
  64435. /**
  64436. * Large blur
  64437. */
  64438. High = 2
  64439. }
  64440. /**
  64441. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64442. */
  64443. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64444. private _circleOfConfusion;
  64445. /**
  64446. * @hidden Internal, blurs from high to low
  64447. */
  64448. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64449. private _depthOfFieldBlurY;
  64450. private _dofMerge;
  64451. /**
  64452. * @hidden Internal post processes in depth of field effect
  64453. */
  64454. _effects: Array<PostProcess>;
  64455. /**
  64456. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64457. */
  64458. set focalLength(value: number);
  64459. get focalLength(): number;
  64460. /**
  64461. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64462. */
  64463. set fStop(value: number);
  64464. get fStop(): number;
  64465. /**
  64466. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64467. */
  64468. set focusDistance(value: number);
  64469. get focusDistance(): number;
  64470. /**
  64471. * 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.
  64472. */
  64473. set lensSize(value: number);
  64474. get lensSize(): number;
  64475. /**
  64476. * Creates a new instance DepthOfFieldEffect
  64477. * @param scene The scene the effect belongs to.
  64478. * @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.
  64479. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64480. * @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)
  64481. */
  64482. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64483. /**
  64484. * Get the current class name of the current effet
  64485. * @returns "DepthOfFieldEffect"
  64486. */
  64487. getClassName(): string;
  64488. /**
  64489. * 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.
  64490. */
  64491. set depthTexture(value: RenderTargetTexture);
  64492. /**
  64493. * Disposes each of the internal effects for a given camera.
  64494. * @param camera The camera to dispose the effect on.
  64495. */
  64496. disposeEffects(camera: Camera): void;
  64497. /**
  64498. * @hidden Internal
  64499. */
  64500. _updateEffects(): void;
  64501. /**
  64502. * Internal
  64503. * @returns if all the contained post processes are ready.
  64504. * @hidden
  64505. */
  64506. _isReady(): boolean;
  64507. }
  64508. }
  64509. declare module BABYLON {
  64510. /** @hidden */
  64511. export var displayPassPixelShader: {
  64512. name: string;
  64513. shader: string;
  64514. };
  64515. }
  64516. declare module BABYLON {
  64517. /**
  64518. * DisplayPassPostProcess which produces an output the same as it's input
  64519. */
  64520. export class DisplayPassPostProcess extends PostProcess {
  64521. /**
  64522. * Creates the DisplayPassPostProcess
  64523. * @param name The name of the effect.
  64524. * @param options The required width/height ratio to downsize to before computing the render pass.
  64525. * @param camera The camera to apply the render pass to.
  64526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64527. * @param engine The engine which the post process will be applied. (default: current engine)
  64528. * @param reusable If the post process can be reused on the same frame. (default: false)
  64529. */
  64530. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64531. }
  64532. }
  64533. declare module BABYLON {
  64534. /** @hidden */
  64535. export var filterPixelShader: {
  64536. name: string;
  64537. shader: string;
  64538. };
  64539. }
  64540. declare module BABYLON {
  64541. /**
  64542. * Applies a kernel filter to the image
  64543. */
  64544. export class FilterPostProcess extends PostProcess {
  64545. /** The matrix to be applied to the image */
  64546. kernelMatrix: Matrix;
  64547. /**
  64548. *
  64549. * @param name The name of the effect.
  64550. * @param kernelMatrix The matrix to be applied to the image
  64551. * @param options The required width/height ratio to downsize to before computing the render pass.
  64552. * @param camera The camera to apply the render pass to.
  64553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64554. * @param engine The engine which the post process will be applied. (default: current engine)
  64555. * @param reusable If the post process can be reused on the same frame. (default: false)
  64556. */
  64557. constructor(name: string,
  64558. /** The matrix to be applied to the image */
  64559. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64560. }
  64561. }
  64562. declare module BABYLON {
  64563. /** @hidden */
  64564. export var fxaaPixelShader: {
  64565. name: string;
  64566. shader: string;
  64567. };
  64568. }
  64569. declare module BABYLON {
  64570. /** @hidden */
  64571. export var fxaaVertexShader: {
  64572. name: string;
  64573. shader: string;
  64574. };
  64575. }
  64576. declare module BABYLON {
  64577. /**
  64578. * Fxaa post process
  64579. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64580. */
  64581. export class FxaaPostProcess extends PostProcess {
  64582. /** @hidden */
  64583. texelWidth: number;
  64584. /** @hidden */
  64585. texelHeight: number;
  64586. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64587. private _getDefines;
  64588. }
  64589. }
  64590. declare module BABYLON {
  64591. /** @hidden */
  64592. export var grainPixelShader: {
  64593. name: string;
  64594. shader: string;
  64595. };
  64596. }
  64597. declare module BABYLON {
  64598. /**
  64599. * The GrainPostProcess adds noise to the image at mid luminance levels
  64600. */
  64601. export class GrainPostProcess extends PostProcess {
  64602. /**
  64603. * The intensity of the grain added (default: 30)
  64604. */
  64605. intensity: number;
  64606. /**
  64607. * If the grain should be randomized on every frame
  64608. */
  64609. animated: boolean;
  64610. /**
  64611. * Creates a new instance of @see GrainPostProcess
  64612. * @param name The name of the effect.
  64613. * @param options The required width/height ratio to downsize to before computing the render pass.
  64614. * @param camera The camera to apply the render pass to.
  64615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64616. * @param engine The engine which the post process will be applied. (default: current engine)
  64617. * @param reusable If the post process can be reused on the same frame. (default: false)
  64618. * @param textureType Type of textures used when performing the post process. (default: 0)
  64619. * @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)
  64620. */
  64621. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64622. }
  64623. }
  64624. declare module BABYLON {
  64625. /** @hidden */
  64626. export var highlightsPixelShader: {
  64627. name: string;
  64628. shader: string;
  64629. };
  64630. }
  64631. declare module BABYLON {
  64632. /**
  64633. * Extracts highlights from the image
  64634. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64635. */
  64636. export class HighlightsPostProcess extends PostProcess {
  64637. /**
  64638. * Extracts highlights from the image
  64639. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64640. * @param name The name of the effect.
  64641. * @param options The required width/height ratio to downsize to before computing the render pass.
  64642. * @param camera The camera to apply the render pass to.
  64643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64644. * @param engine The engine which the post process will be applied. (default: current engine)
  64645. * @param reusable If the post process can be reused on the same frame. (default: false)
  64646. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64647. */
  64648. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64649. }
  64650. }
  64651. declare module BABYLON {
  64652. /** @hidden */
  64653. export var mrtFragmentDeclaration: {
  64654. name: string;
  64655. shader: string;
  64656. };
  64657. }
  64658. declare module BABYLON {
  64659. /** @hidden */
  64660. export var geometryPixelShader: {
  64661. name: string;
  64662. shader: string;
  64663. };
  64664. }
  64665. declare module BABYLON {
  64666. /** @hidden */
  64667. export var geometryVertexShader: {
  64668. name: string;
  64669. shader: string;
  64670. };
  64671. }
  64672. declare module BABYLON {
  64673. /** @hidden */
  64674. interface ISavedTransformationMatrix {
  64675. world: Matrix;
  64676. viewProjection: Matrix;
  64677. }
  64678. /**
  64679. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64680. */
  64681. export class GeometryBufferRenderer {
  64682. /**
  64683. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64684. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64685. */
  64686. static readonly POSITION_TEXTURE_TYPE: number;
  64687. /**
  64688. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64689. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64690. */
  64691. static readonly VELOCITY_TEXTURE_TYPE: number;
  64692. /**
  64693. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64694. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64695. */
  64696. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64697. /**
  64698. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64699. * in order to compute objects velocities when enableVelocity is set to "true"
  64700. * @hidden
  64701. */
  64702. _previousTransformationMatrices: {
  64703. [index: number]: ISavedTransformationMatrix;
  64704. };
  64705. /**
  64706. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64707. * in order to compute objects velocities when enableVelocity is set to "true"
  64708. * @hidden
  64709. */
  64710. _previousBonesTransformationMatrices: {
  64711. [index: number]: Float32Array;
  64712. };
  64713. /**
  64714. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64715. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64716. */
  64717. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64718. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64719. renderTransparentMeshes: boolean;
  64720. private _scene;
  64721. private _multiRenderTarget;
  64722. private _ratio;
  64723. private _enablePosition;
  64724. private _enableVelocity;
  64725. private _enableReflectivity;
  64726. private _positionIndex;
  64727. private _velocityIndex;
  64728. private _reflectivityIndex;
  64729. protected _effect: Effect;
  64730. protected _cachedDefines: string;
  64731. /**
  64732. * Set the render list (meshes to be rendered) used in the G buffer.
  64733. */
  64734. set renderList(meshes: Mesh[]);
  64735. /**
  64736. * Gets wether or not G buffer are supported by the running hardware.
  64737. * This requires draw buffer supports
  64738. */
  64739. get isSupported(): boolean;
  64740. /**
  64741. * Returns the index of the given texture type in the G-Buffer textures array
  64742. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64743. * @returns the index of the given texture type in the G-Buffer textures array
  64744. */
  64745. getTextureIndex(textureType: number): number;
  64746. /**
  64747. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64748. */
  64749. get enablePosition(): boolean;
  64750. /**
  64751. * Sets whether or not objects positions are enabled for the G buffer.
  64752. */
  64753. set enablePosition(enable: boolean);
  64754. /**
  64755. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64756. */
  64757. get enableVelocity(): boolean;
  64758. /**
  64759. * Sets wether or not objects velocities are enabled for the G buffer.
  64760. */
  64761. set enableVelocity(enable: boolean);
  64762. /**
  64763. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64764. */
  64765. get enableReflectivity(): boolean;
  64766. /**
  64767. * Sets wether or not objects roughness are enabled for the G buffer.
  64768. */
  64769. set enableReflectivity(enable: boolean);
  64770. /**
  64771. * Gets the scene associated with the buffer.
  64772. */
  64773. get scene(): Scene;
  64774. /**
  64775. * Gets the ratio used by the buffer during its creation.
  64776. * How big is the buffer related to the main canvas.
  64777. */
  64778. get ratio(): number;
  64779. /** @hidden */
  64780. static _SceneComponentInitialization: (scene: Scene) => void;
  64781. /**
  64782. * Creates a new G Buffer for the scene
  64783. * @param scene The scene the buffer belongs to
  64784. * @param ratio How big is the buffer related to the main canvas.
  64785. */
  64786. constructor(scene: Scene, ratio?: number);
  64787. /**
  64788. * Checks wether everything is ready to render a submesh to the G buffer.
  64789. * @param subMesh the submesh to check readiness for
  64790. * @param useInstances is the mesh drawn using instance or not
  64791. * @returns true if ready otherwise false
  64792. */
  64793. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64794. /**
  64795. * Gets the current underlying G Buffer.
  64796. * @returns the buffer
  64797. */
  64798. getGBuffer(): MultiRenderTarget;
  64799. /**
  64800. * Gets the number of samples used to render the buffer (anti aliasing).
  64801. */
  64802. get samples(): number;
  64803. /**
  64804. * Sets the number of samples used to render the buffer (anti aliasing).
  64805. */
  64806. set samples(value: number);
  64807. /**
  64808. * Disposes the renderer and frees up associated resources.
  64809. */
  64810. dispose(): void;
  64811. protected _createRenderTargets(): void;
  64812. private _copyBonesTransformationMatrices;
  64813. }
  64814. }
  64815. declare module BABYLON {
  64816. interface Scene {
  64817. /** @hidden (Backing field) */
  64818. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64819. /**
  64820. * Gets or Sets the current geometry buffer associated to the scene.
  64821. */
  64822. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64823. /**
  64824. * Enables a GeometryBufferRender and associates it with the scene
  64825. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64826. * @returns the GeometryBufferRenderer
  64827. */
  64828. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64829. /**
  64830. * Disables the GeometryBufferRender associated with the scene
  64831. */
  64832. disableGeometryBufferRenderer(): void;
  64833. }
  64834. /**
  64835. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64836. * in several rendering techniques.
  64837. */
  64838. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64839. /**
  64840. * The component name helpful to identify the component in the list of scene components.
  64841. */
  64842. readonly name: string;
  64843. /**
  64844. * The scene the component belongs to.
  64845. */
  64846. scene: Scene;
  64847. /**
  64848. * Creates a new instance of the component for the given scene
  64849. * @param scene Defines the scene to register the component in
  64850. */
  64851. constructor(scene: Scene);
  64852. /**
  64853. * Registers the component in a given scene
  64854. */
  64855. register(): void;
  64856. /**
  64857. * Rebuilds the elements related to this component in case of
  64858. * context lost for instance.
  64859. */
  64860. rebuild(): void;
  64861. /**
  64862. * Disposes the component and the associated ressources
  64863. */
  64864. dispose(): void;
  64865. private _gatherRenderTargets;
  64866. }
  64867. }
  64868. declare module BABYLON {
  64869. /** @hidden */
  64870. export var motionBlurPixelShader: {
  64871. name: string;
  64872. shader: string;
  64873. };
  64874. }
  64875. declare module BABYLON {
  64876. /**
  64877. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64878. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64879. * As an example, all you have to do is to create the post-process:
  64880. * var mb = new BABYLON.MotionBlurPostProcess(
  64881. * 'mb', // The name of the effect.
  64882. * scene, // The scene containing the objects to blur according to their velocity.
  64883. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64884. * camera // The camera to apply the render pass to.
  64885. * );
  64886. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64887. */
  64888. export class MotionBlurPostProcess extends PostProcess {
  64889. /**
  64890. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64891. */
  64892. motionStrength: number;
  64893. /**
  64894. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64895. */
  64896. get motionBlurSamples(): number;
  64897. /**
  64898. * Sets the number of iterations to be used for motion blur quality
  64899. */
  64900. set motionBlurSamples(samples: number);
  64901. private _motionBlurSamples;
  64902. private _geometryBufferRenderer;
  64903. /**
  64904. * Creates a new instance MotionBlurPostProcess
  64905. * @param name The name of the effect.
  64906. * @param scene The scene containing the objects to blur according to their velocity.
  64907. * @param options The required width/height ratio to downsize to before computing the render pass.
  64908. * @param camera The camera to apply the render pass to.
  64909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64910. * @param engine The engine which the post process will be applied. (default: current engine)
  64911. * @param reusable If the post process can be reused on the same frame. (default: false)
  64912. * @param textureType Type of textures used when performing the post process. (default: 0)
  64913. * @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)
  64914. */
  64915. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64916. /**
  64917. * Excludes the given skinned mesh from computing bones velocities.
  64918. * 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.
  64919. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64920. */
  64921. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64922. /**
  64923. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64924. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64925. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64926. */
  64927. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64928. /**
  64929. * Disposes the post process.
  64930. * @param camera The camera to dispose the post process on.
  64931. */
  64932. dispose(camera?: Camera): void;
  64933. }
  64934. }
  64935. declare module BABYLON {
  64936. /** @hidden */
  64937. export var refractionPixelShader: {
  64938. name: string;
  64939. shader: string;
  64940. };
  64941. }
  64942. declare module BABYLON {
  64943. /**
  64944. * Post process which applies a refractin texture
  64945. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64946. */
  64947. export class RefractionPostProcess extends PostProcess {
  64948. /** the base color of the refraction (used to taint the rendering) */
  64949. color: Color3;
  64950. /** simulated refraction depth */
  64951. depth: number;
  64952. /** the coefficient of the base color (0 to remove base color tainting) */
  64953. colorLevel: number;
  64954. private _refTexture;
  64955. private _ownRefractionTexture;
  64956. /**
  64957. * Gets or sets the refraction texture
  64958. * Please note that you are responsible for disposing the texture if you set it manually
  64959. */
  64960. get refractionTexture(): Texture;
  64961. set refractionTexture(value: Texture);
  64962. /**
  64963. * Initializes the RefractionPostProcess
  64964. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64965. * @param name The name of the effect.
  64966. * @param refractionTextureUrl Url of the refraction texture to use
  64967. * @param color the base color of the refraction (used to taint the rendering)
  64968. * @param depth simulated refraction depth
  64969. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64970. * @param camera The camera to apply the render pass to.
  64971. * @param options The required width/height ratio to downsize to before computing the render pass.
  64972. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64973. * @param engine The engine which the post process will be applied. (default: current engine)
  64974. * @param reusable If the post process can be reused on the same frame. (default: false)
  64975. */
  64976. constructor(name: string, refractionTextureUrl: string,
  64977. /** the base color of the refraction (used to taint the rendering) */
  64978. color: Color3,
  64979. /** simulated refraction depth */
  64980. depth: number,
  64981. /** the coefficient of the base color (0 to remove base color tainting) */
  64982. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64983. /**
  64984. * Disposes of the post process
  64985. * @param camera Camera to dispose post process on
  64986. */
  64987. dispose(camera: Camera): void;
  64988. }
  64989. }
  64990. declare module BABYLON {
  64991. /** @hidden */
  64992. export var sharpenPixelShader: {
  64993. name: string;
  64994. shader: string;
  64995. };
  64996. }
  64997. declare module BABYLON {
  64998. /**
  64999. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65000. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65001. */
  65002. export class SharpenPostProcess extends PostProcess {
  65003. /**
  65004. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65005. */
  65006. colorAmount: number;
  65007. /**
  65008. * How much sharpness should be applied (default: 0.3)
  65009. */
  65010. edgeAmount: number;
  65011. /**
  65012. * Creates a new instance ConvolutionPostProcess
  65013. * @param name The name of the effect.
  65014. * @param options The required width/height ratio to downsize to before computing the render pass.
  65015. * @param camera The camera to apply the render pass to.
  65016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65017. * @param engine The engine which the post process will be applied. (default: current engine)
  65018. * @param reusable If the post process can be reused on the same frame. (default: false)
  65019. * @param textureType Type of textures used when performing the post process. (default: 0)
  65020. * @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)
  65021. */
  65022. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65023. }
  65024. }
  65025. declare module BABYLON {
  65026. /**
  65027. * PostProcessRenderPipeline
  65028. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65029. */
  65030. export class PostProcessRenderPipeline {
  65031. private engine;
  65032. private _renderEffects;
  65033. private _renderEffectsForIsolatedPass;
  65034. /**
  65035. * List of inspectable custom properties (used by the Inspector)
  65036. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65037. */
  65038. inspectableCustomProperties: IInspectable[];
  65039. /**
  65040. * @hidden
  65041. */
  65042. protected _cameras: Camera[];
  65043. /** @hidden */
  65044. _name: string;
  65045. /**
  65046. * Gets pipeline name
  65047. */
  65048. get name(): string;
  65049. /** Gets the list of attached cameras */
  65050. get cameras(): Camera[];
  65051. /**
  65052. * Initializes a PostProcessRenderPipeline
  65053. * @param engine engine to add the pipeline to
  65054. * @param name name of the pipeline
  65055. */
  65056. constructor(engine: Engine, name: string);
  65057. /**
  65058. * Gets the class name
  65059. * @returns "PostProcessRenderPipeline"
  65060. */
  65061. getClassName(): string;
  65062. /**
  65063. * If all the render effects in the pipeline are supported
  65064. */
  65065. get isSupported(): boolean;
  65066. /**
  65067. * Adds an effect to the pipeline
  65068. * @param renderEffect the effect to add
  65069. */
  65070. addEffect(renderEffect: PostProcessRenderEffect): void;
  65071. /** @hidden */
  65072. _rebuild(): void;
  65073. /** @hidden */
  65074. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65075. /** @hidden */
  65076. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65077. /** @hidden */
  65078. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65079. /** @hidden */
  65080. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65081. /** @hidden */
  65082. _attachCameras(cameras: Camera, unique: boolean): void;
  65083. /** @hidden */
  65084. _attachCameras(cameras: Camera[], unique: boolean): void;
  65085. /** @hidden */
  65086. _detachCameras(cameras: Camera): void;
  65087. /** @hidden */
  65088. _detachCameras(cameras: Nullable<Camera[]>): void;
  65089. /** @hidden */
  65090. _update(): void;
  65091. /** @hidden */
  65092. _reset(): void;
  65093. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65094. /**
  65095. * Disposes of the pipeline
  65096. */
  65097. dispose(): void;
  65098. }
  65099. }
  65100. declare module BABYLON {
  65101. /**
  65102. * PostProcessRenderPipelineManager class
  65103. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65104. */
  65105. export class PostProcessRenderPipelineManager {
  65106. private _renderPipelines;
  65107. /**
  65108. * Initializes a PostProcessRenderPipelineManager
  65109. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65110. */
  65111. constructor();
  65112. /**
  65113. * Gets the list of supported render pipelines
  65114. */
  65115. get supportedPipelines(): PostProcessRenderPipeline[];
  65116. /**
  65117. * Adds a pipeline to the manager
  65118. * @param renderPipeline The pipeline to add
  65119. */
  65120. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65121. /**
  65122. * Attaches a camera to the pipeline
  65123. * @param renderPipelineName The name of the pipeline to attach to
  65124. * @param cameras the camera to attach
  65125. * @param unique if the camera can be attached multiple times to the pipeline
  65126. */
  65127. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65128. /**
  65129. * Detaches a camera from the pipeline
  65130. * @param renderPipelineName The name of the pipeline to detach from
  65131. * @param cameras the camera to detach
  65132. */
  65133. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65134. /**
  65135. * Enables an effect by name on a pipeline
  65136. * @param renderPipelineName the name of the pipeline to enable the effect in
  65137. * @param renderEffectName the name of the effect to enable
  65138. * @param cameras the cameras that the effect should be enabled on
  65139. */
  65140. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65141. /**
  65142. * Disables an effect by name on a pipeline
  65143. * @param renderPipelineName the name of the pipeline to disable the effect in
  65144. * @param renderEffectName the name of the effect to disable
  65145. * @param cameras the cameras that the effect should be disabled on
  65146. */
  65147. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65148. /**
  65149. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65150. */
  65151. update(): void;
  65152. /** @hidden */
  65153. _rebuild(): void;
  65154. /**
  65155. * Disposes of the manager and pipelines
  65156. */
  65157. dispose(): void;
  65158. }
  65159. }
  65160. declare module BABYLON {
  65161. interface Scene {
  65162. /** @hidden (Backing field) */
  65163. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65164. /**
  65165. * Gets the postprocess render pipeline manager
  65166. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65167. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65168. */
  65169. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65170. }
  65171. /**
  65172. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65173. */
  65174. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65175. /**
  65176. * The component name helpfull to identify the component in the list of scene components.
  65177. */
  65178. readonly name: string;
  65179. /**
  65180. * The scene the component belongs to.
  65181. */
  65182. scene: Scene;
  65183. /**
  65184. * Creates a new instance of the component for the given scene
  65185. * @param scene Defines the scene to register the component in
  65186. */
  65187. constructor(scene: Scene);
  65188. /**
  65189. * Registers the component in a given scene
  65190. */
  65191. register(): void;
  65192. /**
  65193. * Rebuilds the elements related to this component in case of
  65194. * context lost for instance.
  65195. */
  65196. rebuild(): void;
  65197. /**
  65198. * Disposes the component and the associated ressources
  65199. */
  65200. dispose(): void;
  65201. private _gatherRenderTargets;
  65202. }
  65203. }
  65204. declare module BABYLON {
  65205. /**
  65206. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65207. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65208. */
  65209. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65210. private _scene;
  65211. private _camerasToBeAttached;
  65212. /**
  65213. * ID of the sharpen post process,
  65214. */
  65215. private readonly SharpenPostProcessId;
  65216. /**
  65217. * @ignore
  65218. * ID of the image processing post process;
  65219. */
  65220. readonly ImageProcessingPostProcessId: string;
  65221. /**
  65222. * @ignore
  65223. * ID of the Fast Approximate Anti-Aliasing post process;
  65224. */
  65225. readonly FxaaPostProcessId: string;
  65226. /**
  65227. * ID of the chromatic aberration post process,
  65228. */
  65229. private readonly ChromaticAberrationPostProcessId;
  65230. /**
  65231. * ID of the grain post process
  65232. */
  65233. private readonly GrainPostProcessId;
  65234. /**
  65235. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65236. */
  65237. sharpen: SharpenPostProcess;
  65238. private _sharpenEffect;
  65239. private bloom;
  65240. /**
  65241. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65242. */
  65243. depthOfField: DepthOfFieldEffect;
  65244. /**
  65245. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65246. */
  65247. fxaa: FxaaPostProcess;
  65248. /**
  65249. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65250. */
  65251. imageProcessing: ImageProcessingPostProcess;
  65252. /**
  65253. * Chromatic aberration post process which will shift rgb colors in the image
  65254. */
  65255. chromaticAberration: ChromaticAberrationPostProcess;
  65256. private _chromaticAberrationEffect;
  65257. /**
  65258. * Grain post process which add noise to the image
  65259. */
  65260. grain: GrainPostProcess;
  65261. private _grainEffect;
  65262. /**
  65263. * Glow post process which adds a glow to emissive areas of the image
  65264. */
  65265. private _glowLayer;
  65266. /**
  65267. * Animations which can be used to tweak settings over a period of time
  65268. */
  65269. animations: Animation[];
  65270. private _imageProcessingConfigurationObserver;
  65271. private _sharpenEnabled;
  65272. private _bloomEnabled;
  65273. private _depthOfFieldEnabled;
  65274. private _depthOfFieldBlurLevel;
  65275. private _fxaaEnabled;
  65276. private _imageProcessingEnabled;
  65277. private _defaultPipelineTextureType;
  65278. private _bloomScale;
  65279. private _chromaticAberrationEnabled;
  65280. private _grainEnabled;
  65281. private _buildAllowed;
  65282. /**
  65283. * Gets active scene
  65284. */
  65285. get scene(): Scene;
  65286. /**
  65287. * Enable or disable the sharpen process from the pipeline
  65288. */
  65289. set sharpenEnabled(enabled: boolean);
  65290. get sharpenEnabled(): boolean;
  65291. private _resizeObserver;
  65292. private _hardwareScaleLevel;
  65293. private _bloomKernel;
  65294. /**
  65295. * Specifies the size of the bloom blur kernel, relative to the final output size
  65296. */
  65297. get bloomKernel(): number;
  65298. set bloomKernel(value: number);
  65299. /**
  65300. * Specifies the weight of the bloom in the final rendering
  65301. */
  65302. private _bloomWeight;
  65303. /**
  65304. * Specifies the luma threshold for the area that will be blurred by the bloom
  65305. */
  65306. private _bloomThreshold;
  65307. private _hdr;
  65308. /**
  65309. * The strength of the bloom.
  65310. */
  65311. set bloomWeight(value: number);
  65312. get bloomWeight(): number;
  65313. /**
  65314. * The strength of the bloom.
  65315. */
  65316. set bloomThreshold(value: number);
  65317. get bloomThreshold(): number;
  65318. /**
  65319. * The scale of the bloom, lower value will provide better performance.
  65320. */
  65321. set bloomScale(value: number);
  65322. get bloomScale(): number;
  65323. /**
  65324. * Enable or disable the bloom from the pipeline
  65325. */
  65326. set bloomEnabled(enabled: boolean);
  65327. get bloomEnabled(): boolean;
  65328. private _rebuildBloom;
  65329. /**
  65330. * If the depth of field is enabled.
  65331. */
  65332. get depthOfFieldEnabled(): boolean;
  65333. set depthOfFieldEnabled(enabled: boolean);
  65334. /**
  65335. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65336. */
  65337. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65338. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65339. /**
  65340. * If the anti aliasing is enabled.
  65341. */
  65342. set fxaaEnabled(enabled: boolean);
  65343. get fxaaEnabled(): boolean;
  65344. private _samples;
  65345. /**
  65346. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65347. */
  65348. set samples(sampleCount: number);
  65349. get samples(): number;
  65350. /**
  65351. * If image processing is enabled.
  65352. */
  65353. set imageProcessingEnabled(enabled: boolean);
  65354. get imageProcessingEnabled(): boolean;
  65355. /**
  65356. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65357. */
  65358. set glowLayerEnabled(enabled: boolean);
  65359. get glowLayerEnabled(): boolean;
  65360. /**
  65361. * Gets the glow layer (or null if not defined)
  65362. */
  65363. get glowLayer(): Nullable<GlowLayer>;
  65364. /**
  65365. * Enable or disable the chromaticAberration process from the pipeline
  65366. */
  65367. set chromaticAberrationEnabled(enabled: boolean);
  65368. get chromaticAberrationEnabled(): boolean;
  65369. /**
  65370. * Enable or disable the grain process from the pipeline
  65371. */
  65372. set grainEnabled(enabled: boolean);
  65373. get grainEnabled(): boolean;
  65374. /**
  65375. * @constructor
  65376. * @param name - The rendering pipeline name (default: "")
  65377. * @param hdr - If high dynamic range textures should be used (default: true)
  65378. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65379. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65380. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65381. */
  65382. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65383. /**
  65384. * Get the class name
  65385. * @returns "DefaultRenderingPipeline"
  65386. */
  65387. getClassName(): string;
  65388. /**
  65389. * Force the compilation of the entire pipeline.
  65390. */
  65391. prepare(): void;
  65392. private _hasCleared;
  65393. private _prevPostProcess;
  65394. private _prevPrevPostProcess;
  65395. private _setAutoClearAndTextureSharing;
  65396. private _depthOfFieldSceneObserver;
  65397. private _buildPipeline;
  65398. private _disposePostProcesses;
  65399. /**
  65400. * Adds a camera to the pipeline
  65401. * @param camera the camera to be added
  65402. */
  65403. addCamera(camera: Camera): void;
  65404. /**
  65405. * Removes a camera from the pipeline
  65406. * @param camera the camera to remove
  65407. */
  65408. removeCamera(camera: Camera): void;
  65409. /**
  65410. * Dispose of the pipeline and stop all post processes
  65411. */
  65412. dispose(): void;
  65413. /**
  65414. * Serialize the rendering pipeline (Used when exporting)
  65415. * @returns the serialized object
  65416. */
  65417. serialize(): any;
  65418. /**
  65419. * Parse the serialized pipeline
  65420. * @param source Source pipeline.
  65421. * @param scene The scene to load the pipeline to.
  65422. * @param rootUrl The URL of the serialized pipeline.
  65423. * @returns An instantiated pipeline from the serialized object.
  65424. */
  65425. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65426. }
  65427. }
  65428. declare module BABYLON {
  65429. /** @hidden */
  65430. export var lensHighlightsPixelShader: {
  65431. name: string;
  65432. shader: string;
  65433. };
  65434. }
  65435. declare module BABYLON {
  65436. /** @hidden */
  65437. export var depthOfFieldPixelShader: {
  65438. name: string;
  65439. shader: string;
  65440. };
  65441. }
  65442. declare module BABYLON {
  65443. /**
  65444. * BABYLON.JS Chromatic Aberration GLSL Shader
  65445. * Author: Olivier Guyot
  65446. * Separates very slightly R, G and B colors on the edges of the screen
  65447. * Inspired by Francois Tarlier & Martins Upitis
  65448. */
  65449. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65450. /**
  65451. * @ignore
  65452. * The chromatic aberration PostProcess id in the pipeline
  65453. */
  65454. LensChromaticAberrationEffect: string;
  65455. /**
  65456. * @ignore
  65457. * The highlights enhancing PostProcess id in the pipeline
  65458. */
  65459. HighlightsEnhancingEffect: string;
  65460. /**
  65461. * @ignore
  65462. * The depth-of-field PostProcess id in the pipeline
  65463. */
  65464. LensDepthOfFieldEffect: string;
  65465. private _scene;
  65466. private _depthTexture;
  65467. private _grainTexture;
  65468. private _chromaticAberrationPostProcess;
  65469. private _highlightsPostProcess;
  65470. private _depthOfFieldPostProcess;
  65471. private _edgeBlur;
  65472. private _grainAmount;
  65473. private _chromaticAberration;
  65474. private _distortion;
  65475. private _highlightsGain;
  65476. private _highlightsThreshold;
  65477. private _dofDistance;
  65478. private _dofAperture;
  65479. private _dofDarken;
  65480. private _dofPentagon;
  65481. private _blurNoise;
  65482. /**
  65483. * @constructor
  65484. *
  65485. * Effect parameters are as follow:
  65486. * {
  65487. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65488. * edge_blur: number; // from 0 to x (1 for realism)
  65489. * distortion: number; // from 0 to x (1 for realism)
  65490. * grain_amount: number; // from 0 to 1
  65491. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65492. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65493. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65494. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65495. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65496. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65497. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65498. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65499. * }
  65500. * Note: if an effect parameter is unset, effect is disabled
  65501. *
  65502. * @param name The rendering pipeline name
  65503. * @param parameters - An object containing all parameters (see above)
  65504. * @param scene The scene linked to this pipeline
  65505. * @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)
  65506. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65507. */
  65508. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65509. /**
  65510. * Get the class name
  65511. * @returns "LensRenderingPipeline"
  65512. */
  65513. getClassName(): string;
  65514. /**
  65515. * Gets associated scene
  65516. */
  65517. get scene(): Scene;
  65518. /**
  65519. * Gets or sets the edge blur
  65520. */
  65521. get edgeBlur(): number;
  65522. set edgeBlur(value: number);
  65523. /**
  65524. * Gets or sets the grain amount
  65525. */
  65526. get grainAmount(): number;
  65527. set grainAmount(value: number);
  65528. /**
  65529. * Gets or sets the chromatic aberration amount
  65530. */
  65531. get chromaticAberration(): number;
  65532. set chromaticAberration(value: number);
  65533. /**
  65534. * Gets or sets the depth of field aperture
  65535. */
  65536. get dofAperture(): number;
  65537. set dofAperture(value: number);
  65538. /**
  65539. * Gets or sets the edge distortion
  65540. */
  65541. get edgeDistortion(): number;
  65542. set edgeDistortion(value: number);
  65543. /**
  65544. * Gets or sets the depth of field distortion
  65545. */
  65546. get dofDistortion(): number;
  65547. set dofDistortion(value: number);
  65548. /**
  65549. * Gets or sets the darken out of focus amount
  65550. */
  65551. get darkenOutOfFocus(): number;
  65552. set darkenOutOfFocus(value: number);
  65553. /**
  65554. * Gets or sets a boolean indicating if blur noise is enabled
  65555. */
  65556. get blurNoise(): boolean;
  65557. set blurNoise(value: boolean);
  65558. /**
  65559. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65560. */
  65561. get pentagonBokeh(): boolean;
  65562. set pentagonBokeh(value: boolean);
  65563. /**
  65564. * Gets or sets the highlight grain amount
  65565. */
  65566. get highlightsGain(): number;
  65567. set highlightsGain(value: number);
  65568. /**
  65569. * Gets or sets the highlight threshold
  65570. */
  65571. get highlightsThreshold(): number;
  65572. set highlightsThreshold(value: number);
  65573. /**
  65574. * Sets the amount of blur at the edges
  65575. * @param amount blur amount
  65576. */
  65577. setEdgeBlur(amount: number): void;
  65578. /**
  65579. * Sets edge blur to 0
  65580. */
  65581. disableEdgeBlur(): void;
  65582. /**
  65583. * Sets the amout of grain
  65584. * @param amount Amount of grain
  65585. */
  65586. setGrainAmount(amount: number): void;
  65587. /**
  65588. * Set grain amount to 0
  65589. */
  65590. disableGrain(): void;
  65591. /**
  65592. * Sets the chromatic aberration amount
  65593. * @param amount amount of chromatic aberration
  65594. */
  65595. setChromaticAberration(amount: number): void;
  65596. /**
  65597. * Sets chromatic aberration amount to 0
  65598. */
  65599. disableChromaticAberration(): void;
  65600. /**
  65601. * Sets the EdgeDistortion amount
  65602. * @param amount amount of EdgeDistortion
  65603. */
  65604. setEdgeDistortion(amount: number): void;
  65605. /**
  65606. * Sets edge distortion to 0
  65607. */
  65608. disableEdgeDistortion(): void;
  65609. /**
  65610. * Sets the FocusDistance amount
  65611. * @param amount amount of FocusDistance
  65612. */
  65613. setFocusDistance(amount: number): void;
  65614. /**
  65615. * Disables depth of field
  65616. */
  65617. disableDepthOfField(): void;
  65618. /**
  65619. * Sets the Aperture amount
  65620. * @param amount amount of Aperture
  65621. */
  65622. setAperture(amount: number): void;
  65623. /**
  65624. * Sets the DarkenOutOfFocus amount
  65625. * @param amount amount of DarkenOutOfFocus
  65626. */
  65627. setDarkenOutOfFocus(amount: number): void;
  65628. private _pentagonBokehIsEnabled;
  65629. /**
  65630. * Creates a pentagon bokeh effect
  65631. */
  65632. enablePentagonBokeh(): void;
  65633. /**
  65634. * Disables the pentagon bokeh effect
  65635. */
  65636. disablePentagonBokeh(): void;
  65637. /**
  65638. * Enables noise blur
  65639. */
  65640. enableNoiseBlur(): void;
  65641. /**
  65642. * Disables noise blur
  65643. */
  65644. disableNoiseBlur(): void;
  65645. /**
  65646. * Sets the HighlightsGain amount
  65647. * @param amount amount of HighlightsGain
  65648. */
  65649. setHighlightsGain(amount: number): void;
  65650. /**
  65651. * Sets the HighlightsThreshold amount
  65652. * @param amount amount of HighlightsThreshold
  65653. */
  65654. setHighlightsThreshold(amount: number): void;
  65655. /**
  65656. * Disables highlights
  65657. */
  65658. disableHighlights(): void;
  65659. /**
  65660. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65661. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65662. */
  65663. dispose(disableDepthRender?: boolean): void;
  65664. private _createChromaticAberrationPostProcess;
  65665. private _createHighlightsPostProcess;
  65666. private _createDepthOfFieldPostProcess;
  65667. private _createGrainTexture;
  65668. }
  65669. }
  65670. declare module BABYLON {
  65671. /** @hidden */
  65672. export var ssao2PixelShader: {
  65673. name: string;
  65674. shader: string;
  65675. };
  65676. }
  65677. declare module BABYLON {
  65678. /** @hidden */
  65679. export var ssaoCombinePixelShader: {
  65680. name: string;
  65681. shader: string;
  65682. };
  65683. }
  65684. declare module BABYLON {
  65685. /**
  65686. * Render pipeline to produce ssao effect
  65687. */
  65688. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65689. /**
  65690. * @ignore
  65691. * The PassPostProcess id in the pipeline that contains the original scene color
  65692. */
  65693. SSAOOriginalSceneColorEffect: string;
  65694. /**
  65695. * @ignore
  65696. * The SSAO PostProcess id in the pipeline
  65697. */
  65698. SSAORenderEffect: string;
  65699. /**
  65700. * @ignore
  65701. * The horizontal blur PostProcess id in the pipeline
  65702. */
  65703. SSAOBlurHRenderEffect: string;
  65704. /**
  65705. * @ignore
  65706. * The vertical blur PostProcess id in the pipeline
  65707. */
  65708. SSAOBlurVRenderEffect: string;
  65709. /**
  65710. * @ignore
  65711. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65712. */
  65713. SSAOCombineRenderEffect: string;
  65714. /**
  65715. * The output strength of the SSAO post-process. Default value is 1.0.
  65716. */
  65717. totalStrength: number;
  65718. /**
  65719. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65720. */
  65721. maxZ: number;
  65722. /**
  65723. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65724. */
  65725. minZAspect: number;
  65726. private _samples;
  65727. /**
  65728. * Number of samples used for the SSAO calculations. Default value is 8
  65729. */
  65730. set samples(n: number);
  65731. get samples(): number;
  65732. private _textureSamples;
  65733. /**
  65734. * Number of samples to use for antialiasing
  65735. */
  65736. set textureSamples(n: number);
  65737. get textureSamples(): number;
  65738. /**
  65739. * Ratio object used for SSAO ratio and blur ratio
  65740. */
  65741. private _ratio;
  65742. /**
  65743. * Dynamically generated sphere sampler.
  65744. */
  65745. private _sampleSphere;
  65746. /**
  65747. * Blur filter offsets
  65748. */
  65749. private _samplerOffsets;
  65750. private _expensiveBlur;
  65751. /**
  65752. * If bilateral blur should be used
  65753. */
  65754. set expensiveBlur(b: boolean);
  65755. get expensiveBlur(): boolean;
  65756. /**
  65757. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65758. */
  65759. radius: number;
  65760. /**
  65761. * The base color of the SSAO post-process
  65762. * The final result is "base + ssao" between [0, 1]
  65763. */
  65764. base: number;
  65765. /**
  65766. * Support test.
  65767. */
  65768. static get IsSupported(): boolean;
  65769. private _scene;
  65770. private _depthTexture;
  65771. private _normalTexture;
  65772. private _randomTexture;
  65773. private _originalColorPostProcess;
  65774. private _ssaoPostProcess;
  65775. private _blurHPostProcess;
  65776. private _blurVPostProcess;
  65777. private _ssaoCombinePostProcess;
  65778. /**
  65779. * Gets active scene
  65780. */
  65781. get scene(): Scene;
  65782. /**
  65783. * @constructor
  65784. * @param name The rendering pipeline name
  65785. * @param scene The scene linked to this pipeline
  65786. * @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 }
  65787. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65788. */
  65789. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65790. /**
  65791. * Get the class name
  65792. * @returns "SSAO2RenderingPipeline"
  65793. */
  65794. getClassName(): string;
  65795. /**
  65796. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65797. */
  65798. dispose(disableGeometryBufferRenderer?: boolean): void;
  65799. private _createBlurPostProcess;
  65800. /** @hidden */
  65801. _rebuild(): void;
  65802. private _bits;
  65803. private _radicalInverse_VdC;
  65804. private _hammersley;
  65805. private _hemisphereSample_uniform;
  65806. private _generateHemisphere;
  65807. private _createSSAOPostProcess;
  65808. private _createSSAOCombinePostProcess;
  65809. private _createRandomTexture;
  65810. /**
  65811. * Serialize the rendering pipeline (Used when exporting)
  65812. * @returns the serialized object
  65813. */
  65814. serialize(): any;
  65815. /**
  65816. * Parse the serialized pipeline
  65817. * @param source Source pipeline.
  65818. * @param scene The scene to load the pipeline to.
  65819. * @param rootUrl The URL of the serialized pipeline.
  65820. * @returns An instantiated pipeline from the serialized object.
  65821. */
  65822. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65823. }
  65824. }
  65825. declare module BABYLON {
  65826. /** @hidden */
  65827. export var ssaoPixelShader: {
  65828. name: string;
  65829. shader: string;
  65830. };
  65831. }
  65832. declare module BABYLON {
  65833. /**
  65834. * Render pipeline to produce ssao effect
  65835. */
  65836. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65837. /**
  65838. * @ignore
  65839. * The PassPostProcess id in the pipeline that contains the original scene color
  65840. */
  65841. SSAOOriginalSceneColorEffect: string;
  65842. /**
  65843. * @ignore
  65844. * The SSAO PostProcess id in the pipeline
  65845. */
  65846. SSAORenderEffect: string;
  65847. /**
  65848. * @ignore
  65849. * The horizontal blur PostProcess id in the pipeline
  65850. */
  65851. SSAOBlurHRenderEffect: string;
  65852. /**
  65853. * @ignore
  65854. * The vertical blur PostProcess id in the pipeline
  65855. */
  65856. SSAOBlurVRenderEffect: string;
  65857. /**
  65858. * @ignore
  65859. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65860. */
  65861. SSAOCombineRenderEffect: string;
  65862. /**
  65863. * The output strength of the SSAO post-process. Default value is 1.0.
  65864. */
  65865. totalStrength: number;
  65866. /**
  65867. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65868. */
  65869. radius: number;
  65870. /**
  65871. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65872. * Must not be equal to fallOff and superior to fallOff.
  65873. * Default value is 0.0075
  65874. */
  65875. area: number;
  65876. /**
  65877. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65878. * Must not be equal to area and inferior to area.
  65879. * Default value is 0.000001
  65880. */
  65881. fallOff: number;
  65882. /**
  65883. * The base color of the SSAO post-process
  65884. * The final result is "base + ssao" between [0, 1]
  65885. */
  65886. base: number;
  65887. private _scene;
  65888. private _depthTexture;
  65889. private _randomTexture;
  65890. private _originalColorPostProcess;
  65891. private _ssaoPostProcess;
  65892. private _blurHPostProcess;
  65893. private _blurVPostProcess;
  65894. private _ssaoCombinePostProcess;
  65895. private _firstUpdate;
  65896. /**
  65897. * Gets active scene
  65898. */
  65899. get scene(): Scene;
  65900. /**
  65901. * @constructor
  65902. * @param name - The rendering pipeline name
  65903. * @param scene - The scene linked to this pipeline
  65904. * @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 }
  65905. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65906. */
  65907. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65908. /**
  65909. * Get the class name
  65910. * @returns "SSAORenderingPipeline"
  65911. */
  65912. getClassName(): string;
  65913. /**
  65914. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65915. */
  65916. dispose(disableDepthRender?: boolean): void;
  65917. private _createBlurPostProcess;
  65918. /** @hidden */
  65919. _rebuild(): void;
  65920. private _createSSAOPostProcess;
  65921. private _createSSAOCombinePostProcess;
  65922. private _createRandomTexture;
  65923. }
  65924. }
  65925. declare module BABYLON {
  65926. /** @hidden */
  65927. export var screenSpaceReflectionPixelShader: {
  65928. name: string;
  65929. shader: string;
  65930. };
  65931. }
  65932. declare module BABYLON {
  65933. /**
  65934. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65935. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65936. */
  65937. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65938. /**
  65939. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65940. */
  65941. threshold: number;
  65942. /**
  65943. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65944. */
  65945. strength: number;
  65946. /**
  65947. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65948. */
  65949. reflectionSpecularFalloffExponent: number;
  65950. /**
  65951. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  65952. */
  65953. step: number;
  65954. /**
  65955. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65956. */
  65957. roughnessFactor: number;
  65958. private _geometryBufferRenderer;
  65959. private _enableSmoothReflections;
  65960. private _reflectionSamples;
  65961. private _smoothSteps;
  65962. /**
  65963. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65964. * @param name The name of the effect.
  65965. * @param scene The scene containing the objects to calculate reflections.
  65966. * @param options The required width/height ratio to downsize to before computing the render pass.
  65967. * @param camera The camera to apply the render pass to.
  65968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65969. * @param engine The engine which the post process will be applied. (default: current engine)
  65970. * @param reusable If the post process can be reused on the same frame. (default: false)
  65971. * @param textureType Type of textures used when performing the post process. (default: 0)
  65972. * @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)
  65973. */
  65974. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65975. /**
  65976. * Gets wether or not smoothing reflections is enabled.
  65977. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65978. */
  65979. get enableSmoothReflections(): boolean;
  65980. /**
  65981. * Sets wether or not smoothing reflections is enabled.
  65982. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65983. */
  65984. set enableSmoothReflections(enabled: boolean);
  65985. /**
  65986. * Gets the number of samples taken while computing reflections. More samples count is high,
  65987. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65988. */
  65989. get reflectionSamples(): number;
  65990. /**
  65991. * Sets the number of samples taken while computing reflections. More samples count is high,
  65992. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65993. */
  65994. set reflectionSamples(samples: number);
  65995. /**
  65996. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  65997. * more the post-process will require GPU power and can generate a drop in FPS.
  65998. * Default value (5.0) work pretty well in all cases but can be adjusted.
  65999. */
  66000. get smoothSteps(): number;
  66001. set smoothSteps(steps: number);
  66002. private _updateEffectDefines;
  66003. }
  66004. }
  66005. declare module BABYLON {
  66006. /** @hidden */
  66007. export var standardPixelShader: {
  66008. name: string;
  66009. shader: string;
  66010. };
  66011. }
  66012. declare module BABYLON {
  66013. /**
  66014. * Standard rendering pipeline
  66015. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66016. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66017. */
  66018. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66019. /**
  66020. * Public members
  66021. */
  66022. /**
  66023. * Post-process which contains the original scene color before the pipeline applies all the effects
  66024. */
  66025. originalPostProcess: Nullable<PostProcess>;
  66026. /**
  66027. * Post-process used to down scale an image x4
  66028. */
  66029. downSampleX4PostProcess: Nullable<PostProcess>;
  66030. /**
  66031. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66032. */
  66033. brightPassPostProcess: Nullable<PostProcess>;
  66034. /**
  66035. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66036. */
  66037. blurHPostProcesses: PostProcess[];
  66038. /**
  66039. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66040. */
  66041. blurVPostProcesses: PostProcess[];
  66042. /**
  66043. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66044. */
  66045. textureAdderPostProcess: Nullable<PostProcess>;
  66046. /**
  66047. * Post-process used to create volumetric lighting effect
  66048. */
  66049. volumetricLightPostProcess: Nullable<PostProcess>;
  66050. /**
  66051. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66052. */
  66053. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66054. /**
  66055. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66056. */
  66057. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66058. /**
  66059. * Post-process used to merge the volumetric light effect and the real scene color
  66060. */
  66061. volumetricLightMergePostProces: Nullable<PostProcess>;
  66062. /**
  66063. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66064. */
  66065. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66066. /**
  66067. * Base post-process used to calculate the average luminance of the final image for HDR
  66068. */
  66069. luminancePostProcess: Nullable<PostProcess>;
  66070. /**
  66071. * Post-processes used to create down sample post-processes in order to get
  66072. * the average luminance of the final image for HDR
  66073. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66074. */
  66075. luminanceDownSamplePostProcesses: PostProcess[];
  66076. /**
  66077. * Post-process used to create a HDR effect (light adaptation)
  66078. */
  66079. hdrPostProcess: Nullable<PostProcess>;
  66080. /**
  66081. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66082. */
  66083. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66084. /**
  66085. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66086. */
  66087. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66088. /**
  66089. * Post-process used to merge the final HDR post-process and the real scene color
  66090. */
  66091. hdrFinalPostProcess: Nullable<PostProcess>;
  66092. /**
  66093. * Post-process used to create a lens flare effect
  66094. */
  66095. lensFlarePostProcess: Nullable<PostProcess>;
  66096. /**
  66097. * Post-process that merges the result of the lens flare post-process and the real scene color
  66098. */
  66099. lensFlareComposePostProcess: Nullable<PostProcess>;
  66100. /**
  66101. * Post-process used to create a motion blur effect
  66102. */
  66103. motionBlurPostProcess: Nullable<PostProcess>;
  66104. /**
  66105. * Post-process used to create a depth of field effect
  66106. */
  66107. depthOfFieldPostProcess: Nullable<PostProcess>;
  66108. /**
  66109. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66110. */
  66111. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66112. /**
  66113. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66114. */
  66115. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66116. /**
  66117. * Represents the brightness threshold in order to configure the illuminated surfaces
  66118. */
  66119. brightThreshold: number;
  66120. /**
  66121. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66122. */
  66123. blurWidth: number;
  66124. /**
  66125. * Sets if the blur for highlighted surfaces must be only horizontal
  66126. */
  66127. horizontalBlur: boolean;
  66128. /**
  66129. * Gets the overall exposure used by the pipeline
  66130. */
  66131. get exposure(): number;
  66132. /**
  66133. * Sets the overall exposure used by the pipeline
  66134. */
  66135. set exposure(value: number);
  66136. /**
  66137. * Texture used typically to simulate "dirty" on camera lens
  66138. */
  66139. lensTexture: Nullable<Texture>;
  66140. /**
  66141. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66142. */
  66143. volumetricLightCoefficient: number;
  66144. /**
  66145. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66146. */
  66147. volumetricLightPower: number;
  66148. /**
  66149. * Used the set the blur intensity to smooth the volumetric lights
  66150. */
  66151. volumetricLightBlurScale: number;
  66152. /**
  66153. * Light (spot or directional) used to generate the volumetric lights rays
  66154. * The source light must have a shadow generate so the pipeline can get its
  66155. * depth map
  66156. */
  66157. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66158. /**
  66159. * For eye adaptation, represents the minimum luminance the eye can see
  66160. */
  66161. hdrMinimumLuminance: number;
  66162. /**
  66163. * For eye adaptation, represents the decrease luminance speed
  66164. */
  66165. hdrDecreaseRate: number;
  66166. /**
  66167. * For eye adaptation, represents the increase luminance speed
  66168. */
  66169. hdrIncreaseRate: number;
  66170. /**
  66171. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66172. */
  66173. get hdrAutoExposure(): boolean;
  66174. /**
  66175. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66176. */
  66177. set hdrAutoExposure(value: boolean);
  66178. /**
  66179. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66180. */
  66181. lensColorTexture: Nullable<Texture>;
  66182. /**
  66183. * The overall strengh for the lens flare effect
  66184. */
  66185. lensFlareStrength: number;
  66186. /**
  66187. * Dispersion coefficient for lens flare ghosts
  66188. */
  66189. lensFlareGhostDispersal: number;
  66190. /**
  66191. * Main lens flare halo width
  66192. */
  66193. lensFlareHaloWidth: number;
  66194. /**
  66195. * Based on the lens distortion effect, defines how much the lens flare result
  66196. * is distorted
  66197. */
  66198. lensFlareDistortionStrength: number;
  66199. /**
  66200. * Configures the blur intensity used for for lens flare (halo)
  66201. */
  66202. lensFlareBlurWidth: number;
  66203. /**
  66204. * Lens star texture must be used to simulate rays on the flares and is available
  66205. * in the documentation
  66206. */
  66207. lensStarTexture: Nullable<Texture>;
  66208. /**
  66209. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66210. * flare effect by taking account of the dirt texture
  66211. */
  66212. lensFlareDirtTexture: Nullable<Texture>;
  66213. /**
  66214. * Represents the focal length for the depth of field effect
  66215. */
  66216. depthOfFieldDistance: number;
  66217. /**
  66218. * Represents the blur intensity for the blurred part of the depth of field effect
  66219. */
  66220. depthOfFieldBlurWidth: number;
  66221. /**
  66222. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66223. */
  66224. get motionStrength(): number;
  66225. /**
  66226. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66227. */
  66228. set motionStrength(strength: number);
  66229. /**
  66230. * Gets wether or not the motion blur post-process is object based or screen based.
  66231. */
  66232. get objectBasedMotionBlur(): boolean;
  66233. /**
  66234. * Sets wether or not the motion blur post-process should be object based or screen based
  66235. */
  66236. set objectBasedMotionBlur(value: boolean);
  66237. /**
  66238. * List of animations for the pipeline (IAnimatable implementation)
  66239. */
  66240. animations: Animation[];
  66241. /**
  66242. * Private members
  66243. */
  66244. private _scene;
  66245. private _currentDepthOfFieldSource;
  66246. private _basePostProcess;
  66247. private _fixedExposure;
  66248. private _currentExposure;
  66249. private _hdrAutoExposure;
  66250. private _hdrCurrentLuminance;
  66251. private _motionStrength;
  66252. private _isObjectBasedMotionBlur;
  66253. private _floatTextureType;
  66254. private _camerasToBeAttached;
  66255. private _ratio;
  66256. private _bloomEnabled;
  66257. private _depthOfFieldEnabled;
  66258. private _vlsEnabled;
  66259. private _lensFlareEnabled;
  66260. private _hdrEnabled;
  66261. private _motionBlurEnabled;
  66262. private _fxaaEnabled;
  66263. private _screenSpaceReflectionsEnabled;
  66264. private _motionBlurSamples;
  66265. private _volumetricLightStepsCount;
  66266. private _samples;
  66267. /**
  66268. * @ignore
  66269. * Specifies if the bloom pipeline is enabled
  66270. */
  66271. get BloomEnabled(): boolean;
  66272. set BloomEnabled(enabled: boolean);
  66273. /**
  66274. * @ignore
  66275. * Specifies if the depth of field pipeline is enabed
  66276. */
  66277. get DepthOfFieldEnabled(): boolean;
  66278. set DepthOfFieldEnabled(enabled: boolean);
  66279. /**
  66280. * @ignore
  66281. * Specifies if the lens flare pipeline is enabed
  66282. */
  66283. get LensFlareEnabled(): boolean;
  66284. set LensFlareEnabled(enabled: boolean);
  66285. /**
  66286. * @ignore
  66287. * Specifies if the HDR pipeline is enabled
  66288. */
  66289. get HDREnabled(): boolean;
  66290. set HDREnabled(enabled: boolean);
  66291. /**
  66292. * @ignore
  66293. * Specifies if the volumetric lights scattering effect is enabled
  66294. */
  66295. get VLSEnabled(): boolean;
  66296. set VLSEnabled(enabled: boolean);
  66297. /**
  66298. * @ignore
  66299. * Specifies if the motion blur effect is enabled
  66300. */
  66301. get MotionBlurEnabled(): boolean;
  66302. set MotionBlurEnabled(enabled: boolean);
  66303. /**
  66304. * Specifies if anti-aliasing is enabled
  66305. */
  66306. get fxaaEnabled(): boolean;
  66307. set fxaaEnabled(enabled: boolean);
  66308. /**
  66309. * Specifies if screen space reflections are enabled.
  66310. */
  66311. get screenSpaceReflectionsEnabled(): boolean;
  66312. set screenSpaceReflectionsEnabled(enabled: boolean);
  66313. /**
  66314. * Specifies the number of steps used to calculate the volumetric lights
  66315. * Typically in interval [50, 200]
  66316. */
  66317. get volumetricLightStepsCount(): number;
  66318. set volumetricLightStepsCount(count: number);
  66319. /**
  66320. * Specifies the number of samples used for the motion blur effect
  66321. * Typically in interval [16, 64]
  66322. */
  66323. get motionBlurSamples(): number;
  66324. set motionBlurSamples(samples: number);
  66325. /**
  66326. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66327. */
  66328. get samples(): number;
  66329. set samples(sampleCount: number);
  66330. /**
  66331. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66332. * @constructor
  66333. * @param name The rendering pipeline name
  66334. * @param scene The scene linked to this pipeline
  66335. * @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)
  66336. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66337. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66338. */
  66339. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66340. private _buildPipeline;
  66341. private _createDownSampleX4PostProcess;
  66342. private _createBrightPassPostProcess;
  66343. private _createBlurPostProcesses;
  66344. private _createTextureAdderPostProcess;
  66345. private _createVolumetricLightPostProcess;
  66346. private _createLuminancePostProcesses;
  66347. private _createHdrPostProcess;
  66348. private _createLensFlarePostProcess;
  66349. private _createDepthOfFieldPostProcess;
  66350. private _createMotionBlurPostProcess;
  66351. private _getDepthTexture;
  66352. private _disposePostProcesses;
  66353. /**
  66354. * Dispose of the pipeline and stop all post processes
  66355. */
  66356. dispose(): void;
  66357. /**
  66358. * Serialize the rendering pipeline (Used when exporting)
  66359. * @returns the serialized object
  66360. */
  66361. serialize(): any;
  66362. /**
  66363. * Parse the serialized pipeline
  66364. * @param source Source pipeline.
  66365. * @param scene The scene to load the pipeline to.
  66366. * @param rootUrl The URL of the serialized pipeline.
  66367. * @returns An instantiated pipeline from the serialized object.
  66368. */
  66369. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66370. /**
  66371. * Luminance steps
  66372. */
  66373. static LuminanceSteps: number;
  66374. }
  66375. }
  66376. declare module BABYLON {
  66377. /** @hidden */
  66378. export var tonemapPixelShader: {
  66379. name: string;
  66380. shader: string;
  66381. };
  66382. }
  66383. declare module BABYLON {
  66384. /** Defines operator used for tonemapping */
  66385. export enum TonemappingOperator {
  66386. /** Hable */
  66387. Hable = 0,
  66388. /** Reinhard */
  66389. Reinhard = 1,
  66390. /** HejiDawson */
  66391. HejiDawson = 2,
  66392. /** Photographic */
  66393. Photographic = 3
  66394. }
  66395. /**
  66396. * Defines a post process to apply tone mapping
  66397. */
  66398. export class TonemapPostProcess extends PostProcess {
  66399. private _operator;
  66400. /** Defines the required exposure adjustement */
  66401. exposureAdjustment: number;
  66402. /**
  66403. * Creates a new TonemapPostProcess
  66404. * @param name defines the name of the postprocess
  66405. * @param _operator defines the operator to use
  66406. * @param exposureAdjustment defines the required exposure adjustement
  66407. * @param camera defines the camera to use (can be null)
  66408. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66409. * @param engine defines the hosting engine (can be ignore if camera is set)
  66410. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66411. */
  66412. constructor(name: string, _operator: TonemappingOperator,
  66413. /** Defines the required exposure adjustement */
  66414. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66415. }
  66416. }
  66417. declare module BABYLON {
  66418. /** @hidden */
  66419. export var volumetricLightScatteringPixelShader: {
  66420. name: string;
  66421. shader: string;
  66422. };
  66423. }
  66424. declare module BABYLON {
  66425. /** @hidden */
  66426. export var volumetricLightScatteringPassVertexShader: {
  66427. name: string;
  66428. shader: string;
  66429. };
  66430. }
  66431. declare module BABYLON {
  66432. /** @hidden */
  66433. export var volumetricLightScatteringPassPixelShader: {
  66434. name: string;
  66435. shader: string;
  66436. };
  66437. }
  66438. declare module BABYLON {
  66439. /**
  66440. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66441. */
  66442. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66443. private _volumetricLightScatteringPass;
  66444. private _volumetricLightScatteringRTT;
  66445. private _viewPort;
  66446. private _screenCoordinates;
  66447. private _cachedDefines;
  66448. /**
  66449. * If not undefined, the mesh position is computed from the attached node position
  66450. */
  66451. attachedNode: {
  66452. position: Vector3;
  66453. };
  66454. /**
  66455. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66456. */
  66457. customMeshPosition: Vector3;
  66458. /**
  66459. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66460. */
  66461. useCustomMeshPosition: boolean;
  66462. /**
  66463. * If the post-process should inverse the light scattering direction
  66464. */
  66465. invert: boolean;
  66466. /**
  66467. * The internal mesh used by the post-process
  66468. */
  66469. mesh: Mesh;
  66470. /**
  66471. * @hidden
  66472. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66473. */
  66474. get useDiffuseColor(): boolean;
  66475. set useDiffuseColor(useDiffuseColor: boolean);
  66476. /**
  66477. * Array containing the excluded meshes not rendered in the internal pass
  66478. */
  66479. excludedMeshes: AbstractMesh[];
  66480. /**
  66481. * Controls the overall intensity of the post-process
  66482. */
  66483. exposure: number;
  66484. /**
  66485. * Dissipates each sample's contribution in range [0, 1]
  66486. */
  66487. decay: number;
  66488. /**
  66489. * Controls the overall intensity of each sample
  66490. */
  66491. weight: number;
  66492. /**
  66493. * Controls the density of each sample
  66494. */
  66495. density: number;
  66496. /**
  66497. * @constructor
  66498. * @param name The post-process name
  66499. * @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)
  66500. * @param camera The camera that the post-process will be attached to
  66501. * @param mesh The mesh used to create the light scattering
  66502. * @param samples The post-process quality, default 100
  66503. * @param samplingModeThe post-process filtering mode
  66504. * @param engine The babylon engine
  66505. * @param reusable If the post-process is reusable
  66506. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66507. */
  66508. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66509. /**
  66510. * Returns the string "VolumetricLightScatteringPostProcess"
  66511. * @returns "VolumetricLightScatteringPostProcess"
  66512. */
  66513. getClassName(): string;
  66514. private _isReady;
  66515. /**
  66516. * Sets the new light position for light scattering effect
  66517. * @param position The new custom light position
  66518. */
  66519. setCustomMeshPosition(position: Vector3): void;
  66520. /**
  66521. * Returns the light position for light scattering effect
  66522. * @return Vector3 The custom light position
  66523. */
  66524. getCustomMeshPosition(): Vector3;
  66525. /**
  66526. * Disposes the internal assets and detaches the post-process from the camera
  66527. */
  66528. dispose(camera: Camera): void;
  66529. /**
  66530. * Returns the render target texture used by the post-process
  66531. * @return the render target texture used by the post-process
  66532. */
  66533. getPass(): RenderTargetTexture;
  66534. private _meshExcluded;
  66535. private _createPass;
  66536. private _updateMeshScreenCoordinates;
  66537. /**
  66538. * Creates a default mesh for the Volumeric Light Scattering post-process
  66539. * @param name The mesh name
  66540. * @param scene The scene where to create the mesh
  66541. * @return the default mesh
  66542. */
  66543. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66544. }
  66545. }
  66546. declare module BABYLON {
  66547. interface Scene {
  66548. /** @hidden (Backing field) */
  66549. _boundingBoxRenderer: BoundingBoxRenderer;
  66550. /** @hidden (Backing field) */
  66551. _forceShowBoundingBoxes: boolean;
  66552. /**
  66553. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66554. */
  66555. forceShowBoundingBoxes: boolean;
  66556. /**
  66557. * Gets the bounding box renderer associated with the scene
  66558. * @returns a BoundingBoxRenderer
  66559. */
  66560. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66561. }
  66562. interface AbstractMesh {
  66563. /** @hidden (Backing field) */
  66564. _showBoundingBox: boolean;
  66565. /**
  66566. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66567. */
  66568. showBoundingBox: boolean;
  66569. }
  66570. /**
  66571. * Component responsible of rendering the bounding box of the meshes in a scene.
  66572. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66573. */
  66574. export class BoundingBoxRenderer implements ISceneComponent {
  66575. /**
  66576. * The component name helpfull to identify the component in the list of scene components.
  66577. */
  66578. readonly name: string;
  66579. /**
  66580. * The scene the component belongs to.
  66581. */
  66582. scene: Scene;
  66583. /**
  66584. * Color of the bounding box lines placed in front of an object
  66585. */
  66586. frontColor: Color3;
  66587. /**
  66588. * Color of the bounding box lines placed behind an object
  66589. */
  66590. backColor: Color3;
  66591. /**
  66592. * Defines if the renderer should show the back lines or not
  66593. */
  66594. showBackLines: boolean;
  66595. /**
  66596. * @hidden
  66597. */
  66598. renderList: SmartArray<BoundingBox>;
  66599. private _colorShader;
  66600. private _vertexBuffers;
  66601. private _indexBuffer;
  66602. private _fillIndexBuffer;
  66603. private _fillIndexData;
  66604. /**
  66605. * Instantiates a new bounding box renderer in a scene.
  66606. * @param scene the scene the renderer renders in
  66607. */
  66608. constructor(scene: Scene);
  66609. /**
  66610. * Registers the component in a given scene
  66611. */
  66612. register(): void;
  66613. private _evaluateSubMesh;
  66614. private _activeMesh;
  66615. private _prepareRessources;
  66616. private _createIndexBuffer;
  66617. /**
  66618. * Rebuilds the elements related to this component in case of
  66619. * context lost for instance.
  66620. */
  66621. rebuild(): void;
  66622. /**
  66623. * @hidden
  66624. */
  66625. reset(): void;
  66626. /**
  66627. * Render the bounding boxes of a specific rendering group
  66628. * @param renderingGroupId defines the rendering group to render
  66629. */
  66630. render(renderingGroupId: number): void;
  66631. /**
  66632. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66633. * @param mesh Define the mesh to render the occlusion bounding box for
  66634. */
  66635. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66636. /**
  66637. * Dispose and release the resources attached to this renderer.
  66638. */
  66639. dispose(): void;
  66640. }
  66641. }
  66642. declare module BABYLON {
  66643. interface Scene {
  66644. /** @hidden (Backing field) */
  66645. _depthRenderer: {
  66646. [id: string]: DepthRenderer;
  66647. };
  66648. /**
  66649. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66650. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66651. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66652. * @returns the created depth renderer
  66653. */
  66654. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66655. /**
  66656. * Disables a depth renderer for a given camera
  66657. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66658. */
  66659. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66660. }
  66661. /**
  66662. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66663. * in several rendering techniques.
  66664. */
  66665. export class DepthRendererSceneComponent implements ISceneComponent {
  66666. /**
  66667. * The component name helpfull to identify the component in the list of scene components.
  66668. */
  66669. readonly name: string;
  66670. /**
  66671. * The scene the component belongs to.
  66672. */
  66673. scene: Scene;
  66674. /**
  66675. * Creates a new instance of the component for the given scene
  66676. * @param scene Defines the scene to register the component in
  66677. */
  66678. constructor(scene: Scene);
  66679. /**
  66680. * Registers the component in a given scene
  66681. */
  66682. register(): void;
  66683. /**
  66684. * Rebuilds the elements related to this component in case of
  66685. * context lost for instance.
  66686. */
  66687. rebuild(): void;
  66688. /**
  66689. * Disposes the component and the associated ressources
  66690. */
  66691. dispose(): void;
  66692. private _gatherRenderTargets;
  66693. private _gatherActiveCameraRenderTargets;
  66694. }
  66695. }
  66696. declare module BABYLON {
  66697. /** @hidden */
  66698. export var outlinePixelShader: {
  66699. name: string;
  66700. shader: string;
  66701. };
  66702. }
  66703. declare module BABYLON {
  66704. /** @hidden */
  66705. export var outlineVertexShader: {
  66706. name: string;
  66707. shader: string;
  66708. };
  66709. }
  66710. declare module BABYLON {
  66711. interface Scene {
  66712. /** @hidden */
  66713. _outlineRenderer: OutlineRenderer;
  66714. /**
  66715. * Gets the outline renderer associated with the scene
  66716. * @returns a OutlineRenderer
  66717. */
  66718. getOutlineRenderer(): OutlineRenderer;
  66719. }
  66720. interface AbstractMesh {
  66721. /** @hidden (Backing field) */
  66722. _renderOutline: boolean;
  66723. /**
  66724. * Gets or sets a boolean indicating if the outline must be rendered as well
  66725. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66726. */
  66727. renderOutline: boolean;
  66728. /** @hidden (Backing field) */
  66729. _renderOverlay: boolean;
  66730. /**
  66731. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66732. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66733. */
  66734. renderOverlay: boolean;
  66735. }
  66736. /**
  66737. * This class is responsible to draw bothe outline/overlay of meshes.
  66738. * It should not be used directly but through the available method on mesh.
  66739. */
  66740. export class OutlineRenderer implements ISceneComponent {
  66741. /**
  66742. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66743. */
  66744. private static _StencilReference;
  66745. /**
  66746. * The name of the component. Each component must have a unique name.
  66747. */
  66748. name: string;
  66749. /**
  66750. * The scene the component belongs to.
  66751. */
  66752. scene: Scene;
  66753. /**
  66754. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66755. */
  66756. zOffset: number;
  66757. private _engine;
  66758. private _effect;
  66759. private _cachedDefines;
  66760. private _savedDepthWrite;
  66761. /**
  66762. * Instantiates a new outline renderer. (There could be only one per scene).
  66763. * @param scene Defines the scene it belongs to
  66764. */
  66765. constructor(scene: Scene);
  66766. /**
  66767. * Register the component to one instance of a scene.
  66768. */
  66769. register(): void;
  66770. /**
  66771. * Rebuilds the elements related to this component in case of
  66772. * context lost for instance.
  66773. */
  66774. rebuild(): void;
  66775. /**
  66776. * Disposes the component and the associated ressources.
  66777. */
  66778. dispose(): void;
  66779. /**
  66780. * Renders the outline in the canvas.
  66781. * @param subMesh Defines the sumesh to render
  66782. * @param batch Defines the batch of meshes in case of instances
  66783. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66784. */
  66785. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66786. /**
  66787. * Returns whether or not the outline renderer is ready for a given submesh.
  66788. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66789. * @param subMesh Defines the submesh to check readyness for
  66790. * @param useInstances Defines wheter wee are trying to render instances or not
  66791. * @returns true if ready otherwise false
  66792. */
  66793. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66794. private _beforeRenderingMesh;
  66795. private _afterRenderingMesh;
  66796. }
  66797. }
  66798. declare module BABYLON {
  66799. /**
  66800. * Defines the basic options interface of a Sprite Frame Source Size.
  66801. */
  66802. export interface ISpriteJSONSpriteSourceSize {
  66803. /**
  66804. * number of the original width of the Frame
  66805. */
  66806. w: number;
  66807. /**
  66808. * number of the original height of the Frame
  66809. */
  66810. h: number;
  66811. }
  66812. /**
  66813. * Defines the basic options interface of a Sprite Frame Data.
  66814. */
  66815. export interface ISpriteJSONSpriteFrameData {
  66816. /**
  66817. * number of the x offset of the Frame
  66818. */
  66819. x: number;
  66820. /**
  66821. * number of the y offset of the Frame
  66822. */
  66823. y: number;
  66824. /**
  66825. * number of the width of the Frame
  66826. */
  66827. w: number;
  66828. /**
  66829. * number of the height of the Frame
  66830. */
  66831. h: number;
  66832. }
  66833. /**
  66834. * Defines the basic options interface of a JSON Sprite.
  66835. */
  66836. export interface ISpriteJSONSprite {
  66837. /**
  66838. * string name of the Frame
  66839. */
  66840. filename: string;
  66841. /**
  66842. * ISpriteJSONSpriteFrame basic object of the frame data
  66843. */
  66844. frame: ISpriteJSONSpriteFrameData;
  66845. /**
  66846. * boolean to flag is the frame was rotated.
  66847. */
  66848. rotated: boolean;
  66849. /**
  66850. * boolean to flag is the frame was trimmed.
  66851. */
  66852. trimmed: boolean;
  66853. /**
  66854. * ISpriteJSONSpriteFrame basic object of the source data
  66855. */
  66856. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66857. /**
  66858. * ISpriteJSONSpriteFrame basic object of the source data
  66859. */
  66860. sourceSize: ISpriteJSONSpriteSourceSize;
  66861. }
  66862. /**
  66863. * Defines the basic options interface of a JSON atlas.
  66864. */
  66865. export interface ISpriteJSONAtlas {
  66866. /**
  66867. * Array of objects that contain the frame data.
  66868. */
  66869. frames: Array<ISpriteJSONSprite>;
  66870. /**
  66871. * object basic object containing the sprite meta data.
  66872. */
  66873. meta?: object;
  66874. }
  66875. }
  66876. declare module BABYLON {
  66877. /** @hidden */
  66878. export var spriteMapPixelShader: {
  66879. name: string;
  66880. shader: string;
  66881. };
  66882. }
  66883. declare module BABYLON {
  66884. /** @hidden */
  66885. export var spriteMapVertexShader: {
  66886. name: string;
  66887. shader: string;
  66888. };
  66889. }
  66890. declare module BABYLON {
  66891. /**
  66892. * Defines the basic options interface of a SpriteMap
  66893. */
  66894. export interface ISpriteMapOptions {
  66895. /**
  66896. * Vector2 of the number of cells in the grid.
  66897. */
  66898. stageSize?: Vector2;
  66899. /**
  66900. * Vector2 of the size of the output plane in World Units.
  66901. */
  66902. outputSize?: Vector2;
  66903. /**
  66904. * Vector3 of the position of the output plane in World Units.
  66905. */
  66906. outputPosition?: Vector3;
  66907. /**
  66908. * Vector3 of the rotation of the output plane.
  66909. */
  66910. outputRotation?: Vector3;
  66911. /**
  66912. * number of layers that the system will reserve in resources.
  66913. */
  66914. layerCount?: number;
  66915. /**
  66916. * number of max animation frames a single cell will reserve in resources.
  66917. */
  66918. maxAnimationFrames?: number;
  66919. /**
  66920. * number cell index of the base tile when the system compiles.
  66921. */
  66922. baseTile?: number;
  66923. /**
  66924. * boolean flip the sprite after its been repositioned by the framing data.
  66925. */
  66926. flipU?: boolean;
  66927. /**
  66928. * Vector3 scalar of the global RGB values of the SpriteMap.
  66929. */
  66930. colorMultiply?: Vector3;
  66931. }
  66932. /**
  66933. * Defines the IDisposable interface in order to be cleanable from resources.
  66934. */
  66935. export interface ISpriteMap extends IDisposable {
  66936. /**
  66937. * String name of the SpriteMap.
  66938. */
  66939. name: string;
  66940. /**
  66941. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66942. */
  66943. atlasJSON: ISpriteJSONAtlas;
  66944. /**
  66945. * Texture of the SpriteMap.
  66946. */
  66947. spriteSheet: Texture;
  66948. /**
  66949. * The parameters to initialize the SpriteMap with.
  66950. */
  66951. options: ISpriteMapOptions;
  66952. }
  66953. /**
  66954. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66955. */
  66956. export class SpriteMap implements ISpriteMap {
  66957. /** The Name of the spriteMap */
  66958. name: string;
  66959. /** The JSON file with the frame and meta data */
  66960. atlasJSON: ISpriteJSONAtlas;
  66961. /** The systems Sprite Sheet Texture */
  66962. spriteSheet: Texture;
  66963. /** Arguments passed with the Constructor */
  66964. options: ISpriteMapOptions;
  66965. /** Public Sprite Storage array, parsed from atlasJSON */
  66966. sprites: Array<ISpriteJSONSprite>;
  66967. /** Returns the Number of Sprites in the System */
  66968. get spriteCount(): number;
  66969. /** Returns the Position of Output Plane*/
  66970. get position(): Vector3;
  66971. /** Returns the Position of Output Plane*/
  66972. set position(v: Vector3);
  66973. /** Returns the Rotation of Output Plane*/
  66974. get rotation(): Vector3;
  66975. /** Returns the Rotation of Output Plane*/
  66976. set rotation(v: Vector3);
  66977. /** Sets the AnimationMap*/
  66978. get animationMap(): RawTexture;
  66979. /** Sets the AnimationMap*/
  66980. set animationMap(v: RawTexture);
  66981. /** Scene that the SpriteMap was created in */
  66982. private _scene;
  66983. /** Texture Buffer of Float32 that holds tile frame data*/
  66984. private _frameMap;
  66985. /** Texture Buffers of Float32 that holds tileMap data*/
  66986. private _tileMaps;
  66987. /** Texture Buffer of Float32 that holds Animation Data*/
  66988. private _animationMap;
  66989. /** Custom ShaderMaterial Central to the System*/
  66990. private _material;
  66991. /** Custom ShaderMaterial Central to the System*/
  66992. private _output;
  66993. /** Systems Time Ticker*/
  66994. private _time;
  66995. /**
  66996. * Creates a new SpriteMap
  66997. * @param name defines the SpriteMaps Name
  66998. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66999. * @param spriteSheet is the Texture that the Sprites are on.
  67000. * @param options a basic deployment configuration
  67001. * @param scene The Scene that the map is deployed on
  67002. */
  67003. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67004. /**
  67005. * Returns tileID location
  67006. * @returns Vector2 the cell position ID
  67007. */
  67008. getTileID(): Vector2;
  67009. /**
  67010. * Gets the UV location of the mouse over the SpriteMap.
  67011. * @returns Vector2 the UV position of the mouse interaction
  67012. */
  67013. getMousePosition(): Vector2;
  67014. /**
  67015. * Creates the "frame" texture Buffer
  67016. * -------------------------------------
  67017. * Structure of frames
  67018. * "filename": "Falling-Water-2.png",
  67019. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67020. * "rotated": true,
  67021. * "trimmed": true,
  67022. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67023. * "sourceSize": {"w":32,"h":32}
  67024. * @returns RawTexture of the frameMap
  67025. */
  67026. private _createFrameBuffer;
  67027. /**
  67028. * Creates the tileMap texture Buffer
  67029. * @param buffer normally and array of numbers, or a false to generate from scratch
  67030. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67031. * @returns RawTexture of the tileMap
  67032. */
  67033. private _createTileBuffer;
  67034. /**
  67035. * Modifies the data of the tileMaps
  67036. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67037. * @param pos is the iVector2 Coordinates of the Tile
  67038. * @param tile The SpriteIndex of the new Tile
  67039. */
  67040. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67041. /**
  67042. * Creates the animationMap texture Buffer
  67043. * @param buffer normally and array of numbers, or a false to generate from scratch
  67044. * @returns RawTexture of the animationMap
  67045. */
  67046. private _createTileAnimationBuffer;
  67047. /**
  67048. * Modifies the data of the animationMap
  67049. * @param cellID is the Index of the Sprite
  67050. * @param _frame is the target Animation frame
  67051. * @param toCell is the Target Index of the next frame of the animation
  67052. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67053. * @param speed is a global scalar of the time variable on the map.
  67054. */
  67055. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67056. /**
  67057. * Exports the .tilemaps file
  67058. */
  67059. saveTileMaps(): void;
  67060. /**
  67061. * Imports the .tilemaps file
  67062. * @param url of the .tilemaps file
  67063. */
  67064. loadTileMaps(url: string): void;
  67065. /**
  67066. * Release associated resources
  67067. */
  67068. dispose(): void;
  67069. }
  67070. }
  67071. declare module BABYLON {
  67072. /**
  67073. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67074. * @see http://doc.babylonjs.com/babylon101/sprites
  67075. */
  67076. export class SpritePackedManager extends SpriteManager {
  67077. /** defines the packed manager's name */
  67078. name: string;
  67079. /**
  67080. * Creates a new sprite manager from a packed sprite sheet
  67081. * @param name defines the manager's name
  67082. * @param imgUrl defines the sprite sheet url
  67083. * @param capacity defines the maximum allowed number of sprites
  67084. * @param scene defines the hosting scene
  67085. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67086. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67087. * @param samplingMode defines the smapling mode to use with spritesheet
  67088. * @param fromPacked set to true; do not alter
  67089. */
  67090. constructor(
  67091. /** defines the packed manager's name */
  67092. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67093. }
  67094. }
  67095. declare module BABYLON {
  67096. /**
  67097. * Defines the list of states available for a task inside a AssetsManager
  67098. */
  67099. export enum AssetTaskState {
  67100. /**
  67101. * Initialization
  67102. */
  67103. INIT = 0,
  67104. /**
  67105. * Running
  67106. */
  67107. RUNNING = 1,
  67108. /**
  67109. * Done
  67110. */
  67111. DONE = 2,
  67112. /**
  67113. * Error
  67114. */
  67115. ERROR = 3
  67116. }
  67117. /**
  67118. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67119. */
  67120. export abstract class AbstractAssetTask {
  67121. /**
  67122. * Task name
  67123. */ name: string;
  67124. /**
  67125. * Callback called when the task is successful
  67126. */
  67127. onSuccess: (task: any) => void;
  67128. /**
  67129. * Callback called when the task is not successful
  67130. */
  67131. onError: (task: any, message?: string, exception?: any) => void;
  67132. /**
  67133. * Creates a new AssetsManager
  67134. * @param name defines the name of the task
  67135. */
  67136. constructor(
  67137. /**
  67138. * Task name
  67139. */ name: string);
  67140. private _isCompleted;
  67141. private _taskState;
  67142. private _errorObject;
  67143. /**
  67144. * Get if the task is completed
  67145. */
  67146. get isCompleted(): boolean;
  67147. /**
  67148. * Gets the current state of the task
  67149. */
  67150. get taskState(): AssetTaskState;
  67151. /**
  67152. * Gets the current error object (if task is in error)
  67153. */
  67154. get errorObject(): {
  67155. message?: string;
  67156. exception?: any;
  67157. };
  67158. /**
  67159. * Internal only
  67160. * @hidden
  67161. */
  67162. _setErrorObject(message?: string, exception?: any): void;
  67163. /**
  67164. * Execute the current task
  67165. * @param scene defines the scene where you want your assets to be loaded
  67166. * @param onSuccess is a callback called when the task is successfully executed
  67167. * @param onError is a callback called if an error occurs
  67168. */
  67169. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67170. /**
  67171. * Execute the current task
  67172. * @param scene defines the scene where you want your assets to be loaded
  67173. * @param onSuccess is a callback called when the task is successfully executed
  67174. * @param onError is a callback called if an error occurs
  67175. */
  67176. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67177. /**
  67178. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67179. * This can be used with failed tasks that have the reason for failure fixed.
  67180. */
  67181. reset(): void;
  67182. private onErrorCallback;
  67183. private onDoneCallback;
  67184. }
  67185. /**
  67186. * Define the interface used by progress events raised during assets loading
  67187. */
  67188. export interface IAssetsProgressEvent {
  67189. /**
  67190. * Defines the number of remaining tasks to process
  67191. */
  67192. remainingCount: number;
  67193. /**
  67194. * Defines the total number of tasks
  67195. */
  67196. totalCount: number;
  67197. /**
  67198. * Defines the task that was just processed
  67199. */
  67200. task: AbstractAssetTask;
  67201. }
  67202. /**
  67203. * Class used to share progress information about assets loading
  67204. */
  67205. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67206. /**
  67207. * Defines the number of remaining tasks to process
  67208. */
  67209. remainingCount: number;
  67210. /**
  67211. * Defines the total number of tasks
  67212. */
  67213. totalCount: number;
  67214. /**
  67215. * Defines the task that was just processed
  67216. */
  67217. task: AbstractAssetTask;
  67218. /**
  67219. * Creates a AssetsProgressEvent
  67220. * @param remainingCount defines the number of remaining tasks to process
  67221. * @param totalCount defines the total number of tasks
  67222. * @param task defines the task that was just processed
  67223. */
  67224. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67225. }
  67226. /**
  67227. * Define a task used by AssetsManager to load meshes
  67228. */
  67229. export class MeshAssetTask extends AbstractAssetTask {
  67230. /**
  67231. * Defines the name of the task
  67232. */
  67233. name: string;
  67234. /**
  67235. * Defines the list of mesh's names you want to load
  67236. */
  67237. meshesNames: any;
  67238. /**
  67239. * Defines the root url to use as a base to load your meshes and associated resources
  67240. */
  67241. rootUrl: string;
  67242. /**
  67243. * Defines the filename of the scene to load from
  67244. */
  67245. sceneFilename: string;
  67246. /**
  67247. * Gets the list of loaded meshes
  67248. */
  67249. loadedMeshes: Array<AbstractMesh>;
  67250. /**
  67251. * Gets the list of loaded particle systems
  67252. */
  67253. loadedParticleSystems: Array<IParticleSystem>;
  67254. /**
  67255. * Gets the list of loaded skeletons
  67256. */
  67257. loadedSkeletons: Array<Skeleton>;
  67258. /**
  67259. * Gets the list of loaded animation groups
  67260. */
  67261. loadedAnimationGroups: Array<AnimationGroup>;
  67262. /**
  67263. * Callback called when the task is successful
  67264. */
  67265. onSuccess: (task: MeshAssetTask) => void;
  67266. /**
  67267. * Callback called when the task is successful
  67268. */
  67269. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67270. /**
  67271. * Creates a new MeshAssetTask
  67272. * @param name defines the name of the task
  67273. * @param meshesNames defines the list of mesh's names you want to load
  67274. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67275. * @param sceneFilename defines the filename of the scene to load from
  67276. */
  67277. constructor(
  67278. /**
  67279. * Defines the name of the task
  67280. */
  67281. name: string,
  67282. /**
  67283. * Defines the list of mesh's names you want to load
  67284. */
  67285. meshesNames: any,
  67286. /**
  67287. * Defines the root url to use as a base to load your meshes and associated resources
  67288. */
  67289. rootUrl: string,
  67290. /**
  67291. * Defines the filename of the scene to load from
  67292. */
  67293. sceneFilename: string);
  67294. /**
  67295. * Execute the current task
  67296. * @param scene defines the scene where you want your assets to be loaded
  67297. * @param onSuccess is a callback called when the task is successfully executed
  67298. * @param onError is a callback called if an error occurs
  67299. */
  67300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67301. }
  67302. /**
  67303. * Define a task used by AssetsManager to load text content
  67304. */
  67305. export class TextFileAssetTask extends AbstractAssetTask {
  67306. /**
  67307. * Defines the name of the task
  67308. */
  67309. name: string;
  67310. /**
  67311. * Defines the location of the file to load
  67312. */
  67313. url: string;
  67314. /**
  67315. * Gets the loaded text string
  67316. */
  67317. text: string;
  67318. /**
  67319. * Callback called when the task is successful
  67320. */
  67321. onSuccess: (task: TextFileAssetTask) => void;
  67322. /**
  67323. * Callback called when the task is successful
  67324. */
  67325. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67326. /**
  67327. * Creates a new TextFileAssetTask object
  67328. * @param name defines the name of the task
  67329. * @param url defines the location of the file to load
  67330. */
  67331. constructor(
  67332. /**
  67333. * Defines the name of the task
  67334. */
  67335. name: string,
  67336. /**
  67337. * Defines the location of the file to load
  67338. */
  67339. url: string);
  67340. /**
  67341. * Execute the current task
  67342. * @param scene defines the scene where you want your assets to be loaded
  67343. * @param onSuccess is a callback called when the task is successfully executed
  67344. * @param onError is a callback called if an error occurs
  67345. */
  67346. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67347. }
  67348. /**
  67349. * Define a task used by AssetsManager to load binary data
  67350. */
  67351. export class BinaryFileAssetTask extends AbstractAssetTask {
  67352. /**
  67353. * Defines the name of the task
  67354. */
  67355. name: string;
  67356. /**
  67357. * Defines the location of the file to load
  67358. */
  67359. url: string;
  67360. /**
  67361. * Gets the lodaded data (as an array buffer)
  67362. */
  67363. data: ArrayBuffer;
  67364. /**
  67365. * Callback called when the task is successful
  67366. */
  67367. onSuccess: (task: BinaryFileAssetTask) => void;
  67368. /**
  67369. * Callback called when the task is successful
  67370. */
  67371. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67372. /**
  67373. * Creates a new BinaryFileAssetTask object
  67374. * @param name defines the name of the new task
  67375. * @param url defines the location of the file to load
  67376. */
  67377. constructor(
  67378. /**
  67379. * Defines the name of the task
  67380. */
  67381. name: string,
  67382. /**
  67383. * Defines the location of the file to load
  67384. */
  67385. url: string);
  67386. /**
  67387. * Execute the current task
  67388. * @param scene defines the scene where you want your assets to be loaded
  67389. * @param onSuccess is a callback called when the task is successfully executed
  67390. * @param onError is a callback called if an error occurs
  67391. */
  67392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67393. }
  67394. /**
  67395. * Define a task used by AssetsManager to load images
  67396. */
  67397. export class ImageAssetTask extends AbstractAssetTask {
  67398. /**
  67399. * Defines the name of the task
  67400. */
  67401. name: string;
  67402. /**
  67403. * Defines the location of the image to load
  67404. */
  67405. url: string;
  67406. /**
  67407. * Gets the loaded images
  67408. */
  67409. image: HTMLImageElement;
  67410. /**
  67411. * Callback called when the task is successful
  67412. */
  67413. onSuccess: (task: ImageAssetTask) => void;
  67414. /**
  67415. * Callback called when the task is successful
  67416. */
  67417. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67418. /**
  67419. * Creates a new ImageAssetTask
  67420. * @param name defines the name of the task
  67421. * @param url defines the location of the image to load
  67422. */
  67423. constructor(
  67424. /**
  67425. * Defines the name of the task
  67426. */
  67427. name: string,
  67428. /**
  67429. * Defines the location of the image to load
  67430. */
  67431. url: string);
  67432. /**
  67433. * Execute the current task
  67434. * @param scene defines the scene where you want your assets to be loaded
  67435. * @param onSuccess is a callback called when the task is successfully executed
  67436. * @param onError is a callback called if an error occurs
  67437. */
  67438. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67439. }
  67440. /**
  67441. * Defines the interface used by texture loading tasks
  67442. */
  67443. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67444. /**
  67445. * Gets the loaded texture
  67446. */
  67447. texture: TEX;
  67448. }
  67449. /**
  67450. * Define a task used by AssetsManager to load 2D textures
  67451. */
  67452. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67453. /**
  67454. * Defines the name of the task
  67455. */
  67456. name: string;
  67457. /**
  67458. * Defines the location of the file to load
  67459. */
  67460. url: string;
  67461. /**
  67462. * Defines if mipmap should not be generated (default is false)
  67463. */
  67464. noMipmap?: boolean | undefined;
  67465. /**
  67466. * Defines if texture must be inverted on Y axis (default is false)
  67467. */
  67468. invertY?: boolean | undefined;
  67469. /**
  67470. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67471. */
  67472. samplingMode: number;
  67473. /**
  67474. * Gets the loaded texture
  67475. */
  67476. texture: Texture;
  67477. /**
  67478. * Callback called when the task is successful
  67479. */
  67480. onSuccess: (task: TextureAssetTask) => void;
  67481. /**
  67482. * Callback called when the task is successful
  67483. */
  67484. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67485. /**
  67486. * Creates a new TextureAssetTask object
  67487. * @param name defines the name of the task
  67488. * @param url defines the location of the file to load
  67489. * @param noMipmap defines if mipmap should not be generated (default is false)
  67490. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67491. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67492. */
  67493. constructor(
  67494. /**
  67495. * Defines the name of the task
  67496. */
  67497. name: string,
  67498. /**
  67499. * Defines the location of the file to load
  67500. */
  67501. url: string,
  67502. /**
  67503. * Defines if mipmap should not be generated (default is false)
  67504. */
  67505. noMipmap?: boolean | undefined,
  67506. /**
  67507. * Defines if texture must be inverted on Y axis (default is false)
  67508. */
  67509. invertY?: boolean | undefined,
  67510. /**
  67511. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67512. */
  67513. samplingMode?: number);
  67514. /**
  67515. * Execute the current task
  67516. * @param scene defines the scene where you want your assets to be loaded
  67517. * @param onSuccess is a callback called when the task is successfully executed
  67518. * @param onError is a callback called if an error occurs
  67519. */
  67520. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67521. }
  67522. /**
  67523. * Define a task used by AssetsManager to load cube textures
  67524. */
  67525. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67526. /**
  67527. * Defines the name of the task
  67528. */
  67529. name: string;
  67530. /**
  67531. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67532. */
  67533. url: string;
  67534. /**
  67535. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67536. */
  67537. extensions?: string[] | undefined;
  67538. /**
  67539. * Defines if mipmaps should not be generated (default is false)
  67540. */
  67541. noMipmap?: boolean | undefined;
  67542. /**
  67543. * Defines the explicit list of files (undefined by default)
  67544. */
  67545. files?: string[] | undefined;
  67546. /**
  67547. * Gets the loaded texture
  67548. */
  67549. texture: CubeTexture;
  67550. /**
  67551. * Callback called when the task is successful
  67552. */
  67553. onSuccess: (task: CubeTextureAssetTask) => void;
  67554. /**
  67555. * Callback called when the task is successful
  67556. */
  67557. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67558. /**
  67559. * Creates a new CubeTextureAssetTask
  67560. * @param name defines the name of the task
  67561. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67562. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67563. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67564. * @param files defines the explicit list of files (undefined by default)
  67565. */
  67566. constructor(
  67567. /**
  67568. * Defines the name of the task
  67569. */
  67570. name: string,
  67571. /**
  67572. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67573. */
  67574. url: string,
  67575. /**
  67576. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67577. */
  67578. extensions?: string[] | undefined,
  67579. /**
  67580. * Defines if mipmaps should not be generated (default is false)
  67581. */
  67582. noMipmap?: boolean | undefined,
  67583. /**
  67584. * Defines the explicit list of files (undefined by default)
  67585. */
  67586. files?: string[] | undefined);
  67587. /**
  67588. * Execute the current task
  67589. * @param scene defines the scene where you want your assets to be loaded
  67590. * @param onSuccess is a callback called when the task is successfully executed
  67591. * @param onError is a callback called if an error occurs
  67592. */
  67593. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67594. }
  67595. /**
  67596. * Define a task used by AssetsManager to load HDR cube textures
  67597. */
  67598. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67599. /**
  67600. * Defines the name of the task
  67601. */
  67602. name: string;
  67603. /**
  67604. * Defines the location of the file to load
  67605. */
  67606. url: string;
  67607. /**
  67608. * Defines the desired size (the more it increases the longer the generation will be)
  67609. */
  67610. size: number;
  67611. /**
  67612. * Defines if mipmaps should not be generated (default is false)
  67613. */
  67614. noMipmap: boolean;
  67615. /**
  67616. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67617. */
  67618. generateHarmonics: boolean;
  67619. /**
  67620. * 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)
  67621. */
  67622. gammaSpace: boolean;
  67623. /**
  67624. * Internal Use Only
  67625. */
  67626. reserved: boolean;
  67627. /**
  67628. * Gets the loaded texture
  67629. */
  67630. texture: HDRCubeTexture;
  67631. /**
  67632. * Callback called when the task is successful
  67633. */
  67634. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67635. /**
  67636. * Callback called when the task is successful
  67637. */
  67638. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67639. /**
  67640. * Creates a new HDRCubeTextureAssetTask object
  67641. * @param name defines the name of the task
  67642. * @param url defines the location of the file to load
  67643. * @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.
  67644. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67645. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67646. * @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)
  67647. * @param reserved Internal use only
  67648. */
  67649. constructor(
  67650. /**
  67651. * Defines the name of the task
  67652. */
  67653. name: string,
  67654. /**
  67655. * Defines the location of the file to load
  67656. */
  67657. url: string,
  67658. /**
  67659. * Defines the desired size (the more it increases the longer the generation will be)
  67660. */
  67661. size: number,
  67662. /**
  67663. * Defines if mipmaps should not be generated (default is false)
  67664. */
  67665. noMipmap?: boolean,
  67666. /**
  67667. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67668. */
  67669. generateHarmonics?: boolean,
  67670. /**
  67671. * 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)
  67672. */
  67673. gammaSpace?: boolean,
  67674. /**
  67675. * Internal Use Only
  67676. */
  67677. reserved?: boolean);
  67678. /**
  67679. * Execute the current task
  67680. * @param scene defines the scene where you want your assets to be loaded
  67681. * @param onSuccess is a callback called when the task is successfully executed
  67682. * @param onError is a callback called if an error occurs
  67683. */
  67684. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67685. }
  67686. /**
  67687. * Define a task used by AssetsManager to load Equirectangular cube textures
  67688. */
  67689. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67690. /**
  67691. * Defines the name of the task
  67692. */
  67693. name: string;
  67694. /**
  67695. * Defines the location of the file to load
  67696. */
  67697. url: string;
  67698. /**
  67699. * Defines the desired size (the more it increases the longer the generation will be)
  67700. */
  67701. size: number;
  67702. /**
  67703. * Defines if mipmaps should not be generated (default is false)
  67704. */
  67705. noMipmap: boolean;
  67706. /**
  67707. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67708. * but the standard material would require them in Gamma space) (default is true)
  67709. */
  67710. gammaSpace: boolean;
  67711. /**
  67712. * Gets the loaded texture
  67713. */
  67714. texture: EquiRectangularCubeTexture;
  67715. /**
  67716. * Callback called when the task is successful
  67717. */
  67718. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67719. /**
  67720. * Callback called when the task is successful
  67721. */
  67722. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67723. /**
  67724. * Creates a new EquiRectangularCubeTextureAssetTask object
  67725. * @param name defines the name of the task
  67726. * @param url defines the location of the file to load
  67727. * @param size defines the desired size (the more it increases the longer the generation will be)
  67728. * If the size is omitted this implies you are using a preprocessed cubemap.
  67729. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67730. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67731. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67732. * (default is true)
  67733. */
  67734. constructor(
  67735. /**
  67736. * Defines the name of the task
  67737. */
  67738. name: string,
  67739. /**
  67740. * Defines the location of the file to load
  67741. */
  67742. url: string,
  67743. /**
  67744. * Defines the desired size (the more it increases the longer the generation will be)
  67745. */
  67746. size: number,
  67747. /**
  67748. * Defines if mipmaps should not be generated (default is false)
  67749. */
  67750. noMipmap?: boolean,
  67751. /**
  67752. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67753. * but the standard material would require them in Gamma space) (default is true)
  67754. */
  67755. gammaSpace?: boolean);
  67756. /**
  67757. * Execute the current task
  67758. * @param scene defines the scene where you want your assets to be loaded
  67759. * @param onSuccess is a callback called when the task is successfully executed
  67760. * @param onError is a callback called if an error occurs
  67761. */
  67762. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67763. }
  67764. /**
  67765. * This class can be used to easily import assets into a scene
  67766. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67767. */
  67768. export class AssetsManager {
  67769. private _scene;
  67770. private _isLoading;
  67771. protected _tasks: AbstractAssetTask[];
  67772. protected _waitingTasksCount: number;
  67773. protected _totalTasksCount: number;
  67774. /**
  67775. * Callback called when all tasks are processed
  67776. */
  67777. onFinish: (tasks: AbstractAssetTask[]) => void;
  67778. /**
  67779. * Callback called when a task is successful
  67780. */
  67781. onTaskSuccess: (task: AbstractAssetTask) => void;
  67782. /**
  67783. * Callback called when a task had an error
  67784. */
  67785. onTaskError: (task: AbstractAssetTask) => void;
  67786. /**
  67787. * Callback called when a task is done (whatever the result is)
  67788. */
  67789. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67790. /**
  67791. * Observable called when all tasks are processed
  67792. */
  67793. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67794. /**
  67795. * Observable called when a task had an error
  67796. */
  67797. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67798. /**
  67799. * Observable called when all tasks were executed
  67800. */
  67801. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67802. /**
  67803. * Observable called when a task is done (whatever the result is)
  67804. */
  67805. onProgressObservable: Observable<IAssetsProgressEvent>;
  67806. /**
  67807. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67808. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67809. */
  67810. useDefaultLoadingScreen: boolean;
  67811. /**
  67812. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67813. * when all assets have been downloaded.
  67814. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67815. */
  67816. autoHideLoadingUI: boolean;
  67817. /**
  67818. * Creates a new AssetsManager
  67819. * @param scene defines the scene to work on
  67820. */
  67821. constructor(scene: Scene);
  67822. /**
  67823. * Add a MeshAssetTask to the list of active tasks
  67824. * @param taskName defines the name of the new task
  67825. * @param meshesNames defines the name of meshes to load
  67826. * @param rootUrl defines the root url to use to locate files
  67827. * @param sceneFilename defines the filename of the scene file
  67828. * @returns a new MeshAssetTask object
  67829. */
  67830. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67831. /**
  67832. * Add a TextFileAssetTask to the list of active tasks
  67833. * @param taskName defines the name of the new task
  67834. * @param url defines the url of the file to load
  67835. * @returns a new TextFileAssetTask object
  67836. */
  67837. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67838. /**
  67839. * Add a BinaryFileAssetTask to the list of active tasks
  67840. * @param taskName defines the name of the new task
  67841. * @param url defines the url of the file to load
  67842. * @returns a new BinaryFileAssetTask object
  67843. */
  67844. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67845. /**
  67846. * Add a ImageAssetTask to the list of active tasks
  67847. * @param taskName defines the name of the new task
  67848. * @param url defines the url of the file to load
  67849. * @returns a new ImageAssetTask object
  67850. */
  67851. addImageTask(taskName: string, url: string): ImageAssetTask;
  67852. /**
  67853. * Add a TextureAssetTask to the list of active tasks
  67854. * @param taskName defines the name of the new task
  67855. * @param url defines the url of the file to load
  67856. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67857. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67858. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67859. * @returns a new TextureAssetTask object
  67860. */
  67861. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67862. /**
  67863. * Add a CubeTextureAssetTask to the list of active tasks
  67864. * @param taskName defines the name of the new task
  67865. * @param url defines the url of the file to load
  67866. * @param extensions defines the extension to use to load the cube map (can be null)
  67867. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67868. * @param files defines the list of files to load (can be null)
  67869. * @returns a new CubeTextureAssetTask object
  67870. */
  67871. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67872. /**
  67873. *
  67874. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67875. * @param taskName defines the name of the new task
  67876. * @param url defines the url of the file to load
  67877. * @param size defines the size you want for the cubemap (can be null)
  67878. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67879. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67880. * @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)
  67881. * @param reserved Internal use only
  67882. * @returns a new HDRCubeTextureAssetTask object
  67883. */
  67884. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67885. /**
  67886. *
  67887. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67888. * @param taskName defines the name of the new task
  67889. * @param url defines the url of the file to load
  67890. * @param size defines the size you want for the cubemap (can be null)
  67891. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67892. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67893. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67894. * @returns a new EquiRectangularCubeTextureAssetTask object
  67895. */
  67896. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67897. /**
  67898. * Remove a task from the assets manager.
  67899. * @param task the task to remove
  67900. */
  67901. removeTask(task: AbstractAssetTask): void;
  67902. private _decreaseWaitingTasksCount;
  67903. private _runTask;
  67904. /**
  67905. * Reset the AssetsManager and remove all tasks
  67906. * @return the current instance of the AssetsManager
  67907. */
  67908. reset(): AssetsManager;
  67909. /**
  67910. * Start the loading process
  67911. * @return the current instance of the AssetsManager
  67912. */
  67913. load(): AssetsManager;
  67914. /**
  67915. * Start the loading process as an async operation
  67916. * @return a promise returning the list of failed tasks
  67917. */
  67918. loadAsync(): Promise<void>;
  67919. }
  67920. }
  67921. declare module BABYLON {
  67922. /**
  67923. * Wrapper class for promise with external resolve and reject.
  67924. */
  67925. export class Deferred<T> {
  67926. /**
  67927. * The promise associated with this deferred object.
  67928. */
  67929. readonly promise: Promise<T>;
  67930. private _resolve;
  67931. private _reject;
  67932. /**
  67933. * The resolve method of the promise associated with this deferred object.
  67934. */
  67935. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67936. /**
  67937. * The reject method of the promise associated with this deferred object.
  67938. */
  67939. get reject(): (reason?: any) => void;
  67940. /**
  67941. * Constructor for this deferred object.
  67942. */
  67943. constructor();
  67944. }
  67945. }
  67946. declare module BABYLON {
  67947. /**
  67948. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67949. */
  67950. export class MeshExploder {
  67951. private _centerMesh;
  67952. private _meshes;
  67953. private _meshesOrigins;
  67954. private _toCenterVectors;
  67955. private _scaledDirection;
  67956. private _newPosition;
  67957. private _centerPosition;
  67958. /**
  67959. * Explodes meshes from a center mesh.
  67960. * @param meshes The meshes to explode.
  67961. * @param centerMesh The mesh to be center of explosion.
  67962. */
  67963. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67964. private _setCenterMesh;
  67965. /**
  67966. * Get class name
  67967. * @returns "MeshExploder"
  67968. */
  67969. getClassName(): string;
  67970. /**
  67971. * "Exploded meshes"
  67972. * @returns Array of meshes with the centerMesh at index 0.
  67973. */
  67974. getMeshes(): Array<Mesh>;
  67975. /**
  67976. * Explodes meshes giving a specific direction
  67977. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67978. */
  67979. explode(direction?: number): void;
  67980. }
  67981. }
  67982. declare module BABYLON {
  67983. /**
  67984. * Class used to help managing file picking and drag'n'drop
  67985. */
  67986. export class FilesInput {
  67987. /**
  67988. * List of files ready to be loaded
  67989. */
  67990. static get FilesToLoad(): {
  67991. [key: string]: File;
  67992. };
  67993. /**
  67994. * Callback called when a file is processed
  67995. */
  67996. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67997. private _engine;
  67998. private _currentScene;
  67999. private _sceneLoadedCallback;
  68000. private _progressCallback;
  68001. private _additionalRenderLoopLogicCallback;
  68002. private _textureLoadingCallback;
  68003. private _startingProcessingFilesCallback;
  68004. private _onReloadCallback;
  68005. private _errorCallback;
  68006. private _elementToMonitor;
  68007. private _sceneFileToLoad;
  68008. private _filesToLoad;
  68009. /**
  68010. * Creates a new FilesInput
  68011. * @param engine defines the rendering engine
  68012. * @param scene defines the hosting scene
  68013. * @param sceneLoadedCallback callback called when scene is loaded
  68014. * @param progressCallback callback called to track progress
  68015. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68016. * @param textureLoadingCallback callback called when a texture is loading
  68017. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68018. * @param onReloadCallback callback called when a reload is requested
  68019. * @param errorCallback callback call if an error occurs
  68020. */
  68021. 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);
  68022. private _dragEnterHandler;
  68023. private _dragOverHandler;
  68024. private _dropHandler;
  68025. /**
  68026. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68027. * @param elementToMonitor defines the DOM element to track
  68028. */
  68029. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68030. /**
  68031. * Release all associated resources
  68032. */
  68033. dispose(): void;
  68034. private renderFunction;
  68035. private drag;
  68036. private drop;
  68037. private _traverseFolder;
  68038. private _processFiles;
  68039. /**
  68040. * Load files from a drop event
  68041. * @param event defines the drop event to use as source
  68042. */
  68043. loadFiles(event: any): void;
  68044. private _processReload;
  68045. /**
  68046. * Reload the current scene from the loaded files
  68047. */
  68048. reload(): void;
  68049. }
  68050. }
  68051. declare module BABYLON {
  68052. /**
  68053. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68054. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68055. */
  68056. export class SceneOptimization {
  68057. /**
  68058. * Defines the priority of this optimization (0 by default which means first in the list)
  68059. */
  68060. priority: number;
  68061. /**
  68062. * Gets a string describing the action executed by the current optimization
  68063. * @returns description string
  68064. */
  68065. getDescription(): string;
  68066. /**
  68067. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68068. * @param scene defines the current scene where to apply this optimization
  68069. * @param optimizer defines the current optimizer
  68070. * @returns true if everything that can be done was applied
  68071. */
  68072. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68073. /**
  68074. * Creates the SceneOptimization object
  68075. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68076. * @param desc defines the description associated with the optimization
  68077. */
  68078. constructor(
  68079. /**
  68080. * Defines the priority of this optimization (0 by default which means first in the list)
  68081. */
  68082. priority?: number);
  68083. }
  68084. /**
  68085. * Defines an optimization used to reduce the size of render target textures
  68086. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68087. */
  68088. export class TextureOptimization extends SceneOptimization {
  68089. /**
  68090. * Defines the priority of this optimization (0 by default which means first in the list)
  68091. */
  68092. priority: number;
  68093. /**
  68094. * 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
  68095. */
  68096. maximumSize: number;
  68097. /**
  68098. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68099. */
  68100. step: number;
  68101. /**
  68102. * Gets a string describing the action executed by the current optimization
  68103. * @returns description string
  68104. */
  68105. getDescription(): string;
  68106. /**
  68107. * Creates the TextureOptimization object
  68108. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68109. * @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
  68110. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68111. */
  68112. constructor(
  68113. /**
  68114. * Defines the priority of this optimization (0 by default which means first in the list)
  68115. */
  68116. priority?: number,
  68117. /**
  68118. * 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
  68119. */
  68120. maximumSize?: number,
  68121. /**
  68122. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68123. */
  68124. step?: number);
  68125. /**
  68126. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68127. * @param scene defines the current scene where to apply this optimization
  68128. * @param optimizer defines the current optimizer
  68129. * @returns true if everything that can be done was applied
  68130. */
  68131. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68132. }
  68133. /**
  68134. * Defines an optimization used to increase or decrease the rendering resolution
  68135. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68136. */
  68137. export class HardwareScalingOptimization extends SceneOptimization {
  68138. /**
  68139. * Defines the priority of this optimization (0 by default which means first in the list)
  68140. */
  68141. priority: number;
  68142. /**
  68143. * Defines the maximum scale to use (2 by default)
  68144. */
  68145. maximumScale: number;
  68146. /**
  68147. * Defines the step to use between two passes (0.5 by default)
  68148. */
  68149. step: number;
  68150. private _currentScale;
  68151. private _directionOffset;
  68152. /**
  68153. * Gets a string describing the action executed by the current optimization
  68154. * @return description string
  68155. */
  68156. getDescription(): string;
  68157. /**
  68158. * Creates the HardwareScalingOptimization object
  68159. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68160. * @param maximumScale defines the maximum scale to use (2 by default)
  68161. * @param step defines the step to use between two passes (0.5 by default)
  68162. */
  68163. constructor(
  68164. /**
  68165. * Defines the priority of this optimization (0 by default which means first in the list)
  68166. */
  68167. priority?: number,
  68168. /**
  68169. * Defines the maximum scale to use (2 by default)
  68170. */
  68171. maximumScale?: number,
  68172. /**
  68173. * Defines the step to use between two passes (0.5 by default)
  68174. */
  68175. step?: number);
  68176. /**
  68177. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68178. * @param scene defines the current scene where to apply this optimization
  68179. * @param optimizer defines the current optimizer
  68180. * @returns true if everything that can be done was applied
  68181. */
  68182. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68183. }
  68184. /**
  68185. * Defines an optimization used to remove shadows
  68186. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68187. */
  68188. export class ShadowsOptimization extends SceneOptimization {
  68189. /**
  68190. * Gets a string describing the action executed by the current optimization
  68191. * @return description string
  68192. */
  68193. getDescription(): string;
  68194. /**
  68195. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68196. * @param scene defines the current scene where to apply this optimization
  68197. * @param optimizer defines the current optimizer
  68198. * @returns true if everything that can be done was applied
  68199. */
  68200. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68201. }
  68202. /**
  68203. * Defines an optimization used to turn post-processes off
  68204. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68205. */
  68206. export class PostProcessesOptimization extends SceneOptimization {
  68207. /**
  68208. * Gets a string describing the action executed by the current optimization
  68209. * @return description string
  68210. */
  68211. getDescription(): string;
  68212. /**
  68213. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68214. * @param scene defines the current scene where to apply this optimization
  68215. * @param optimizer defines the current optimizer
  68216. * @returns true if everything that can be done was applied
  68217. */
  68218. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68219. }
  68220. /**
  68221. * Defines an optimization used to turn lens flares off
  68222. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68223. */
  68224. export class LensFlaresOptimization extends SceneOptimization {
  68225. /**
  68226. * Gets a string describing the action executed by the current optimization
  68227. * @return description string
  68228. */
  68229. getDescription(): string;
  68230. /**
  68231. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68232. * @param scene defines the current scene where to apply this optimization
  68233. * @param optimizer defines the current optimizer
  68234. * @returns true if everything that can be done was applied
  68235. */
  68236. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68237. }
  68238. /**
  68239. * Defines an optimization based on user defined callback.
  68240. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68241. */
  68242. export class CustomOptimization extends SceneOptimization {
  68243. /**
  68244. * Callback called to apply the custom optimization.
  68245. */
  68246. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68247. /**
  68248. * Callback called to get custom description
  68249. */
  68250. onGetDescription: () => string;
  68251. /**
  68252. * Gets a string describing the action executed by the current optimization
  68253. * @returns description string
  68254. */
  68255. getDescription(): string;
  68256. /**
  68257. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68258. * @param scene defines the current scene where to apply this optimization
  68259. * @param optimizer defines the current optimizer
  68260. * @returns true if everything that can be done was applied
  68261. */
  68262. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68263. }
  68264. /**
  68265. * Defines an optimization used to turn particles off
  68266. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68267. */
  68268. export class ParticlesOptimization extends SceneOptimization {
  68269. /**
  68270. * Gets a string describing the action executed by the current optimization
  68271. * @return description string
  68272. */
  68273. getDescription(): string;
  68274. /**
  68275. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68276. * @param scene defines the current scene where to apply this optimization
  68277. * @param optimizer defines the current optimizer
  68278. * @returns true if everything that can be done was applied
  68279. */
  68280. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68281. }
  68282. /**
  68283. * Defines an optimization used to turn render targets off
  68284. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68285. */
  68286. export class RenderTargetsOptimization extends SceneOptimization {
  68287. /**
  68288. * Gets a string describing the action executed by the current optimization
  68289. * @return description string
  68290. */
  68291. getDescription(): string;
  68292. /**
  68293. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68294. * @param scene defines the current scene where to apply this optimization
  68295. * @param optimizer defines the current optimizer
  68296. * @returns true if everything that can be done was applied
  68297. */
  68298. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68299. }
  68300. /**
  68301. * Defines an optimization used to merge meshes with compatible materials
  68302. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68303. */
  68304. export class MergeMeshesOptimization extends SceneOptimization {
  68305. private static _UpdateSelectionTree;
  68306. /**
  68307. * Gets or sets a boolean which defines if optimization octree has to be updated
  68308. */
  68309. static get UpdateSelectionTree(): boolean;
  68310. /**
  68311. * Gets or sets a boolean which defines if optimization octree has to be updated
  68312. */
  68313. static set UpdateSelectionTree(value: boolean);
  68314. /**
  68315. * Gets a string describing the action executed by the current optimization
  68316. * @return description string
  68317. */
  68318. getDescription(): string;
  68319. private _canBeMerged;
  68320. /**
  68321. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68322. * @param scene defines the current scene where to apply this optimization
  68323. * @param optimizer defines the current optimizer
  68324. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68325. * @returns true if everything that can be done was applied
  68326. */
  68327. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68328. }
  68329. /**
  68330. * Defines a list of options used by SceneOptimizer
  68331. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68332. */
  68333. export class SceneOptimizerOptions {
  68334. /**
  68335. * Defines the target frame rate to reach (60 by default)
  68336. */
  68337. targetFrameRate: number;
  68338. /**
  68339. * Defines the interval between two checkes (2000ms by default)
  68340. */
  68341. trackerDuration: number;
  68342. /**
  68343. * Gets the list of optimizations to apply
  68344. */
  68345. optimizations: SceneOptimization[];
  68346. /**
  68347. * Creates a new list of options used by SceneOptimizer
  68348. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68349. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68350. */
  68351. constructor(
  68352. /**
  68353. * Defines the target frame rate to reach (60 by default)
  68354. */
  68355. targetFrameRate?: number,
  68356. /**
  68357. * Defines the interval between two checkes (2000ms by default)
  68358. */
  68359. trackerDuration?: number);
  68360. /**
  68361. * Add a new optimization
  68362. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68363. * @returns the current SceneOptimizerOptions
  68364. */
  68365. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68366. /**
  68367. * Add a new custom optimization
  68368. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68369. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68370. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68371. * @returns the current SceneOptimizerOptions
  68372. */
  68373. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68374. /**
  68375. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68376. * @param targetFrameRate defines the target frame rate (60 by default)
  68377. * @returns a SceneOptimizerOptions object
  68378. */
  68379. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68380. /**
  68381. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68382. * @param targetFrameRate defines the target frame rate (60 by default)
  68383. * @returns a SceneOptimizerOptions object
  68384. */
  68385. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68386. /**
  68387. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68388. * @param targetFrameRate defines the target frame rate (60 by default)
  68389. * @returns a SceneOptimizerOptions object
  68390. */
  68391. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68392. }
  68393. /**
  68394. * Class used to run optimizations in order to reach a target frame rate
  68395. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68396. */
  68397. export class SceneOptimizer implements IDisposable {
  68398. private _isRunning;
  68399. private _options;
  68400. private _scene;
  68401. private _currentPriorityLevel;
  68402. private _targetFrameRate;
  68403. private _trackerDuration;
  68404. private _currentFrameRate;
  68405. private _sceneDisposeObserver;
  68406. private _improvementMode;
  68407. /**
  68408. * Defines an observable called when the optimizer reaches the target frame rate
  68409. */
  68410. onSuccessObservable: Observable<SceneOptimizer>;
  68411. /**
  68412. * Defines an observable called when the optimizer enables an optimization
  68413. */
  68414. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68415. /**
  68416. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68417. */
  68418. onFailureObservable: Observable<SceneOptimizer>;
  68419. /**
  68420. * Gets a boolean indicating if the optimizer is in improvement mode
  68421. */
  68422. get isInImprovementMode(): boolean;
  68423. /**
  68424. * Gets the current priority level (0 at start)
  68425. */
  68426. get currentPriorityLevel(): number;
  68427. /**
  68428. * Gets the current frame rate checked by the SceneOptimizer
  68429. */
  68430. get currentFrameRate(): number;
  68431. /**
  68432. * Gets or sets the current target frame rate (60 by default)
  68433. */
  68434. get targetFrameRate(): number;
  68435. /**
  68436. * Gets or sets the current target frame rate (60 by default)
  68437. */
  68438. set targetFrameRate(value: number);
  68439. /**
  68440. * Gets or sets the current interval between two checks (every 2000ms by default)
  68441. */
  68442. get trackerDuration(): number;
  68443. /**
  68444. * Gets or sets the current interval between two checks (every 2000ms by default)
  68445. */
  68446. set trackerDuration(value: number);
  68447. /**
  68448. * Gets the list of active optimizations
  68449. */
  68450. get optimizations(): SceneOptimization[];
  68451. /**
  68452. * Creates a new SceneOptimizer
  68453. * @param scene defines the scene to work on
  68454. * @param options defines the options to use with the SceneOptimizer
  68455. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68456. * @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)
  68457. */
  68458. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68459. /**
  68460. * Stops the current optimizer
  68461. */
  68462. stop(): void;
  68463. /**
  68464. * Reset the optimizer to initial step (current priority level = 0)
  68465. */
  68466. reset(): void;
  68467. /**
  68468. * Start the optimizer. By default it will try to reach a specific framerate
  68469. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68470. */
  68471. start(): void;
  68472. private _checkCurrentState;
  68473. /**
  68474. * Release all resources
  68475. */
  68476. dispose(): void;
  68477. /**
  68478. * Helper function to create a SceneOptimizer with one single line of code
  68479. * @param scene defines the scene to work on
  68480. * @param options defines the options to use with the SceneOptimizer
  68481. * @param onSuccess defines a callback to call on success
  68482. * @param onFailure defines a callback to call on failure
  68483. * @returns the new SceneOptimizer object
  68484. */
  68485. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68486. }
  68487. }
  68488. declare module BABYLON {
  68489. /**
  68490. * Class used to serialize a scene into a string
  68491. */
  68492. export class SceneSerializer {
  68493. /**
  68494. * Clear cache used by a previous serialization
  68495. */
  68496. static ClearCache(): void;
  68497. /**
  68498. * Serialize a scene into a JSON compatible object
  68499. * @param scene defines the scene to serialize
  68500. * @returns a JSON compatible object
  68501. */
  68502. static Serialize(scene: Scene): any;
  68503. /**
  68504. * Serialize a mesh into a JSON compatible object
  68505. * @param toSerialize defines the mesh to serialize
  68506. * @param withParents defines if parents must be serialized as well
  68507. * @param withChildren defines if children must be serialized as well
  68508. * @returns a JSON compatible object
  68509. */
  68510. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68511. }
  68512. }
  68513. declare module BABYLON {
  68514. /**
  68515. * Class used to host texture specific utilities
  68516. */
  68517. export class TextureTools {
  68518. /**
  68519. * Uses the GPU to create a copy texture rescaled at a given size
  68520. * @param texture Texture to copy from
  68521. * @param width defines the desired width
  68522. * @param height defines the desired height
  68523. * @param useBilinearMode defines if bilinear mode has to be used
  68524. * @return the generated texture
  68525. */
  68526. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68527. }
  68528. }
  68529. declare module BABYLON {
  68530. /**
  68531. * This represents the different options available for the video capture.
  68532. */
  68533. export interface VideoRecorderOptions {
  68534. /** Defines the mime type of the video. */
  68535. mimeType: string;
  68536. /** Defines the FPS the video should be recorded at. */
  68537. fps: number;
  68538. /** Defines the chunk size for the recording data. */
  68539. recordChunckSize: number;
  68540. /** The audio tracks to attach to the recording. */
  68541. audioTracks?: MediaStreamTrack[];
  68542. }
  68543. /**
  68544. * This can help with recording videos from BabylonJS.
  68545. * This is based on the available WebRTC functionalities of the browser.
  68546. *
  68547. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68548. */
  68549. export class VideoRecorder {
  68550. private static readonly _defaultOptions;
  68551. /**
  68552. * Returns whether or not the VideoRecorder is available in your browser.
  68553. * @param engine Defines the Babylon Engine.
  68554. * @returns true if supported otherwise false.
  68555. */
  68556. static IsSupported(engine: Engine): boolean;
  68557. private readonly _options;
  68558. private _canvas;
  68559. private _mediaRecorder;
  68560. private _recordedChunks;
  68561. private _fileName;
  68562. private _resolve;
  68563. private _reject;
  68564. /**
  68565. * True when a recording is already in progress.
  68566. */
  68567. get isRecording(): boolean;
  68568. /**
  68569. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68570. * @param engine Defines the BabylonJS Engine you wish to record.
  68571. * @param options Defines options that can be used to customize the capture.
  68572. */
  68573. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68574. /**
  68575. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68576. */
  68577. stopRecording(): void;
  68578. /**
  68579. * Starts recording the canvas for a max duration specified in parameters.
  68580. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68581. * If null no automatic download will start and you can rely on the promise to get the data back.
  68582. * @param maxDuration Defines the maximum recording time in seconds.
  68583. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68584. * @return A promise callback at the end of the recording with the video data in Blob.
  68585. */
  68586. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68587. /**
  68588. * Releases internal resources used during the recording.
  68589. */
  68590. dispose(): void;
  68591. private _handleDataAvailable;
  68592. private _handleError;
  68593. private _handleStop;
  68594. }
  68595. }
  68596. declare module BABYLON {
  68597. /**
  68598. * Class containing a set of static utilities functions for screenshots
  68599. */
  68600. export class ScreenshotTools {
  68601. /**
  68602. * Captures a screenshot of the current rendering
  68603. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68604. * @param engine defines the rendering engine
  68605. * @param camera defines the source camera
  68606. * @param size This parameter can be set to a single number or to an object with the
  68607. * following (optional) properties: precision, width, height. If a single number is passed,
  68608. * it will be used for both width and height. If an object is passed, the screenshot size
  68609. * will be derived from the parameters. The precision property is a multiplier allowing
  68610. * rendering at a higher or lower resolution
  68611. * @param successCallback defines the callback receives a single parameter which contains the
  68612. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68613. * src parameter of an <img> to display it
  68614. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68615. * Check your browser for supported MIME types
  68616. */
  68617. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68618. /**
  68619. * Captures a screenshot of the current rendering
  68620. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68621. * @param engine defines the rendering engine
  68622. * @param camera defines the source camera
  68623. * @param size This parameter can be set to a single number or to an object with the
  68624. * following (optional) properties: precision, width, height. If a single number is passed,
  68625. * it will be used for both width and height. If an object is passed, the screenshot size
  68626. * will be derived from the parameters. The precision property is a multiplier allowing
  68627. * rendering at a higher or lower resolution
  68628. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68629. * Check your browser for supported MIME types
  68630. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68631. * to the src parameter of an <img> to display it
  68632. */
  68633. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68634. /**
  68635. * Generates an image screenshot from the specified camera.
  68636. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68637. * @param engine The engine to use for rendering
  68638. * @param camera The camera to use for rendering
  68639. * @param size This parameter can be set to a single number or to an object with the
  68640. * following (optional) properties: precision, width, height. If a single number is passed,
  68641. * it will be used for both width and height. If an object is passed, the screenshot size
  68642. * will be derived from the parameters. The precision property is a multiplier allowing
  68643. * rendering at a higher or lower resolution
  68644. * @param successCallback The callback receives a single parameter which contains the
  68645. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68646. * src parameter of an <img> to display it
  68647. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68648. * Check your browser for supported MIME types
  68649. * @param samples Texture samples (default: 1)
  68650. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68651. * @param fileName A name for for the downloaded file.
  68652. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68653. */
  68654. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  68655. /**
  68656. * Generates an image screenshot from the specified camera.
  68657. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68658. * @param engine The engine to use for rendering
  68659. * @param camera The camera to use for rendering
  68660. * @param size This parameter can be set to a single number or to an object with the
  68661. * following (optional) properties: precision, width, height. If a single number is passed,
  68662. * it will be used for both width and height. If an object is passed, the screenshot size
  68663. * will be derived from the parameters. The precision property is a multiplier allowing
  68664. * rendering at a higher or lower resolution
  68665. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68666. * Check your browser for supported MIME types
  68667. * @param samples Texture samples (default: 1)
  68668. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68669. * @param fileName A name for for the downloaded file.
  68670. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68671. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68672. * to the src parameter of an <img> to display it
  68673. */
  68674. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  68675. /**
  68676. * Gets height and width for screenshot size
  68677. * @private
  68678. */
  68679. private static _getScreenshotSize;
  68680. }
  68681. }
  68682. declare module BABYLON {
  68683. /**
  68684. * Interface for a data buffer
  68685. */
  68686. export interface IDataBuffer {
  68687. /**
  68688. * Reads bytes from the data buffer.
  68689. * @param byteOffset The byte offset to read
  68690. * @param byteLength The byte length to read
  68691. * @returns A promise that resolves when the bytes are read
  68692. */
  68693. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68694. /**
  68695. * The byte length of the buffer.
  68696. */
  68697. readonly byteLength: number;
  68698. }
  68699. /**
  68700. * Utility class for reading from a data buffer
  68701. */
  68702. export class DataReader {
  68703. /**
  68704. * The data buffer associated with this data reader.
  68705. */
  68706. readonly buffer: IDataBuffer;
  68707. /**
  68708. * The current byte offset from the beginning of the data buffer.
  68709. */
  68710. byteOffset: number;
  68711. private _dataView;
  68712. private _dataByteOffset;
  68713. /**
  68714. * Constructor
  68715. * @param buffer The buffer to read
  68716. */
  68717. constructor(buffer: IDataBuffer);
  68718. /**
  68719. * Loads the given byte length.
  68720. * @param byteLength The byte length to load
  68721. * @returns A promise that resolves when the load is complete
  68722. */
  68723. loadAsync(byteLength: number): Promise<void>;
  68724. /**
  68725. * Read a unsigned 32-bit integer from the currently loaded data range.
  68726. * @returns The 32-bit integer read
  68727. */
  68728. readUint32(): number;
  68729. /**
  68730. * Read a byte array from the currently loaded data range.
  68731. * @param byteLength The byte length to read
  68732. * @returns The byte array read
  68733. */
  68734. readUint8Array(byteLength: number): Uint8Array;
  68735. /**
  68736. * Read a string from the currently loaded data range.
  68737. * @param byteLength The byte length to read
  68738. * @returns The string read
  68739. */
  68740. readString(byteLength: number): string;
  68741. /**
  68742. * Skips the given byte length the currently loaded data range.
  68743. * @param byteLength The byte length to skip
  68744. */
  68745. skipBytes(byteLength: number): void;
  68746. }
  68747. }
  68748. declare module BABYLON {
  68749. /**
  68750. * Class for storing data to local storage if available or in-memory storage otherwise
  68751. */
  68752. export class DataStorage {
  68753. private static _Storage;
  68754. private static _GetStorage;
  68755. /**
  68756. * Reads a string from the data storage
  68757. * @param key The key to read
  68758. * @param defaultValue The value if the key doesn't exist
  68759. * @returns The string value
  68760. */
  68761. static ReadString(key: string, defaultValue: string): string;
  68762. /**
  68763. * Writes a string to the data storage
  68764. * @param key The key to write
  68765. * @param value The value to write
  68766. */
  68767. static WriteString(key: string, value: string): void;
  68768. /**
  68769. * Reads a boolean from the data storage
  68770. * @param key The key to read
  68771. * @param defaultValue The value if the key doesn't exist
  68772. * @returns The boolean value
  68773. */
  68774. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  68775. /**
  68776. * Writes a boolean to the data storage
  68777. * @param key The key to write
  68778. * @param value The value to write
  68779. */
  68780. static WriteBoolean(key: string, value: boolean): void;
  68781. /**
  68782. * Reads a number from the data storage
  68783. * @param key The key to read
  68784. * @param defaultValue The value if the key doesn't exist
  68785. * @returns The number value
  68786. */
  68787. static ReadNumber(key: string, defaultValue: number): number;
  68788. /**
  68789. * Writes a number to the data storage
  68790. * @param key The key to write
  68791. * @param value The value to write
  68792. */
  68793. static WriteNumber(key: string, value: number): void;
  68794. }
  68795. }
  68796. declare module BABYLON {
  68797. /**
  68798. * Options used for hit testing
  68799. */
  68800. export interface IWebXRHitTestOptions {
  68801. /**
  68802. * Only test when user interacted with the scene. Default - hit test every frame
  68803. */
  68804. testOnPointerDownOnly?: boolean;
  68805. /**
  68806. * The node to use to transform the local results to world coordinates
  68807. */
  68808. worldParentNode?: TransformNode;
  68809. }
  68810. /**
  68811. * Interface defining the babylon result of raycasting/hit-test
  68812. */
  68813. export interface IWebXRHitResult {
  68814. /**
  68815. * Transformation matrix that can be applied to a node that will put it in the hit point location
  68816. */
  68817. transformationMatrix: Matrix;
  68818. /**
  68819. * The native hit test result
  68820. */
  68821. xrHitResult: XRHitResult;
  68822. }
  68823. /**
  68824. * The currently-working hit-test module.
  68825. * Hit test (or Ray-casting) is used to interact with the real world.
  68826. * For further information read here - https://github.com/immersive-web/hit-test
  68827. */
  68828. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  68829. /**
  68830. * options to use when constructing this feature
  68831. */
  68832. readonly options: IWebXRHitTestOptions;
  68833. private _direction;
  68834. private _mat;
  68835. private _onSelectEnabled;
  68836. private _origin;
  68837. /**
  68838. * The module's name
  68839. */
  68840. static readonly Name: string;
  68841. /**
  68842. * The (Babylon) version of this module.
  68843. * This is an integer representing the implementation version.
  68844. * This number does not correspond to the WebXR specs version
  68845. */
  68846. static readonly Version: number;
  68847. /**
  68848. * Populated with the last native XR Hit Results
  68849. */
  68850. lastNativeXRHitResults: XRHitResult[];
  68851. /**
  68852. * Triggered when new babylon (transformed) hit test results are available
  68853. */
  68854. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  68855. /**
  68856. * Creates a new instance of the (legacy version) hit test feature
  68857. * @param _xrSessionManager an instance of WebXRSessionManager
  68858. * @param options options to use when constructing this feature
  68859. */
  68860. constructor(_xrSessionManager: WebXRSessionManager,
  68861. /**
  68862. * options to use when constructing this feature
  68863. */
  68864. options?: IWebXRHitTestOptions);
  68865. /**
  68866. * execute a hit test with an XR Ray
  68867. *
  68868. * @param xrSession a native xrSession that will execute this hit test
  68869. * @param xrRay the ray (position and direction) to use for ray-casting
  68870. * @param referenceSpace native XR reference space to use for the hit-test
  68871. * @param filter filter function that will filter the results
  68872. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68873. */
  68874. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  68875. /**
  68876. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  68877. * @param event the (select) event to use to select with
  68878. * @param referenceSpace the reference space to use for this hit test
  68879. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68880. */
  68881. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68882. /**
  68883. * attach this feature
  68884. * Will usually be called by the features manager
  68885. *
  68886. * @returns true if successful.
  68887. */
  68888. attach(): boolean;
  68889. /**
  68890. * detach this feature.
  68891. * Will usually be called by the features manager
  68892. *
  68893. * @returns true if successful.
  68894. */
  68895. detach(): boolean;
  68896. /**
  68897. * Dispose this feature and all of the resources attached
  68898. */
  68899. dispose(): void;
  68900. protected _onXRFrame(frame: XRFrame): void;
  68901. private _onHitTestResults;
  68902. private _onSelect;
  68903. }
  68904. }
  68905. declare module BABYLON {
  68906. /**
  68907. * Options used in the plane detector module
  68908. */
  68909. export interface IWebXRPlaneDetectorOptions {
  68910. /**
  68911. * The node to use to transform the local results to world coordinates
  68912. */
  68913. worldParentNode?: TransformNode;
  68914. }
  68915. /**
  68916. * A babylon interface for a WebXR plane.
  68917. * A Plane is actually a polygon, built from N points in space
  68918. *
  68919. * Supported in chrome 79, not supported in canary 81 ATM
  68920. */
  68921. export interface IWebXRPlane {
  68922. /**
  68923. * a babylon-assigned ID for this polygon
  68924. */
  68925. id: number;
  68926. /**
  68927. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  68928. */
  68929. polygonDefinition: Array<Vector3>;
  68930. /**
  68931. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  68932. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  68933. */
  68934. transformationMatrix: Matrix;
  68935. /**
  68936. * the native xr-plane object
  68937. */
  68938. xrPlane: XRPlane;
  68939. }
  68940. /**
  68941. * The plane detector is used to detect planes in the real world when in AR
  68942. * For more information see https://github.com/immersive-web/real-world-geometry/
  68943. */
  68944. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  68945. private _options;
  68946. private _detectedPlanes;
  68947. private _enabled;
  68948. private _lastFrameDetected;
  68949. /**
  68950. * The module's name
  68951. */
  68952. static readonly Name: string;
  68953. /**
  68954. * The (Babylon) version of this module.
  68955. * This is an integer representing the implementation version.
  68956. * This number does not correspond to the WebXR specs version
  68957. */
  68958. static readonly Version: number;
  68959. /**
  68960. * Observers registered here will be executed when a new plane was added to the session
  68961. */
  68962. onPlaneAddedObservable: Observable<IWebXRPlane>;
  68963. /**
  68964. * Observers registered here will be executed when a plane is no longer detected in the session
  68965. */
  68966. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  68967. /**
  68968. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  68969. * This can execute N times every frame
  68970. */
  68971. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  68972. /**
  68973. * construct a new Plane Detector
  68974. * @param _xrSessionManager an instance of xr Session manager
  68975. * @param _options configuration to use when constructing this feature
  68976. */
  68977. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  68978. /**
  68979. * Dispose this feature and all of the resources attached
  68980. */
  68981. dispose(): void;
  68982. protected _onXRFrame(frame: XRFrame): void;
  68983. private _init;
  68984. private _updatePlaneWithXRPlane;
  68985. /**
  68986. * avoiding using Array.find for global support.
  68987. * @param xrPlane the plane to find in the array
  68988. */
  68989. private findIndexInPlaneArray;
  68990. }
  68991. }
  68992. declare module BABYLON {
  68993. /**
  68994. * Configuration options of the anchor system
  68995. */
  68996. export interface IWebXRAnchorSystemOptions {
  68997. /**
  68998. * Should a new anchor be added every time a select event is triggered
  68999. */
  69000. addAnchorOnSelect?: boolean;
  69001. /**
  69002. * should the anchor system use plane detection.
  69003. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69004. */
  69005. usePlaneDetection?: boolean;
  69006. /**
  69007. * a node that will be used to convert local to world coordinates
  69008. */
  69009. worldParentNode?: TransformNode;
  69010. }
  69011. /**
  69012. * A babylon container for an XR Anchor
  69013. */
  69014. export interface IWebXRAnchor {
  69015. /**
  69016. * A babylon-assigned ID for this anchor
  69017. */
  69018. id: number;
  69019. /**
  69020. * Transformation matrix to apply to an object attached to this anchor
  69021. */
  69022. transformationMatrix: Matrix;
  69023. /**
  69024. * The native anchor object
  69025. */
  69026. xrAnchor: XRAnchor;
  69027. }
  69028. /**
  69029. * An implementation of the anchor system of WebXR.
  69030. * Note that the current documented implementation is not available in any browser. Future implementations
  69031. * will use the frame to create an anchor and not the session or a detected plane
  69032. * For further information see https://github.com/immersive-web/anchors/
  69033. */
  69034. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69035. private _options;
  69036. private _enabled;
  69037. private _hitTestModule;
  69038. private _lastFrameDetected;
  69039. private _onSelect;
  69040. private _planeDetector;
  69041. private _trackedAnchors;
  69042. /**
  69043. * The module's name
  69044. */
  69045. static readonly Name: string;
  69046. /**
  69047. * The (Babylon) version of this module.
  69048. * This is an integer representing the implementation version.
  69049. * This number does not correspond to the WebXR specs version
  69050. */
  69051. static readonly Version: number;
  69052. /**
  69053. * Observers registered here will be executed when a new anchor was added to the session
  69054. */
  69055. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69056. /**
  69057. * Observers registered here will be executed when an anchor was removed from the session
  69058. */
  69059. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69060. /**
  69061. * Observers registered here will be executed when an existing anchor updates
  69062. * This can execute N times every frame
  69063. */
  69064. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69065. /**
  69066. * constructs a new anchor system
  69067. * @param _xrSessionManager an instance of WebXRSessionManager
  69068. * @param _options configuration object for this feature
  69069. */
  69070. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69071. /**
  69072. * Add anchor at a specific XR point.
  69073. *
  69074. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69075. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69076. * @returns a promise the fulfills when the anchor was created
  69077. */
  69078. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69079. /**
  69080. * attach this feature
  69081. * Will usually be called by the features manager
  69082. *
  69083. * @returns true if successful.
  69084. */
  69085. attach(): boolean;
  69086. /**
  69087. * detach this feature.
  69088. * Will usually be called by the features manager
  69089. *
  69090. * @returns true if successful.
  69091. */
  69092. detach(): boolean;
  69093. /**
  69094. * Dispose this feature and all of the resources attached
  69095. */
  69096. dispose(): void;
  69097. /**
  69098. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69099. * @param hitTestModule the hit-test module to use.
  69100. */
  69101. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69102. /**
  69103. * set the plane detector to use in order to create anchors from frames
  69104. * @param planeDetector the plane-detector module to use
  69105. * @param enable enable plane-anchors. default is true
  69106. */
  69107. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69108. protected _onXRFrame(frame: XRFrame): void;
  69109. /**
  69110. * avoiding using Array.find for global support.
  69111. * @param xrAnchor the plane to find in the array
  69112. */
  69113. private _findIndexInAnchorArray;
  69114. private _updateAnchorWithXRFrame;
  69115. }
  69116. }
  69117. declare module BABYLON {
  69118. /**
  69119. * Options interface for the background remover plugin
  69120. */
  69121. export interface IWebXRBackgroundRemoverOptions {
  69122. /**
  69123. * Further background meshes to disable when entering AR
  69124. */
  69125. backgroundMeshes?: AbstractMesh[];
  69126. /**
  69127. * flags to configure the removal of the environment helper.
  69128. * If not set, the entire background will be removed. If set, flags should be set as well.
  69129. */
  69130. environmentHelperRemovalFlags?: {
  69131. /**
  69132. * Should the skybox be removed (default false)
  69133. */
  69134. skyBox?: boolean;
  69135. /**
  69136. * Should the ground be removed (default false)
  69137. */
  69138. ground?: boolean;
  69139. };
  69140. /**
  69141. * don't disable the environment helper
  69142. */
  69143. ignoreEnvironmentHelper?: boolean;
  69144. }
  69145. /**
  69146. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69147. */
  69148. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69149. /**
  69150. * read-only options to be used in this module
  69151. */
  69152. readonly options: IWebXRBackgroundRemoverOptions;
  69153. /**
  69154. * The module's name
  69155. */
  69156. static readonly Name: string;
  69157. /**
  69158. * The (Babylon) version of this module.
  69159. * This is an integer representing the implementation version.
  69160. * This number does not correspond to the WebXR specs version
  69161. */
  69162. static readonly Version: number;
  69163. /**
  69164. * registered observers will be triggered when the background state changes
  69165. */
  69166. onBackgroundStateChangedObservable: Observable<boolean>;
  69167. /**
  69168. * constructs a new background remover module
  69169. * @param _xrSessionManager the session manager for this module
  69170. * @param options read-only options to be used in this module
  69171. */
  69172. constructor(_xrSessionManager: WebXRSessionManager,
  69173. /**
  69174. * read-only options to be used in this module
  69175. */
  69176. options?: IWebXRBackgroundRemoverOptions);
  69177. /**
  69178. * attach this feature
  69179. * Will usually be called by the features manager
  69180. *
  69181. * @returns true if successful.
  69182. */
  69183. attach(): boolean;
  69184. /**
  69185. * detach this feature.
  69186. * Will usually be called by the features manager
  69187. *
  69188. * @returns true if successful.
  69189. */
  69190. detach(): boolean;
  69191. /**
  69192. * Dispose this feature and all of the resources attached
  69193. */
  69194. dispose(): void;
  69195. protected _onXRFrame(_xrFrame: XRFrame): void;
  69196. private _setBackgroundState;
  69197. }
  69198. }
  69199. declare module BABYLON {
  69200. /**
  69201. * Options for the controller physics feature
  69202. */
  69203. export class IWebXRControllerPhysicsOptions {
  69204. /**
  69205. * Should the headset get its own impostor
  69206. */
  69207. enableHeadsetImpostor?: boolean;
  69208. /**
  69209. * Optional parameters for the headset impostor
  69210. */
  69211. headsetImpostorParams?: {
  69212. /**
  69213. * The type of impostor to create. Default is sphere
  69214. */
  69215. impostorType: number;
  69216. /**
  69217. * the size of the impostor. Defaults to 10cm
  69218. */
  69219. impostorSize?: number | {
  69220. width: number;
  69221. height: number;
  69222. depth: number;
  69223. };
  69224. /**
  69225. * Friction definitions
  69226. */
  69227. friction?: number;
  69228. /**
  69229. * Restitution
  69230. */
  69231. restitution?: number;
  69232. };
  69233. /**
  69234. * The physics properties of the future impostors
  69235. */
  69236. physicsProperties?: {
  69237. /**
  69238. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69239. * Note that this requires a physics engine that supports mesh impostors!
  69240. */
  69241. useControllerMesh?: boolean;
  69242. /**
  69243. * The type of impostor to create. Default is sphere
  69244. */
  69245. impostorType?: number;
  69246. /**
  69247. * the size of the impostor. Defaults to 10cm
  69248. */
  69249. impostorSize?: number | {
  69250. width: number;
  69251. height: number;
  69252. depth: number;
  69253. };
  69254. /**
  69255. * Friction definitions
  69256. */
  69257. friction?: number;
  69258. /**
  69259. * Restitution
  69260. */
  69261. restitution?: number;
  69262. };
  69263. /**
  69264. * the xr input to use with this pointer selection
  69265. */
  69266. xrInput: WebXRInput;
  69267. }
  69268. /**
  69269. * Add physics impostor to your webxr controllers,
  69270. * including naive calculation of their linear and angular velocity
  69271. */
  69272. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69273. private readonly _options;
  69274. private _attachController;
  69275. private _controllers;
  69276. private _debugMode;
  69277. private _delta;
  69278. private _headsetImpostor?;
  69279. private _headsetMesh?;
  69280. private _lastTimestamp;
  69281. private _tmpQuaternion;
  69282. private _tmpVector;
  69283. /**
  69284. * The module's name
  69285. */
  69286. static readonly Name: string;
  69287. /**
  69288. * The (Babylon) version of this module.
  69289. * This is an integer representing the implementation version.
  69290. * This number does not correspond to the webxr specs version
  69291. */
  69292. static readonly Version: number;
  69293. /**
  69294. * Construct a new Controller Physics Feature
  69295. * @param _xrSessionManager the corresponding xr session manager
  69296. * @param _options options to create this feature with
  69297. */
  69298. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69299. /**
  69300. * @hidden
  69301. * enable debugging - will show console outputs and the impostor mesh
  69302. */
  69303. _enablePhysicsDebug(): void;
  69304. /**
  69305. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69306. * @param xrController the controller to add
  69307. */
  69308. addController(xrController: WebXRInputSource): void;
  69309. /**
  69310. * attach this feature
  69311. * Will usually be called by the features manager
  69312. *
  69313. * @returns true if successful.
  69314. */
  69315. attach(): boolean;
  69316. /**
  69317. * detach this feature.
  69318. * Will usually be called by the features manager
  69319. *
  69320. * @returns true if successful.
  69321. */
  69322. detach(): boolean;
  69323. /**
  69324. * Get the headset impostor, if enabled
  69325. * @returns the impostor
  69326. */
  69327. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69328. /**
  69329. * Get the physics impostor of a specific controller.
  69330. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69331. * @param controller the controller or the controller id of which to get the impostor
  69332. * @returns the impostor or null
  69333. */
  69334. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69335. /**
  69336. * Update the physics properties provided in the constructor
  69337. * @param newProperties the new properties object
  69338. */
  69339. setPhysicsProperties(newProperties: {
  69340. impostorType?: number;
  69341. impostorSize?: number | {
  69342. width: number;
  69343. height: number;
  69344. depth: number;
  69345. };
  69346. friction?: number;
  69347. restitution?: number;
  69348. }): void;
  69349. protected _onXRFrame(_xrFrame: any): void;
  69350. private _detachController;
  69351. }
  69352. }
  69353. declare module BABYLON {
  69354. /**
  69355. * The motion controller class for all microsoft mixed reality controllers
  69356. */
  69357. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69358. protected readonly _mapping: {
  69359. defaultButton: {
  69360. "valueNodeName": string;
  69361. "unpressedNodeName": string;
  69362. "pressedNodeName": string;
  69363. };
  69364. defaultAxis: {
  69365. "valueNodeName": string;
  69366. "minNodeName": string;
  69367. "maxNodeName": string;
  69368. };
  69369. buttons: {
  69370. "xr-standard-trigger": {
  69371. "rootNodeName": string;
  69372. "componentProperty": string;
  69373. "states": string[];
  69374. };
  69375. "xr-standard-squeeze": {
  69376. "rootNodeName": string;
  69377. "componentProperty": string;
  69378. "states": string[];
  69379. };
  69380. "xr-standard-touchpad": {
  69381. "rootNodeName": string;
  69382. "labelAnchorNodeName": string;
  69383. "touchPointNodeName": string;
  69384. };
  69385. "xr-standard-thumbstick": {
  69386. "rootNodeName": string;
  69387. "componentProperty": string;
  69388. "states": string[];
  69389. };
  69390. };
  69391. axes: {
  69392. "xr-standard-touchpad": {
  69393. "x-axis": {
  69394. "rootNodeName": string;
  69395. };
  69396. "y-axis": {
  69397. "rootNodeName": string;
  69398. };
  69399. };
  69400. "xr-standard-thumbstick": {
  69401. "x-axis": {
  69402. "rootNodeName": string;
  69403. };
  69404. "y-axis": {
  69405. "rootNodeName": string;
  69406. };
  69407. };
  69408. };
  69409. };
  69410. /**
  69411. * The base url used to load the left and right controller models
  69412. */
  69413. static MODEL_BASE_URL: string;
  69414. /**
  69415. * The name of the left controller model file
  69416. */
  69417. static MODEL_LEFT_FILENAME: string;
  69418. /**
  69419. * The name of the right controller model file
  69420. */
  69421. static MODEL_RIGHT_FILENAME: string;
  69422. profileId: string;
  69423. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69424. protected _getFilenameAndPath(): {
  69425. filename: string;
  69426. path: string;
  69427. };
  69428. protected _getModelLoadingConstraints(): boolean;
  69429. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69430. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69431. protected _updateModel(): void;
  69432. }
  69433. }
  69434. declare module BABYLON {
  69435. /**
  69436. * The motion controller class for oculus touch (quest, rift).
  69437. * This class supports legacy mapping as well the standard xr mapping
  69438. */
  69439. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69440. private _forceLegacyControllers;
  69441. private _modelRootNode;
  69442. /**
  69443. * The base url used to load the left and right controller models
  69444. */
  69445. static MODEL_BASE_URL: string;
  69446. /**
  69447. * The name of the left controller model file
  69448. */
  69449. static MODEL_LEFT_FILENAME: string;
  69450. /**
  69451. * The name of the right controller model file
  69452. */
  69453. static MODEL_RIGHT_FILENAME: string;
  69454. /**
  69455. * Base Url for the Quest controller model.
  69456. */
  69457. static QUEST_MODEL_BASE_URL: string;
  69458. profileId: string;
  69459. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69460. protected _getFilenameAndPath(): {
  69461. filename: string;
  69462. path: string;
  69463. };
  69464. protected _getModelLoadingConstraints(): boolean;
  69465. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69466. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69467. protected _updateModel(): void;
  69468. /**
  69469. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69470. * between the touch and touch 2.
  69471. */
  69472. private _isQuest;
  69473. }
  69474. }
  69475. declare module BABYLON {
  69476. /**
  69477. * The motion controller class for the standard HTC-Vive controllers
  69478. */
  69479. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69480. private _modelRootNode;
  69481. /**
  69482. * The base url used to load the left and right controller models
  69483. */
  69484. static MODEL_BASE_URL: string;
  69485. /**
  69486. * File name for the controller model.
  69487. */
  69488. static MODEL_FILENAME: string;
  69489. profileId: string;
  69490. /**
  69491. * Create a new Vive motion controller object
  69492. * @param scene the scene to use to create this controller
  69493. * @param gamepadObject the corresponding gamepad object
  69494. * @param handness the handness of the controller
  69495. */
  69496. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69497. protected _getFilenameAndPath(): {
  69498. filename: string;
  69499. path: string;
  69500. };
  69501. protected _getModelLoadingConstraints(): boolean;
  69502. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69503. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69504. protected _updateModel(): void;
  69505. }
  69506. }
  69507. declare module BABYLON {
  69508. /**
  69509. * A cursor which tracks a point on a path
  69510. */
  69511. export class PathCursor {
  69512. private path;
  69513. /**
  69514. * Stores path cursor callbacks for when an onchange event is triggered
  69515. */
  69516. private _onchange;
  69517. /**
  69518. * The value of the path cursor
  69519. */
  69520. value: number;
  69521. /**
  69522. * The animation array of the path cursor
  69523. */
  69524. animations: Animation[];
  69525. /**
  69526. * Initializes the path cursor
  69527. * @param path The path to track
  69528. */
  69529. constructor(path: Path2);
  69530. /**
  69531. * Gets the cursor point on the path
  69532. * @returns A point on the path cursor at the cursor location
  69533. */
  69534. getPoint(): Vector3;
  69535. /**
  69536. * Moves the cursor ahead by the step amount
  69537. * @param step The amount to move the cursor forward
  69538. * @returns This path cursor
  69539. */
  69540. moveAhead(step?: number): PathCursor;
  69541. /**
  69542. * Moves the cursor behind by the step amount
  69543. * @param step The amount to move the cursor back
  69544. * @returns This path cursor
  69545. */
  69546. moveBack(step?: number): PathCursor;
  69547. /**
  69548. * Moves the cursor by the step amount
  69549. * If the step amount is greater than one, an exception is thrown
  69550. * @param step The amount to move the cursor
  69551. * @returns This path cursor
  69552. */
  69553. move(step: number): PathCursor;
  69554. /**
  69555. * Ensures that the value is limited between zero and one
  69556. * @returns This path cursor
  69557. */
  69558. private ensureLimits;
  69559. /**
  69560. * Runs onchange callbacks on change (used by the animation engine)
  69561. * @returns This path cursor
  69562. */
  69563. private raiseOnChange;
  69564. /**
  69565. * Executes a function on change
  69566. * @param f A path cursor onchange callback
  69567. * @returns This path cursor
  69568. */
  69569. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69570. }
  69571. }
  69572. declare module BABYLON {
  69573. /** @hidden */
  69574. export var blurPixelShader: {
  69575. name: string;
  69576. shader: string;
  69577. };
  69578. }
  69579. declare module BABYLON {
  69580. /** @hidden */
  69581. export var pointCloudVertexDeclaration: {
  69582. name: string;
  69583. shader: string;
  69584. };
  69585. }
  69586. // Mixins
  69587. interface Window {
  69588. mozIndexedDB: IDBFactory;
  69589. webkitIndexedDB: IDBFactory;
  69590. msIndexedDB: IDBFactory;
  69591. webkitURL: typeof URL;
  69592. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69593. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69594. WebGLRenderingContext: WebGLRenderingContext;
  69595. MSGesture: MSGesture;
  69596. CANNON: any;
  69597. AudioContext: AudioContext;
  69598. webkitAudioContext: AudioContext;
  69599. PointerEvent: any;
  69600. Math: Math;
  69601. Uint8Array: Uint8ArrayConstructor;
  69602. Float32Array: Float32ArrayConstructor;
  69603. mozURL: typeof URL;
  69604. msURL: typeof URL;
  69605. VRFrameData: any; // WebVR, from specs 1.1
  69606. DracoDecoderModule: any;
  69607. setImmediate(handler: (...args: any[]) => void): number;
  69608. }
  69609. interface HTMLCanvasElement {
  69610. requestPointerLock(): void;
  69611. msRequestPointerLock?(): void;
  69612. mozRequestPointerLock?(): void;
  69613. webkitRequestPointerLock?(): void;
  69614. /** Track wether a record is in progress */
  69615. isRecording: boolean;
  69616. /** Capture Stream method defined by some browsers */
  69617. captureStream(fps?: number): MediaStream;
  69618. }
  69619. interface CanvasRenderingContext2D {
  69620. msImageSmoothingEnabled: boolean;
  69621. }
  69622. interface MouseEvent {
  69623. mozMovementX: number;
  69624. mozMovementY: number;
  69625. webkitMovementX: number;
  69626. webkitMovementY: number;
  69627. msMovementX: number;
  69628. msMovementY: number;
  69629. }
  69630. interface Navigator {
  69631. mozGetVRDevices: (any: any) => any;
  69632. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69633. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69634. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69635. webkitGetGamepads(): Gamepad[];
  69636. msGetGamepads(): Gamepad[];
  69637. webkitGamepads(): Gamepad[];
  69638. }
  69639. interface HTMLVideoElement {
  69640. mozSrcObject: any;
  69641. }
  69642. interface Math {
  69643. fround(x: number): number;
  69644. imul(a: number, b: number): number;
  69645. }
  69646. interface WebGLRenderingContext {
  69647. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69648. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69649. vertexAttribDivisor(index: number, divisor: number): void;
  69650. createVertexArray(): any;
  69651. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69652. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69653. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69654. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69655. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69656. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69657. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69658. // Queries
  69659. createQuery(): WebGLQuery;
  69660. deleteQuery(query: WebGLQuery): void;
  69661. beginQuery(target: number, query: WebGLQuery): void;
  69662. endQuery(target: number): void;
  69663. getQueryParameter(query: WebGLQuery, pname: number): any;
  69664. getQuery(target: number, pname: number): any;
  69665. MAX_SAMPLES: number;
  69666. RGBA8: number;
  69667. READ_FRAMEBUFFER: number;
  69668. DRAW_FRAMEBUFFER: number;
  69669. UNIFORM_BUFFER: number;
  69670. HALF_FLOAT_OES: number;
  69671. RGBA16F: number;
  69672. RGBA32F: number;
  69673. R32F: number;
  69674. RG32F: number;
  69675. RGB32F: number;
  69676. R16F: number;
  69677. RG16F: number;
  69678. RGB16F: number;
  69679. RED: number;
  69680. RG: number;
  69681. R8: number;
  69682. RG8: number;
  69683. UNSIGNED_INT_24_8: number;
  69684. DEPTH24_STENCIL8: number;
  69685. MIN: number;
  69686. MAX: number;
  69687. /* Multiple Render Targets */
  69688. drawBuffers(buffers: number[]): void;
  69689. readBuffer(src: number): void;
  69690. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69691. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69692. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69693. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69694. // Occlusion Query
  69695. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69696. ANY_SAMPLES_PASSED: number;
  69697. QUERY_RESULT_AVAILABLE: number;
  69698. QUERY_RESULT: number;
  69699. }
  69700. interface WebGLProgram {
  69701. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69702. }
  69703. interface EXT_disjoint_timer_query {
  69704. QUERY_COUNTER_BITS_EXT: number;
  69705. TIME_ELAPSED_EXT: number;
  69706. TIMESTAMP_EXT: number;
  69707. GPU_DISJOINT_EXT: number;
  69708. QUERY_RESULT_EXT: number;
  69709. QUERY_RESULT_AVAILABLE_EXT: number;
  69710. queryCounterEXT(query: WebGLQuery, target: number): void;
  69711. createQueryEXT(): WebGLQuery;
  69712. beginQueryEXT(target: number, query: WebGLQuery): void;
  69713. endQueryEXT(target: number): void;
  69714. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69715. deleteQueryEXT(query: WebGLQuery): void;
  69716. }
  69717. interface WebGLUniformLocation {
  69718. _currentState: any;
  69719. }
  69720. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69721. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69722. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69723. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69724. interface WebGLRenderingContext {
  69725. readonly RASTERIZER_DISCARD: number;
  69726. readonly DEPTH_COMPONENT24: number;
  69727. readonly TEXTURE_3D: number;
  69728. readonly TEXTURE_2D_ARRAY: number;
  69729. readonly TEXTURE_COMPARE_FUNC: number;
  69730. readonly TEXTURE_COMPARE_MODE: number;
  69731. readonly COMPARE_REF_TO_TEXTURE: number;
  69732. readonly TEXTURE_WRAP_R: number;
  69733. readonly HALF_FLOAT: number;
  69734. readonly RGB8: number;
  69735. readonly RED_INTEGER: number;
  69736. readonly RG_INTEGER: number;
  69737. readonly RGB_INTEGER: number;
  69738. readonly RGBA_INTEGER: number;
  69739. readonly R8_SNORM: number;
  69740. readonly RG8_SNORM: number;
  69741. readonly RGB8_SNORM: number;
  69742. readonly RGBA8_SNORM: number;
  69743. readonly R8I: number;
  69744. readonly RG8I: number;
  69745. readonly RGB8I: number;
  69746. readonly RGBA8I: number;
  69747. readonly R8UI: number;
  69748. readonly RG8UI: number;
  69749. readonly RGB8UI: number;
  69750. readonly RGBA8UI: number;
  69751. readonly R16I: number;
  69752. readonly RG16I: number;
  69753. readonly RGB16I: number;
  69754. readonly RGBA16I: number;
  69755. readonly R16UI: number;
  69756. readonly RG16UI: number;
  69757. readonly RGB16UI: number;
  69758. readonly RGBA16UI: number;
  69759. readonly R32I: number;
  69760. readonly RG32I: number;
  69761. readonly RGB32I: number;
  69762. readonly RGBA32I: number;
  69763. readonly R32UI: number;
  69764. readonly RG32UI: number;
  69765. readonly RGB32UI: number;
  69766. readonly RGBA32UI: number;
  69767. readonly RGB10_A2UI: number;
  69768. readonly R11F_G11F_B10F: number;
  69769. readonly RGB9_E5: number;
  69770. readonly RGB10_A2: number;
  69771. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69772. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69773. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69774. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69775. readonly DEPTH_COMPONENT32F: number;
  69776. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69777. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69778. 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;
  69779. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69780. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69781. readonly TRANSFORM_FEEDBACK: number;
  69782. readonly INTERLEAVED_ATTRIBS: number;
  69783. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69784. createTransformFeedback(): WebGLTransformFeedback;
  69785. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69786. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69787. beginTransformFeedback(primitiveMode: number): void;
  69788. endTransformFeedback(): void;
  69789. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69790. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69791. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69792. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69793. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69794. }
  69795. interface ImageBitmap {
  69796. readonly width: number;
  69797. readonly height: number;
  69798. close(): void;
  69799. }
  69800. interface WebGLQuery extends WebGLObject {
  69801. }
  69802. declare var WebGLQuery: {
  69803. prototype: WebGLQuery;
  69804. new(): WebGLQuery;
  69805. };
  69806. interface WebGLSampler extends WebGLObject {
  69807. }
  69808. declare var WebGLSampler: {
  69809. prototype: WebGLSampler;
  69810. new(): WebGLSampler;
  69811. };
  69812. interface WebGLSync extends WebGLObject {
  69813. }
  69814. declare var WebGLSync: {
  69815. prototype: WebGLSync;
  69816. new(): WebGLSync;
  69817. };
  69818. interface WebGLTransformFeedback extends WebGLObject {
  69819. }
  69820. declare var WebGLTransformFeedback: {
  69821. prototype: WebGLTransformFeedback;
  69822. new(): WebGLTransformFeedback;
  69823. };
  69824. interface WebGLVertexArrayObject extends WebGLObject {
  69825. }
  69826. declare var WebGLVertexArrayObject: {
  69827. prototype: WebGLVertexArrayObject;
  69828. new(): WebGLVertexArrayObject;
  69829. };
  69830. // Type definitions for WebVR API
  69831. // Project: https://w3c.github.io/webvr/
  69832. // Definitions by: six a <https://github.com/lostfictions>
  69833. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69834. interface VRDisplay extends EventTarget {
  69835. /**
  69836. * Dictionary of capabilities describing the VRDisplay.
  69837. */
  69838. readonly capabilities: VRDisplayCapabilities;
  69839. /**
  69840. * z-depth defining the far plane of the eye view frustum
  69841. * enables mapping of values in the render target depth
  69842. * attachment to scene coordinates. Initially set to 10000.0.
  69843. */
  69844. depthFar: number;
  69845. /**
  69846. * z-depth defining the near plane of the eye view frustum
  69847. * enables mapping of values in the render target depth
  69848. * attachment to scene coordinates. Initially set to 0.01.
  69849. */
  69850. depthNear: number;
  69851. /**
  69852. * An identifier for this distinct VRDisplay. Used as an
  69853. * association point in the Gamepad API.
  69854. */
  69855. readonly displayId: number;
  69856. /**
  69857. * A display name, a user-readable name identifying it.
  69858. */
  69859. readonly displayName: string;
  69860. readonly isConnected: boolean;
  69861. readonly isPresenting: boolean;
  69862. /**
  69863. * If this VRDisplay supports room-scale experiences, the optional
  69864. * stage attribute contains details on the room-scale parameters.
  69865. */
  69866. readonly stageParameters: VRStageParameters | null;
  69867. /**
  69868. * Passing the value returned by `requestAnimationFrame` to
  69869. * `cancelAnimationFrame` will unregister the callback.
  69870. * @param handle Define the hanle of the request to cancel
  69871. */
  69872. cancelAnimationFrame(handle: number): void;
  69873. /**
  69874. * Stops presenting to the VRDisplay.
  69875. * @returns a promise to know when it stopped
  69876. */
  69877. exitPresent(): Promise<void>;
  69878. /**
  69879. * Return the current VREyeParameters for the given eye.
  69880. * @param whichEye Define the eye we want the parameter for
  69881. * @returns the eye parameters
  69882. */
  69883. getEyeParameters(whichEye: string): VREyeParameters;
  69884. /**
  69885. * Populates the passed VRFrameData with the information required to render
  69886. * the current frame.
  69887. * @param frameData Define the data structure to populate
  69888. * @returns true if ok otherwise false
  69889. */
  69890. getFrameData(frameData: VRFrameData): boolean;
  69891. /**
  69892. * Get the layers currently being presented.
  69893. * @returns the list of VR layers
  69894. */
  69895. getLayers(): VRLayer[];
  69896. /**
  69897. * Return a VRPose containing the future predicted pose of the VRDisplay
  69898. * when the current frame will be presented. The value returned will not
  69899. * change until JavaScript has returned control to the browser.
  69900. *
  69901. * The VRPose will contain the position, orientation, velocity,
  69902. * and acceleration of each of these properties.
  69903. * @returns the pose object
  69904. */
  69905. getPose(): VRPose;
  69906. /**
  69907. * Return the current instantaneous pose of the VRDisplay, with no
  69908. * prediction applied.
  69909. * @returns the current instantaneous pose
  69910. */
  69911. getImmediatePose(): VRPose;
  69912. /**
  69913. * The callback passed to `requestAnimationFrame` will be called
  69914. * any time a new frame should be rendered. When the VRDisplay is
  69915. * presenting the callback will be called at the native refresh
  69916. * rate of the HMD. When not presenting this function acts
  69917. * identically to how window.requestAnimationFrame acts. Content should
  69918. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69919. * asynchronously from other displays and at differing refresh rates.
  69920. * @param callback Define the eaction to run next frame
  69921. * @returns the request handle it
  69922. */
  69923. requestAnimationFrame(callback: FrameRequestCallback): number;
  69924. /**
  69925. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69926. * Repeat calls while already presenting will update the VRLayers being displayed.
  69927. * @param layers Define the list of layer to present
  69928. * @returns a promise to know when the request has been fulfilled
  69929. */
  69930. requestPresent(layers: VRLayer[]): Promise<void>;
  69931. /**
  69932. * Reset the pose for this display, treating its current position and
  69933. * orientation as the "origin/zero" values. VRPose.position,
  69934. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69935. * updated when calling resetPose(). This should be called in only
  69936. * sitting-space experiences.
  69937. */
  69938. resetPose(): void;
  69939. /**
  69940. * The VRLayer provided to the VRDisplay will be captured and presented
  69941. * in the HMD. Calling this function has the same effect on the source
  69942. * canvas as any other operation that uses its source image, and canvases
  69943. * created without preserveDrawingBuffer set to true will be cleared.
  69944. * @param pose Define the pose to submit
  69945. */
  69946. submitFrame(pose?: VRPose): void;
  69947. }
  69948. declare var VRDisplay: {
  69949. prototype: VRDisplay;
  69950. new(): VRDisplay;
  69951. };
  69952. interface VRLayer {
  69953. leftBounds?: number[] | Float32Array | null;
  69954. rightBounds?: number[] | Float32Array | null;
  69955. source?: HTMLCanvasElement | null;
  69956. }
  69957. interface VRDisplayCapabilities {
  69958. readonly canPresent: boolean;
  69959. readonly hasExternalDisplay: boolean;
  69960. readonly hasOrientation: boolean;
  69961. readonly hasPosition: boolean;
  69962. readonly maxLayers: number;
  69963. }
  69964. interface VREyeParameters {
  69965. /** @deprecated */
  69966. readonly fieldOfView: VRFieldOfView;
  69967. readonly offset: Float32Array;
  69968. readonly renderHeight: number;
  69969. readonly renderWidth: number;
  69970. }
  69971. interface VRFieldOfView {
  69972. readonly downDegrees: number;
  69973. readonly leftDegrees: number;
  69974. readonly rightDegrees: number;
  69975. readonly upDegrees: number;
  69976. }
  69977. interface VRFrameData {
  69978. readonly leftProjectionMatrix: Float32Array;
  69979. readonly leftViewMatrix: Float32Array;
  69980. readonly pose: VRPose;
  69981. readonly rightProjectionMatrix: Float32Array;
  69982. readonly rightViewMatrix: Float32Array;
  69983. readonly timestamp: number;
  69984. }
  69985. interface VRPose {
  69986. readonly angularAcceleration: Float32Array | null;
  69987. readonly angularVelocity: Float32Array | null;
  69988. readonly linearAcceleration: Float32Array | null;
  69989. readonly linearVelocity: Float32Array | null;
  69990. readonly orientation: Float32Array | null;
  69991. readonly position: Float32Array | null;
  69992. readonly timestamp: number;
  69993. }
  69994. interface VRStageParameters {
  69995. sittingToStandingTransform?: Float32Array;
  69996. sizeX?: number;
  69997. sizeY?: number;
  69998. }
  69999. interface Navigator {
  70000. getVRDisplays(): Promise<VRDisplay[]>;
  70001. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70002. }
  70003. interface Window {
  70004. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70005. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70006. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70007. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70008. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70009. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70010. }
  70011. interface Gamepad {
  70012. readonly displayId: number;
  70013. }
  70014. type XRSessionMode =
  70015. | "inline"
  70016. | "immersive-vr"
  70017. | "immersive-ar";
  70018. type XRReferenceSpaceType =
  70019. | "viewer"
  70020. | "local"
  70021. | "local-floor"
  70022. | "bounded-floor"
  70023. | "unbounded";
  70024. type XREnvironmentBlendMode =
  70025. | "opaque"
  70026. | "additive"
  70027. | "alpha-blend";
  70028. type XRVisibilityState =
  70029. | "visible"
  70030. | "visible-blurred"
  70031. | "hidden";
  70032. type XRHandedness =
  70033. | "none"
  70034. | "left"
  70035. | "right";
  70036. type XRTargetRayMode =
  70037. | "gaze"
  70038. | "tracked-pointer"
  70039. | "screen";
  70040. type XREye =
  70041. | "none"
  70042. | "left"
  70043. | "right";
  70044. interface XRSpace extends EventTarget {
  70045. }
  70046. interface XRRenderState {
  70047. depthNear?: number;
  70048. depthFar?: number;
  70049. inlineVerticalFieldOfView?: number;
  70050. baseLayer?: XRWebGLLayer;
  70051. }
  70052. interface XRInputSource {
  70053. handedness: XRHandedness;
  70054. targetRayMode: XRTargetRayMode;
  70055. targetRaySpace: XRSpace;
  70056. gripSpace: XRSpace | undefined;
  70057. gamepad: Gamepad | undefined;
  70058. profiles: Array<string>;
  70059. }
  70060. interface XRSessionInit {
  70061. optionalFeatures?: XRReferenceSpaceType[];
  70062. requiredFeatures?: XRReferenceSpaceType[];
  70063. }
  70064. interface XRSession extends XRAnchorCreator {
  70065. addEventListener: Function;
  70066. removeEventListener: Function;
  70067. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70068. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70069. requestAnimationFrame: Function;
  70070. end(): Promise<void>;
  70071. renderState: XRRenderState;
  70072. inputSources: Array<XRInputSource>;
  70073. // AR hit test
  70074. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70075. updateWorldTrackingState(options: {
  70076. planeDetectionState?: { enabled: boolean; }
  70077. }): void;
  70078. }
  70079. interface XRReferenceSpace extends XRSpace {
  70080. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70081. onreset: any;
  70082. }
  70083. type XRPlaneSet = Set<XRPlane>;
  70084. type XRAnchorSet = Set<XRAnchor>;
  70085. interface XRFrame {
  70086. session: XRSession;
  70087. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70088. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70089. // Anchors
  70090. trackedAnchors?: XRAnchorSet;
  70091. // Planes
  70092. worldInformation: {
  70093. detectedPlanes?: XRPlaneSet;
  70094. };
  70095. }
  70096. interface XRViewerPose extends XRPose {
  70097. views: Array<XRView>;
  70098. }
  70099. interface XRPose {
  70100. transform: XRRigidTransform;
  70101. emulatedPosition: boolean;
  70102. }
  70103. interface XRWebGLLayerOptions {
  70104. antialias?: boolean;
  70105. depth?: boolean;
  70106. stencil?: boolean;
  70107. alpha?: boolean;
  70108. multiview?: boolean;
  70109. framebufferScaleFactor?: number;
  70110. }
  70111. declare var XRWebGLLayer: {
  70112. prototype: XRWebGLLayer;
  70113. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70114. };
  70115. interface XRWebGLLayer {
  70116. framebuffer: WebGLFramebuffer;
  70117. framebufferWidth: number;
  70118. framebufferHeight: number;
  70119. getViewport: Function;
  70120. }
  70121. declare class XRRigidTransform {
  70122. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70123. position: DOMPointReadOnly;
  70124. orientation: DOMPointReadOnly;
  70125. matrix: Float32Array;
  70126. inverse: XRRigidTransform;
  70127. }
  70128. interface XRView {
  70129. eye: XREye;
  70130. projectionMatrix: Float32Array;
  70131. transform: XRRigidTransform;
  70132. }
  70133. interface XRInputSourceChangeEvent {
  70134. session: XRSession;
  70135. removed: Array<XRInputSource>;
  70136. added: Array<XRInputSource>;
  70137. }
  70138. interface XRInputSourceEvent extends Event {
  70139. readonly frame: XRFrame;
  70140. readonly inputSource: XRInputSource;
  70141. }
  70142. // Experimental(er) features
  70143. declare class XRRay {
  70144. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70145. origin: DOMPointReadOnly;
  70146. direction: DOMPointReadOnly;
  70147. matrix: Float32Array;
  70148. }
  70149. interface XRHitResult {
  70150. hitMatrix: Float32Array;
  70151. }
  70152. interface XRAnchor {
  70153. // remove?
  70154. id?: string;
  70155. anchorSpace: XRSpace;
  70156. lastChangedTime: number;
  70157. detach(): void;
  70158. }
  70159. interface XRPlane extends XRAnchorCreator {
  70160. orientation: "Horizontal" | "Vertical";
  70161. planeSpace: XRSpace;
  70162. polygon: Array<DOMPointReadOnly>;
  70163. lastChangedTime: number;
  70164. }
  70165. interface XRAnchorCreator {
  70166. // AR Anchors
  70167. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  70168. }
  70169. /**
  70170. * @ignore
  70171. */
  70172. declare module BABYLON.GLTF2.Exporter {
  70173. }
  70174. /**
  70175. * @ignore
  70176. */
  70177. declare module BABYLON.GLTF1 {
  70178. }
  70179. declare module BABYLON.GUI {
  70180. /**
  70181. * Class used to specific a value and its associated unit
  70182. */
  70183. export class ValueAndUnit {
  70184. /** defines the unit to store */
  70185. unit: number;
  70186. /** defines a boolean indicating if the value can be negative */
  70187. negativeValueAllowed: boolean;
  70188. private _value;
  70189. private _originalUnit;
  70190. /**
  70191. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70192. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70193. */
  70194. ignoreAdaptiveScaling: boolean;
  70195. /**
  70196. * Creates a new ValueAndUnit
  70197. * @param value defines the value to store
  70198. * @param unit defines the unit to store
  70199. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70200. */
  70201. constructor(value: number,
  70202. /** defines the unit to store */
  70203. unit?: number,
  70204. /** defines a boolean indicating if the value can be negative */
  70205. negativeValueAllowed?: boolean);
  70206. /** Gets a boolean indicating if the value is a percentage */
  70207. get isPercentage(): boolean;
  70208. /** Gets a boolean indicating if the value is store as pixel */
  70209. get isPixel(): boolean;
  70210. /** Gets direct internal value */
  70211. get internalValue(): number;
  70212. /**
  70213. * Gets value as pixel
  70214. * @param host defines the root host
  70215. * @param refValue defines the reference value for percentages
  70216. * @returns the value as pixel
  70217. */
  70218. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70219. /**
  70220. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70221. * @param value defines the value to store
  70222. * @param unit defines the unit to store
  70223. * @returns the current ValueAndUnit
  70224. */
  70225. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70226. /**
  70227. * Gets the value accordingly to its unit
  70228. * @param host defines the root host
  70229. * @returns the value
  70230. */
  70231. getValue(host: AdvancedDynamicTexture): number;
  70232. /**
  70233. * Gets a string representation of the value
  70234. * @param host defines the root host
  70235. * @param decimals defines an optional number of decimals to display
  70236. * @returns a string
  70237. */
  70238. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70239. /**
  70240. * Store a value parsed from a string
  70241. * @param source defines the source string
  70242. * @returns true if the value was successfully parsed
  70243. */
  70244. fromString(source: string | number): boolean;
  70245. private static _Regex;
  70246. private static _UNITMODE_PERCENTAGE;
  70247. private static _UNITMODE_PIXEL;
  70248. /** UNITMODE_PERCENTAGE */
  70249. static get UNITMODE_PERCENTAGE(): number;
  70250. /** UNITMODE_PIXEL */
  70251. static get UNITMODE_PIXEL(): number;
  70252. }
  70253. }
  70254. declare module BABYLON.GUI {
  70255. /**
  70256. * Define a style used by control to automatically setup properties based on a template.
  70257. * Only support font related properties so far
  70258. */
  70259. export class Style implements BABYLON.IDisposable {
  70260. private _fontFamily;
  70261. private _fontStyle;
  70262. private _fontWeight;
  70263. /** @hidden */
  70264. _host: AdvancedDynamicTexture;
  70265. /** @hidden */
  70266. _fontSize: ValueAndUnit;
  70267. /**
  70268. * BABYLON.Observable raised when the style values are changed
  70269. */
  70270. onChangedObservable: BABYLON.Observable<Style>;
  70271. /**
  70272. * Creates a new style object
  70273. * @param host defines the AdvancedDynamicTexture which hosts this style
  70274. */
  70275. constructor(host: AdvancedDynamicTexture);
  70276. /**
  70277. * Gets or sets the font size
  70278. */
  70279. get fontSize(): string | number;
  70280. set fontSize(value: string | number);
  70281. /**
  70282. * Gets or sets the font family
  70283. */
  70284. get fontFamily(): string;
  70285. set fontFamily(value: string);
  70286. /**
  70287. * Gets or sets the font style
  70288. */
  70289. get fontStyle(): string;
  70290. set fontStyle(value: string);
  70291. /** Gets or sets font weight */
  70292. get fontWeight(): string;
  70293. set fontWeight(value: string);
  70294. /** Dispose all associated resources */
  70295. dispose(): void;
  70296. }
  70297. }
  70298. declare module BABYLON.GUI {
  70299. /**
  70300. * Class used to transport BABYLON.Vector2 information for pointer events
  70301. */
  70302. export class Vector2WithInfo extends BABYLON.Vector2 {
  70303. /** defines the current mouse button index */
  70304. buttonIndex: number;
  70305. /**
  70306. * Creates a new Vector2WithInfo
  70307. * @param source defines the vector2 data to transport
  70308. * @param buttonIndex defines the current mouse button index
  70309. */
  70310. constructor(source: BABYLON.Vector2,
  70311. /** defines the current mouse button index */
  70312. buttonIndex?: number);
  70313. }
  70314. /** Class used to provide 2D matrix features */
  70315. export class Matrix2D {
  70316. /** Gets the internal array of 6 floats used to store matrix data */
  70317. m: Float32Array;
  70318. /**
  70319. * Creates a new matrix
  70320. * @param m00 defines value for (0, 0)
  70321. * @param m01 defines value for (0, 1)
  70322. * @param m10 defines value for (1, 0)
  70323. * @param m11 defines value for (1, 1)
  70324. * @param m20 defines value for (2, 0)
  70325. * @param m21 defines value for (2, 1)
  70326. */
  70327. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70328. /**
  70329. * Fills the matrix from direct values
  70330. * @param m00 defines value for (0, 0)
  70331. * @param m01 defines value for (0, 1)
  70332. * @param m10 defines value for (1, 0)
  70333. * @param m11 defines value for (1, 1)
  70334. * @param m20 defines value for (2, 0)
  70335. * @param m21 defines value for (2, 1)
  70336. * @returns the current modified matrix
  70337. */
  70338. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70339. /**
  70340. * Gets matrix determinant
  70341. * @returns the determinant
  70342. */
  70343. determinant(): number;
  70344. /**
  70345. * Inverses the matrix and stores it in a target matrix
  70346. * @param result defines the target matrix
  70347. * @returns the current matrix
  70348. */
  70349. invertToRef(result: Matrix2D): Matrix2D;
  70350. /**
  70351. * Multiplies the current matrix with another one
  70352. * @param other defines the second operand
  70353. * @param result defines the target matrix
  70354. * @returns the current matrix
  70355. */
  70356. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70357. /**
  70358. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70359. * @param x defines the x coordinate to transform
  70360. * @param y defines the x coordinate to transform
  70361. * @param result defines the target vector2
  70362. * @returns the current matrix
  70363. */
  70364. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70365. /**
  70366. * Creates an identity matrix
  70367. * @returns a new matrix
  70368. */
  70369. static Identity(): Matrix2D;
  70370. /**
  70371. * Creates a translation matrix and stores it in a target matrix
  70372. * @param x defines the x coordinate of the translation
  70373. * @param y defines the y coordinate of the translation
  70374. * @param result defines the target matrix
  70375. */
  70376. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70377. /**
  70378. * Creates a scaling matrix and stores it in a target matrix
  70379. * @param x defines the x coordinate of the scaling
  70380. * @param y defines the y coordinate of the scaling
  70381. * @param result defines the target matrix
  70382. */
  70383. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70384. /**
  70385. * Creates a rotation matrix and stores it in a target matrix
  70386. * @param angle defines the rotation angle
  70387. * @param result defines the target matrix
  70388. */
  70389. static RotationToRef(angle: number, result: Matrix2D): void;
  70390. private static _TempPreTranslationMatrix;
  70391. private static _TempPostTranslationMatrix;
  70392. private static _TempRotationMatrix;
  70393. private static _TempScalingMatrix;
  70394. private static _TempCompose0;
  70395. private static _TempCompose1;
  70396. private static _TempCompose2;
  70397. /**
  70398. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70399. * @param tx defines the x coordinate of the translation
  70400. * @param ty defines the y coordinate of the translation
  70401. * @param angle defines the rotation angle
  70402. * @param scaleX defines the x coordinate of the scaling
  70403. * @param scaleY defines the y coordinate of the scaling
  70404. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70405. * @param result defines the target matrix
  70406. */
  70407. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  70408. }
  70409. }
  70410. declare module BABYLON.GUI {
  70411. /**
  70412. * Class used to store 2D control sizes
  70413. */
  70414. export class Measure {
  70415. /** defines left coordinate */
  70416. left: number;
  70417. /** defines top coordinate */
  70418. top: number;
  70419. /** defines width dimension */
  70420. width: number;
  70421. /** defines height dimension */
  70422. height: number;
  70423. /**
  70424. * Creates a new measure
  70425. * @param left defines left coordinate
  70426. * @param top defines top coordinate
  70427. * @param width defines width dimension
  70428. * @param height defines height dimension
  70429. */
  70430. constructor(
  70431. /** defines left coordinate */
  70432. left: number,
  70433. /** defines top coordinate */
  70434. top: number,
  70435. /** defines width dimension */
  70436. width: number,
  70437. /** defines height dimension */
  70438. height: number);
  70439. /**
  70440. * Copy from another measure
  70441. * @param other defines the other measure to copy from
  70442. */
  70443. copyFrom(other: Measure): void;
  70444. /**
  70445. * Copy from a group of 4 floats
  70446. * @param left defines left coordinate
  70447. * @param top defines top coordinate
  70448. * @param width defines width dimension
  70449. * @param height defines height dimension
  70450. */
  70451. copyFromFloats(left: number, top: number, width: number, height: number): void;
  70452. /**
  70453. * Computes the axis aligned bounding box measure for two given measures
  70454. * @param a Input measure
  70455. * @param b Input measure
  70456. * @param result the resulting bounding measure
  70457. */
  70458. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  70459. /**
  70460. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  70461. * @param transform the matrix to transform the measure before computing the AABB
  70462. * @param result the resulting AABB
  70463. */
  70464. transformToRef(transform: Matrix2D, result: Measure): void;
  70465. /**
  70466. * Check equality between this measure and another one
  70467. * @param other defines the other measures
  70468. * @returns true if both measures are equals
  70469. */
  70470. isEqualsTo(other: Measure): boolean;
  70471. /**
  70472. * Creates an empty measure
  70473. * @returns a new measure
  70474. */
  70475. static Empty(): Measure;
  70476. }
  70477. }
  70478. declare module BABYLON.GUI {
  70479. /**
  70480. * Interface used to define a control that can receive focus
  70481. */
  70482. export interface IFocusableControl {
  70483. /**
  70484. * Function called when the control receives the focus
  70485. */
  70486. onFocus(): void;
  70487. /**
  70488. * Function called when the control loses the focus
  70489. */
  70490. onBlur(): void;
  70491. /**
  70492. * Function called to let the control handle keyboard events
  70493. * @param evt defines the current keyboard event
  70494. */
  70495. processKeyboard(evt: KeyboardEvent): void;
  70496. /**
  70497. * Function called to get the list of controls that should not steal the focus from this control
  70498. * @returns an array of controls
  70499. */
  70500. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70501. }
  70502. /**
  70503. * Class used to create texture to support 2D GUI elements
  70504. * @see http://doc.babylonjs.com/how_to/gui
  70505. */
  70506. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  70507. private _isDirty;
  70508. private _renderObserver;
  70509. private _resizeObserver;
  70510. private _preKeyboardObserver;
  70511. private _pointerMoveObserver;
  70512. private _pointerObserver;
  70513. private _canvasPointerOutObserver;
  70514. private _background;
  70515. /** @hidden */
  70516. _rootContainer: Container;
  70517. /** @hidden */
  70518. _lastPickedControl: Control;
  70519. /** @hidden */
  70520. _lastControlOver: {
  70521. [pointerId: number]: Control;
  70522. };
  70523. /** @hidden */
  70524. _lastControlDown: {
  70525. [pointerId: number]: Control;
  70526. };
  70527. /** @hidden */
  70528. _capturingControl: {
  70529. [pointerId: number]: Control;
  70530. };
  70531. /** @hidden */
  70532. _shouldBlockPointer: boolean;
  70533. /** @hidden */
  70534. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  70535. /** @hidden */
  70536. _linkedControls: Control[];
  70537. private _isFullscreen;
  70538. private _fullscreenViewport;
  70539. private _idealWidth;
  70540. private _idealHeight;
  70541. private _useSmallestIdeal;
  70542. private _renderAtIdealSize;
  70543. private _focusedControl;
  70544. private _blockNextFocusCheck;
  70545. private _renderScale;
  70546. private _rootElement;
  70547. private _cursorChanged;
  70548. private _defaultMousePointerId;
  70549. /** @hidden */
  70550. _numLayoutCalls: number;
  70551. /** Gets the number of layout calls made the last time the ADT has been rendered */
  70552. get numLayoutCalls(): number;
  70553. /** @hidden */
  70554. _numRenderCalls: number;
  70555. /** Gets the number of render calls made the last time the ADT has been rendered */
  70556. get numRenderCalls(): number;
  70557. /**
  70558. * Define type to string to ensure compatibility across browsers
  70559. * Safari doesn't support DataTransfer constructor
  70560. */
  70561. private _clipboardData;
  70562. /**
  70563. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  70564. */
  70565. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  70566. /**
  70567. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  70568. */
  70569. onControlPickedObservable: BABYLON.Observable<Control>;
  70570. /**
  70571. * BABYLON.Observable event triggered before layout is evaluated
  70572. */
  70573. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70574. /**
  70575. * BABYLON.Observable event triggered after the layout was evaluated
  70576. */
  70577. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70578. /**
  70579. * BABYLON.Observable event triggered before the texture is rendered
  70580. */
  70581. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70582. /**
  70583. * BABYLON.Observable event triggered after the texture was rendered
  70584. */
  70585. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70586. /**
  70587. * Gets or sets a boolean defining if alpha is stored as premultiplied
  70588. */
  70589. premulAlpha: boolean;
  70590. /**
  70591. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  70592. * Useful when you want more antialiasing
  70593. */
  70594. get renderScale(): number;
  70595. set renderScale(value: number);
  70596. /** Gets or sets the background color */
  70597. get background(): string;
  70598. set background(value: string);
  70599. /**
  70600. * Gets or sets the ideal width used to design controls.
  70601. * The GUI will then rescale everything accordingly
  70602. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70603. */
  70604. get idealWidth(): number;
  70605. set idealWidth(value: number);
  70606. /**
  70607. * Gets or sets the ideal height used to design controls.
  70608. * The GUI will then rescale everything accordingly
  70609. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70610. */
  70611. get idealHeight(): number;
  70612. set idealHeight(value: number);
  70613. /**
  70614. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  70615. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70616. */
  70617. get useSmallestIdeal(): boolean;
  70618. set useSmallestIdeal(value: boolean);
  70619. /**
  70620. * Gets or sets a boolean indicating if adaptive scaling must be used
  70621. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70622. */
  70623. get renderAtIdealSize(): boolean;
  70624. set renderAtIdealSize(value: boolean);
  70625. /**
  70626. * Gets the ratio used when in "ideal mode"
  70627. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70628. * */
  70629. get idealRatio(): number;
  70630. /**
  70631. * Gets the underlying layer used to render the texture when in fullscreen mode
  70632. */
  70633. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  70634. /**
  70635. * Gets the root container control
  70636. */
  70637. get rootContainer(): Container;
  70638. /**
  70639. * Returns an array containing the root container.
  70640. * This is mostly used to let the Inspector introspects the ADT
  70641. * @returns an array containing the rootContainer
  70642. */
  70643. getChildren(): Array<Container>;
  70644. /**
  70645. * Will return all controls that are inside this texture
  70646. * @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
  70647. * @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
  70648. * @return all child controls
  70649. */
  70650. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70651. /**
  70652. * Gets or sets the current focused control
  70653. */
  70654. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  70655. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  70656. /**
  70657. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  70658. */
  70659. get isForeground(): boolean;
  70660. set isForeground(value: boolean);
  70661. /**
  70662. * Gets or set information about clipboardData
  70663. */
  70664. get clipboardData(): string;
  70665. set clipboardData(value: string);
  70666. /**
  70667. * Creates a new AdvancedDynamicTexture
  70668. * @param name defines the name of the texture
  70669. * @param width defines the width of the texture
  70670. * @param height defines the height of the texture
  70671. * @param scene defines the hosting scene
  70672. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  70673. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  70674. */
  70675. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  70676. /**
  70677. * Get the current class name of the texture useful for serialization or dynamic coding.
  70678. * @returns "AdvancedDynamicTexture"
  70679. */
  70680. getClassName(): string;
  70681. /**
  70682. * Function used to execute a function on all controls
  70683. * @param func defines the function to execute
  70684. * @param container defines the container where controls belong. If null the root container will be used
  70685. */
  70686. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  70687. private _useInvalidateRectOptimization;
  70688. /**
  70689. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  70690. */
  70691. get useInvalidateRectOptimization(): boolean;
  70692. set useInvalidateRectOptimization(value: boolean);
  70693. private _invalidatedRectangle;
  70694. /**
  70695. * Invalidates a rectangle area on the gui texture
  70696. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  70697. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  70698. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  70699. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  70700. */
  70701. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  70702. /**
  70703. * Marks the texture as dirty forcing a complete update
  70704. */
  70705. markAsDirty(): void;
  70706. /**
  70707. * Helper function used to create a new style
  70708. * @returns a new style
  70709. * @see http://doc.babylonjs.com/how_to/gui#styles
  70710. */
  70711. createStyle(): Style;
  70712. /**
  70713. * Adds a new control to the root container
  70714. * @param control defines the control to add
  70715. * @returns the current texture
  70716. */
  70717. addControl(control: Control): AdvancedDynamicTexture;
  70718. /**
  70719. * Removes a control from the root container
  70720. * @param control defines the control to remove
  70721. * @returns the current texture
  70722. */
  70723. removeControl(control: Control): AdvancedDynamicTexture;
  70724. /**
  70725. * Release all resources
  70726. */
  70727. dispose(): void;
  70728. private _onResize;
  70729. /** @hidden */
  70730. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  70731. /**
  70732. * Get screen coordinates for a vector3
  70733. * @param position defines the position to project
  70734. * @param worldMatrix defines the world matrix to use
  70735. * @returns the projected position
  70736. */
  70737. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  70738. private _checkUpdate;
  70739. private _clearMeasure;
  70740. private _render;
  70741. /** @hidden */
  70742. _changeCursor(cursor: string): void;
  70743. /** @hidden */
  70744. _registerLastControlDown(control: Control, pointerId: number): void;
  70745. private _doPicking;
  70746. /** @hidden */
  70747. _cleanControlAfterRemovalFromList(list: {
  70748. [pointerId: number]: Control;
  70749. }, control: Control): void;
  70750. /** @hidden */
  70751. _cleanControlAfterRemoval(control: Control): void;
  70752. /** Attach to all scene events required to support pointer events */
  70753. attach(): void;
  70754. /** @hidden */
  70755. private onClipboardCopy;
  70756. /** @hidden */
  70757. private onClipboardCut;
  70758. /** @hidden */
  70759. private onClipboardPaste;
  70760. /**
  70761. * Register the clipboard Events onto the canvas
  70762. */
  70763. registerClipboardEvents(): void;
  70764. /**
  70765. * Unregister the clipboard Events from the canvas
  70766. */
  70767. unRegisterClipboardEvents(): void;
  70768. /**
  70769. * Connect the texture to a hosting mesh to enable interactions
  70770. * @param mesh defines the mesh to attach to
  70771. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70772. */
  70773. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70774. /**
  70775. * Move the focus to a specific control
  70776. * @param control defines the control which will receive the focus
  70777. */
  70778. moveFocusToControl(control: IFocusableControl): void;
  70779. private _manageFocus;
  70780. private _attachToOnPointerOut;
  70781. /**
  70782. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70783. * @param mesh defines the mesh which will receive the texture
  70784. * @param width defines the texture width (1024 by default)
  70785. * @param height defines the texture height (1024 by default)
  70786. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70787. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70788. * @returns a new AdvancedDynamicTexture
  70789. */
  70790. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70791. /**
  70792. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70793. * In this mode the texture will rely on a layer for its rendering.
  70794. * This allows it to be treated like any other layer.
  70795. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70796. * LayerMask is set through advancedTexture.layer.layerMask
  70797. * @param name defines name for the texture
  70798. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70799. * @param scene defines the hsoting scene
  70800. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70801. * @returns a new AdvancedDynamicTexture
  70802. */
  70803. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70804. }
  70805. }
  70806. declare module BABYLON.GUI {
  70807. /**
  70808. * Root class used for all 2D controls
  70809. * @see http://doc.babylonjs.com/how_to/gui#controls
  70810. */
  70811. export class Control {
  70812. /** defines the name of the control */
  70813. name?: string | undefined;
  70814. /**
  70815. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70816. */
  70817. static AllowAlphaInheritance: boolean;
  70818. private _alpha;
  70819. private _alphaSet;
  70820. private _zIndex;
  70821. /** @hidden */
  70822. _host: AdvancedDynamicTexture;
  70823. /** Gets or sets the control parent */
  70824. parent: BABYLON.Nullable<Container>;
  70825. /** @hidden */
  70826. _currentMeasure: Measure;
  70827. private _fontFamily;
  70828. private _fontStyle;
  70829. private _fontWeight;
  70830. private _fontSize;
  70831. private _font;
  70832. /** @hidden */
  70833. _width: ValueAndUnit;
  70834. /** @hidden */
  70835. _height: ValueAndUnit;
  70836. /** @hidden */
  70837. protected _fontOffset: {
  70838. ascent: number;
  70839. height: number;
  70840. descent: number;
  70841. };
  70842. private _color;
  70843. private _style;
  70844. private _styleObserver;
  70845. /** @hidden */
  70846. protected _horizontalAlignment: number;
  70847. /** @hidden */
  70848. protected _verticalAlignment: number;
  70849. /** @hidden */
  70850. protected _isDirty: boolean;
  70851. /** @hidden */
  70852. protected _wasDirty: boolean;
  70853. /** @hidden */
  70854. _tempParentMeasure: Measure;
  70855. /** @hidden */
  70856. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70857. /** @hidden */
  70858. protected _cachedParentMeasure: Measure;
  70859. private _paddingLeft;
  70860. private _paddingRight;
  70861. private _paddingTop;
  70862. private _paddingBottom;
  70863. /** @hidden */
  70864. _left: ValueAndUnit;
  70865. /** @hidden */
  70866. _top: ValueAndUnit;
  70867. private _scaleX;
  70868. private _scaleY;
  70869. private _rotation;
  70870. private _transformCenterX;
  70871. private _transformCenterY;
  70872. /** @hidden */
  70873. _transformMatrix: Matrix2D;
  70874. /** @hidden */
  70875. protected _invertTransformMatrix: Matrix2D;
  70876. /** @hidden */
  70877. protected _transformedPosition: BABYLON.Vector2;
  70878. private _isMatrixDirty;
  70879. private _cachedOffsetX;
  70880. private _cachedOffsetY;
  70881. private _isVisible;
  70882. private _isHighlighted;
  70883. /** @hidden */
  70884. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70885. private _fontSet;
  70886. private _dummyVector2;
  70887. private _downCount;
  70888. private _enterCount;
  70889. private _doNotRender;
  70890. private _downPointerIds;
  70891. protected _isEnabled: boolean;
  70892. protected _disabledColor: string;
  70893. protected _disabledColorItem: string;
  70894. /** @hidden */
  70895. protected _rebuildLayout: boolean;
  70896. /** @hidden */
  70897. _customData: any;
  70898. /** @hidden */
  70899. _isClipped: boolean;
  70900. /** @hidden */
  70901. _automaticSize: boolean;
  70902. /** @hidden */
  70903. _tag: any;
  70904. /**
  70905. * 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
  70906. */
  70907. uniqueId: number;
  70908. /**
  70909. * Gets or sets an object used to store user defined information for the node
  70910. */
  70911. metadata: any;
  70912. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70913. isHitTestVisible: boolean;
  70914. /** Gets or sets a boolean indicating if the control can block pointer events */
  70915. isPointerBlocker: boolean;
  70916. /** Gets or sets a boolean indicating if the control can be focusable */
  70917. isFocusInvisible: boolean;
  70918. /**
  70919. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70920. * 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
  70921. */
  70922. clipChildren: boolean;
  70923. /**
  70924. * Gets or sets a boolean indicating that control content must be clipped
  70925. * 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
  70926. */
  70927. clipContent: boolean;
  70928. /**
  70929. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70930. */
  70931. useBitmapCache: boolean;
  70932. private _cacheData;
  70933. private _shadowOffsetX;
  70934. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70935. get shadowOffsetX(): number;
  70936. set shadowOffsetX(value: number);
  70937. private _shadowOffsetY;
  70938. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70939. get shadowOffsetY(): number;
  70940. set shadowOffsetY(value: number);
  70941. private _shadowBlur;
  70942. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70943. get shadowBlur(): number;
  70944. set shadowBlur(value: number);
  70945. private _shadowColor;
  70946. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70947. get shadowColor(): string;
  70948. set shadowColor(value: string);
  70949. /** Gets or sets the cursor to use when the control is hovered */
  70950. hoverCursor: string;
  70951. /** @hidden */
  70952. protected _linkOffsetX: ValueAndUnit;
  70953. /** @hidden */
  70954. protected _linkOffsetY: ValueAndUnit;
  70955. /** Gets the control type name */
  70956. get typeName(): string;
  70957. /**
  70958. * Get the current class name of the control.
  70959. * @returns current class name
  70960. */
  70961. getClassName(): string;
  70962. /**
  70963. * An event triggered when pointer wheel is scrolled
  70964. */
  70965. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  70966. /**
  70967. * An event triggered when the pointer move over the control.
  70968. */
  70969. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70970. /**
  70971. * An event triggered when the pointer move out of the control.
  70972. */
  70973. onPointerOutObservable: BABYLON.Observable<Control>;
  70974. /**
  70975. * An event triggered when the pointer taps the control
  70976. */
  70977. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70978. /**
  70979. * An event triggered when pointer up
  70980. */
  70981. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70982. /**
  70983. * An event triggered when a control is clicked on
  70984. */
  70985. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70986. /**
  70987. * An event triggered when pointer enters the control
  70988. */
  70989. onPointerEnterObservable: BABYLON.Observable<Control>;
  70990. /**
  70991. * An event triggered when the control is marked as dirty
  70992. */
  70993. onDirtyObservable: BABYLON.Observable<Control>;
  70994. /**
  70995. * An event triggered before drawing the control
  70996. */
  70997. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70998. /**
  70999. * An event triggered after the control was drawn
  71000. */
  71001. onAfterDrawObservable: BABYLON.Observable<Control>;
  71002. /**
  71003. * Get the hosting AdvancedDynamicTexture
  71004. */
  71005. get host(): AdvancedDynamicTexture;
  71006. /** Gets or set information about font offsets (used to render and align text) */
  71007. get fontOffset(): {
  71008. ascent: number;
  71009. height: number;
  71010. descent: number;
  71011. };
  71012. set fontOffset(offset: {
  71013. ascent: number;
  71014. height: number;
  71015. descent: number;
  71016. });
  71017. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71018. get alpha(): number;
  71019. set alpha(value: number);
  71020. /**
  71021. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71022. */
  71023. get isHighlighted(): boolean;
  71024. set isHighlighted(value: boolean);
  71025. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71026. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71027. */
  71028. get scaleX(): number;
  71029. set scaleX(value: number);
  71030. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71031. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71032. */
  71033. get scaleY(): number;
  71034. set scaleY(value: number);
  71035. /** Gets or sets the rotation angle (0 by default)
  71036. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71037. */
  71038. get rotation(): number;
  71039. set rotation(value: number);
  71040. /** Gets or sets the transformation center on Y axis (0 by default)
  71041. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71042. */
  71043. get transformCenterY(): number;
  71044. set transformCenterY(value: number);
  71045. /** Gets or sets the transformation center on X axis (0 by default)
  71046. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71047. */
  71048. get transformCenterX(): number;
  71049. set transformCenterX(value: number);
  71050. /**
  71051. * Gets or sets the horizontal alignment
  71052. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71053. */
  71054. get horizontalAlignment(): number;
  71055. set horizontalAlignment(value: number);
  71056. /**
  71057. * Gets or sets the vertical alignment
  71058. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71059. */
  71060. get verticalAlignment(): number;
  71061. set verticalAlignment(value: number);
  71062. /**
  71063. * Gets or sets control width
  71064. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71065. */
  71066. get width(): string | number;
  71067. set width(value: string | number);
  71068. /**
  71069. * Gets or sets the control width in pixel
  71070. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71071. */
  71072. get widthInPixels(): number;
  71073. set widthInPixels(value: number);
  71074. /**
  71075. * Gets or sets control height
  71076. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71077. */
  71078. get height(): string | number;
  71079. set height(value: string | number);
  71080. /**
  71081. * Gets or sets control height in pixel
  71082. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71083. */
  71084. get heightInPixels(): number;
  71085. set heightInPixels(value: number);
  71086. /** Gets or set font family */
  71087. get fontFamily(): string;
  71088. set fontFamily(value: string);
  71089. /** Gets or sets font style */
  71090. get fontStyle(): string;
  71091. set fontStyle(value: string);
  71092. /** Gets or sets font weight */
  71093. get fontWeight(): string;
  71094. set fontWeight(value: string);
  71095. /**
  71096. * Gets or sets style
  71097. * @see http://doc.babylonjs.com/how_to/gui#styles
  71098. */
  71099. get style(): BABYLON.Nullable<Style>;
  71100. set style(value: BABYLON.Nullable<Style>);
  71101. /** @hidden */
  71102. get _isFontSizeInPercentage(): boolean;
  71103. /** Gets or sets font size in pixels */
  71104. get fontSizeInPixels(): number;
  71105. set fontSizeInPixels(value: number);
  71106. /** Gets or sets font size */
  71107. get fontSize(): string | number;
  71108. set fontSize(value: string | number);
  71109. /** Gets or sets foreground color */
  71110. get color(): string;
  71111. set color(value: string);
  71112. /** Gets or sets z index which is used to reorder controls on the z axis */
  71113. get zIndex(): number;
  71114. set zIndex(value: number);
  71115. /** Gets or sets a boolean indicating if the control can be rendered */
  71116. get notRenderable(): boolean;
  71117. set notRenderable(value: boolean);
  71118. /** Gets or sets a boolean indicating if the control is visible */
  71119. get isVisible(): boolean;
  71120. set isVisible(value: boolean);
  71121. /** Gets a boolean indicating that the control needs to update its rendering */
  71122. get isDirty(): boolean;
  71123. /**
  71124. * Gets the current linked mesh (or null if none)
  71125. */
  71126. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71127. /**
  71128. * Gets or sets a value indicating the padding to use on the left of the control
  71129. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71130. */
  71131. get paddingLeft(): string | number;
  71132. set paddingLeft(value: string | number);
  71133. /**
  71134. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71135. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71136. */
  71137. get paddingLeftInPixels(): number;
  71138. set paddingLeftInPixels(value: number);
  71139. /**
  71140. * Gets or sets a value indicating the padding to use on the right of the control
  71141. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71142. */
  71143. get paddingRight(): string | number;
  71144. set paddingRight(value: string | number);
  71145. /**
  71146. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71147. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71148. */
  71149. get paddingRightInPixels(): number;
  71150. set paddingRightInPixels(value: number);
  71151. /**
  71152. * Gets or sets a value indicating the padding to use on the top of the control
  71153. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71154. */
  71155. get paddingTop(): string | number;
  71156. set paddingTop(value: string | number);
  71157. /**
  71158. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71159. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71160. */
  71161. get paddingTopInPixels(): number;
  71162. set paddingTopInPixels(value: number);
  71163. /**
  71164. * Gets or sets a value indicating the padding to use on the bottom of the control
  71165. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71166. */
  71167. get paddingBottom(): string | number;
  71168. set paddingBottom(value: string | number);
  71169. /**
  71170. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  71171. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71172. */
  71173. get paddingBottomInPixels(): number;
  71174. set paddingBottomInPixels(value: number);
  71175. /**
  71176. * Gets or sets a value indicating the left coordinate of the control
  71177. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71178. */
  71179. get left(): string | number;
  71180. set left(value: string | number);
  71181. /**
  71182. * Gets or sets a value indicating the left coordinate in pixels of the control
  71183. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71184. */
  71185. get leftInPixels(): number;
  71186. set leftInPixels(value: number);
  71187. /**
  71188. * Gets or sets a value indicating the top coordinate of the control
  71189. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71190. */
  71191. get top(): string | number;
  71192. set top(value: string | number);
  71193. /**
  71194. * Gets or sets a value indicating the top coordinate in pixels of the control
  71195. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71196. */
  71197. get topInPixels(): number;
  71198. set topInPixels(value: number);
  71199. /**
  71200. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71201. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71202. */
  71203. get linkOffsetX(): string | number;
  71204. set linkOffsetX(value: string | number);
  71205. /**
  71206. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71207. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71208. */
  71209. get linkOffsetXInPixels(): number;
  71210. set linkOffsetXInPixels(value: number);
  71211. /**
  71212. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71213. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71214. */
  71215. get linkOffsetY(): string | number;
  71216. set linkOffsetY(value: string | number);
  71217. /**
  71218. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71219. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71220. */
  71221. get linkOffsetYInPixels(): number;
  71222. set linkOffsetYInPixels(value: number);
  71223. /** Gets the center coordinate on X axis */
  71224. get centerX(): number;
  71225. /** Gets the center coordinate on Y axis */
  71226. get centerY(): number;
  71227. /** Gets or sets if control is Enabled*/
  71228. get isEnabled(): boolean;
  71229. set isEnabled(value: boolean);
  71230. /** Gets or sets background color of control if it's disabled*/
  71231. get disabledColor(): string;
  71232. set disabledColor(value: string);
  71233. /** Gets or sets front color of control if it's disabled*/
  71234. get disabledColorItem(): string;
  71235. set disabledColorItem(value: string);
  71236. /**
  71237. * Creates a new control
  71238. * @param name defines the name of the control
  71239. */
  71240. constructor(
  71241. /** defines the name of the control */
  71242. name?: string | undefined);
  71243. /** @hidden */
  71244. protected _getTypeName(): string;
  71245. /**
  71246. * Gets the first ascendant in the hierarchy of the given type
  71247. * @param className defines the required type
  71248. * @returns the ascendant or null if not found
  71249. */
  71250. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71251. /** @hidden */
  71252. _resetFontCache(): void;
  71253. /**
  71254. * Determines if a container is an ascendant of the current control
  71255. * @param container defines the container to look for
  71256. * @returns true if the container is one of the ascendant of the control
  71257. */
  71258. isAscendant(container: Control): boolean;
  71259. /**
  71260. * Gets coordinates in local control space
  71261. * @param globalCoordinates defines the coordinates to transform
  71262. * @returns the new coordinates in local space
  71263. */
  71264. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71265. /**
  71266. * Gets coordinates in local control space
  71267. * @param globalCoordinates defines the coordinates to transform
  71268. * @param result defines the target vector2 where to store the result
  71269. * @returns the current control
  71270. */
  71271. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71272. /**
  71273. * Gets coordinates in parent local control space
  71274. * @param globalCoordinates defines the coordinates to transform
  71275. * @returns the new coordinates in parent local space
  71276. */
  71277. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71278. /**
  71279. * Move the current control to a vector3 position projected onto the screen.
  71280. * @param position defines the target position
  71281. * @param scene defines the hosting scene
  71282. */
  71283. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71284. /**
  71285. * Will store all controls that have this control as ascendant in a given array
  71286. * @param results defines the array where to store the descendants
  71287. * @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
  71288. * @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
  71289. */
  71290. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71291. /**
  71292. * Will return all controls that have this control as ascendant
  71293. * @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
  71294. * @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
  71295. * @return all child controls
  71296. */
  71297. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71298. /**
  71299. * Link current control with a target mesh
  71300. * @param mesh defines the mesh to link with
  71301. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71302. */
  71303. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71304. /** @hidden */
  71305. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71306. /** @hidden */
  71307. _offsetLeft(offset: number): void;
  71308. /** @hidden */
  71309. _offsetTop(offset: number): void;
  71310. /** @hidden */
  71311. _markMatrixAsDirty(): void;
  71312. /** @hidden */
  71313. _flagDescendantsAsMatrixDirty(): void;
  71314. /** @hidden */
  71315. _intersectsRect(rect: Measure): boolean;
  71316. /** @hidden */
  71317. protected invalidateRect(): void;
  71318. /** @hidden */
  71319. _markAsDirty(force?: boolean): void;
  71320. /** @hidden */
  71321. _markAllAsDirty(): void;
  71322. /** @hidden */
  71323. _link(host: AdvancedDynamicTexture): void;
  71324. /** @hidden */
  71325. protected _transform(context?: CanvasRenderingContext2D): void;
  71326. /** @hidden */
  71327. _renderHighlight(context: CanvasRenderingContext2D): void;
  71328. /** @hidden */
  71329. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71330. /** @hidden */
  71331. protected _applyStates(context: CanvasRenderingContext2D): void;
  71332. /** @hidden */
  71333. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71334. /** @hidden */
  71335. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71336. protected _evaluateClippingState(parentMeasure: Measure): void;
  71337. /** @hidden */
  71338. _measure(): void;
  71339. /** @hidden */
  71340. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71341. /** @hidden */
  71342. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71343. /** @hidden */
  71344. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71345. /** @hidden */
  71346. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71347. private static _ClipMeasure;
  71348. private _tmpMeasureA;
  71349. private _clip;
  71350. /** @hidden */
  71351. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71352. /** @hidden */
  71353. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71354. /**
  71355. * Tests if a given coordinates belong to the current control
  71356. * @param x defines x coordinate to test
  71357. * @param y defines y coordinate to test
  71358. * @returns true if the coordinates are inside the control
  71359. */
  71360. contains(x: number, y: number): boolean;
  71361. /** @hidden */
  71362. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71363. /** @hidden */
  71364. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71365. /** @hidden */
  71366. _onPointerEnter(target: Control): boolean;
  71367. /** @hidden */
  71368. _onPointerOut(target: Control, force?: boolean): void;
  71369. /** @hidden */
  71370. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71371. /** @hidden */
  71372. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71373. /** @hidden */
  71374. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71375. /** @hidden */
  71376. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  71377. /** @hidden */
  71378. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71379. private _prepareFont;
  71380. /** Releases associated resources */
  71381. dispose(): void;
  71382. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71383. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71384. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71385. private static _VERTICAL_ALIGNMENT_TOP;
  71386. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71387. private static _VERTICAL_ALIGNMENT_CENTER;
  71388. /** HORIZONTAL_ALIGNMENT_LEFT */
  71389. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71390. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71391. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71392. /** HORIZONTAL_ALIGNMENT_CENTER */
  71393. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71394. /** VERTICAL_ALIGNMENT_TOP */
  71395. static get VERTICAL_ALIGNMENT_TOP(): number;
  71396. /** VERTICAL_ALIGNMENT_BOTTOM */
  71397. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71398. /** VERTICAL_ALIGNMENT_CENTER */
  71399. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71400. private static _FontHeightSizes;
  71401. /** @hidden */
  71402. static _GetFontOffset(font: string): {
  71403. ascent: number;
  71404. height: number;
  71405. descent: number;
  71406. };
  71407. /**
  71408. * Creates a stack panel that can be used to render headers
  71409. * @param control defines the control to associate with the header
  71410. * @param text defines the text of the header
  71411. * @param size defines the size of the header
  71412. * @param options defines options used to configure the header
  71413. * @returns a new StackPanel
  71414. * @ignore
  71415. * @hidden
  71416. */
  71417. static AddHeader: (control: Control, text: string, size: string | number, options: {
  71418. isHorizontal: boolean;
  71419. controlFirst: boolean;
  71420. }) => any;
  71421. /** @hidden */
  71422. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  71423. }
  71424. }
  71425. declare module BABYLON.GUI {
  71426. /**
  71427. * Root class for 2D containers
  71428. * @see http://doc.babylonjs.com/how_to/gui#containers
  71429. */
  71430. export class Container extends Control {
  71431. name?: string | undefined;
  71432. /** @hidden */
  71433. _children: Control[];
  71434. /** @hidden */
  71435. protected _measureForChildren: Measure;
  71436. /** @hidden */
  71437. protected _background: string;
  71438. /** @hidden */
  71439. protected _adaptWidthToChildren: boolean;
  71440. /** @hidden */
  71441. protected _adaptHeightToChildren: boolean;
  71442. /**
  71443. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  71444. */
  71445. logLayoutCycleErrors: boolean;
  71446. /**
  71447. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  71448. */
  71449. maxLayoutCycle: number;
  71450. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  71451. get adaptHeightToChildren(): boolean;
  71452. set adaptHeightToChildren(value: boolean);
  71453. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  71454. get adaptWidthToChildren(): boolean;
  71455. set adaptWidthToChildren(value: boolean);
  71456. /** Gets or sets background color */
  71457. get background(): string;
  71458. set background(value: string);
  71459. /** Gets the list of children */
  71460. get children(): Control[];
  71461. /**
  71462. * Creates a new Container
  71463. * @param name defines the name of the container
  71464. */
  71465. constructor(name?: string | undefined);
  71466. protected _getTypeName(): string;
  71467. _flagDescendantsAsMatrixDirty(): void;
  71468. /**
  71469. * Gets a child using its name
  71470. * @param name defines the child name to look for
  71471. * @returns the child control if found
  71472. */
  71473. getChildByName(name: string): BABYLON.Nullable<Control>;
  71474. /**
  71475. * Gets a child using its type and its name
  71476. * @param name defines the child name to look for
  71477. * @param type defines the child type to look for
  71478. * @returns the child control if found
  71479. */
  71480. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  71481. /**
  71482. * Search for a specific control in children
  71483. * @param control defines the control to look for
  71484. * @returns true if the control is in child list
  71485. */
  71486. containsControl(control: Control): boolean;
  71487. /**
  71488. * Adds a new control to the current container
  71489. * @param control defines the control to add
  71490. * @returns the current container
  71491. */
  71492. addControl(control: BABYLON.Nullable<Control>): Container;
  71493. /**
  71494. * Removes all controls from the current container
  71495. * @returns the current container
  71496. */
  71497. clearControls(): Container;
  71498. /**
  71499. * Removes a control from the current container
  71500. * @param control defines the control to remove
  71501. * @returns the current container
  71502. */
  71503. removeControl(control: Control): Container;
  71504. /** @hidden */
  71505. _reOrderControl(control: Control): void;
  71506. /** @hidden */
  71507. _offsetLeft(offset: number): void;
  71508. /** @hidden */
  71509. _offsetTop(offset: number): void;
  71510. /** @hidden */
  71511. _markAllAsDirty(): void;
  71512. /** @hidden */
  71513. protected _localDraw(context: CanvasRenderingContext2D): void;
  71514. /** @hidden */
  71515. _link(host: AdvancedDynamicTexture): void;
  71516. /** @hidden */
  71517. protected _beforeLayout(): void;
  71518. /** @hidden */
  71519. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71520. /** @hidden */
  71521. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71522. protected _postMeasure(): void;
  71523. /** @hidden */
  71524. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  71525. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71526. /** @hidden */
  71527. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71528. /** @hidden */
  71529. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71530. /** Releases associated resources */
  71531. dispose(): void;
  71532. }
  71533. }
  71534. declare module BABYLON.GUI {
  71535. /** Class used to create rectangle container */
  71536. export class Rectangle extends Container {
  71537. name?: string | undefined;
  71538. private _thickness;
  71539. private _cornerRadius;
  71540. /** Gets or sets border thickness */
  71541. get thickness(): number;
  71542. set thickness(value: number);
  71543. /** Gets or sets the corner radius angle */
  71544. get cornerRadius(): number;
  71545. set cornerRadius(value: number);
  71546. /**
  71547. * Creates a new Rectangle
  71548. * @param name defines the control name
  71549. */
  71550. constructor(name?: string | undefined);
  71551. protected _getTypeName(): string;
  71552. protected _localDraw(context: CanvasRenderingContext2D): void;
  71553. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71554. private _drawRoundedRect;
  71555. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71556. }
  71557. }
  71558. declare module BABYLON.GUI {
  71559. /**
  71560. * Enum that determines the text-wrapping mode to use.
  71561. */
  71562. export enum TextWrapping {
  71563. /**
  71564. * Clip the text when it's larger than Control.width; this is the default mode.
  71565. */
  71566. Clip = 0,
  71567. /**
  71568. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  71569. */
  71570. WordWrap = 1,
  71571. /**
  71572. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  71573. */
  71574. Ellipsis = 2
  71575. }
  71576. /**
  71577. * Class used to create text block control
  71578. */
  71579. export class TextBlock extends Control {
  71580. /**
  71581. * Defines the name of the control
  71582. */
  71583. name?: string | undefined;
  71584. private _text;
  71585. private _textWrapping;
  71586. private _textHorizontalAlignment;
  71587. private _textVerticalAlignment;
  71588. private _lines;
  71589. private _resizeToFit;
  71590. private _lineSpacing;
  71591. private _outlineWidth;
  71592. private _outlineColor;
  71593. /**
  71594. * An event triggered after the text is changed
  71595. */
  71596. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  71597. /**
  71598. * An event triggered after the text was broken up into lines
  71599. */
  71600. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  71601. /**
  71602. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  71603. */
  71604. get lines(): any[];
  71605. /**
  71606. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71607. */
  71608. get resizeToFit(): boolean;
  71609. /**
  71610. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71611. */
  71612. set resizeToFit(value: boolean);
  71613. /**
  71614. * Gets or sets a boolean indicating if text must be wrapped
  71615. */
  71616. get textWrapping(): TextWrapping | boolean;
  71617. /**
  71618. * Gets or sets a boolean indicating if text must be wrapped
  71619. */
  71620. set textWrapping(value: TextWrapping | boolean);
  71621. /**
  71622. * Gets or sets text to display
  71623. */
  71624. get text(): string;
  71625. /**
  71626. * Gets or sets text to display
  71627. */
  71628. set text(value: string);
  71629. /**
  71630. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71631. */
  71632. get textHorizontalAlignment(): number;
  71633. /**
  71634. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71635. */
  71636. set textHorizontalAlignment(value: number);
  71637. /**
  71638. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71639. */
  71640. get textVerticalAlignment(): number;
  71641. /**
  71642. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71643. */
  71644. set textVerticalAlignment(value: number);
  71645. /**
  71646. * Gets or sets line spacing value
  71647. */
  71648. set lineSpacing(value: string | number);
  71649. /**
  71650. * Gets or sets line spacing value
  71651. */
  71652. get lineSpacing(): string | number;
  71653. /**
  71654. * Gets or sets outlineWidth of the text to display
  71655. */
  71656. get outlineWidth(): number;
  71657. /**
  71658. * Gets or sets outlineWidth of the text to display
  71659. */
  71660. set outlineWidth(value: number);
  71661. /**
  71662. * Gets or sets outlineColor of the text to display
  71663. */
  71664. get outlineColor(): string;
  71665. /**
  71666. * Gets or sets outlineColor of the text to display
  71667. */
  71668. set outlineColor(value: string);
  71669. /**
  71670. * Creates a new TextBlock object
  71671. * @param name defines the name of the control
  71672. * @param text defines the text to display (emptry string by default)
  71673. */
  71674. constructor(
  71675. /**
  71676. * Defines the name of the control
  71677. */
  71678. name?: string | undefined, text?: string);
  71679. protected _getTypeName(): string;
  71680. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71681. private _drawText;
  71682. /** @hidden */
  71683. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71684. protected _applyStates(context: CanvasRenderingContext2D): void;
  71685. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  71686. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  71687. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  71688. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  71689. protected _renderLines(context: CanvasRenderingContext2D): void;
  71690. /**
  71691. * Given a width constraint applied on the text block, find the expected height
  71692. * @returns expected height
  71693. */
  71694. computeExpectedHeight(): number;
  71695. dispose(): void;
  71696. }
  71697. }
  71698. declare module BABYLON.GUI {
  71699. /**
  71700. * Class used to create 2D images
  71701. */
  71702. export class Image extends Control {
  71703. name?: string | undefined;
  71704. private _workingCanvas;
  71705. private _domImage;
  71706. private _imageWidth;
  71707. private _imageHeight;
  71708. private _loaded;
  71709. private _stretch;
  71710. private _source;
  71711. private _autoScale;
  71712. private _sourceLeft;
  71713. private _sourceTop;
  71714. private _sourceWidth;
  71715. private _sourceHeight;
  71716. private _svgAttributesComputationCompleted;
  71717. private _isSVG;
  71718. private _cellWidth;
  71719. private _cellHeight;
  71720. private _cellId;
  71721. private _populateNinePatchSlicesFromImage;
  71722. private _sliceLeft;
  71723. private _sliceRight;
  71724. private _sliceTop;
  71725. private _sliceBottom;
  71726. private _detectPointerOnOpaqueOnly;
  71727. /**
  71728. * BABYLON.Observable notified when the content is loaded
  71729. */
  71730. onImageLoadedObservable: BABYLON.Observable<Image>;
  71731. /**
  71732. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  71733. */
  71734. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  71735. /**
  71736. * Gets a boolean indicating that the content is loaded
  71737. */
  71738. get isLoaded(): boolean;
  71739. /**
  71740. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  71741. */
  71742. get populateNinePatchSlicesFromImage(): boolean;
  71743. set populateNinePatchSlicesFromImage(value: boolean);
  71744. /**
  71745. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  71746. * Beware using this as this will comsume more memory as the image has to be stored twice
  71747. */
  71748. get detectPointerOnOpaqueOnly(): boolean;
  71749. set detectPointerOnOpaqueOnly(value: boolean);
  71750. /**
  71751. * Gets or sets the left value for slicing (9-patch)
  71752. */
  71753. get sliceLeft(): number;
  71754. set sliceLeft(value: number);
  71755. /**
  71756. * Gets or sets the right value for slicing (9-patch)
  71757. */
  71758. get sliceRight(): number;
  71759. set sliceRight(value: number);
  71760. /**
  71761. * Gets or sets the top value for slicing (9-patch)
  71762. */
  71763. get sliceTop(): number;
  71764. set sliceTop(value: number);
  71765. /**
  71766. * Gets or sets the bottom value for slicing (9-patch)
  71767. */
  71768. get sliceBottom(): number;
  71769. set sliceBottom(value: number);
  71770. /**
  71771. * Gets or sets the left coordinate in the source image
  71772. */
  71773. get sourceLeft(): number;
  71774. set sourceLeft(value: number);
  71775. /**
  71776. * Gets or sets the top coordinate in the source image
  71777. */
  71778. get sourceTop(): number;
  71779. set sourceTop(value: number);
  71780. /**
  71781. * Gets or sets the width to capture in the source image
  71782. */
  71783. get sourceWidth(): number;
  71784. set sourceWidth(value: number);
  71785. /**
  71786. * Gets or sets the height to capture in the source image
  71787. */
  71788. get sourceHeight(): number;
  71789. set sourceHeight(value: number);
  71790. /** Indicates if the format of the image is SVG */
  71791. get isSVG(): boolean;
  71792. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  71793. get svgAttributesComputationCompleted(): boolean;
  71794. /**
  71795. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71796. * @see http://doc.babylonjs.com/how_to/gui#image
  71797. */
  71798. get autoScale(): boolean;
  71799. set autoScale(value: boolean);
  71800. /** Gets or sets the streching mode used by the image */
  71801. get stretch(): number;
  71802. set stretch(value: number);
  71803. /** @hidden */
  71804. _rotate90(n: number, preserveProperties?: boolean): Image;
  71805. private _handleRotationForSVGImage;
  71806. private _rotate90SourceProperties;
  71807. /**
  71808. * Gets or sets the internal DOM image used to render the control
  71809. */
  71810. set domImage(value: HTMLImageElement);
  71811. get domImage(): HTMLImageElement;
  71812. private _onImageLoaded;
  71813. private _extractNinePatchSliceDataFromImage;
  71814. /**
  71815. * Gets or sets image source url
  71816. */
  71817. set source(value: BABYLON.Nullable<string>);
  71818. /**
  71819. * Checks for svg document with icon id present
  71820. */
  71821. private _svgCheck;
  71822. /**
  71823. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71824. * given external svg file and icon id
  71825. */
  71826. private _getSVGAttribs;
  71827. /**
  71828. * Gets or sets the cell width to use when animation sheet is enabled
  71829. * @see http://doc.babylonjs.com/how_to/gui#image
  71830. */
  71831. get cellWidth(): number;
  71832. set cellWidth(value: number);
  71833. /**
  71834. * Gets or sets the cell height to use when animation sheet is enabled
  71835. * @see http://doc.babylonjs.com/how_to/gui#image
  71836. */
  71837. get cellHeight(): number;
  71838. set cellHeight(value: number);
  71839. /**
  71840. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71841. * @see http://doc.babylonjs.com/how_to/gui#image
  71842. */
  71843. get cellId(): number;
  71844. set cellId(value: number);
  71845. /**
  71846. * Creates a new Image
  71847. * @param name defines the control name
  71848. * @param url defines the image url
  71849. */
  71850. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71851. /**
  71852. * Tests if a given coordinates belong to the current control
  71853. * @param x defines x coordinate to test
  71854. * @param y defines y coordinate to test
  71855. * @returns true if the coordinates are inside the control
  71856. */
  71857. contains(x: number, y: number): boolean;
  71858. protected _getTypeName(): string;
  71859. /** Force the control to synchronize with its content */
  71860. synchronizeSizeWithContent(): void;
  71861. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71862. private _prepareWorkingCanvasForOpaqueDetection;
  71863. private _drawImage;
  71864. _draw(context: CanvasRenderingContext2D): void;
  71865. private _renderCornerPatch;
  71866. private _renderNinePatch;
  71867. dispose(): void;
  71868. /** STRETCH_NONE */
  71869. static readonly STRETCH_NONE: number;
  71870. /** STRETCH_FILL */
  71871. static readonly STRETCH_FILL: number;
  71872. /** STRETCH_UNIFORM */
  71873. static readonly STRETCH_UNIFORM: number;
  71874. /** STRETCH_EXTEND */
  71875. static readonly STRETCH_EXTEND: number;
  71876. /** NINE_PATCH */
  71877. static readonly STRETCH_NINE_PATCH: number;
  71878. }
  71879. }
  71880. declare module BABYLON.GUI {
  71881. /**
  71882. * Class used to create 2D buttons
  71883. */
  71884. export class Button extends Rectangle {
  71885. name?: string | undefined;
  71886. /**
  71887. * Function called to generate a pointer enter animation
  71888. */
  71889. pointerEnterAnimation: () => void;
  71890. /**
  71891. * Function called to generate a pointer out animation
  71892. */
  71893. pointerOutAnimation: () => void;
  71894. /**
  71895. * Function called to generate a pointer down animation
  71896. */
  71897. pointerDownAnimation: () => void;
  71898. /**
  71899. * Function called to generate a pointer up animation
  71900. */
  71901. pointerUpAnimation: () => void;
  71902. /**
  71903. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71904. */
  71905. delegatePickingToChildren: boolean;
  71906. private _image;
  71907. /**
  71908. * Returns the image part of the button (if any)
  71909. */
  71910. get image(): BABYLON.Nullable<Image>;
  71911. private _textBlock;
  71912. /**
  71913. * Returns the image part of the button (if any)
  71914. */
  71915. get textBlock(): BABYLON.Nullable<TextBlock>;
  71916. /**
  71917. * Creates a new Button
  71918. * @param name defines the name of the button
  71919. */
  71920. constructor(name?: string | undefined);
  71921. protected _getTypeName(): string;
  71922. /** @hidden */
  71923. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71924. /** @hidden */
  71925. _onPointerEnter(target: Control): boolean;
  71926. /** @hidden */
  71927. _onPointerOut(target: Control, force?: boolean): void;
  71928. /** @hidden */
  71929. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71930. /** @hidden */
  71931. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71932. /**
  71933. * Creates a new button made with an image and a text
  71934. * @param name defines the name of the button
  71935. * @param text defines the text of the button
  71936. * @param imageUrl defines the url of the image
  71937. * @returns a new Button
  71938. */
  71939. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71940. /**
  71941. * Creates a new button made with an image
  71942. * @param name defines the name of the button
  71943. * @param imageUrl defines the url of the image
  71944. * @returns a new Button
  71945. */
  71946. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71947. /**
  71948. * Creates a new button made with a text
  71949. * @param name defines the name of the button
  71950. * @param text defines the text of the button
  71951. * @returns a new Button
  71952. */
  71953. static CreateSimpleButton(name: string, text: string): Button;
  71954. /**
  71955. * Creates a new button made with an image and a centered text
  71956. * @param name defines the name of the button
  71957. * @param text defines the text of the button
  71958. * @param imageUrl defines the url of the image
  71959. * @returns a new Button
  71960. */
  71961. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71962. }
  71963. }
  71964. declare module BABYLON.GUI {
  71965. /**
  71966. * Class used to create a 2D stack panel container
  71967. */
  71968. export class StackPanel extends Container {
  71969. name?: string | undefined;
  71970. private _isVertical;
  71971. private _manualWidth;
  71972. private _manualHeight;
  71973. private _doNotTrackManualChanges;
  71974. /**
  71975. * Gets or sets a boolean indicating that layou warnings should be ignored
  71976. */
  71977. ignoreLayoutWarnings: boolean;
  71978. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71979. get isVertical(): boolean;
  71980. set isVertical(value: boolean);
  71981. /**
  71982. * Gets or sets panel width.
  71983. * This value should not be set when in horizontal mode as it will be computed automatically
  71984. */
  71985. set width(value: string | number);
  71986. get width(): string | number;
  71987. /**
  71988. * Gets or sets panel height.
  71989. * This value should not be set when in vertical mode as it will be computed automatically
  71990. */
  71991. set height(value: string | number);
  71992. get height(): string | number;
  71993. /**
  71994. * Creates a new StackPanel
  71995. * @param name defines control name
  71996. */
  71997. constructor(name?: string | undefined);
  71998. protected _getTypeName(): string;
  71999. /** @hidden */
  72000. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72001. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72002. protected _postMeasure(): void;
  72003. }
  72004. }
  72005. declare module BABYLON.GUI {
  72006. /**
  72007. * Class used to represent a 2D checkbox
  72008. */
  72009. export class Checkbox extends Control {
  72010. name?: string | undefined;
  72011. private _isChecked;
  72012. private _background;
  72013. private _checkSizeRatio;
  72014. private _thickness;
  72015. /** Gets or sets border thickness */
  72016. get thickness(): number;
  72017. set thickness(value: number);
  72018. /**
  72019. * BABYLON.Observable raised when isChecked property changes
  72020. */
  72021. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72022. /** Gets or sets a value indicating the ratio between overall size and check size */
  72023. get checkSizeRatio(): number;
  72024. set checkSizeRatio(value: number);
  72025. /** Gets or sets background color */
  72026. get background(): string;
  72027. set background(value: string);
  72028. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72029. get isChecked(): boolean;
  72030. set isChecked(value: boolean);
  72031. /**
  72032. * Creates a new CheckBox
  72033. * @param name defines the control name
  72034. */
  72035. constructor(name?: string | undefined);
  72036. protected _getTypeName(): string;
  72037. /** @hidden */
  72038. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72039. /** @hidden */
  72040. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72041. /**
  72042. * Utility function to easily create a checkbox with a header
  72043. * @param title defines the label to use for the header
  72044. * @param onValueChanged defines the callback to call when value changes
  72045. * @returns a StackPanel containing the checkbox and a textBlock
  72046. */
  72047. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72048. }
  72049. }
  72050. declare module BABYLON.GUI {
  72051. /**
  72052. * Class used to store key control properties
  72053. */
  72054. export class KeyPropertySet {
  72055. /** Width */
  72056. width?: string;
  72057. /** Height */
  72058. height?: string;
  72059. /** Left padding */
  72060. paddingLeft?: string;
  72061. /** Right padding */
  72062. paddingRight?: string;
  72063. /** Top padding */
  72064. paddingTop?: string;
  72065. /** Bottom padding */
  72066. paddingBottom?: string;
  72067. /** Foreground color */
  72068. color?: string;
  72069. /** Background color */
  72070. background?: string;
  72071. }
  72072. /**
  72073. * Class used to create virtual keyboard
  72074. */
  72075. export class VirtualKeyboard extends StackPanel {
  72076. /** BABYLON.Observable raised when a key is pressed */
  72077. onKeyPressObservable: BABYLON.Observable<string>;
  72078. /** Gets or sets default key button width */
  72079. defaultButtonWidth: string;
  72080. /** Gets or sets default key button height */
  72081. defaultButtonHeight: string;
  72082. /** Gets or sets default key button left padding */
  72083. defaultButtonPaddingLeft: string;
  72084. /** Gets or sets default key button right padding */
  72085. defaultButtonPaddingRight: string;
  72086. /** Gets or sets default key button top padding */
  72087. defaultButtonPaddingTop: string;
  72088. /** Gets or sets default key button bottom padding */
  72089. defaultButtonPaddingBottom: string;
  72090. /** Gets or sets default key button foreground color */
  72091. defaultButtonColor: string;
  72092. /** Gets or sets default key button background color */
  72093. defaultButtonBackground: string;
  72094. /** Gets or sets shift button foreground color */
  72095. shiftButtonColor: string;
  72096. /** Gets or sets shift button thickness*/
  72097. selectedShiftThickness: number;
  72098. /** Gets shift key state */
  72099. shiftState: number;
  72100. protected _getTypeName(): string;
  72101. private _createKey;
  72102. /**
  72103. * Adds a new row of keys
  72104. * @param keys defines the list of keys to add
  72105. * @param propertySets defines the associated property sets
  72106. */
  72107. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72108. /**
  72109. * Set the shift key to a specific state
  72110. * @param shiftState defines the new shift state
  72111. */
  72112. applyShiftState(shiftState: number): void;
  72113. private _currentlyConnectedInputText;
  72114. private _connectedInputTexts;
  72115. private _onKeyPressObserver;
  72116. /** Gets the input text control currently attached to the keyboard */
  72117. get connectedInputText(): BABYLON.Nullable<InputText>;
  72118. /**
  72119. * Connects the keyboard with an input text control
  72120. *
  72121. * @param input defines the target control
  72122. */
  72123. connect(input: InputText): void;
  72124. /**
  72125. * Disconnects the keyboard from connected InputText controls
  72126. *
  72127. * @param input optionally defines a target control, otherwise all are disconnected
  72128. */
  72129. disconnect(input?: InputText): void;
  72130. private _removeConnectedInputObservables;
  72131. /**
  72132. * Release all resources
  72133. */
  72134. dispose(): void;
  72135. /**
  72136. * Creates a new keyboard using a default layout
  72137. *
  72138. * @param name defines control name
  72139. * @returns a new VirtualKeyboard
  72140. */
  72141. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72142. }
  72143. }
  72144. declare module BABYLON.GUI {
  72145. /**
  72146. * Class used to create input text control
  72147. */
  72148. export class InputText extends Control implements IFocusableControl {
  72149. name?: string | undefined;
  72150. private _text;
  72151. private _placeholderText;
  72152. private _background;
  72153. private _focusedBackground;
  72154. private _focusedColor;
  72155. private _placeholderColor;
  72156. private _thickness;
  72157. private _margin;
  72158. private _autoStretchWidth;
  72159. private _maxWidth;
  72160. private _isFocused;
  72161. private _blinkTimeout;
  72162. private _blinkIsEven;
  72163. private _cursorOffset;
  72164. private _scrollLeft;
  72165. private _textWidth;
  72166. private _clickedCoordinate;
  72167. private _deadKey;
  72168. private _addKey;
  72169. private _currentKey;
  72170. private _isTextHighlightOn;
  72171. private _textHighlightColor;
  72172. private _highligherOpacity;
  72173. private _highlightedText;
  72174. private _startHighlightIndex;
  72175. private _endHighlightIndex;
  72176. private _cursorIndex;
  72177. private _onFocusSelectAll;
  72178. private _isPointerDown;
  72179. private _onClipboardObserver;
  72180. private _onPointerDblTapObserver;
  72181. /** @hidden */
  72182. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  72183. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  72184. promptMessage: string;
  72185. /** Force disable prompt on mobile device */
  72186. disableMobilePrompt: boolean;
  72187. /** BABYLON.Observable raised when the text changes */
  72188. onTextChangedObservable: BABYLON.Observable<InputText>;
  72189. /** BABYLON.Observable raised just before an entered character is to be added */
  72190. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72191. /** BABYLON.Observable raised when the control gets the focus */
  72192. onFocusObservable: BABYLON.Observable<InputText>;
  72193. /** BABYLON.Observable raised when the control loses the focus */
  72194. onBlurObservable: BABYLON.Observable<InputText>;
  72195. /**Observable raised when the text is highlighted */
  72196. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72197. /**Observable raised when copy event is triggered */
  72198. onTextCopyObservable: BABYLON.Observable<InputText>;
  72199. /** BABYLON.Observable raised when cut event is triggered */
  72200. onTextCutObservable: BABYLON.Observable<InputText>;
  72201. /** BABYLON.Observable raised when paste event is triggered */
  72202. onTextPasteObservable: BABYLON.Observable<InputText>;
  72203. /** BABYLON.Observable raised when a key event was processed */
  72204. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72205. /** Gets or sets the maximum width allowed by the control */
  72206. get maxWidth(): string | number;
  72207. /** Gets the maximum width allowed by the control in pixels */
  72208. get maxWidthInPixels(): number;
  72209. set maxWidth(value: string | number);
  72210. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72211. get highligherOpacity(): number;
  72212. set highligherOpacity(value: number);
  72213. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72214. get onFocusSelectAll(): boolean;
  72215. set onFocusSelectAll(value: boolean);
  72216. /** Gets or sets the text hightlight color */
  72217. get textHighlightColor(): string;
  72218. set textHighlightColor(value: string);
  72219. /** Gets or sets control margin */
  72220. get margin(): string;
  72221. /** Gets control margin in pixels */
  72222. get marginInPixels(): number;
  72223. set margin(value: string);
  72224. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72225. get autoStretchWidth(): boolean;
  72226. set autoStretchWidth(value: boolean);
  72227. /** Gets or sets border thickness */
  72228. get thickness(): number;
  72229. set thickness(value: number);
  72230. /** Gets or sets the background color when focused */
  72231. get focusedBackground(): string;
  72232. set focusedBackground(value: string);
  72233. /** Gets or sets the background color when focused */
  72234. get focusedColor(): string;
  72235. set focusedColor(value: string);
  72236. /** Gets or sets the background color */
  72237. get background(): string;
  72238. set background(value: string);
  72239. /** Gets or sets the placeholder color */
  72240. get placeholderColor(): string;
  72241. set placeholderColor(value: string);
  72242. /** Gets or sets the text displayed when the control is empty */
  72243. get placeholderText(): string;
  72244. set placeholderText(value: string);
  72245. /** Gets or sets the dead key flag */
  72246. get deadKey(): boolean;
  72247. set deadKey(flag: boolean);
  72248. /** Gets or sets the highlight text */
  72249. get highlightedText(): string;
  72250. set highlightedText(text: string);
  72251. /** Gets or sets if the current key should be added */
  72252. get addKey(): boolean;
  72253. set addKey(flag: boolean);
  72254. /** Gets or sets the value of the current key being entered */
  72255. get currentKey(): string;
  72256. set currentKey(key: string);
  72257. /** Gets or sets the text displayed in the control */
  72258. get text(): string;
  72259. set text(value: string);
  72260. /** Gets or sets control width */
  72261. get width(): string | number;
  72262. set width(value: string | number);
  72263. /**
  72264. * Creates a new InputText
  72265. * @param name defines the control name
  72266. * @param text defines the text of the control
  72267. */
  72268. constructor(name?: string | undefined, text?: string);
  72269. /** @hidden */
  72270. onBlur(): void;
  72271. /** @hidden */
  72272. onFocus(): void;
  72273. protected _getTypeName(): string;
  72274. /**
  72275. * Function called to get the list of controls that should not steal the focus from this control
  72276. * @returns an array of controls
  72277. */
  72278. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72279. /** @hidden */
  72280. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72281. /** @hidden */
  72282. private _updateValueFromCursorIndex;
  72283. /** @hidden */
  72284. private _processDblClick;
  72285. /** @hidden */
  72286. private _selectAllText;
  72287. /**
  72288. * Handles the keyboard event
  72289. * @param evt Defines the KeyboardEvent
  72290. */
  72291. processKeyboard(evt: KeyboardEvent): void;
  72292. /** @hidden */
  72293. private _onCopyText;
  72294. /** @hidden */
  72295. private _onCutText;
  72296. /** @hidden */
  72297. private _onPasteText;
  72298. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72299. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72300. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72301. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72302. protected _beforeRenderText(text: string): string;
  72303. dispose(): void;
  72304. }
  72305. }
  72306. declare module BABYLON.GUI {
  72307. /**
  72308. * Class used to create a 2D grid container
  72309. */
  72310. export class Grid extends Container {
  72311. name?: string | undefined;
  72312. private _rowDefinitions;
  72313. private _columnDefinitions;
  72314. private _cells;
  72315. private _childControls;
  72316. /**
  72317. * Gets the number of columns
  72318. */
  72319. get columnCount(): number;
  72320. /**
  72321. * Gets the number of rows
  72322. */
  72323. get rowCount(): number;
  72324. /** Gets the list of children */
  72325. get children(): Control[];
  72326. /** Gets the list of cells (e.g. the containers) */
  72327. get cells(): {
  72328. [key: string]: Container;
  72329. };
  72330. /**
  72331. * Gets the definition of a specific row
  72332. * @param index defines the index of the row
  72333. * @returns the row definition
  72334. */
  72335. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72336. /**
  72337. * Gets the definition of a specific column
  72338. * @param index defines the index of the column
  72339. * @returns the column definition
  72340. */
  72341. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72342. /**
  72343. * Adds a new row to the grid
  72344. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72345. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72346. * @returns the current grid
  72347. */
  72348. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72349. /**
  72350. * Adds a new column to the grid
  72351. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72352. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72353. * @returns the current grid
  72354. */
  72355. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72356. /**
  72357. * Update a row definition
  72358. * @param index defines the index of the row to update
  72359. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72360. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72361. * @returns the current grid
  72362. */
  72363. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72364. /**
  72365. * Update a column definition
  72366. * @param index defines the index of the column to update
  72367. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72368. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72369. * @returns the current grid
  72370. */
  72371. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72372. /**
  72373. * Gets the list of children stored in a specific cell
  72374. * @param row defines the row to check
  72375. * @param column defines the column to check
  72376. * @returns the list of controls
  72377. */
  72378. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72379. /**
  72380. * Gets a string representing the child cell info (row x column)
  72381. * @param child defines the control to get info from
  72382. * @returns a string containing the child cell info (row x column)
  72383. */
  72384. getChildCellInfo(child: Control): string;
  72385. private _removeCell;
  72386. private _offsetCell;
  72387. /**
  72388. * Remove a column definition at specified index
  72389. * @param index defines the index of the column to remove
  72390. * @returns the current grid
  72391. */
  72392. removeColumnDefinition(index: number): Grid;
  72393. /**
  72394. * Remove a row definition at specified index
  72395. * @param index defines the index of the row to remove
  72396. * @returns the current grid
  72397. */
  72398. removeRowDefinition(index: number): Grid;
  72399. /**
  72400. * Adds a new control to the current grid
  72401. * @param control defines the control to add
  72402. * @param row defines the row where to add the control (0 by default)
  72403. * @param column defines the column where to add the control (0 by default)
  72404. * @returns the current grid
  72405. */
  72406. addControl(control: Control, row?: number, column?: number): Grid;
  72407. /**
  72408. * Removes a control from the current container
  72409. * @param control defines the control to remove
  72410. * @returns the current container
  72411. */
  72412. removeControl(control: Control): Container;
  72413. /**
  72414. * Creates a new Grid
  72415. * @param name defines control name
  72416. */
  72417. constructor(name?: string | undefined);
  72418. protected _getTypeName(): string;
  72419. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  72420. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72421. _flagDescendantsAsMatrixDirty(): void;
  72422. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72423. /** Releases associated resources */
  72424. dispose(): void;
  72425. }
  72426. }
  72427. declare module BABYLON.GUI {
  72428. /** Class used to create color pickers */
  72429. export class ColorPicker extends Control {
  72430. name?: string | undefined;
  72431. private static _Epsilon;
  72432. private _colorWheelCanvas;
  72433. private _value;
  72434. private _tmpColor;
  72435. private _pointerStartedOnSquare;
  72436. private _pointerStartedOnWheel;
  72437. private _squareLeft;
  72438. private _squareTop;
  72439. private _squareSize;
  72440. private _h;
  72441. private _s;
  72442. private _v;
  72443. private _lastPointerDownID;
  72444. /**
  72445. * BABYLON.Observable raised when the value changes
  72446. */
  72447. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  72448. /** Gets or sets the color of the color picker */
  72449. get value(): BABYLON.Color3;
  72450. set value(value: BABYLON.Color3);
  72451. /**
  72452. * Gets or sets control width
  72453. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72454. */
  72455. get width(): string | number;
  72456. set width(value: string | number);
  72457. /**
  72458. * Gets or sets control height
  72459. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72460. */
  72461. get height(): string | number;
  72462. /** Gets or sets control height */
  72463. set height(value: string | number);
  72464. /** Gets or sets control size */
  72465. get size(): string | number;
  72466. set size(value: string | number);
  72467. /**
  72468. * Creates a new ColorPicker
  72469. * @param name defines the control name
  72470. */
  72471. constructor(name?: string | undefined);
  72472. protected _getTypeName(): string;
  72473. /** @hidden */
  72474. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72475. private _updateSquareProps;
  72476. private _drawGradientSquare;
  72477. private _drawCircle;
  72478. private _createColorWheelCanvas;
  72479. /** @hidden */
  72480. _draw(context: CanvasRenderingContext2D): void;
  72481. private _pointerIsDown;
  72482. private _updateValueFromPointer;
  72483. private _isPointOnSquare;
  72484. private _isPointOnWheel;
  72485. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72486. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72487. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72488. /**
  72489. * This function expands the color picker by creating a color picker dialog with manual
  72490. * color value input and the ability to save colors into an array to be used later in
  72491. * subsequent launches of the dialogue.
  72492. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  72493. * @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.
  72494. * @returns picked color as a hex string and the saved colors array as hex strings.
  72495. */
  72496. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  72497. pickerWidth?: string;
  72498. pickerHeight?: string;
  72499. headerHeight?: string;
  72500. lastColor?: string;
  72501. swatchLimit?: number;
  72502. numSwatchesPerLine?: number;
  72503. savedColors?: Array<string>;
  72504. }): Promise<{
  72505. savedColors?: string[];
  72506. pickedColor: string;
  72507. }>;
  72508. }
  72509. }
  72510. declare module BABYLON.GUI {
  72511. /** Class used to create 2D ellipse containers */
  72512. export class Ellipse extends Container {
  72513. name?: string | undefined;
  72514. private _thickness;
  72515. /** Gets or sets border thickness */
  72516. get thickness(): number;
  72517. set thickness(value: number);
  72518. /**
  72519. * Creates a new Ellipse
  72520. * @param name defines the control name
  72521. */
  72522. constructor(name?: string | undefined);
  72523. protected _getTypeName(): string;
  72524. protected _localDraw(context: CanvasRenderingContext2D): void;
  72525. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72526. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72527. }
  72528. }
  72529. declare module BABYLON.GUI {
  72530. /**
  72531. * Class used to create a password control
  72532. */
  72533. export class InputPassword extends InputText {
  72534. protected _beforeRenderText(text: string): string;
  72535. }
  72536. }
  72537. declare module BABYLON.GUI {
  72538. /** Class used to render 2D lines */
  72539. export class Line extends Control {
  72540. name?: string | undefined;
  72541. private _lineWidth;
  72542. private _x1;
  72543. private _y1;
  72544. private _x2;
  72545. private _y2;
  72546. private _dash;
  72547. private _connectedControl;
  72548. private _connectedControlDirtyObserver;
  72549. /** Gets or sets the dash pattern */
  72550. get dash(): Array<number>;
  72551. set dash(value: Array<number>);
  72552. /** Gets or sets the control connected with the line end */
  72553. get connectedControl(): Control;
  72554. set connectedControl(value: Control);
  72555. /** Gets or sets start coordinates on X axis */
  72556. get x1(): string | number;
  72557. set x1(value: string | number);
  72558. /** Gets or sets start coordinates on Y axis */
  72559. get y1(): string | number;
  72560. set y1(value: string | number);
  72561. /** Gets or sets end coordinates on X axis */
  72562. get x2(): string | number;
  72563. set x2(value: string | number);
  72564. /** Gets or sets end coordinates on Y axis */
  72565. get y2(): string | number;
  72566. set y2(value: string | number);
  72567. /** Gets or sets line width */
  72568. get lineWidth(): number;
  72569. set lineWidth(value: number);
  72570. /** Gets or sets horizontal alignment */
  72571. set horizontalAlignment(value: number);
  72572. /** Gets or sets vertical alignment */
  72573. set verticalAlignment(value: number);
  72574. private get _effectiveX2();
  72575. private get _effectiveY2();
  72576. /**
  72577. * Creates a new Line
  72578. * @param name defines the control name
  72579. */
  72580. constructor(name?: string | undefined);
  72581. protected _getTypeName(): string;
  72582. _draw(context: CanvasRenderingContext2D): void;
  72583. _measure(): void;
  72584. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72585. /**
  72586. * Move one end of the line given 3D cartesian coordinates.
  72587. * @param position Targeted world position
  72588. * @param scene BABYLON.Scene
  72589. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72590. */
  72591. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  72592. /**
  72593. * Move one end of the line to a position in screen absolute space.
  72594. * @param projectedPosition Position in screen absolute space (X, Y)
  72595. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72596. */
  72597. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  72598. }
  72599. }
  72600. declare module BABYLON.GUI {
  72601. /**
  72602. * Class used to store a point for a MultiLine object.
  72603. * The point can be pure 2D coordinates, a mesh or a control
  72604. */
  72605. export class MultiLinePoint {
  72606. private _multiLine;
  72607. private _x;
  72608. private _y;
  72609. private _control;
  72610. private _mesh;
  72611. private _controlObserver;
  72612. private _meshObserver;
  72613. /** @hidden */
  72614. _point: BABYLON.Vector2;
  72615. /**
  72616. * Creates a new MultiLinePoint
  72617. * @param multiLine defines the source MultiLine object
  72618. */
  72619. constructor(multiLine: MultiLine);
  72620. /** Gets or sets x coordinate */
  72621. get x(): string | number;
  72622. set x(value: string | number);
  72623. /** Gets or sets y coordinate */
  72624. get y(): string | number;
  72625. set y(value: string | number);
  72626. /** Gets or sets the control associated with this point */
  72627. get control(): BABYLON.Nullable<Control>;
  72628. set control(value: BABYLON.Nullable<Control>);
  72629. /** Gets or sets the mesh associated with this point */
  72630. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72631. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  72632. /** Resets links */
  72633. resetLinks(): void;
  72634. /**
  72635. * Gets a translation vector
  72636. * @returns the translation vector
  72637. */
  72638. translate(): BABYLON.Vector2;
  72639. private _translatePoint;
  72640. /** Release associated resources */
  72641. dispose(): void;
  72642. }
  72643. }
  72644. declare module BABYLON.GUI {
  72645. /**
  72646. * Class used to create multi line control
  72647. */
  72648. export class MultiLine extends Control {
  72649. name?: string | undefined;
  72650. private _lineWidth;
  72651. private _dash;
  72652. private _points;
  72653. private _minX;
  72654. private _minY;
  72655. private _maxX;
  72656. private _maxY;
  72657. /**
  72658. * Creates a new MultiLine
  72659. * @param name defines the control name
  72660. */
  72661. constructor(name?: string | undefined);
  72662. /** Gets or sets dash pattern */
  72663. get dash(): Array<number>;
  72664. set dash(value: Array<number>);
  72665. /**
  72666. * Gets point stored at specified index
  72667. * @param index defines the index to look for
  72668. * @returns the requested point if found
  72669. */
  72670. getAt(index: number): MultiLinePoint;
  72671. /** Function called when a point is updated */
  72672. onPointUpdate: () => void;
  72673. /**
  72674. * Adds new points to the point collection
  72675. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  72676. * @returns the list of created MultiLinePoint
  72677. */
  72678. add(...items: (AbstractMesh | Control | {
  72679. x: string | number;
  72680. y: string | number;
  72681. })[]): MultiLinePoint[];
  72682. /**
  72683. * Adds a new point to the point collection
  72684. * @param item defines the item (mesh, control or 2d coordiantes) to add
  72685. * @returns the created MultiLinePoint
  72686. */
  72687. push(item?: (AbstractMesh | Control | {
  72688. x: string | number;
  72689. y: string | number;
  72690. })): MultiLinePoint;
  72691. /**
  72692. * Remove a specific value or point from the active point collection
  72693. * @param value defines the value or point to remove
  72694. */
  72695. remove(value: number | MultiLinePoint): void;
  72696. /**
  72697. * Resets this object to initial state (no point)
  72698. */
  72699. reset(): void;
  72700. /**
  72701. * Resets all links
  72702. */
  72703. resetLinks(): void;
  72704. /** Gets or sets line width */
  72705. get lineWidth(): number;
  72706. set lineWidth(value: number);
  72707. set horizontalAlignment(value: number);
  72708. set verticalAlignment(value: number);
  72709. protected _getTypeName(): string;
  72710. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72711. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72712. _measure(): void;
  72713. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72714. dispose(): void;
  72715. }
  72716. }
  72717. declare module BABYLON.GUI {
  72718. /**
  72719. * Class used to create radio button controls
  72720. */
  72721. export class RadioButton extends Control {
  72722. name?: string | undefined;
  72723. private _isChecked;
  72724. private _background;
  72725. private _checkSizeRatio;
  72726. private _thickness;
  72727. /** Gets or sets border thickness */
  72728. get thickness(): number;
  72729. set thickness(value: number);
  72730. /** Gets or sets group name */
  72731. group: string;
  72732. /** BABYLON.Observable raised when isChecked is changed */
  72733. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72734. /** Gets or sets a value indicating the ratio between overall size and check size */
  72735. get checkSizeRatio(): number;
  72736. set checkSizeRatio(value: number);
  72737. /** Gets or sets background color */
  72738. get background(): string;
  72739. set background(value: string);
  72740. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72741. get isChecked(): boolean;
  72742. set isChecked(value: boolean);
  72743. /**
  72744. * Creates a new RadioButton
  72745. * @param name defines the control name
  72746. */
  72747. constructor(name?: string | undefined);
  72748. protected _getTypeName(): string;
  72749. _draw(context: CanvasRenderingContext2D): void;
  72750. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72751. /**
  72752. * Utility function to easily create a radio button with a header
  72753. * @param title defines the label to use for the header
  72754. * @param group defines the group to use for the radio button
  72755. * @param isChecked defines the initial state of the radio button
  72756. * @param onValueChanged defines the callback to call when value changes
  72757. * @returns a StackPanel containing the radio button and a textBlock
  72758. */
  72759. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  72760. }
  72761. }
  72762. declare module BABYLON.GUI {
  72763. /**
  72764. * Class used to create slider controls
  72765. */
  72766. export class BaseSlider extends Control {
  72767. name?: string | undefined;
  72768. protected _thumbWidth: ValueAndUnit;
  72769. private _minimum;
  72770. private _maximum;
  72771. private _value;
  72772. private _isVertical;
  72773. protected _barOffset: ValueAndUnit;
  72774. private _isThumbClamped;
  72775. protected _displayThumb: boolean;
  72776. private _step;
  72777. private _lastPointerDownID;
  72778. protected _effectiveBarOffset: number;
  72779. protected _renderLeft: number;
  72780. protected _renderTop: number;
  72781. protected _renderWidth: number;
  72782. protected _renderHeight: number;
  72783. protected _backgroundBoxLength: number;
  72784. protected _backgroundBoxThickness: number;
  72785. protected _effectiveThumbThickness: number;
  72786. /** BABYLON.Observable raised when the sldier value changes */
  72787. onValueChangedObservable: BABYLON.Observable<number>;
  72788. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72789. get displayThumb(): boolean;
  72790. set displayThumb(value: boolean);
  72791. /** Gets or sets a step to apply to values (0 by default) */
  72792. get step(): number;
  72793. set step(value: number);
  72794. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72795. get barOffset(): string | number;
  72796. /** Gets main bar offset in pixels*/
  72797. get barOffsetInPixels(): number;
  72798. set barOffset(value: string | number);
  72799. /** Gets or sets thumb width */
  72800. get thumbWidth(): string | number;
  72801. /** Gets thumb width in pixels */
  72802. get thumbWidthInPixels(): number;
  72803. set thumbWidth(value: string | number);
  72804. /** Gets or sets minimum value */
  72805. get minimum(): number;
  72806. set minimum(value: number);
  72807. /** Gets or sets maximum value */
  72808. get maximum(): number;
  72809. set maximum(value: number);
  72810. /** Gets or sets current value */
  72811. get value(): number;
  72812. set value(value: number);
  72813. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72814. get isVertical(): boolean;
  72815. set isVertical(value: boolean);
  72816. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72817. get isThumbClamped(): boolean;
  72818. set isThumbClamped(value: boolean);
  72819. /**
  72820. * Creates a new BaseSlider
  72821. * @param name defines the control name
  72822. */
  72823. constructor(name?: string | undefined);
  72824. protected _getTypeName(): string;
  72825. protected _getThumbPosition(): number;
  72826. protected _getThumbThickness(type: string): number;
  72827. protected _prepareRenderingData(type: string): void;
  72828. private _pointerIsDown;
  72829. /** @hidden */
  72830. protected _updateValueFromPointer(x: number, y: number): void;
  72831. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72832. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72833. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72834. }
  72835. }
  72836. declare module BABYLON.GUI {
  72837. /**
  72838. * Class used to create slider controls
  72839. */
  72840. export class Slider extends BaseSlider {
  72841. name?: string | undefined;
  72842. private _background;
  72843. private _borderColor;
  72844. private _isThumbCircle;
  72845. protected _displayValueBar: boolean;
  72846. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72847. get displayValueBar(): boolean;
  72848. set displayValueBar(value: boolean);
  72849. /** Gets or sets border color */
  72850. get borderColor(): string;
  72851. set borderColor(value: string);
  72852. /** Gets or sets background color */
  72853. get background(): string;
  72854. set background(value: string);
  72855. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72856. get isThumbCircle(): boolean;
  72857. set isThumbCircle(value: boolean);
  72858. /**
  72859. * Creates a new Slider
  72860. * @param name defines the control name
  72861. */
  72862. constructor(name?: string | undefined);
  72863. protected _getTypeName(): string;
  72864. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72865. }
  72866. }
  72867. declare module BABYLON.GUI {
  72868. /** Class used to create a RadioGroup
  72869. * which contains groups of radio buttons
  72870. */
  72871. export class SelectorGroup {
  72872. /** name of SelectorGroup */
  72873. name: string;
  72874. private _groupPanel;
  72875. private _selectors;
  72876. private _groupHeader;
  72877. /**
  72878. * Creates a new SelectorGroup
  72879. * @param name of group, used as a group heading
  72880. */
  72881. constructor(
  72882. /** name of SelectorGroup */
  72883. name: string);
  72884. /** Gets the groupPanel of the SelectorGroup */
  72885. get groupPanel(): StackPanel;
  72886. /** Gets the selectors array */
  72887. get selectors(): StackPanel[];
  72888. /** Gets and sets the group header */
  72889. get header(): string;
  72890. set header(label: string);
  72891. /** @hidden */
  72892. private _addGroupHeader;
  72893. /** @hidden*/
  72894. _getSelector(selectorNb: number): StackPanel | undefined;
  72895. /** Removes the selector at the given position
  72896. * @param selectorNb the position of the selector within the group
  72897. */
  72898. removeSelector(selectorNb: number): void;
  72899. }
  72900. /** Class used to create a CheckboxGroup
  72901. * which contains groups of checkbox buttons
  72902. */
  72903. export class CheckboxGroup extends SelectorGroup {
  72904. /** Adds a checkbox as a control
  72905. * @param text is the label for the selector
  72906. * @param func is the function called when the Selector is checked
  72907. * @param checked is true when Selector is checked
  72908. */
  72909. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72910. /** @hidden */
  72911. _setSelectorLabel(selectorNb: number, label: string): void;
  72912. /** @hidden */
  72913. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72914. /** @hidden */
  72915. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72916. /** @hidden */
  72917. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72918. }
  72919. /** Class used to create a RadioGroup
  72920. * which contains groups of radio buttons
  72921. */
  72922. export class RadioGroup extends SelectorGroup {
  72923. private _selectNb;
  72924. /** Adds a radio button as a control
  72925. * @param label is the label for the selector
  72926. * @param func is the function called when the Selector is checked
  72927. * @param checked is true when Selector is checked
  72928. */
  72929. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72930. /** @hidden */
  72931. _setSelectorLabel(selectorNb: number, label: string): void;
  72932. /** @hidden */
  72933. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72934. /** @hidden */
  72935. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72936. /** @hidden */
  72937. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72938. }
  72939. /** Class used to create a SliderGroup
  72940. * which contains groups of slider buttons
  72941. */
  72942. export class SliderGroup extends SelectorGroup {
  72943. /**
  72944. * Adds a slider to the SelectorGroup
  72945. * @param label is the label for the SliderBar
  72946. * @param func is the function called when the Slider moves
  72947. * @param unit is a string describing the units used, eg degrees or metres
  72948. * @param min is the minimum value for the Slider
  72949. * @param max is the maximum value for the Slider
  72950. * @param value is the start value for the Slider between min and max
  72951. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72952. */
  72953. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72954. /** @hidden */
  72955. _setSelectorLabel(selectorNb: number, label: string): void;
  72956. /** @hidden */
  72957. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72958. /** @hidden */
  72959. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72960. /** @hidden */
  72961. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72962. }
  72963. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72964. * @see http://doc.babylonjs.com/how_to/selector
  72965. */
  72966. export class SelectionPanel extends Rectangle {
  72967. /** name of SelectionPanel */
  72968. name: string;
  72969. /** an array of SelectionGroups */
  72970. groups: SelectorGroup[];
  72971. private _panel;
  72972. private _buttonColor;
  72973. private _buttonBackground;
  72974. private _headerColor;
  72975. private _barColor;
  72976. private _barHeight;
  72977. private _spacerHeight;
  72978. private _labelColor;
  72979. private _groups;
  72980. private _bars;
  72981. /**
  72982. * Creates a new SelectionPanel
  72983. * @param name of SelectionPanel
  72984. * @param groups is an array of SelectionGroups
  72985. */
  72986. constructor(
  72987. /** name of SelectionPanel */
  72988. name: string,
  72989. /** an array of SelectionGroups */
  72990. groups?: SelectorGroup[]);
  72991. protected _getTypeName(): string;
  72992. /** Gets or sets the headerColor */
  72993. get headerColor(): string;
  72994. set headerColor(color: string);
  72995. private _setHeaderColor;
  72996. /** Gets or sets the button color */
  72997. get buttonColor(): string;
  72998. set buttonColor(color: string);
  72999. private _setbuttonColor;
  73000. /** Gets or sets the label color */
  73001. get labelColor(): string;
  73002. set labelColor(color: string);
  73003. private _setLabelColor;
  73004. /** Gets or sets the button background */
  73005. get buttonBackground(): string;
  73006. set buttonBackground(color: string);
  73007. private _setButtonBackground;
  73008. /** Gets or sets the color of separator bar */
  73009. get barColor(): string;
  73010. set barColor(color: string);
  73011. private _setBarColor;
  73012. /** Gets or sets the height of separator bar */
  73013. get barHeight(): string;
  73014. set barHeight(value: string);
  73015. private _setBarHeight;
  73016. /** Gets or sets the height of spacers*/
  73017. get spacerHeight(): string;
  73018. set spacerHeight(value: string);
  73019. private _setSpacerHeight;
  73020. /** Adds a bar between groups */
  73021. private _addSpacer;
  73022. /** Add a group to the selection panel
  73023. * @param group is the selector group to add
  73024. */
  73025. addGroup(group: SelectorGroup): void;
  73026. /** Remove the group from the given position
  73027. * @param groupNb is the position of the group in the list
  73028. */
  73029. removeGroup(groupNb: number): void;
  73030. /** Change a group header label
  73031. * @param label is the new group header label
  73032. * @param groupNb is the number of the group to relabel
  73033. * */
  73034. setHeaderName(label: string, groupNb: number): void;
  73035. /** Change selector label to the one given
  73036. * @param label is the new selector label
  73037. * @param groupNb is the number of the groupcontaining the selector
  73038. * @param selectorNb is the number of the selector within a group to relabel
  73039. * */
  73040. relabel(label: string, groupNb: number, selectorNb: number): void;
  73041. /** For a given group position remove the selector at the given position
  73042. * @param groupNb is the number of the group to remove the selector from
  73043. * @param selectorNb is the number of the selector within the group
  73044. */
  73045. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73046. /** For a given group position of correct type add a checkbox button
  73047. * @param groupNb is the number of the group to remove the selector from
  73048. * @param label is the label for the selector
  73049. * @param func is the function called when the Selector is checked
  73050. * @param checked is true when Selector is checked
  73051. */
  73052. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73053. /** For a given group position of correct type add a radio button
  73054. * @param groupNb is the number of the group to remove the selector from
  73055. * @param label is the label for the selector
  73056. * @param func is the function called when the Selector is checked
  73057. * @param checked is true when Selector is checked
  73058. */
  73059. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73060. /**
  73061. * For a given slider group add a slider
  73062. * @param groupNb is the number of the group to add the slider to
  73063. * @param label is the label for the Slider
  73064. * @param func is the function called when the Slider moves
  73065. * @param unit is a string describing the units used, eg degrees or metres
  73066. * @param min is the minimum value for the Slider
  73067. * @param max is the maximum value for the Slider
  73068. * @param value is the start value for the Slider between min and max
  73069. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73070. */
  73071. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73072. }
  73073. }
  73074. declare module BABYLON.GUI {
  73075. /**
  73076. * Class used to hold a the container for ScrollViewer
  73077. * @hidden
  73078. */
  73079. export class _ScrollViewerWindow extends Container {
  73080. parentClientWidth: number;
  73081. parentClientHeight: number;
  73082. private _freezeControls;
  73083. private _parentMeasure;
  73084. private _oldLeft;
  73085. private _oldTop;
  73086. get freezeControls(): boolean;
  73087. set freezeControls(value: boolean);
  73088. private _bucketWidth;
  73089. private _bucketHeight;
  73090. private _buckets;
  73091. private _bucketLen;
  73092. get bucketWidth(): number;
  73093. get bucketHeight(): number;
  73094. setBucketSizes(width: number, height: number): void;
  73095. private _useBuckets;
  73096. private _makeBuckets;
  73097. private _dispatchInBuckets;
  73098. private _updateMeasures;
  73099. private _updateChildrenMeasures;
  73100. /**
  73101. * Creates a new ScrollViewerWindow
  73102. * @param name of ScrollViewerWindow
  73103. */
  73104. constructor(name?: string);
  73105. protected _getTypeName(): string;
  73106. /** @hidden */
  73107. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73108. /** @hidden */
  73109. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73110. private _scrollChildren;
  73111. private _scrollChildrenWithBuckets;
  73112. /** @hidden */
  73113. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73114. protected _postMeasure(): void;
  73115. }
  73116. }
  73117. declare module BABYLON.GUI {
  73118. /**
  73119. * Class used to create slider controls
  73120. */
  73121. export class ScrollBar extends BaseSlider {
  73122. name?: string | undefined;
  73123. private _background;
  73124. private _borderColor;
  73125. private _tempMeasure;
  73126. /** Gets or sets border color */
  73127. get borderColor(): string;
  73128. set borderColor(value: string);
  73129. /** Gets or sets background color */
  73130. get background(): string;
  73131. set background(value: string);
  73132. /**
  73133. * Creates a new Slider
  73134. * @param name defines the control name
  73135. */
  73136. constructor(name?: string | undefined);
  73137. protected _getTypeName(): string;
  73138. protected _getThumbThickness(): number;
  73139. _draw(context: CanvasRenderingContext2D): void;
  73140. private _first;
  73141. private _originX;
  73142. private _originY;
  73143. /** @hidden */
  73144. protected _updateValueFromPointer(x: number, y: number): void;
  73145. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73146. }
  73147. }
  73148. declare module BABYLON.GUI {
  73149. /**
  73150. * Class used to create slider controls
  73151. */
  73152. export class ImageScrollBar extends BaseSlider {
  73153. name?: string | undefined;
  73154. private _backgroundBaseImage;
  73155. private _backgroundImage;
  73156. private _thumbImage;
  73157. private _thumbBaseImage;
  73158. private _thumbLength;
  73159. private _thumbHeight;
  73160. private _barImageHeight;
  73161. private _tempMeasure;
  73162. /** Number of 90° rotation to apply on the images when in vertical mode */
  73163. num90RotationInVerticalMode: number;
  73164. /**
  73165. * Gets or sets the image used to render the background for horizontal bar
  73166. */
  73167. get backgroundImage(): Image;
  73168. set backgroundImage(value: Image);
  73169. /**
  73170. * Gets or sets the image used to render the thumb
  73171. */
  73172. get thumbImage(): Image;
  73173. set thumbImage(value: Image);
  73174. /**
  73175. * Gets or sets the length of the thumb
  73176. */
  73177. get thumbLength(): number;
  73178. set thumbLength(value: number);
  73179. /**
  73180. * Gets or sets the height of the thumb
  73181. */
  73182. get thumbHeight(): number;
  73183. set thumbHeight(value: number);
  73184. /**
  73185. * Gets or sets the height of the bar image
  73186. */
  73187. get barImageHeight(): number;
  73188. set barImageHeight(value: number);
  73189. /**
  73190. * Creates a new ImageScrollBar
  73191. * @param name defines the control name
  73192. */
  73193. constructor(name?: string | undefined);
  73194. protected _getTypeName(): string;
  73195. protected _getThumbThickness(): number;
  73196. _draw(context: CanvasRenderingContext2D): void;
  73197. private _first;
  73198. private _originX;
  73199. private _originY;
  73200. /** @hidden */
  73201. protected _updateValueFromPointer(x: number, y: number): void;
  73202. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73203. }
  73204. }
  73205. declare module BABYLON.GUI {
  73206. /**
  73207. * Class used to hold a viewer window and sliders in a grid
  73208. */
  73209. export class ScrollViewer extends Rectangle {
  73210. private _grid;
  73211. private _horizontalBarSpace;
  73212. private _verticalBarSpace;
  73213. private _dragSpace;
  73214. private _horizontalBar;
  73215. private _verticalBar;
  73216. private _barColor;
  73217. private _barBackground;
  73218. private _barImage;
  73219. private _horizontalBarImage;
  73220. private _verticalBarImage;
  73221. private _barBackgroundImage;
  73222. private _horizontalBarBackgroundImage;
  73223. private _verticalBarBackgroundImage;
  73224. private _barSize;
  73225. private _window;
  73226. private _pointerIsOver;
  73227. private _wheelPrecision;
  73228. private _onWheelObserver;
  73229. private _clientWidth;
  73230. private _clientHeight;
  73231. private _useImageBar;
  73232. private _thumbLength;
  73233. private _thumbHeight;
  73234. private _barImageHeight;
  73235. private _horizontalBarImageHeight;
  73236. private _verticalBarImageHeight;
  73237. /**
  73238. * Gets the horizontal scrollbar
  73239. */
  73240. get horizontalBar(): ScrollBar | ImageScrollBar;
  73241. /**
  73242. * Gets the vertical scrollbar
  73243. */
  73244. get verticalBar(): ScrollBar | ImageScrollBar;
  73245. /**
  73246. * Adds a new control to the current container
  73247. * @param control defines the control to add
  73248. * @returns the current container
  73249. */
  73250. addControl(control: BABYLON.Nullable<Control>): Container;
  73251. /**
  73252. * Removes a control from the current container
  73253. * @param control defines the control to remove
  73254. * @returns the current container
  73255. */
  73256. removeControl(control: Control): Container;
  73257. /** Gets the list of children */
  73258. get children(): Control[];
  73259. _flagDescendantsAsMatrixDirty(): void;
  73260. /**
  73261. * Freezes or unfreezes the controls in the window.
  73262. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73263. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73264. */
  73265. get freezeControls(): boolean;
  73266. set freezeControls(value: boolean);
  73267. /** Gets the bucket width */
  73268. get bucketWidth(): number;
  73269. /** Gets the bucket height */
  73270. get bucketHeight(): number;
  73271. /**
  73272. * Sets the bucket sizes.
  73273. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73274. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73275. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73276. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73277. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73278. * used), that's why it is not enabled by default.
  73279. * @param width width of the bucket
  73280. * @param height height of the bucket
  73281. */
  73282. setBucketSizes(width: number, height: number): void;
  73283. private _forceHorizontalBar;
  73284. private _forceVerticalBar;
  73285. /**
  73286. * Forces the horizontal scroll bar to be displayed
  73287. */
  73288. get forceHorizontalBar(): boolean;
  73289. set forceHorizontalBar(value: boolean);
  73290. /**
  73291. * Forces the vertical scroll bar to be displayed
  73292. */
  73293. get forceVerticalBar(): boolean;
  73294. set forceVerticalBar(value: boolean);
  73295. /**
  73296. * Creates a new ScrollViewer
  73297. * @param name of ScrollViewer
  73298. */
  73299. constructor(name?: string, isImageBased?: boolean);
  73300. /** Reset the scroll viewer window to initial size */
  73301. resetWindow(): void;
  73302. protected _getTypeName(): string;
  73303. private _buildClientSizes;
  73304. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73305. protected _postMeasure(): void;
  73306. /**
  73307. * Gets or sets the mouse wheel precision
  73308. * from 0 to 1 with a default value of 0.05
  73309. * */
  73310. get wheelPrecision(): number;
  73311. set wheelPrecision(value: number);
  73312. /** Gets or sets the scroll bar container background color */
  73313. get scrollBackground(): string;
  73314. set scrollBackground(color: string);
  73315. /** Gets or sets the bar color */
  73316. get barColor(): string;
  73317. set barColor(color: string);
  73318. /** Gets or sets the bar image */
  73319. get thumbImage(): Image;
  73320. set thumbImage(value: Image);
  73321. /** Gets or sets the horizontal bar image */
  73322. get horizontalThumbImage(): Image;
  73323. set horizontalThumbImage(value: Image);
  73324. /** Gets or sets the vertical bar image */
  73325. get verticalThumbImage(): Image;
  73326. set verticalThumbImage(value: Image);
  73327. /** Gets or sets the size of the bar */
  73328. get barSize(): number;
  73329. set barSize(value: number);
  73330. /** Gets or sets the length of the thumb */
  73331. get thumbLength(): number;
  73332. set thumbLength(value: number);
  73333. /** Gets or sets the height of the thumb */
  73334. get thumbHeight(): number;
  73335. set thumbHeight(value: number);
  73336. /** Gets or sets the height of the bar image */
  73337. get barImageHeight(): number;
  73338. set barImageHeight(value: number);
  73339. /** Gets or sets the height of the horizontal bar image */
  73340. get horizontalBarImageHeight(): number;
  73341. set horizontalBarImageHeight(value: number);
  73342. /** Gets or sets the height of the vertical bar image */
  73343. get verticalBarImageHeight(): number;
  73344. set verticalBarImageHeight(value: number);
  73345. /** Gets or sets the bar background */
  73346. get barBackground(): string;
  73347. set barBackground(color: string);
  73348. /** Gets or sets the bar background image */
  73349. get barImage(): Image;
  73350. set barImage(value: Image);
  73351. /** Gets or sets the horizontal bar background image */
  73352. get horizontalBarImage(): Image;
  73353. set horizontalBarImage(value: Image);
  73354. /** Gets or sets the vertical bar background image */
  73355. get verticalBarImage(): Image;
  73356. set verticalBarImage(value: Image);
  73357. private _setWindowPosition;
  73358. /** @hidden */
  73359. private _updateScroller;
  73360. _link(host: AdvancedDynamicTexture): void;
  73361. /** @hidden */
  73362. private _addBar;
  73363. /** @hidden */
  73364. private _attachWheel;
  73365. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73366. /** Releases associated resources */
  73367. dispose(): void;
  73368. }
  73369. }
  73370. declare module BABYLON.GUI {
  73371. /** Class used to render a grid */
  73372. export class DisplayGrid extends Control {
  73373. name?: string | undefined;
  73374. private _cellWidth;
  73375. private _cellHeight;
  73376. private _minorLineTickness;
  73377. private _minorLineColor;
  73378. private _majorLineTickness;
  73379. private _majorLineColor;
  73380. private _majorLineFrequency;
  73381. private _background;
  73382. private _displayMajorLines;
  73383. private _displayMinorLines;
  73384. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73385. get displayMinorLines(): boolean;
  73386. set displayMinorLines(value: boolean);
  73387. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73388. get displayMajorLines(): boolean;
  73389. set displayMajorLines(value: boolean);
  73390. /** Gets or sets background color (Black by default) */
  73391. get background(): string;
  73392. set background(value: string);
  73393. /** Gets or sets the width of each cell (20 by default) */
  73394. get cellWidth(): number;
  73395. set cellWidth(value: number);
  73396. /** Gets or sets the height of each cell (20 by default) */
  73397. get cellHeight(): number;
  73398. set cellHeight(value: number);
  73399. /** Gets or sets the tickness of minor lines (1 by default) */
  73400. get minorLineTickness(): number;
  73401. set minorLineTickness(value: number);
  73402. /** Gets or sets the color of minor lines (DarkGray by default) */
  73403. get minorLineColor(): string;
  73404. set minorLineColor(value: string);
  73405. /** Gets or sets the tickness of major lines (2 by default) */
  73406. get majorLineTickness(): number;
  73407. set majorLineTickness(value: number);
  73408. /** Gets or sets the color of major lines (White by default) */
  73409. get majorLineColor(): string;
  73410. set majorLineColor(value: string);
  73411. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  73412. get majorLineFrequency(): number;
  73413. set majorLineFrequency(value: number);
  73414. /**
  73415. * Creates a new GridDisplayRectangle
  73416. * @param name defines the control name
  73417. */
  73418. constructor(name?: string | undefined);
  73419. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73420. protected _getTypeName(): string;
  73421. }
  73422. }
  73423. declare module BABYLON.GUI {
  73424. /**
  73425. * Class used to create slider controls based on images
  73426. */
  73427. export class ImageBasedSlider extends BaseSlider {
  73428. name?: string | undefined;
  73429. private _backgroundImage;
  73430. private _thumbImage;
  73431. private _valueBarImage;
  73432. private _tempMeasure;
  73433. get displayThumb(): boolean;
  73434. set displayThumb(value: boolean);
  73435. /**
  73436. * Gets or sets the image used to render the background
  73437. */
  73438. get backgroundImage(): Image;
  73439. set backgroundImage(value: Image);
  73440. /**
  73441. * Gets or sets the image used to render the value bar
  73442. */
  73443. get valueBarImage(): Image;
  73444. set valueBarImage(value: Image);
  73445. /**
  73446. * Gets or sets the image used to render the thumb
  73447. */
  73448. get thumbImage(): Image;
  73449. set thumbImage(value: Image);
  73450. /**
  73451. * Creates a new ImageBasedSlider
  73452. * @param name defines the control name
  73453. */
  73454. constructor(name?: string | undefined);
  73455. protected _getTypeName(): string;
  73456. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73457. }
  73458. }
  73459. declare module BABYLON.GUI {
  73460. /**
  73461. * Forcing an export so that this code will execute
  73462. * @hidden
  73463. */
  73464. const name = "Statics";
  73465. }
  73466. declare module BABYLON.GUI {
  73467. /**
  73468. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  73469. */
  73470. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  73471. /**
  73472. * Define the instrumented AdvancedDynamicTexture.
  73473. */
  73474. texture: AdvancedDynamicTexture;
  73475. private _captureRenderTime;
  73476. private _renderTime;
  73477. private _captureLayoutTime;
  73478. private _layoutTime;
  73479. private _onBeginRenderObserver;
  73480. private _onEndRenderObserver;
  73481. private _onBeginLayoutObserver;
  73482. private _onEndLayoutObserver;
  73483. /**
  73484. * Gets the perf counter used to capture render time
  73485. */
  73486. get renderTimeCounter(): BABYLON.PerfCounter;
  73487. /**
  73488. * Gets the perf counter used to capture layout time
  73489. */
  73490. get layoutTimeCounter(): BABYLON.PerfCounter;
  73491. /**
  73492. * Enable or disable the render time capture
  73493. */
  73494. get captureRenderTime(): boolean;
  73495. set captureRenderTime(value: boolean);
  73496. /**
  73497. * Enable or disable the layout time capture
  73498. */
  73499. get captureLayoutTime(): boolean;
  73500. set captureLayoutTime(value: boolean);
  73501. /**
  73502. * Instantiates a new advanced dynamic texture instrumentation.
  73503. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  73504. * @param texture Defines the AdvancedDynamicTexture to instrument
  73505. */
  73506. constructor(
  73507. /**
  73508. * Define the instrumented AdvancedDynamicTexture.
  73509. */
  73510. texture: AdvancedDynamicTexture);
  73511. /**
  73512. * Dispose and release associated resources.
  73513. */
  73514. dispose(): void;
  73515. }
  73516. }
  73517. declare module BABYLON.GUI {
  73518. /**
  73519. * Class used to load GUI via XML.
  73520. */
  73521. export class XmlLoader {
  73522. private _nodes;
  73523. private _nodeTypes;
  73524. private _isLoaded;
  73525. private _objectAttributes;
  73526. private _parentClass;
  73527. /**
  73528. * Create a new xml loader
  73529. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  73530. */
  73531. constructor(parentClass?: null);
  73532. private _getChainElement;
  73533. private _getClassAttribute;
  73534. private _createGuiElement;
  73535. private _parseGrid;
  73536. private _parseElement;
  73537. private _prepareSourceElement;
  73538. private _parseElementsFromSource;
  73539. private _parseXml;
  73540. /**
  73541. * Gets if the loading has finished.
  73542. * @returns whether the loading has finished or not
  73543. */
  73544. isLoaded(): boolean;
  73545. /**
  73546. * Gets a loaded node / control by id.
  73547. * @param id the Controls id set in the xml
  73548. * @returns element of type Control
  73549. */
  73550. getNodeById(id: string): any;
  73551. /**
  73552. * Gets all loaded nodes / controls
  73553. * @returns Array of controls
  73554. */
  73555. getNodes(): any;
  73556. /**
  73557. * Initiates the xml layout loading
  73558. * @param xmlFile defines the xml layout to load
  73559. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  73560. * @param callback defines the callback called on layout load.
  73561. */
  73562. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  73563. }
  73564. }
  73565. declare module BABYLON.GUI {
  73566. /**
  73567. * Class used to create containers for controls
  73568. */
  73569. export class Container3D extends Control3D {
  73570. private _blockLayout;
  73571. /**
  73572. * Gets the list of child controls
  73573. */
  73574. protected _children: Control3D[];
  73575. /**
  73576. * Gets the list of child controls
  73577. */
  73578. get children(): Array<Control3D>;
  73579. /**
  73580. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  73581. * This is helpful to optimize layout operation when adding multiple children in a row
  73582. */
  73583. get blockLayout(): boolean;
  73584. set blockLayout(value: boolean);
  73585. /**
  73586. * Creates a new container
  73587. * @param name defines the container name
  73588. */
  73589. constructor(name?: string);
  73590. /**
  73591. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  73592. * @returns the current container
  73593. */
  73594. updateLayout(): Container3D;
  73595. /**
  73596. * Gets a boolean indicating if the given control is in the children of this control
  73597. * @param control defines the control to check
  73598. * @returns true if the control is in the child list
  73599. */
  73600. containsControl(control: Control3D): boolean;
  73601. /**
  73602. * Adds a control to the children of this control
  73603. * @param control defines the control to add
  73604. * @returns the current container
  73605. */
  73606. addControl(control: Control3D): Container3D;
  73607. /**
  73608. * This function will be called everytime a new control is added
  73609. */
  73610. protected _arrangeChildren(): void;
  73611. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73612. /**
  73613. * Removes a control from the children of this control
  73614. * @param control defines the control to remove
  73615. * @returns the current container
  73616. */
  73617. removeControl(control: Control3D): Container3D;
  73618. protected _getTypeName(): string;
  73619. /**
  73620. * Releases all associated resources
  73621. */
  73622. dispose(): void;
  73623. /** Control rotation will remain unchanged */
  73624. static readonly UNSET_ORIENTATION: number;
  73625. /** Control will rotate to make it look at sphere central axis */
  73626. static readonly FACEORIGIN_ORIENTATION: number;
  73627. /** Control will rotate to make it look back at sphere central axis */
  73628. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  73629. /** Control will rotate to look at z axis (0, 0, 1) */
  73630. static readonly FACEFORWARD_ORIENTATION: number;
  73631. /** Control will rotate to look at negative z axis (0, 0, -1) */
  73632. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  73633. }
  73634. }
  73635. declare module BABYLON.GUI {
  73636. /**
  73637. * Class used to manage 3D user interface
  73638. * @see http://doc.babylonjs.com/how_to/gui3d
  73639. */
  73640. export class GUI3DManager implements BABYLON.IDisposable {
  73641. private _scene;
  73642. private _sceneDisposeObserver;
  73643. private _utilityLayer;
  73644. private _rootContainer;
  73645. private _pointerObserver;
  73646. private _pointerOutObserver;
  73647. /** @hidden */
  73648. _lastPickedControl: Control3D;
  73649. /** @hidden */
  73650. _lastControlOver: {
  73651. [pointerId: number]: Control3D;
  73652. };
  73653. /** @hidden */
  73654. _lastControlDown: {
  73655. [pointerId: number]: Control3D;
  73656. };
  73657. /**
  73658. * BABYLON.Observable raised when the point picked by the pointer events changed
  73659. */
  73660. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  73661. /** @hidden */
  73662. _sharedMaterials: {
  73663. [key: string]: BABYLON.Material;
  73664. };
  73665. /** Gets the hosting scene */
  73666. get scene(): BABYLON.Scene;
  73667. /** Gets associated utility layer */
  73668. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  73669. /**
  73670. * Creates a new GUI3DManager
  73671. * @param scene
  73672. */
  73673. constructor(scene?: BABYLON.Scene);
  73674. private _handlePointerOut;
  73675. private _doPicking;
  73676. /**
  73677. * Gets the root container
  73678. */
  73679. get rootContainer(): Container3D;
  73680. /**
  73681. * Gets a boolean indicating if the given control is in the root child list
  73682. * @param control defines the control to check
  73683. * @returns true if the control is in the root child list
  73684. */
  73685. containsControl(control: Control3D): boolean;
  73686. /**
  73687. * Adds a control to the root child list
  73688. * @param control defines the control to add
  73689. * @returns the current manager
  73690. */
  73691. addControl(control: Control3D): GUI3DManager;
  73692. /**
  73693. * Removes a control from the root child list
  73694. * @param control defines the control to remove
  73695. * @returns the current container
  73696. */
  73697. removeControl(control: Control3D): GUI3DManager;
  73698. /**
  73699. * Releases all associated resources
  73700. */
  73701. dispose(): void;
  73702. }
  73703. }
  73704. declare module BABYLON.GUI {
  73705. /**
  73706. * Class used to transport BABYLON.Vector3 information for pointer events
  73707. */
  73708. export class Vector3WithInfo extends BABYLON.Vector3 {
  73709. /** defines the current mouse button index */
  73710. buttonIndex: number;
  73711. /**
  73712. * Creates a new Vector3WithInfo
  73713. * @param source defines the vector3 data to transport
  73714. * @param buttonIndex defines the current mouse button index
  73715. */
  73716. constructor(source: BABYLON.Vector3,
  73717. /** defines the current mouse button index */
  73718. buttonIndex?: number);
  73719. }
  73720. }
  73721. declare module BABYLON.GUI {
  73722. /**
  73723. * Class used as base class for controls
  73724. */
  73725. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  73726. /** Defines the control name */
  73727. name?: string | undefined;
  73728. /** @hidden */
  73729. _host: GUI3DManager;
  73730. private _node;
  73731. private _downCount;
  73732. private _enterCount;
  73733. private _downPointerIds;
  73734. private _isVisible;
  73735. /** Gets or sets the control position in world space */
  73736. get position(): BABYLON.Vector3;
  73737. set position(value: BABYLON.Vector3);
  73738. /** Gets or sets the control scaling in world space */
  73739. get scaling(): BABYLON.Vector3;
  73740. set scaling(value: BABYLON.Vector3);
  73741. /** Callback used to start pointer enter animation */
  73742. pointerEnterAnimation: () => void;
  73743. /** Callback used to start pointer out animation */
  73744. pointerOutAnimation: () => void;
  73745. /** Callback used to start pointer down animation */
  73746. pointerDownAnimation: () => void;
  73747. /** Callback used to start pointer up animation */
  73748. pointerUpAnimation: () => void;
  73749. /**
  73750. * An event triggered when the pointer move over the control
  73751. */
  73752. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  73753. /**
  73754. * An event triggered when the pointer move out of the control
  73755. */
  73756. onPointerOutObservable: BABYLON.Observable<Control3D>;
  73757. /**
  73758. * An event triggered when the pointer taps the control
  73759. */
  73760. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  73761. /**
  73762. * An event triggered when pointer is up
  73763. */
  73764. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  73765. /**
  73766. * An event triggered when a control is clicked on (with a mouse)
  73767. */
  73768. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  73769. /**
  73770. * An event triggered when pointer enters the control
  73771. */
  73772. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  73773. /**
  73774. * Gets or sets the parent container
  73775. */
  73776. parent: BABYLON.Nullable<Container3D>;
  73777. private _behaviors;
  73778. /**
  73779. * Gets the list of attached behaviors
  73780. * @see http://doc.babylonjs.com/features/behaviour
  73781. */
  73782. get behaviors(): BABYLON.Behavior<Control3D>[];
  73783. /**
  73784. * Attach a behavior to the control
  73785. * @see http://doc.babylonjs.com/features/behaviour
  73786. * @param behavior defines the behavior to attach
  73787. * @returns the current control
  73788. */
  73789. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73790. /**
  73791. * Remove an attached behavior
  73792. * @see http://doc.babylonjs.com/features/behaviour
  73793. * @param behavior defines the behavior to attach
  73794. * @returns the current control
  73795. */
  73796. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73797. /**
  73798. * Gets an attached behavior by name
  73799. * @param name defines the name of the behavior to look for
  73800. * @see http://doc.babylonjs.com/features/behaviour
  73801. * @returns null if behavior was not found else the requested behavior
  73802. */
  73803. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  73804. /** Gets or sets a boolean indicating if the control is visible */
  73805. get isVisible(): boolean;
  73806. set isVisible(value: boolean);
  73807. /**
  73808. * Creates a new control
  73809. * @param name defines the control name
  73810. */
  73811. constructor(
  73812. /** Defines the control name */
  73813. name?: string | undefined);
  73814. /**
  73815. * Gets a string representing the class name
  73816. */
  73817. get typeName(): string;
  73818. /**
  73819. * Get the current class name of the control.
  73820. * @returns current class name
  73821. */
  73822. getClassName(): string;
  73823. protected _getTypeName(): string;
  73824. /**
  73825. * Gets the transform node used by this control
  73826. */
  73827. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  73828. /**
  73829. * Gets the mesh used to render this control
  73830. */
  73831. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73832. /**
  73833. * Link the control as child of the given node
  73834. * @param node defines the node to link to. Use null to unlink the control
  73835. * @returns the current control
  73836. */
  73837. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  73838. /** @hidden **/
  73839. _prepareNode(scene: BABYLON.Scene): void;
  73840. /**
  73841. * Node creation.
  73842. * Can be overriden by children
  73843. * @param scene defines the scene where the node must be attached
  73844. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  73845. */
  73846. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73847. /**
  73848. * Affect a material to the given mesh
  73849. * @param mesh defines the mesh which will represent the control
  73850. */
  73851. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73852. /** @hidden */
  73853. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  73854. /** @hidden */
  73855. _onPointerEnter(target: Control3D): boolean;
  73856. /** @hidden */
  73857. _onPointerOut(target: Control3D): void;
  73858. /** @hidden */
  73859. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73860. /** @hidden */
  73861. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73862. /** @hidden */
  73863. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73864. /** @hidden */
  73865. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73866. /** @hidden */
  73867. _disposeNode(): void;
  73868. /**
  73869. * Releases all associated resources
  73870. */
  73871. dispose(): void;
  73872. }
  73873. }
  73874. declare module BABYLON.GUI {
  73875. /**
  73876. * Class used as a root to all buttons
  73877. */
  73878. export class AbstractButton3D extends Control3D {
  73879. /**
  73880. * Creates a new button
  73881. * @param name defines the control name
  73882. */
  73883. constructor(name?: string);
  73884. protected _getTypeName(): string;
  73885. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73886. }
  73887. }
  73888. declare module BABYLON.GUI {
  73889. /**
  73890. * Class used to create a button in 3D
  73891. */
  73892. export class Button3D extends AbstractButton3D {
  73893. /** @hidden */
  73894. protected _currentMaterial: BABYLON.Material;
  73895. private _facadeTexture;
  73896. private _content;
  73897. private _contentResolution;
  73898. private _contentScaleRatio;
  73899. /**
  73900. * Gets or sets the texture resolution used to render content (512 by default)
  73901. */
  73902. get contentResolution(): BABYLON.int;
  73903. set contentResolution(value: BABYLON.int);
  73904. /**
  73905. * Gets or sets the texture scale ratio used to render content (2 by default)
  73906. */
  73907. get contentScaleRatio(): number;
  73908. set contentScaleRatio(value: number);
  73909. protected _disposeFacadeTexture(): void;
  73910. protected _resetContent(): void;
  73911. /**
  73912. * Creates a new button
  73913. * @param name defines the control name
  73914. */
  73915. constructor(name?: string);
  73916. /**
  73917. * Gets or sets the GUI 2D content used to display the button's facade
  73918. */
  73919. get content(): Control;
  73920. set content(value: Control);
  73921. /**
  73922. * Apply the facade texture (created from the content property).
  73923. * This function can be overloaded by child classes
  73924. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73925. */
  73926. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73927. protected _getTypeName(): string;
  73928. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73929. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73930. /**
  73931. * Releases all associated resources
  73932. */
  73933. dispose(): void;
  73934. }
  73935. }
  73936. declare module BABYLON.GUI {
  73937. /**
  73938. * Abstract class used to create a container panel deployed on the surface of a volume
  73939. */
  73940. export abstract class VolumeBasedPanel extends Container3D {
  73941. private _columns;
  73942. private _rows;
  73943. private _rowThenColum;
  73944. private _orientation;
  73945. protected _cellWidth: number;
  73946. protected _cellHeight: number;
  73947. /**
  73948. * Gets or sets the distance between elements
  73949. */
  73950. margin: number;
  73951. /**
  73952. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73953. * | Value | Type | Description |
  73954. * | ----- | ----------------------------------- | ----------- |
  73955. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73956. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73957. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73958. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73959. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73960. */
  73961. get orientation(): number;
  73962. set orientation(value: number);
  73963. /**
  73964. * Gets or sets the number of columns requested (10 by default).
  73965. * The panel will automatically compute the number of rows based on number of child controls.
  73966. */
  73967. get columns(): BABYLON.int;
  73968. set columns(value: BABYLON.int);
  73969. /**
  73970. * Gets or sets a the number of rows requested.
  73971. * The panel will automatically compute the number of columns based on number of child controls.
  73972. */
  73973. get rows(): BABYLON.int;
  73974. set rows(value: BABYLON.int);
  73975. /**
  73976. * Creates new VolumeBasedPanel
  73977. */
  73978. constructor();
  73979. protected _arrangeChildren(): void;
  73980. /** Child classes must implement this function to provide correct control positioning */
  73981. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73982. /** Child classes can implement this function to provide additional processing */
  73983. protected _finalProcessing(): void;
  73984. }
  73985. }
  73986. declare module BABYLON.GUI {
  73987. /**
  73988. * Class used to create a container panel deployed on the surface of a cylinder
  73989. */
  73990. export class CylinderPanel extends VolumeBasedPanel {
  73991. private _radius;
  73992. /**
  73993. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73994. */
  73995. get radius(): BABYLON.float;
  73996. set radius(value: BABYLON.float);
  73997. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73998. private _cylindricalMapping;
  73999. }
  74000. }
  74001. declare module BABYLON.GUI {
  74002. /** @hidden */
  74003. export var fluentVertexShader: {
  74004. name: string;
  74005. shader: string;
  74006. };
  74007. }
  74008. declare module BABYLON.GUI {
  74009. /** @hidden */
  74010. export var fluentPixelShader: {
  74011. name: string;
  74012. shader: string;
  74013. };
  74014. }
  74015. declare module BABYLON.GUI {
  74016. /** @hidden */
  74017. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74018. INNERGLOW: boolean;
  74019. BORDER: boolean;
  74020. HOVERLIGHT: boolean;
  74021. TEXTURE: boolean;
  74022. constructor();
  74023. }
  74024. /**
  74025. * Class used to render controls with fluent desgin
  74026. */
  74027. export class FluentMaterial extends BABYLON.PushMaterial {
  74028. /**
  74029. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74030. */
  74031. innerGlowColorIntensity: number;
  74032. /**
  74033. * Gets or sets the inner glow color (white by default)
  74034. */
  74035. innerGlowColor: BABYLON.Color3;
  74036. /**
  74037. * Gets or sets alpha value (default is 1.0)
  74038. */
  74039. alpha: number;
  74040. /**
  74041. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74042. */
  74043. albedoColor: BABYLON.Color3;
  74044. /**
  74045. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74046. */
  74047. renderBorders: boolean;
  74048. /**
  74049. * Gets or sets border width (default is 0.5)
  74050. */
  74051. borderWidth: number;
  74052. /**
  74053. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74054. */
  74055. edgeSmoothingValue: number;
  74056. /**
  74057. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74058. */
  74059. borderMinValue: number;
  74060. /**
  74061. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74062. */
  74063. renderHoverLight: boolean;
  74064. /**
  74065. * Gets or sets the radius used to render the hover light (default is 1.0)
  74066. */
  74067. hoverRadius: number;
  74068. /**
  74069. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74070. */
  74071. hoverColor: BABYLON.Color4;
  74072. /**
  74073. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74074. */
  74075. hoverPosition: BABYLON.Vector3;
  74076. private _albedoTexture;
  74077. /** Gets or sets the texture to use for albedo color */
  74078. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74079. /**
  74080. * Creates a new Fluent material
  74081. * @param name defines the name of the material
  74082. * @param scene defines the hosting scene
  74083. */
  74084. constructor(name: string, scene: BABYLON.Scene);
  74085. needAlphaBlending(): boolean;
  74086. needAlphaTesting(): boolean;
  74087. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74088. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74089. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74090. getActiveTextures(): BABYLON.BaseTexture[];
  74091. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74092. dispose(forceDisposeEffect?: boolean): void;
  74093. clone(name: string): FluentMaterial;
  74094. serialize(): any;
  74095. getClassName(): string;
  74096. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74097. }
  74098. }
  74099. declare module BABYLON.GUI {
  74100. /**
  74101. * Class used to create a holographic button in 3D
  74102. */
  74103. export class HolographicButton extends Button3D {
  74104. private _backPlate;
  74105. private _textPlate;
  74106. private _frontPlate;
  74107. private _text;
  74108. private _imageUrl;
  74109. private _shareMaterials;
  74110. private _frontMaterial;
  74111. private _backMaterial;
  74112. private _plateMaterial;
  74113. private _pickedPointObserver;
  74114. private _tooltipFade;
  74115. private _tooltipTextBlock;
  74116. private _tooltipTexture;
  74117. private _tooltipMesh;
  74118. private _tooltipHoverObserver;
  74119. private _tooltipOutObserver;
  74120. private _disposeTooltip;
  74121. /**
  74122. * Rendering ground id of all the mesh in the button
  74123. */
  74124. set renderingGroupId(id: number);
  74125. get renderingGroupId(): number;
  74126. /**
  74127. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74128. */
  74129. set tooltipText(text: BABYLON.Nullable<string>);
  74130. get tooltipText(): BABYLON.Nullable<string>;
  74131. /**
  74132. * Gets or sets text for the button
  74133. */
  74134. get text(): string;
  74135. set text(value: string);
  74136. /**
  74137. * Gets or sets the image url for the button
  74138. */
  74139. get imageUrl(): string;
  74140. set imageUrl(value: string);
  74141. /**
  74142. * Gets the back material used by this button
  74143. */
  74144. get backMaterial(): FluentMaterial;
  74145. /**
  74146. * Gets the front material used by this button
  74147. */
  74148. get frontMaterial(): FluentMaterial;
  74149. /**
  74150. * Gets the plate material used by this button
  74151. */
  74152. get plateMaterial(): BABYLON.StandardMaterial;
  74153. /**
  74154. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74155. */
  74156. get shareMaterials(): boolean;
  74157. /**
  74158. * Creates a new button
  74159. * @param name defines the control name
  74160. */
  74161. constructor(name?: string, shareMaterials?: boolean);
  74162. protected _getTypeName(): string;
  74163. private _rebuildContent;
  74164. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74165. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74166. private _createBackMaterial;
  74167. private _createFrontMaterial;
  74168. private _createPlateMaterial;
  74169. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  74170. /**
  74171. * Releases all associated resources
  74172. */
  74173. dispose(): void;
  74174. }
  74175. }
  74176. declare module BABYLON.GUI {
  74177. /**
  74178. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  74179. */
  74180. export class MeshButton3D extends Button3D {
  74181. /** @hidden */
  74182. protected _currentMesh: BABYLON.Mesh;
  74183. /**
  74184. * Creates a new 3D button based on a mesh
  74185. * @param mesh mesh to become a 3D button
  74186. * @param name defines the control name
  74187. */
  74188. constructor(mesh: BABYLON.Mesh, name?: string);
  74189. protected _getTypeName(): string;
  74190. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74191. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74192. }
  74193. }
  74194. declare module BABYLON.GUI {
  74195. /**
  74196. * Class used to create a container panel deployed on the surface of a plane
  74197. */
  74198. export class PlanePanel extends VolumeBasedPanel {
  74199. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74200. }
  74201. }
  74202. declare module BABYLON.GUI {
  74203. /**
  74204. * Class used to create a container panel where items get randomized planar mapping
  74205. */
  74206. export class ScatterPanel extends VolumeBasedPanel {
  74207. private _iteration;
  74208. /**
  74209. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74210. */
  74211. get iteration(): BABYLON.float;
  74212. set iteration(value: BABYLON.float);
  74213. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74214. private _scatterMapping;
  74215. protected _finalProcessing(): void;
  74216. }
  74217. }
  74218. declare module BABYLON.GUI {
  74219. /**
  74220. * Class used to create a container panel deployed on the surface of a sphere
  74221. */
  74222. export class SpherePanel extends VolumeBasedPanel {
  74223. private _radius;
  74224. /**
  74225. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74226. */
  74227. get radius(): BABYLON.float;
  74228. set radius(value: BABYLON.float);
  74229. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74230. private _sphericalMapping;
  74231. }
  74232. }
  74233. declare module BABYLON.GUI {
  74234. /**
  74235. * Class used to create a stack panel in 3D on XY plane
  74236. */
  74237. export class StackPanel3D extends Container3D {
  74238. private _isVertical;
  74239. /**
  74240. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74241. */
  74242. get isVertical(): boolean;
  74243. set isVertical(value: boolean);
  74244. /**
  74245. * Gets or sets the distance between elements
  74246. */
  74247. margin: number;
  74248. /**
  74249. * Creates new StackPanel
  74250. * @param isVertical
  74251. */
  74252. constructor(isVertical?: boolean);
  74253. protected _arrangeChildren(): void;
  74254. }
  74255. }
  74256. declare module BABYLON {
  74257. /**
  74258. * Configuration for glTF validation
  74259. */
  74260. export interface IGLTFValidationConfiguration {
  74261. /**
  74262. * The url of the glTF validator.
  74263. */
  74264. url: string;
  74265. }
  74266. /**
  74267. * glTF validation
  74268. */
  74269. export class GLTFValidation {
  74270. /**
  74271. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74272. */
  74273. static Configuration: IGLTFValidationConfiguration;
  74274. private static _LoadScriptPromise;
  74275. /**
  74276. * Validate a glTF asset using the glTF-Validator.
  74277. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74278. * @param rootUrl The root url for the glTF
  74279. * @param fileName The file name for the glTF
  74280. * @param getExternalResource The callback to get external resources for the glTF validator
  74281. * @returns A promise that resolves with the glTF validation results once complete
  74282. */
  74283. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74284. }
  74285. }
  74286. declare module BABYLON {
  74287. /**
  74288. * Mode that determines the coordinate system to use.
  74289. */
  74290. export enum GLTFLoaderCoordinateSystemMode {
  74291. /**
  74292. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74293. */
  74294. AUTO = 0,
  74295. /**
  74296. * Sets the useRightHandedSystem flag on the scene.
  74297. */
  74298. FORCE_RIGHT_HANDED = 1
  74299. }
  74300. /**
  74301. * Mode that determines what animations will start.
  74302. */
  74303. export enum GLTFLoaderAnimationStartMode {
  74304. /**
  74305. * No animation will start.
  74306. */
  74307. NONE = 0,
  74308. /**
  74309. * The first animation will start.
  74310. */
  74311. FIRST = 1,
  74312. /**
  74313. * All animations will start.
  74314. */
  74315. ALL = 2
  74316. }
  74317. /**
  74318. * Interface that contains the data for the glTF asset.
  74319. */
  74320. export interface IGLTFLoaderData {
  74321. /**
  74322. * The object that represents the glTF JSON.
  74323. */
  74324. json: Object;
  74325. /**
  74326. * The BIN chunk of a binary glTF.
  74327. */
  74328. bin: Nullable<IDataBuffer>;
  74329. }
  74330. /**
  74331. * Interface for extending the loader.
  74332. */
  74333. export interface IGLTFLoaderExtension {
  74334. /**
  74335. * The name of this extension.
  74336. */
  74337. readonly name: string;
  74338. /**
  74339. * Defines whether this extension is enabled.
  74340. */
  74341. enabled: boolean;
  74342. /**
  74343. * Defines the order of this extension.
  74344. * The loader sorts the extensions using these values when loading.
  74345. */
  74346. order?: number;
  74347. }
  74348. /**
  74349. * Loader state.
  74350. */
  74351. export enum GLTFLoaderState {
  74352. /**
  74353. * The asset is loading.
  74354. */
  74355. LOADING = 0,
  74356. /**
  74357. * The asset is ready for rendering.
  74358. */
  74359. READY = 1,
  74360. /**
  74361. * The asset is completely loaded.
  74362. */
  74363. COMPLETE = 2
  74364. }
  74365. /** @hidden */
  74366. export interface IImportMeshAsyncOutput {
  74367. meshes: AbstractMesh[];
  74368. particleSystems: IParticleSystem[];
  74369. skeletons: Skeleton[];
  74370. animationGroups: AnimationGroup[];
  74371. lights: Light[];
  74372. transformNodes: TransformNode[];
  74373. }
  74374. /** @hidden */
  74375. export interface IGLTFLoader extends IDisposable {
  74376. readonly state: Nullable<GLTFLoaderState>;
  74377. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  74378. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74379. }
  74380. /**
  74381. * File loader for loading glTF files into a scene.
  74382. */
  74383. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74384. /** @hidden */
  74385. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74386. /** @hidden */
  74387. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74388. /**
  74389. * Raised when the asset has been parsed
  74390. */
  74391. onParsedObservable: Observable<IGLTFLoaderData>;
  74392. private _onParsedObserver;
  74393. /**
  74394. * Raised when the asset has been parsed
  74395. */
  74396. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74397. /**
  74398. * 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.
  74399. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74400. * Defaults to true.
  74401. * @hidden
  74402. */
  74403. static IncrementalLoading: boolean;
  74404. /**
  74405. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  74406. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  74407. * @hidden
  74408. */
  74409. static HomogeneousCoordinates: boolean;
  74410. /**
  74411. * The coordinate system mode. Defaults to AUTO.
  74412. */
  74413. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  74414. /**
  74415. * The animation start mode. Defaults to FIRST.
  74416. */
  74417. animationStartMode: GLTFLoaderAnimationStartMode;
  74418. /**
  74419. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  74420. */
  74421. compileMaterials: boolean;
  74422. /**
  74423. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  74424. */
  74425. useClipPlane: boolean;
  74426. /**
  74427. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  74428. */
  74429. compileShadowGenerators: boolean;
  74430. /**
  74431. * Defines if the Alpha blended materials are only applied as coverage.
  74432. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  74433. * If true, no extra effects are applied to transparent pixels.
  74434. */
  74435. transparencyAsCoverage: boolean;
  74436. /**
  74437. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  74438. * Enabling will disable offline support and glTF validator.
  74439. * Defaults to false.
  74440. */
  74441. useRangeRequests: boolean;
  74442. /**
  74443. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  74444. */
  74445. createInstances: boolean;
  74446. /**
  74447. * Function called before loading a url referenced by the asset.
  74448. */
  74449. preprocessUrlAsync: (url: string) => Promise<string>;
  74450. /**
  74451. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74452. */
  74453. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  74454. private _onMeshLoadedObserver;
  74455. /**
  74456. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74457. */
  74458. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  74459. /**
  74460. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  74461. */
  74462. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  74463. private _onTextureLoadedObserver;
  74464. /**
  74465. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  74466. */
  74467. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  74468. /**
  74469. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  74470. */
  74471. readonly onMaterialLoadedObservable: Observable<Material>;
  74472. private _onMaterialLoadedObserver;
  74473. /**
  74474. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  74475. */
  74476. set onMaterialLoaded(callback: (material: Material) => void);
  74477. /**
  74478. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  74479. */
  74480. readonly onCameraLoadedObservable: Observable<Camera>;
  74481. private _onCameraLoadedObserver;
  74482. /**
  74483. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  74484. */
  74485. set onCameraLoaded(callback: (camera: Camera) => void);
  74486. /**
  74487. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  74488. * For assets with LODs, raised when all of the LODs are complete.
  74489. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74490. */
  74491. readonly onCompleteObservable: Observable<void>;
  74492. private _onCompleteObserver;
  74493. /**
  74494. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  74495. * For assets with LODs, raised when all of the LODs are complete.
  74496. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74497. */
  74498. set onComplete(callback: () => void);
  74499. /**
  74500. * Observable raised when an error occurs.
  74501. */
  74502. readonly onErrorObservable: Observable<any>;
  74503. private _onErrorObserver;
  74504. /**
  74505. * Callback raised when an error occurs.
  74506. */
  74507. set onError(callback: (reason: any) => void);
  74508. /**
  74509. * Observable raised after the loader is disposed.
  74510. */
  74511. readonly onDisposeObservable: Observable<void>;
  74512. private _onDisposeObserver;
  74513. /**
  74514. * Callback raised after the loader is disposed.
  74515. */
  74516. set onDispose(callback: () => void);
  74517. /**
  74518. * Observable raised after a loader extension is created.
  74519. * Set additional options for a loader extension in this event.
  74520. */
  74521. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  74522. private _onExtensionLoadedObserver;
  74523. /**
  74524. * Callback raised after a loader extension is created.
  74525. */
  74526. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  74527. /**
  74528. * Defines if the loader logging is enabled.
  74529. */
  74530. get loggingEnabled(): boolean;
  74531. set loggingEnabled(value: boolean);
  74532. /**
  74533. * Defines if the loader should capture performance counters.
  74534. */
  74535. get capturePerformanceCounters(): boolean;
  74536. set capturePerformanceCounters(value: boolean);
  74537. /**
  74538. * Defines if the loader should validate the asset.
  74539. */
  74540. validate: boolean;
  74541. /**
  74542. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  74543. */
  74544. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  74545. private _onValidatedObserver;
  74546. /**
  74547. * Callback raised after a loader extension is created.
  74548. */
  74549. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  74550. private _loader;
  74551. /**
  74552. * Name of the loader ("gltf")
  74553. */
  74554. name: string;
  74555. /** @hidden */
  74556. extensions: ISceneLoaderPluginExtensions;
  74557. /**
  74558. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  74559. */
  74560. dispose(): void;
  74561. /** @hidden */
  74562. _clear(): void;
  74563. /** @hidden */
  74564. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74565. /** @hidden */
  74566. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74567. /** @hidden */
  74568. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74569. meshes: AbstractMesh[];
  74570. particleSystems: IParticleSystem[];
  74571. skeletons: Skeleton[];
  74572. animationGroups: AnimationGroup[];
  74573. }>;
  74574. /** @hidden */
  74575. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74576. /** @hidden */
  74577. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74578. /** @hidden */
  74579. canDirectLoad(data: string): boolean;
  74580. /** @hidden */
  74581. directLoad(scene: Scene, data: string): any;
  74582. /**
  74583. * The callback that allows custom handling of the root url based on the response url.
  74584. * @param rootUrl the original root url
  74585. * @param responseURL the response url if available
  74586. * @returns the new root url
  74587. */
  74588. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  74589. /** @hidden */
  74590. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  74591. /**
  74592. * The loader state or null if the loader is not active.
  74593. */
  74594. get loaderState(): Nullable<GLTFLoaderState>;
  74595. /**
  74596. * Returns a promise that resolves when the asset is completely loaded.
  74597. * @returns a promise that resolves when the asset is completely loaded.
  74598. */
  74599. whenCompleteAsync(): Promise<void>;
  74600. private _validate;
  74601. private _getLoader;
  74602. private _parseJson;
  74603. private _unpackBinaryAsync;
  74604. private _unpackBinaryV1Async;
  74605. private _unpackBinaryV2Async;
  74606. private static _parseVersion;
  74607. private static _compareVersion;
  74608. private static readonly _logSpaces;
  74609. private _logIndentLevel;
  74610. private _loggingEnabled;
  74611. /** @hidden */
  74612. _log: (message: string) => void;
  74613. /** @hidden */
  74614. _logOpen(message: string): void;
  74615. /** @hidden */
  74616. _logClose(): void;
  74617. private _logEnabled;
  74618. private _logDisabled;
  74619. private _capturePerformanceCounters;
  74620. /** @hidden */
  74621. _startPerformanceCounter: (counterName: string) => void;
  74622. /** @hidden */
  74623. _endPerformanceCounter: (counterName: string) => void;
  74624. private _startPerformanceCounterEnabled;
  74625. private _startPerformanceCounterDisabled;
  74626. private _endPerformanceCounterEnabled;
  74627. private _endPerformanceCounterDisabled;
  74628. }
  74629. }
  74630. declare module BABYLON.GLTF1 {
  74631. /**
  74632. * Enums
  74633. * @hidden
  74634. */
  74635. export enum EComponentType {
  74636. BYTE = 5120,
  74637. UNSIGNED_BYTE = 5121,
  74638. SHORT = 5122,
  74639. UNSIGNED_SHORT = 5123,
  74640. FLOAT = 5126
  74641. }
  74642. /** @hidden */
  74643. export enum EShaderType {
  74644. FRAGMENT = 35632,
  74645. VERTEX = 35633
  74646. }
  74647. /** @hidden */
  74648. export enum EParameterType {
  74649. BYTE = 5120,
  74650. UNSIGNED_BYTE = 5121,
  74651. SHORT = 5122,
  74652. UNSIGNED_SHORT = 5123,
  74653. INT = 5124,
  74654. UNSIGNED_INT = 5125,
  74655. FLOAT = 5126,
  74656. FLOAT_VEC2 = 35664,
  74657. FLOAT_VEC3 = 35665,
  74658. FLOAT_VEC4 = 35666,
  74659. INT_VEC2 = 35667,
  74660. INT_VEC3 = 35668,
  74661. INT_VEC4 = 35669,
  74662. BOOL = 35670,
  74663. BOOL_VEC2 = 35671,
  74664. BOOL_VEC3 = 35672,
  74665. BOOL_VEC4 = 35673,
  74666. FLOAT_MAT2 = 35674,
  74667. FLOAT_MAT3 = 35675,
  74668. FLOAT_MAT4 = 35676,
  74669. SAMPLER_2D = 35678
  74670. }
  74671. /** @hidden */
  74672. export enum ETextureWrapMode {
  74673. CLAMP_TO_EDGE = 33071,
  74674. MIRRORED_REPEAT = 33648,
  74675. REPEAT = 10497
  74676. }
  74677. /** @hidden */
  74678. export enum ETextureFilterType {
  74679. NEAREST = 9728,
  74680. LINEAR = 9728,
  74681. NEAREST_MIPMAP_NEAREST = 9984,
  74682. LINEAR_MIPMAP_NEAREST = 9985,
  74683. NEAREST_MIPMAP_LINEAR = 9986,
  74684. LINEAR_MIPMAP_LINEAR = 9987
  74685. }
  74686. /** @hidden */
  74687. export enum ETextureFormat {
  74688. ALPHA = 6406,
  74689. RGB = 6407,
  74690. RGBA = 6408,
  74691. LUMINANCE = 6409,
  74692. LUMINANCE_ALPHA = 6410
  74693. }
  74694. /** @hidden */
  74695. export enum ECullingType {
  74696. FRONT = 1028,
  74697. BACK = 1029,
  74698. FRONT_AND_BACK = 1032
  74699. }
  74700. /** @hidden */
  74701. export enum EBlendingFunction {
  74702. ZERO = 0,
  74703. ONE = 1,
  74704. SRC_COLOR = 768,
  74705. ONE_MINUS_SRC_COLOR = 769,
  74706. DST_COLOR = 774,
  74707. ONE_MINUS_DST_COLOR = 775,
  74708. SRC_ALPHA = 770,
  74709. ONE_MINUS_SRC_ALPHA = 771,
  74710. DST_ALPHA = 772,
  74711. ONE_MINUS_DST_ALPHA = 773,
  74712. CONSTANT_COLOR = 32769,
  74713. ONE_MINUS_CONSTANT_COLOR = 32770,
  74714. CONSTANT_ALPHA = 32771,
  74715. ONE_MINUS_CONSTANT_ALPHA = 32772,
  74716. SRC_ALPHA_SATURATE = 776
  74717. }
  74718. /** @hidden */
  74719. export interface IGLTFProperty {
  74720. extensions?: {
  74721. [key: string]: any;
  74722. };
  74723. extras?: Object;
  74724. }
  74725. /** @hidden */
  74726. export interface IGLTFChildRootProperty extends IGLTFProperty {
  74727. name?: string;
  74728. }
  74729. /** @hidden */
  74730. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  74731. bufferView: string;
  74732. byteOffset: number;
  74733. byteStride: number;
  74734. count: number;
  74735. type: string;
  74736. componentType: EComponentType;
  74737. max?: number[];
  74738. min?: number[];
  74739. name?: string;
  74740. }
  74741. /** @hidden */
  74742. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  74743. buffer: string;
  74744. byteOffset: number;
  74745. byteLength: number;
  74746. byteStride: number;
  74747. target?: number;
  74748. }
  74749. /** @hidden */
  74750. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  74751. uri: string;
  74752. byteLength?: number;
  74753. type?: string;
  74754. }
  74755. /** @hidden */
  74756. export interface IGLTFShader extends IGLTFChildRootProperty {
  74757. uri: string;
  74758. type: EShaderType;
  74759. }
  74760. /** @hidden */
  74761. export interface IGLTFProgram extends IGLTFChildRootProperty {
  74762. attributes: string[];
  74763. fragmentShader: string;
  74764. vertexShader: string;
  74765. }
  74766. /** @hidden */
  74767. export interface IGLTFTechniqueParameter {
  74768. type: number;
  74769. count?: number;
  74770. semantic?: string;
  74771. node?: string;
  74772. value?: number | boolean | string | Array<any>;
  74773. source?: string;
  74774. babylonValue?: any;
  74775. }
  74776. /** @hidden */
  74777. export interface IGLTFTechniqueCommonProfile {
  74778. lightingModel: string;
  74779. texcoordBindings: Object;
  74780. parameters?: Array<any>;
  74781. }
  74782. /** @hidden */
  74783. export interface IGLTFTechniqueStatesFunctions {
  74784. blendColor?: number[];
  74785. blendEquationSeparate?: number[];
  74786. blendFuncSeparate?: number[];
  74787. colorMask: boolean[];
  74788. cullFace: number[];
  74789. }
  74790. /** @hidden */
  74791. export interface IGLTFTechniqueStates {
  74792. enable: number[];
  74793. functions: IGLTFTechniqueStatesFunctions;
  74794. }
  74795. /** @hidden */
  74796. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  74797. parameters: {
  74798. [key: string]: IGLTFTechniqueParameter;
  74799. };
  74800. program: string;
  74801. attributes: {
  74802. [key: string]: string;
  74803. };
  74804. uniforms: {
  74805. [key: string]: string;
  74806. };
  74807. states: IGLTFTechniqueStates;
  74808. }
  74809. /** @hidden */
  74810. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  74811. technique?: string;
  74812. values: string[];
  74813. }
  74814. /** @hidden */
  74815. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  74816. attributes: {
  74817. [key: string]: string;
  74818. };
  74819. indices: string;
  74820. material: string;
  74821. mode?: number;
  74822. }
  74823. /** @hidden */
  74824. export interface IGLTFMesh extends IGLTFChildRootProperty {
  74825. primitives: IGLTFMeshPrimitive[];
  74826. }
  74827. /** @hidden */
  74828. export interface IGLTFImage extends IGLTFChildRootProperty {
  74829. uri: string;
  74830. }
  74831. /** @hidden */
  74832. export interface IGLTFSampler extends IGLTFChildRootProperty {
  74833. magFilter?: number;
  74834. minFilter?: number;
  74835. wrapS?: number;
  74836. wrapT?: number;
  74837. }
  74838. /** @hidden */
  74839. export interface IGLTFTexture extends IGLTFChildRootProperty {
  74840. sampler: string;
  74841. source: string;
  74842. format?: ETextureFormat;
  74843. internalFormat?: ETextureFormat;
  74844. target?: number;
  74845. type?: number;
  74846. babylonTexture?: Texture;
  74847. }
  74848. /** @hidden */
  74849. export interface IGLTFAmbienLight {
  74850. color?: number[];
  74851. }
  74852. /** @hidden */
  74853. export interface IGLTFDirectionalLight {
  74854. color?: number[];
  74855. }
  74856. /** @hidden */
  74857. export interface IGLTFPointLight {
  74858. color?: number[];
  74859. constantAttenuation?: number;
  74860. linearAttenuation?: number;
  74861. quadraticAttenuation?: number;
  74862. }
  74863. /** @hidden */
  74864. export interface IGLTFSpotLight {
  74865. color?: number[];
  74866. constantAttenuation?: number;
  74867. fallOfAngle?: number;
  74868. fallOffExponent?: number;
  74869. linearAttenuation?: number;
  74870. quadraticAttenuation?: number;
  74871. }
  74872. /** @hidden */
  74873. export interface IGLTFLight extends IGLTFChildRootProperty {
  74874. type: string;
  74875. }
  74876. /** @hidden */
  74877. export interface IGLTFCameraOrthographic {
  74878. xmag: number;
  74879. ymag: number;
  74880. zfar: number;
  74881. znear: number;
  74882. }
  74883. /** @hidden */
  74884. export interface IGLTFCameraPerspective {
  74885. aspectRatio: number;
  74886. yfov: number;
  74887. zfar: number;
  74888. znear: number;
  74889. }
  74890. /** @hidden */
  74891. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74892. type: string;
  74893. }
  74894. /** @hidden */
  74895. export interface IGLTFAnimationChannelTarget {
  74896. id: string;
  74897. path: string;
  74898. }
  74899. /** @hidden */
  74900. export interface IGLTFAnimationChannel {
  74901. sampler: string;
  74902. target: IGLTFAnimationChannelTarget;
  74903. }
  74904. /** @hidden */
  74905. export interface IGLTFAnimationSampler {
  74906. input: string;
  74907. output: string;
  74908. interpolation?: string;
  74909. }
  74910. /** @hidden */
  74911. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74912. channels?: IGLTFAnimationChannel[];
  74913. parameters?: {
  74914. [key: string]: string;
  74915. };
  74916. samplers?: {
  74917. [key: string]: IGLTFAnimationSampler;
  74918. };
  74919. }
  74920. /** @hidden */
  74921. export interface IGLTFNodeInstanceSkin {
  74922. skeletons: string[];
  74923. skin: string;
  74924. meshes: string[];
  74925. }
  74926. /** @hidden */
  74927. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74928. bindShapeMatrix: number[];
  74929. inverseBindMatrices: string;
  74930. jointNames: string[];
  74931. babylonSkeleton?: Skeleton;
  74932. }
  74933. /** @hidden */
  74934. export interface IGLTFNode extends IGLTFChildRootProperty {
  74935. camera?: string;
  74936. children: string[];
  74937. skin?: string;
  74938. jointName?: string;
  74939. light?: string;
  74940. matrix: number[];
  74941. mesh?: string;
  74942. meshes?: string[];
  74943. rotation?: number[];
  74944. scale?: number[];
  74945. translation?: number[];
  74946. babylonNode?: Node;
  74947. }
  74948. /** @hidden */
  74949. export interface IGLTFScene extends IGLTFChildRootProperty {
  74950. nodes: string[];
  74951. }
  74952. /** @hidden */
  74953. export interface IGLTFRuntime {
  74954. extensions: {
  74955. [key: string]: any;
  74956. };
  74957. accessors: {
  74958. [key: string]: IGLTFAccessor;
  74959. };
  74960. buffers: {
  74961. [key: string]: IGLTFBuffer;
  74962. };
  74963. bufferViews: {
  74964. [key: string]: IGLTFBufferView;
  74965. };
  74966. meshes: {
  74967. [key: string]: IGLTFMesh;
  74968. };
  74969. lights: {
  74970. [key: string]: IGLTFLight;
  74971. };
  74972. cameras: {
  74973. [key: string]: IGLTFCamera;
  74974. };
  74975. nodes: {
  74976. [key: string]: IGLTFNode;
  74977. };
  74978. images: {
  74979. [key: string]: IGLTFImage;
  74980. };
  74981. textures: {
  74982. [key: string]: IGLTFTexture;
  74983. };
  74984. shaders: {
  74985. [key: string]: IGLTFShader;
  74986. };
  74987. programs: {
  74988. [key: string]: IGLTFProgram;
  74989. };
  74990. samplers: {
  74991. [key: string]: IGLTFSampler;
  74992. };
  74993. techniques: {
  74994. [key: string]: IGLTFTechnique;
  74995. };
  74996. materials: {
  74997. [key: string]: IGLTFMaterial;
  74998. };
  74999. animations: {
  75000. [key: string]: IGLTFAnimation;
  75001. };
  75002. skins: {
  75003. [key: string]: IGLTFSkins;
  75004. };
  75005. currentScene?: Object;
  75006. scenes: {
  75007. [key: string]: IGLTFScene;
  75008. };
  75009. extensionsUsed: string[];
  75010. extensionsRequired?: string[];
  75011. buffersCount: number;
  75012. shaderscount: number;
  75013. scene: Scene;
  75014. rootUrl: string;
  75015. loadedBufferCount: number;
  75016. loadedBufferViews: {
  75017. [name: string]: ArrayBufferView;
  75018. };
  75019. loadedShaderCount: number;
  75020. importOnlyMeshes: boolean;
  75021. importMeshesNames?: string[];
  75022. dummyNodes: Node[];
  75023. forAssetContainer: boolean;
  75024. }
  75025. /** @hidden */
  75026. export interface INodeToRoot {
  75027. bone: Bone;
  75028. node: IGLTFNode;
  75029. id: string;
  75030. }
  75031. /** @hidden */
  75032. export interface IJointNode {
  75033. node: IGLTFNode;
  75034. id: string;
  75035. }
  75036. }
  75037. declare module BABYLON.GLTF1 {
  75038. /**
  75039. * Utils functions for GLTF
  75040. * @hidden
  75041. */
  75042. export class GLTFUtils {
  75043. /**
  75044. * Sets the given "parameter" matrix
  75045. * @param scene: the Scene object
  75046. * @param source: the source node where to pick the matrix
  75047. * @param parameter: the GLTF technique parameter
  75048. * @param uniformName: the name of the shader's uniform
  75049. * @param shaderMaterial: the shader material
  75050. */
  75051. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75052. /**
  75053. * Sets the given "parameter" matrix
  75054. * @param shaderMaterial: the shader material
  75055. * @param uniform: the name of the shader's uniform
  75056. * @param value: the value of the uniform
  75057. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75058. */
  75059. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75060. /**
  75061. * Returns the wrap mode of the texture
  75062. * @param mode: the mode value
  75063. */
  75064. static GetWrapMode(mode: number): number;
  75065. /**
  75066. * Returns the byte stride giving an accessor
  75067. * @param accessor: the GLTF accessor objet
  75068. */
  75069. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75070. /**
  75071. * Returns the texture filter mode giving a mode value
  75072. * @param mode: the filter mode value
  75073. */
  75074. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75075. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75076. /**
  75077. * Returns a buffer from its accessor
  75078. * @param gltfRuntime: the GLTF runtime
  75079. * @param accessor: the GLTF accessor
  75080. */
  75081. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75082. /**
  75083. * Decodes a buffer view into a string
  75084. * @param view: the buffer view
  75085. */
  75086. static DecodeBufferToText(view: ArrayBufferView): string;
  75087. /**
  75088. * Returns the default material of gltf. Related to
  75089. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75090. * @param scene: the Babylon.js scene
  75091. */
  75092. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75093. private static _DefaultMaterial;
  75094. }
  75095. }
  75096. declare module BABYLON.GLTF1 {
  75097. /**
  75098. * Implementation of the base glTF spec
  75099. * @hidden
  75100. */
  75101. export class GLTFLoaderBase {
  75102. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75103. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75104. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75105. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75106. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75107. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75108. }
  75109. /**
  75110. * glTF V1 Loader
  75111. * @hidden
  75112. */
  75113. export class GLTFLoader implements IGLTFLoader {
  75114. static Extensions: {
  75115. [name: string]: GLTFLoaderExtension;
  75116. };
  75117. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75118. state: Nullable<GLTFLoaderState>;
  75119. dispose(): void;
  75120. private _importMeshAsync;
  75121. /**
  75122. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75123. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75124. * @param scene the scene the meshes should be added to
  75125. * @param forAssetContainer defines if the entities must be stored in the scene
  75126. * @param data gltf data containing information of the meshes in a loaded file
  75127. * @param rootUrl root url to load from
  75128. * @param onProgress event that fires when loading progress has occured
  75129. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75130. */
  75131. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75132. private _loadAsync;
  75133. /**
  75134. * Imports all objects from a loaded gltf file and adds them to the scene
  75135. * @param scene the scene the objects should be added to
  75136. * @param data gltf data containing information of the meshes in a loaded file
  75137. * @param rootUrl root url to load from
  75138. * @param onProgress event that fires when loading progress has occured
  75139. * @returns a promise which completes when objects have been loaded to the scene
  75140. */
  75141. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75142. private _loadShadersAsync;
  75143. private _loadBuffersAsync;
  75144. private _createNodes;
  75145. }
  75146. /** @hidden */
  75147. export abstract class GLTFLoaderExtension {
  75148. private _name;
  75149. constructor(name: string);
  75150. get name(): string;
  75151. /**
  75152. * Defines an override for loading the runtime
  75153. * Return true to stop further extensions from loading the runtime
  75154. */
  75155. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75156. /**
  75157. * Defines an onverride for creating gltf runtime
  75158. * Return true to stop further extensions from creating the runtime
  75159. */
  75160. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75161. /**
  75162. * Defines an override for loading buffers
  75163. * Return true to stop further extensions from loading this buffer
  75164. */
  75165. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  75166. /**
  75167. * Defines an override for loading texture buffers
  75168. * Return true to stop further extensions from loading this texture data
  75169. */
  75170. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75171. /**
  75172. * Defines an override for creating textures
  75173. * Return true to stop further extensions from loading this texture
  75174. */
  75175. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  75176. /**
  75177. * Defines an override for loading shader strings
  75178. * Return true to stop further extensions from loading this shader data
  75179. */
  75180. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75181. /**
  75182. * Defines an override for loading materials
  75183. * Return true to stop further extensions from loading this material
  75184. */
  75185. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75186. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75187. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75188. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75189. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75190. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75191. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75192. private static LoadTextureBufferAsync;
  75193. private static CreateTextureAsync;
  75194. private static ApplyExtensions;
  75195. }
  75196. }
  75197. declare module BABYLON.GLTF1 {
  75198. /** @hidden */
  75199. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75200. private _bin;
  75201. constructor();
  75202. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75203. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75204. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75205. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75206. }
  75207. }
  75208. declare module BABYLON.GLTF1 {
  75209. /** @hidden */
  75210. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75211. constructor();
  75212. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75213. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75214. private _loadTexture;
  75215. }
  75216. }
  75217. declare module BABYLON.GLTF2.Loader {
  75218. /**
  75219. * Loader interface with an index field.
  75220. */
  75221. export interface IArrayItem {
  75222. /**
  75223. * The index of this item in the array.
  75224. */
  75225. index: number;
  75226. }
  75227. /**
  75228. * Loader interface with additional members.
  75229. */
  75230. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75231. /** @hidden */
  75232. _data?: Promise<ArrayBufferView>;
  75233. /** @hidden */
  75234. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75235. }
  75236. /**
  75237. * Loader interface with additional members.
  75238. */
  75239. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75240. }
  75241. /** @hidden */
  75242. export interface _IAnimationSamplerData {
  75243. input: Float32Array;
  75244. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75245. output: Float32Array;
  75246. }
  75247. /**
  75248. * Loader interface with additional members.
  75249. */
  75250. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75251. /** @hidden */
  75252. _data?: Promise<_IAnimationSamplerData>;
  75253. }
  75254. /**
  75255. * Loader interface with additional members.
  75256. */
  75257. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75258. channels: IAnimationChannel[];
  75259. samplers: IAnimationSampler[];
  75260. /** @hidden */
  75261. _babylonAnimationGroup?: AnimationGroup;
  75262. }
  75263. /**
  75264. * Loader interface with additional members.
  75265. */
  75266. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75267. /** @hidden */
  75268. _data?: Promise<ArrayBufferView>;
  75269. }
  75270. /**
  75271. * Loader interface with additional members.
  75272. */
  75273. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75274. /** @hidden */
  75275. _data?: Promise<ArrayBufferView>;
  75276. /** @hidden */
  75277. _babylonBuffer?: Promise<Buffer>;
  75278. }
  75279. /**
  75280. * Loader interface with additional members.
  75281. */
  75282. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75283. }
  75284. /**
  75285. * Loader interface with additional members.
  75286. */
  75287. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75288. /** @hidden */
  75289. _data?: Promise<ArrayBufferView>;
  75290. }
  75291. /**
  75292. * Loader interface with additional members.
  75293. */
  75294. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75295. }
  75296. /**
  75297. * Loader interface with additional members.
  75298. */
  75299. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75300. }
  75301. /**
  75302. * Loader interface with additional members.
  75303. */
  75304. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75305. baseColorTexture?: ITextureInfo;
  75306. metallicRoughnessTexture?: ITextureInfo;
  75307. }
  75308. /**
  75309. * Loader interface with additional members.
  75310. */
  75311. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75312. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75313. normalTexture?: IMaterialNormalTextureInfo;
  75314. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75315. emissiveTexture?: ITextureInfo;
  75316. /** @hidden */
  75317. _data?: {
  75318. [babylonDrawMode: number]: {
  75319. babylonMaterial: Material;
  75320. babylonMeshes: AbstractMesh[];
  75321. promise: Promise<void>;
  75322. };
  75323. };
  75324. }
  75325. /**
  75326. * Loader interface with additional members.
  75327. */
  75328. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75329. primitives: IMeshPrimitive[];
  75330. }
  75331. /**
  75332. * Loader interface with additional members.
  75333. */
  75334. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75335. /** @hidden */
  75336. _instanceData?: {
  75337. babylonSourceMesh: Mesh;
  75338. promise: Promise<any>;
  75339. };
  75340. }
  75341. /**
  75342. * Loader interface with additional members.
  75343. */
  75344. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75345. /**
  75346. * The parent glTF node.
  75347. */
  75348. parent?: INode;
  75349. /** @hidden */
  75350. _babylonTransformNode?: TransformNode;
  75351. /** @hidden */
  75352. _primitiveBabylonMeshes?: AbstractMesh[];
  75353. /** @hidden */
  75354. _babylonBones?: Bone[];
  75355. /** @hidden */
  75356. _numMorphTargets?: number;
  75357. }
  75358. /** @hidden */
  75359. export interface _ISamplerData {
  75360. noMipMaps: boolean;
  75361. samplingMode: number;
  75362. wrapU: number;
  75363. wrapV: number;
  75364. }
  75365. /**
  75366. * Loader interface with additional members.
  75367. */
  75368. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75369. /** @hidden */
  75370. _data?: _ISamplerData;
  75371. }
  75372. /**
  75373. * Loader interface with additional members.
  75374. */
  75375. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75376. }
  75377. /**
  75378. * Loader interface with additional members.
  75379. */
  75380. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75381. /** @hidden */
  75382. _data?: {
  75383. babylonSkeleton: Skeleton;
  75384. promise: Promise<void>;
  75385. };
  75386. }
  75387. /**
  75388. * Loader interface with additional members.
  75389. */
  75390. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75391. }
  75392. /**
  75393. * Loader interface with additional members.
  75394. */
  75395. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75396. }
  75397. /**
  75398. * Loader interface with additional members.
  75399. */
  75400. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75401. accessors?: IAccessor[];
  75402. animations?: IAnimation[];
  75403. buffers?: IBuffer[];
  75404. bufferViews?: IBufferView[];
  75405. cameras?: ICamera[];
  75406. images?: IImage[];
  75407. materials?: IMaterial[];
  75408. meshes?: IMesh[];
  75409. nodes?: INode[];
  75410. samplers?: ISampler[];
  75411. scenes?: IScene[];
  75412. skins?: ISkin[];
  75413. textures?: ITexture[];
  75414. }
  75415. }
  75416. declare module BABYLON.GLTF2 {
  75417. /**
  75418. * Interface for a glTF loader extension.
  75419. */
  75420. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  75421. /**
  75422. * Called after the loader state changes to LOADING.
  75423. */
  75424. onLoading?(): void;
  75425. /**
  75426. * Called after the loader state changes to READY.
  75427. */
  75428. onReady?(): void;
  75429. /**
  75430. * Define this method to modify the default behavior when loading scenes.
  75431. * @param context The context when loading the asset
  75432. * @param scene The glTF scene property
  75433. * @returns A promise that resolves when the load is complete or null if not handled
  75434. */
  75435. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  75436. /**
  75437. * Define this method to modify the default behavior when loading nodes.
  75438. * @param context The context when loading the asset
  75439. * @param node The glTF node property
  75440. * @param assign A function called synchronously after parsing the glTF properties
  75441. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  75442. */
  75443. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75444. /**
  75445. * Define this method to modify the default behavior when loading cameras.
  75446. * @param context The context when loading the asset
  75447. * @param camera The glTF camera property
  75448. * @param assign A function called synchronously after parsing the glTF properties
  75449. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  75450. */
  75451. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75452. /**
  75453. * @hidden
  75454. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  75455. * @param context The context when loading the asset
  75456. * @param primitive The glTF mesh primitive property
  75457. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  75458. */
  75459. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75460. /**
  75461. * @hidden
  75462. * Define this method to modify the default behavior when loading data for mesh primitives.
  75463. * @param context The context when loading the asset
  75464. * @param name The mesh name when loading the asset
  75465. * @param node The glTF node when loading the asset
  75466. * @param mesh The glTF mesh when loading the asset
  75467. * @param primitive The glTF mesh primitive property
  75468. * @param assign A function called synchronously after parsing the glTF properties
  75469. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75470. */
  75471. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75472. /**
  75473. * @hidden
  75474. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  75475. * @param context The context when loading the asset
  75476. * @param material The glTF material property
  75477. * @param assign A function called synchronously after parsing the glTF properties
  75478. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  75479. */
  75480. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75481. /**
  75482. * Define this method to modify the default behavior when creating materials.
  75483. * @param context The context when loading the asset
  75484. * @param material The glTF material property
  75485. * @param babylonDrawMode The draw mode for the Babylon material
  75486. * @returns The Babylon material or null if not handled
  75487. */
  75488. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75489. /**
  75490. * Define this method to modify the default behavior when loading material properties.
  75491. * @param context The context when loading the asset
  75492. * @param material The glTF material property
  75493. * @param babylonMaterial The Babylon material
  75494. * @returns A promise that resolves when the load is complete or null if not handled
  75495. */
  75496. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75497. /**
  75498. * Define this method to modify the default behavior when loading texture infos.
  75499. * @param context The context when loading the asset
  75500. * @param textureInfo The glTF texture info property
  75501. * @param assign A function called synchronously after parsing the glTF properties
  75502. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75503. */
  75504. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75505. /**
  75506. * @hidden
  75507. * Define this method to modify the default behavior when loading textures.
  75508. * @param context The context when loading the asset
  75509. * @param texture The glTF texture property
  75510. * @param assign A function called synchronously after parsing the glTF properties
  75511. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75512. */
  75513. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75514. /**
  75515. * Define this method to modify the default behavior when loading animations.
  75516. * @param context The context when loading the asset
  75517. * @param animation The glTF animation property
  75518. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  75519. */
  75520. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75521. /**
  75522. * @hidden
  75523. * Define this method to modify the default behavior when loading skins.
  75524. * @param context The context when loading the asset
  75525. * @param node The glTF node property
  75526. * @param skin The glTF skin property
  75527. * @returns A promise that resolves when the load is complete or null if not handled
  75528. */
  75529. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  75530. /**
  75531. * @hidden
  75532. * Define this method to modify the default behavior when loading uris.
  75533. * @param context The context when loading the asset
  75534. * @param property The glTF property associated with the uri
  75535. * @param uri The uri to load
  75536. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75537. */
  75538. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75539. /**
  75540. * Define this method to modify the default behavior when loading buffer views.
  75541. * @param context The context when loading the asset
  75542. * @param bufferView The glTF buffer view property
  75543. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75544. */
  75545. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  75546. /**
  75547. * Define this method to modify the default behavior when loading buffers.
  75548. * @param context The context when loading the asset
  75549. * @param buffer The glTF buffer property
  75550. * @param byteOffset The byte offset to load
  75551. * @param byteLength The byte length to load
  75552. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75553. */
  75554. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75555. }
  75556. }
  75557. declare module BABYLON.GLTF2 {
  75558. /**
  75559. * Helper class for working with arrays when loading the glTF asset
  75560. */
  75561. export class ArrayItem {
  75562. /**
  75563. * Gets an item from the given array.
  75564. * @param context The context when loading the asset
  75565. * @param array The array to get the item from
  75566. * @param index The index to the array
  75567. * @returns The array item
  75568. */
  75569. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  75570. /**
  75571. * Assign an `index` field to each item of the given array.
  75572. * @param array The array of items
  75573. */
  75574. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  75575. }
  75576. /**
  75577. * The glTF 2.0 loader
  75578. */
  75579. export class GLTFLoader implements IGLTFLoader {
  75580. /** @hidden */
  75581. _completePromises: Promise<any>[];
  75582. /** @hidden */
  75583. _forAssetContainer: boolean;
  75584. /** Storage */
  75585. _babylonLights: Light[];
  75586. private _disposed;
  75587. private _parent;
  75588. private _state;
  75589. private _extensions;
  75590. private _rootUrl;
  75591. private _fileName;
  75592. private _uniqueRootUrl;
  75593. private _gltf;
  75594. private _bin;
  75595. private _babylonScene;
  75596. private _rootBabylonMesh;
  75597. private _defaultBabylonMaterialData;
  75598. private _progressCallback?;
  75599. private _requests;
  75600. private static _RegisteredExtensions;
  75601. /**
  75602. * The default glTF sampler.
  75603. */
  75604. static readonly DefaultSampler: ISampler;
  75605. /**
  75606. * Registers a loader extension.
  75607. * @param name The name of the loader extension.
  75608. * @param factory The factory function that creates the loader extension.
  75609. */
  75610. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  75611. /**
  75612. * Unregisters a loader extension.
  75613. * @param name The name of the loader extension.
  75614. * @returns A boolean indicating whether the extension has been unregistered
  75615. */
  75616. static UnregisterExtension(name: string): boolean;
  75617. /**
  75618. * The loader state.
  75619. */
  75620. get state(): Nullable<GLTFLoaderState>;
  75621. /**
  75622. * The object that represents the glTF JSON.
  75623. */
  75624. get gltf(): IGLTF;
  75625. /**
  75626. * The BIN chunk of a binary glTF.
  75627. */
  75628. get bin(): Nullable<IDataBuffer>;
  75629. /**
  75630. * The parent file loader.
  75631. */
  75632. get parent(): GLTFFileLoader;
  75633. /**
  75634. * The Babylon scene when loading the asset.
  75635. */
  75636. get babylonScene(): Scene;
  75637. /**
  75638. * The root Babylon mesh when loading the asset.
  75639. */
  75640. get rootBabylonMesh(): Mesh;
  75641. /** @hidden */
  75642. constructor(parent: GLTFFileLoader);
  75643. /** @hidden */
  75644. dispose(): void;
  75645. /** @hidden */
  75646. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  75647. /** @hidden */
  75648. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75649. private _loadAsync;
  75650. private _loadData;
  75651. private _setupData;
  75652. private _loadExtensions;
  75653. private _checkExtensions;
  75654. private _setState;
  75655. private _createRootNode;
  75656. /**
  75657. * Loads a glTF scene.
  75658. * @param context The context when loading the asset
  75659. * @param scene The glTF scene property
  75660. * @returns A promise that resolves when the load is complete
  75661. */
  75662. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  75663. private _forEachPrimitive;
  75664. private _getMeshes;
  75665. private _getTransformNodes;
  75666. private _getSkeletons;
  75667. private _getAnimationGroups;
  75668. private _startAnimations;
  75669. /**
  75670. * Loads a glTF node.
  75671. * @param context The context when loading the asset
  75672. * @param node The glTF node property
  75673. * @param assign A function called synchronously after parsing the glTF properties
  75674. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  75675. */
  75676. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  75677. private _loadMeshAsync;
  75678. /**
  75679. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75680. * @param context The context when loading the asset
  75681. * @param name The mesh name when loading the asset
  75682. * @param node The glTF node when loading the asset
  75683. * @param mesh The glTF mesh when loading the asset
  75684. * @param primitive The glTF mesh primitive property
  75685. * @param assign A function called synchronously after parsing the glTF properties
  75686. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75687. */
  75688. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75689. private _loadVertexDataAsync;
  75690. private _createMorphTargets;
  75691. private _loadMorphTargetsAsync;
  75692. private _loadMorphTargetVertexDataAsync;
  75693. private static _LoadTransform;
  75694. private _loadSkinAsync;
  75695. private _loadBones;
  75696. private _loadBone;
  75697. private _loadSkinInverseBindMatricesDataAsync;
  75698. private _updateBoneMatrices;
  75699. private _getNodeMatrix;
  75700. /**
  75701. * Loads a glTF camera.
  75702. * @param context The context when loading the asset
  75703. * @param camera The glTF camera property
  75704. * @param assign A function called synchronously after parsing the glTF properties
  75705. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  75706. */
  75707. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  75708. private _loadAnimationsAsync;
  75709. /**
  75710. * Loads a glTF animation.
  75711. * @param context The context when loading the asset
  75712. * @param animation The glTF animation property
  75713. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  75714. */
  75715. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  75716. /**
  75717. * @hidden Loads a glTF animation channel.
  75718. * @param context The context when loading the asset
  75719. * @param animationContext The context of the animation when loading the asset
  75720. * @param animation The glTF animation property
  75721. * @param channel The glTF animation channel property
  75722. * @param babylonAnimationGroup The babylon animation group property
  75723. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  75724. * @returns A void promise when the channel load is complete
  75725. */
  75726. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  75727. private _loadAnimationSamplerAsync;
  75728. private _loadBufferAsync;
  75729. /**
  75730. * Loads a glTF buffer view.
  75731. * @param context The context when loading the asset
  75732. * @param bufferView The glTF buffer view property
  75733. * @returns A promise that resolves with the loaded data when the load is complete
  75734. */
  75735. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  75736. private _loadAccessorAsync;
  75737. /** @hidden */
  75738. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  75739. private _loadIndicesAccessorAsync;
  75740. private _loadVertexBufferViewAsync;
  75741. private _loadVertexAccessorAsync;
  75742. private _loadMaterialMetallicRoughnessPropertiesAsync;
  75743. /** @hidden */
  75744. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  75745. private _createDefaultMaterial;
  75746. /**
  75747. * Creates a Babylon material from a glTF material.
  75748. * @param context The context when loading the asset
  75749. * @param material The glTF material property
  75750. * @param babylonDrawMode The draw mode for the Babylon material
  75751. * @returns The Babylon material
  75752. */
  75753. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  75754. /**
  75755. * Loads properties from a glTF material into a Babylon material.
  75756. * @param context The context when loading the asset
  75757. * @param material The glTF material property
  75758. * @param babylonMaterial The Babylon material
  75759. * @returns A promise that resolves when the load is complete
  75760. */
  75761. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75762. /**
  75763. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  75764. * @param context The context when loading the asset
  75765. * @param material The glTF material property
  75766. * @param babylonMaterial The Babylon material
  75767. * @returns A promise that resolves when the load is complete
  75768. */
  75769. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75770. /**
  75771. * Loads the alpha properties from a glTF material into a Babylon material.
  75772. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  75773. * @param context The context when loading the asset
  75774. * @param material The glTF material property
  75775. * @param babylonMaterial The Babylon material
  75776. */
  75777. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  75778. /**
  75779. * Loads a glTF texture info.
  75780. * @param context The context when loading the asset
  75781. * @param textureInfo The glTF texture info property
  75782. * @param assign A function called synchronously after parsing the glTF properties
  75783. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  75784. */
  75785. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75786. /** @hidden */
  75787. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75788. /** @hidden */
  75789. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75790. private _loadSampler;
  75791. /**
  75792. * Loads a glTF image.
  75793. * @param context The context when loading the asset
  75794. * @param image The glTF image property
  75795. * @returns A promise that resolves with the loaded data when the load is complete
  75796. */
  75797. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  75798. /**
  75799. * Loads a glTF uri.
  75800. * @param context The context when loading the asset
  75801. * @param property The glTF property associated with the uri
  75802. * @param uri The base64 or relative uri
  75803. * @returns A promise that resolves with the loaded data when the load is complete
  75804. */
  75805. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  75806. private _onProgress;
  75807. /**
  75808. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  75809. * @param babylonObject the Babylon object with metadata
  75810. * @param pointer the JSON pointer
  75811. */
  75812. static AddPointerMetadata(babylonObject: {
  75813. metadata: any;
  75814. }, pointer: string): void;
  75815. private static _GetTextureWrapMode;
  75816. private static _GetTextureSamplingMode;
  75817. private static _GetTypedArrayConstructor;
  75818. private static _GetTypedArray;
  75819. private static _GetNumComponents;
  75820. private static _ValidateUri;
  75821. private static _GetDrawMode;
  75822. private _compileMaterialsAsync;
  75823. private _compileShadowGeneratorsAsync;
  75824. private _forEachExtensions;
  75825. private _applyExtensions;
  75826. private _extensionsOnLoading;
  75827. private _extensionsOnReady;
  75828. private _extensionsLoadSceneAsync;
  75829. private _extensionsLoadNodeAsync;
  75830. private _extensionsLoadCameraAsync;
  75831. private _extensionsLoadVertexDataAsync;
  75832. private _extensionsLoadMeshPrimitiveAsync;
  75833. private _extensionsLoadMaterialAsync;
  75834. private _extensionsCreateMaterial;
  75835. private _extensionsLoadMaterialPropertiesAsync;
  75836. private _extensionsLoadTextureInfoAsync;
  75837. private _extensionsLoadTextureAsync;
  75838. private _extensionsLoadAnimationAsync;
  75839. private _extensionsLoadSkinAsync;
  75840. private _extensionsLoadUriAsync;
  75841. private _extensionsLoadBufferViewAsync;
  75842. private _extensionsLoadBufferAsync;
  75843. /**
  75844. * Helper method called by a loader extension to load an glTF extension.
  75845. * @param context The context when loading the asset
  75846. * @param property The glTF property to load the extension from
  75847. * @param extensionName The name of the extension to load
  75848. * @param actionAsync The action to run
  75849. * @returns The promise returned by actionAsync or null if the extension does not exist
  75850. */
  75851. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75852. /**
  75853. * Helper method called by a loader extension to load a glTF extra.
  75854. * @param context The context when loading the asset
  75855. * @param property The glTF property to load the extra from
  75856. * @param extensionName The name of the extension to load
  75857. * @param actionAsync The action to run
  75858. * @returns The promise returned by actionAsync or null if the extra does not exist
  75859. */
  75860. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75861. /**
  75862. * Checks for presence of an extension.
  75863. * @param name The name of the extension to check
  75864. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  75865. */
  75866. isExtensionUsed(name: string): boolean;
  75867. /**
  75868. * Increments the indentation level and logs a message.
  75869. * @param message The message to log
  75870. */
  75871. logOpen(message: string): void;
  75872. /**
  75873. * Decrements the indentation level.
  75874. */
  75875. logClose(): void;
  75876. /**
  75877. * Logs a message
  75878. * @param message The message to log
  75879. */
  75880. log(message: string): void;
  75881. /**
  75882. * Starts a performance counter.
  75883. * @param counterName The name of the performance counter
  75884. */
  75885. startPerformanceCounter(counterName: string): void;
  75886. /**
  75887. * Ends a performance counter.
  75888. * @param counterName The name of the performance counter
  75889. */
  75890. endPerformanceCounter(counterName: string): void;
  75891. }
  75892. }
  75893. declare module BABYLON.GLTF2.Loader.Extensions {
  75894. /**
  75895. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75896. */
  75897. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75898. /**
  75899. * The name of this extension.
  75900. */
  75901. readonly name: string;
  75902. /**
  75903. * Defines whether this extension is enabled.
  75904. */
  75905. enabled: boolean;
  75906. private _loader;
  75907. private _lights?;
  75908. /** @hidden */
  75909. constructor(loader: GLTFLoader);
  75910. /** @hidden */
  75911. dispose(): void;
  75912. /** @hidden */
  75913. onLoading(): void;
  75914. /** @hidden */
  75915. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75916. private _loadLightAsync;
  75917. }
  75918. }
  75919. declare module BABYLON.GLTF2.Loader.Extensions {
  75920. /**
  75921. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75922. */
  75923. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75924. /**
  75925. * The name of this extension.
  75926. */
  75927. readonly name: string;
  75928. /**
  75929. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75930. */
  75931. dracoCompression?: DracoCompression;
  75932. /**
  75933. * Defines whether this extension is enabled.
  75934. */
  75935. enabled: boolean;
  75936. private _loader;
  75937. /** @hidden */
  75938. constructor(loader: GLTFLoader);
  75939. /** @hidden */
  75940. dispose(): void;
  75941. /** @hidden */
  75942. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75943. }
  75944. }
  75945. declare module BABYLON.GLTF2.Loader.Extensions {
  75946. /**
  75947. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  75948. */
  75949. export class KHR_lights implements IGLTFLoaderExtension {
  75950. /**
  75951. * The name of this extension.
  75952. */
  75953. readonly name: string;
  75954. /**
  75955. * Defines whether this extension is enabled.
  75956. */
  75957. enabled: boolean;
  75958. private _loader;
  75959. private _lights?;
  75960. /** @hidden */
  75961. constructor(loader: GLTFLoader);
  75962. /** @hidden */
  75963. dispose(): void;
  75964. /** @hidden */
  75965. onLoading(): void;
  75966. /** @hidden */
  75967. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75968. }
  75969. }
  75970. declare module BABYLON.GLTF2.Loader.Extensions {
  75971. /**
  75972. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75973. */
  75974. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75975. /**
  75976. * The name of this extension.
  75977. */
  75978. readonly name: string;
  75979. /**
  75980. * Defines whether this extension is enabled.
  75981. */
  75982. enabled: boolean;
  75983. /**
  75984. * Defines a number that determines the order the extensions are applied.
  75985. */
  75986. order: number;
  75987. private _loader;
  75988. /** @hidden */
  75989. constructor(loader: GLTFLoader);
  75990. /** @hidden */
  75991. dispose(): void;
  75992. /** @hidden */
  75993. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75994. private _loadSpecularGlossinessPropertiesAsync;
  75995. }
  75996. }
  75997. declare module BABYLON.GLTF2.Loader.Extensions {
  75998. /**
  75999. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76000. */
  76001. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76002. /**
  76003. * The name of this extension.
  76004. */
  76005. readonly name: string;
  76006. /**
  76007. * Defines whether this extension is enabled.
  76008. */
  76009. enabled: boolean;
  76010. /**
  76011. * Defines a number that determines the order the extensions are applied.
  76012. */
  76013. order: number;
  76014. private _loader;
  76015. /** @hidden */
  76016. constructor(loader: GLTFLoader);
  76017. /** @hidden */
  76018. dispose(): void;
  76019. /** @hidden */
  76020. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76021. private _loadUnlitPropertiesAsync;
  76022. }
  76023. }
  76024. declare module BABYLON.GLTF2.Loader.Extensions {
  76025. /**
  76026. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76027. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76028. * !!! Experimental Extension Subject to Changes !!!
  76029. */
  76030. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76031. /**
  76032. * The name of this extension.
  76033. */
  76034. readonly name: string;
  76035. /**
  76036. * Defines whether this extension is enabled.
  76037. */
  76038. enabled: boolean;
  76039. /**
  76040. * Defines a number that determines the order the extensions are applied.
  76041. */
  76042. order: number;
  76043. private _loader;
  76044. /** @hidden */
  76045. constructor(loader: GLTFLoader);
  76046. /** @hidden */
  76047. dispose(): void;
  76048. /** @hidden */
  76049. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76050. private _loadClearCoatPropertiesAsync;
  76051. }
  76052. }
  76053. declare module BABYLON.GLTF2.Loader.Extensions {
  76054. /**
  76055. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76056. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76057. * !!! Experimental Extension Subject to Changes !!!
  76058. */
  76059. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76060. /**
  76061. * The name of this extension.
  76062. */
  76063. readonly name: string;
  76064. /**
  76065. * Defines whether this extension is enabled.
  76066. */
  76067. enabled: boolean;
  76068. /**
  76069. * Defines a number that determines the order the extensions are applied.
  76070. */
  76071. order: number;
  76072. private _loader;
  76073. /** @hidden */
  76074. constructor(loader: GLTFLoader);
  76075. /** @hidden */
  76076. dispose(): void;
  76077. /** @hidden */
  76078. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76079. private _loadSheenPropertiesAsync;
  76080. }
  76081. }
  76082. declare module BABYLON.GLTF2.Loader.Extensions {
  76083. /**
  76084. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76085. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76086. * !!! Experimental Extension Subject to Changes !!!
  76087. */
  76088. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76089. /**
  76090. * The name of this extension.
  76091. */
  76092. readonly name: string;
  76093. /**
  76094. * Defines whether this extension is enabled.
  76095. */
  76096. enabled: boolean;
  76097. /**
  76098. * Defines a number that determines the order the extensions are applied.
  76099. */
  76100. order: number;
  76101. private _loader;
  76102. /** @hidden */
  76103. constructor(loader: GLTFLoader);
  76104. /** @hidden */
  76105. dispose(): void;
  76106. /** @hidden */
  76107. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76108. private _loadSpecularPropertiesAsync;
  76109. }
  76110. }
  76111. declare module BABYLON.GLTF2.Loader.Extensions {
  76112. /**
  76113. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76114. * [Playground Sample](//TODO)
  76115. * !!! Experimental Extension Subject to Changes !!!
  76116. */
  76117. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  76118. /**
  76119. * The name of this extension.
  76120. */
  76121. readonly name: string;
  76122. /**
  76123. * Defines whether this extension is enabled.
  76124. */
  76125. enabled: boolean;
  76126. private _loader;
  76127. /** @hidden */
  76128. constructor(loader: GLTFLoader);
  76129. /** @hidden */
  76130. dispose(): void;
  76131. /** @hidden */
  76132. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76133. }
  76134. }
  76135. declare module BABYLON.GLTF2.Loader.Extensions {
  76136. /**
  76137. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76138. */
  76139. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76140. /**
  76141. * The name of this extension.
  76142. */
  76143. readonly name: string;
  76144. /**
  76145. * Defines whether this extension is enabled.
  76146. */
  76147. enabled: boolean;
  76148. /** @hidden */
  76149. constructor(loader: GLTFLoader);
  76150. /** @hidden */
  76151. dispose(): void;
  76152. }
  76153. }
  76154. declare module BABYLON.GLTF2.Loader.Extensions {
  76155. /**
  76156. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  76157. * !!! Experimental Extension Subject to Changes !!!
  76158. */
  76159. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  76160. /** The name of this extension. */
  76161. readonly name: string;
  76162. /** Defines whether this extension is enabled. */
  76163. enabled: boolean;
  76164. private _loader;
  76165. /** @hidden */
  76166. constructor(loader: GLTFLoader);
  76167. /** @hidden */
  76168. dispose(): void;
  76169. /** @hidden */
  76170. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76171. }
  76172. }
  76173. declare module BABYLON.GLTF2.Loader.Extensions {
  76174. /**
  76175. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  76176. */
  76177. export class KHR_texture_transform implements IGLTFLoaderExtension {
  76178. /**
  76179. * The name of this extension.
  76180. */
  76181. readonly name: string;
  76182. /**
  76183. * Defines whether this extension is enabled.
  76184. */
  76185. enabled: boolean;
  76186. private _loader;
  76187. /** @hidden */
  76188. constructor(loader: GLTFLoader);
  76189. /** @hidden */
  76190. dispose(): void;
  76191. /** @hidden */
  76192. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76193. }
  76194. }
  76195. declare module BABYLON.GLTF2.Loader.Extensions {
  76196. /**
  76197. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  76198. */
  76199. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  76200. /**
  76201. * The name of this extension.
  76202. */
  76203. readonly name: string;
  76204. /**
  76205. * Defines whether this extension is enabled.
  76206. */
  76207. enabled: boolean;
  76208. private _loader;
  76209. private _clips;
  76210. private _emitters;
  76211. /** @hidden */
  76212. constructor(loader: GLTFLoader);
  76213. /** @hidden */
  76214. dispose(): void;
  76215. /** @hidden */
  76216. onLoading(): void;
  76217. /** @hidden */
  76218. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76219. /** @hidden */
  76220. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76221. /** @hidden */
  76222. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76223. private _loadClipAsync;
  76224. private _loadEmitterAsync;
  76225. private _getEventAction;
  76226. private _loadAnimationEventAsync;
  76227. }
  76228. }
  76229. declare module BABYLON.GLTF2.Loader.Extensions {
  76230. /**
  76231. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  76232. */
  76233. export class MSFT_lod implements IGLTFLoaderExtension {
  76234. /**
  76235. * The name of this extension.
  76236. */
  76237. readonly name: string;
  76238. /**
  76239. * Defines whether this extension is enabled.
  76240. */
  76241. enabled: boolean;
  76242. /**
  76243. * Defines a number that determines the order the extensions are applied.
  76244. */
  76245. order: number;
  76246. /**
  76247. * Maximum number of LODs to load, starting from the lowest LOD.
  76248. */
  76249. maxLODsToLoad: number;
  76250. /**
  76251. * Observable raised when all node LODs of one level are loaded.
  76252. * The event data is the index of the loaded LOD starting from zero.
  76253. * Dispose the loader to cancel the loading of the next level of LODs.
  76254. */
  76255. onNodeLODsLoadedObservable: Observable<number>;
  76256. /**
  76257. * Observable raised when all material LODs of one level are loaded.
  76258. * The event data is the index of the loaded LOD starting from zero.
  76259. * Dispose the loader to cancel the loading of the next level of LODs.
  76260. */
  76261. onMaterialLODsLoadedObservable: Observable<number>;
  76262. private _loader;
  76263. private _nodeIndexLOD;
  76264. private _nodeSignalLODs;
  76265. private _nodePromiseLODs;
  76266. private _materialIndexLOD;
  76267. private _materialSignalLODs;
  76268. private _materialPromiseLODs;
  76269. private _indexLOD;
  76270. private _bufferLODs;
  76271. /** @hidden */
  76272. constructor(loader: GLTFLoader);
  76273. /** @hidden */
  76274. dispose(): void;
  76275. /** @hidden */
  76276. onReady(): void;
  76277. /** @hidden */
  76278. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76279. /** @hidden */
  76280. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76281. /** @hidden */
  76282. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76283. /** @hidden */
  76284. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76285. /** @hidden */
  76286. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76287. private _loadBufferLOD;
  76288. /**
  76289. * Gets an array of LOD properties from lowest to highest.
  76290. */
  76291. private _getLODs;
  76292. private _disposeTransformNode;
  76293. private _disposeMaterials;
  76294. }
  76295. }
  76296. declare module BABYLON.GLTF2.Loader.Extensions {
  76297. /** @hidden */
  76298. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76299. readonly name: string;
  76300. enabled: boolean;
  76301. private _loader;
  76302. constructor(loader: GLTFLoader);
  76303. dispose(): void;
  76304. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76305. }
  76306. }
  76307. declare module BABYLON.GLTF2.Loader.Extensions {
  76308. /** @hidden */
  76309. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76310. readonly name: string;
  76311. enabled: boolean;
  76312. private _loader;
  76313. constructor(loader: GLTFLoader);
  76314. dispose(): void;
  76315. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76316. }
  76317. }
  76318. declare module BABYLON.GLTF2.Loader.Extensions {
  76319. /**
  76320. * Store glTF extras (if present) in BJS objects' metadata
  76321. */
  76322. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76323. /**
  76324. * The name of this extension.
  76325. */
  76326. readonly name: string;
  76327. /**
  76328. * Defines whether this extension is enabled.
  76329. */
  76330. enabled: boolean;
  76331. private _loader;
  76332. private _assignExtras;
  76333. /** @hidden */
  76334. constructor(loader: GLTFLoader);
  76335. /** @hidden */
  76336. dispose(): void;
  76337. /** @hidden */
  76338. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76339. /** @hidden */
  76340. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76341. /** @hidden */
  76342. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76343. }
  76344. }
  76345. declare module BABYLON {
  76346. /**
  76347. * Class reading and parsing the MTL file bundled with the obj file.
  76348. */
  76349. export class MTLFileLoader {
  76350. /**
  76351. * Invert Y-Axis of referenced textures on load
  76352. */
  76353. static INVERT_TEXTURE_Y: boolean;
  76354. /**
  76355. * All material loaded from the mtl will be set here
  76356. */
  76357. materials: StandardMaterial[];
  76358. /**
  76359. * This function will read the mtl file and create each material described inside
  76360. * This function could be improve by adding :
  76361. * -some component missing (Ni, Tf...)
  76362. * -including the specific options available
  76363. *
  76364. * @param scene defines the scene the material will be created in
  76365. * @param data defines the mtl data to parse
  76366. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76367. * @param forAssetContainer defines if the material should be registered in the scene
  76368. */
  76369. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  76370. /**
  76371. * Gets the texture for the material.
  76372. *
  76373. * If the material is imported from input file,
  76374. * We sanitize the url to ensure it takes the textre from aside the material.
  76375. *
  76376. * @param rootUrl The root url to load from
  76377. * @param value The value stored in the mtl
  76378. * @return The Texture
  76379. */
  76380. private static _getTexture;
  76381. }
  76382. }
  76383. declare module BABYLON {
  76384. /**
  76385. * Options for loading OBJ/MTL files
  76386. */
  76387. type MeshLoadOptions = {
  76388. /**
  76389. * Defines if UVs are optimized by default during load.
  76390. */
  76391. OptimizeWithUV: boolean;
  76392. /**
  76393. * Defines custom scaling of UV coordinates of loaded meshes.
  76394. */
  76395. UVScaling: Vector2;
  76396. /**
  76397. * Invert model on y-axis (does a model scaling inversion)
  76398. */
  76399. InvertY: boolean;
  76400. /**
  76401. * Invert Y-Axis of referenced textures on load
  76402. */
  76403. InvertTextureY: boolean;
  76404. /**
  76405. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76406. */
  76407. ImportVertexColors: boolean;
  76408. /**
  76409. * Compute the normals for the model, even if normals are present in the file.
  76410. */
  76411. ComputeNormals: boolean;
  76412. /**
  76413. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76414. */
  76415. SkipMaterials: boolean;
  76416. /**
  76417. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76418. */
  76419. MaterialLoadingFailsSilently: boolean;
  76420. };
  76421. /**
  76422. * OBJ file type loader.
  76423. * This is a babylon scene loader plugin.
  76424. */
  76425. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76426. /**
  76427. * Defines if UVs are optimized by default during load.
  76428. */
  76429. static OPTIMIZE_WITH_UV: boolean;
  76430. /**
  76431. * Invert model on y-axis (does a model scaling inversion)
  76432. */
  76433. static INVERT_Y: boolean;
  76434. /**
  76435. * Invert Y-Axis of referenced textures on load
  76436. */
  76437. static get INVERT_TEXTURE_Y(): boolean;
  76438. static set INVERT_TEXTURE_Y(value: boolean);
  76439. /**
  76440. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76441. */
  76442. static IMPORT_VERTEX_COLORS: boolean;
  76443. /**
  76444. * Compute the normals for the model, even if normals are present in the file.
  76445. */
  76446. static COMPUTE_NORMALS: boolean;
  76447. /**
  76448. * Defines custom scaling of UV coordinates of loaded meshes.
  76449. */
  76450. static UV_SCALING: Vector2;
  76451. /**
  76452. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76453. */
  76454. static SKIP_MATERIALS: boolean;
  76455. /**
  76456. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76457. *
  76458. * Defaults to true for backwards compatibility.
  76459. */
  76460. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  76461. /**
  76462. * Defines the name of the plugin.
  76463. */
  76464. name: string;
  76465. /**
  76466. * Defines the extension the plugin is able to load.
  76467. */
  76468. extensions: string;
  76469. /** @hidden */
  76470. obj: RegExp;
  76471. /** @hidden */
  76472. group: RegExp;
  76473. /** @hidden */
  76474. mtllib: RegExp;
  76475. /** @hidden */
  76476. usemtl: RegExp;
  76477. /** @hidden */
  76478. smooth: RegExp;
  76479. /** @hidden */
  76480. vertexPattern: RegExp;
  76481. /** @hidden */
  76482. normalPattern: RegExp;
  76483. /** @hidden */
  76484. uvPattern: RegExp;
  76485. /** @hidden */
  76486. facePattern1: RegExp;
  76487. /** @hidden */
  76488. facePattern2: RegExp;
  76489. /** @hidden */
  76490. facePattern3: RegExp;
  76491. /** @hidden */
  76492. facePattern4: RegExp;
  76493. /** @hidden */
  76494. facePattern5: RegExp;
  76495. private _forAssetContainer;
  76496. private _meshLoadOptions;
  76497. /**
  76498. * Creates loader for .OBJ files
  76499. *
  76500. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  76501. */
  76502. constructor(meshLoadOptions?: MeshLoadOptions);
  76503. private static get currentMeshLoadOptions();
  76504. /**
  76505. * Calls synchronously the MTL file attached to this obj.
  76506. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  76507. * Without this function materials are not displayed in the first frame (but displayed after).
  76508. * In consequence it is impossible to get material information in your HTML file
  76509. *
  76510. * @param url The URL of the MTL file
  76511. * @param rootUrl
  76512. * @param onSuccess Callback function to be called when the MTL file is loaded
  76513. * @private
  76514. */
  76515. private _loadMTL;
  76516. /**
  76517. * Instantiates a OBJ file loader plugin.
  76518. * @returns the created plugin
  76519. */
  76520. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  76521. /**
  76522. * If the data string can be loaded directly.
  76523. *
  76524. * @param data string containing the file data
  76525. * @returns if the data can be loaded directly
  76526. */
  76527. canDirectLoad(data: string): boolean;
  76528. /**
  76529. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  76530. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76531. * @param scene the scene the meshes should be added to
  76532. * @param data the OBJ data to load
  76533. * @param rootUrl root url to load from
  76534. * @param onProgress event that fires when loading progress has occured
  76535. * @param fileName Defines the name of the file to load
  76536. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76537. */
  76538. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76539. meshes: AbstractMesh[];
  76540. particleSystems: IParticleSystem[];
  76541. skeletons: Skeleton[];
  76542. animationGroups: AnimationGroup[];
  76543. }>;
  76544. /**
  76545. * Imports all objects from the loaded OBJ data and adds them to the scene
  76546. * @param scene the scene the objects should be added to
  76547. * @param data the OBJ data to load
  76548. * @param rootUrl root url to load from
  76549. * @param onProgress event that fires when loading progress has occured
  76550. * @param fileName Defines the name of the file to load
  76551. * @returns a promise which completes when objects have been loaded to the scene
  76552. */
  76553. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76554. /**
  76555. * Load into an asset container.
  76556. * @param scene The scene to load into
  76557. * @param data The data to import
  76558. * @param rootUrl The root url for scene and resources
  76559. * @param onProgress The callback when the load progresses
  76560. * @param fileName Defines the name of the file to load
  76561. * @returns The loaded asset container
  76562. */
  76563. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76564. /**
  76565. * Read the OBJ file and create an Array of meshes.
  76566. * Each mesh contains all information given by the OBJ and the MTL file.
  76567. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  76568. *
  76569. * @param meshesNames
  76570. * @param scene Scene The scene where are displayed the data
  76571. * @param data String The content of the obj file
  76572. * @param rootUrl String The path to the folder
  76573. * @returns Array<AbstractMesh>
  76574. * @private
  76575. */
  76576. private _parseSolid;
  76577. }
  76578. }
  76579. declare module BABYLON {
  76580. /**
  76581. * STL file type loader.
  76582. * This is a babylon scene loader plugin.
  76583. */
  76584. export class STLFileLoader implements ISceneLoaderPlugin {
  76585. /** @hidden */
  76586. solidPattern: RegExp;
  76587. /** @hidden */
  76588. facetsPattern: RegExp;
  76589. /** @hidden */
  76590. normalPattern: RegExp;
  76591. /** @hidden */
  76592. vertexPattern: RegExp;
  76593. /**
  76594. * Defines the name of the plugin.
  76595. */
  76596. name: string;
  76597. /**
  76598. * Defines the extensions the stl loader is able to load.
  76599. * force data to come in as an ArrayBuffer
  76600. * we'll convert to string if it looks like it's an ASCII .stl
  76601. */
  76602. extensions: ISceneLoaderPluginExtensions;
  76603. /**
  76604. * Import meshes into a scene.
  76605. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  76606. * @param scene The scene to import into
  76607. * @param data The data to import
  76608. * @param rootUrl The root url for scene and resources
  76609. * @param meshes The meshes array to import into
  76610. * @param particleSystems The particle systems array to import into
  76611. * @param skeletons The skeletons array to import into
  76612. * @param onError The callback when import fails
  76613. * @returns True if successful or false otherwise
  76614. */
  76615. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  76616. /**
  76617. * Load into a scene.
  76618. * @param scene The scene to load into
  76619. * @param data The data to import
  76620. * @param rootUrl The root url for scene and resources
  76621. * @param onError The callback when import fails
  76622. * @returns true if successful or false otherwise
  76623. */
  76624. load(scene: Scene, data: any, rootUrl: string): boolean;
  76625. /**
  76626. * Load into an asset container.
  76627. * @param scene The scene to load into
  76628. * @param data The data to import
  76629. * @param rootUrl The root url for scene and resources
  76630. * @param onError The callback when import fails
  76631. * @returns The loaded asset container
  76632. */
  76633. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  76634. private _isBinary;
  76635. private _parseBinary;
  76636. private _parseASCII;
  76637. }
  76638. }
  76639. declare module BABYLON {
  76640. /**
  76641. * Class for generating OBJ data from a Babylon scene.
  76642. */
  76643. export class OBJExport {
  76644. /**
  76645. * Exports the geometry of a Mesh array in .OBJ file format (text)
  76646. * @param mesh defines the list of meshes to serialize
  76647. * @param materials defines if materials should be exported
  76648. * @param matlibname defines the name of the associated mtl file
  76649. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  76650. * @returns the OBJ content
  76651. */
  76652. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  76653. /**
  76654. * Exports the material(s) of a mesh in .MTL file format (text)
  76655. * @param mesh defines the mesh to extract the material from
  76656. * @returns the mtl content
  76657. */
  76658. static MTL(mesh: Mesh): string;
  76659. }
  76660. }
  76661. declare module BABYLON {
  76662. /** @hidden */
  76663. export var __IGLTFExporterExtension: number;
  76664. /**
  76665. * Interface for extending the exporter
  76666. * @hidden
  76667. */
  76668. export interface IGLTFExporterExtension {
  76669. /**
  76670. * The name of this extension
  76671. */
  76672. readonly name: string;
  76673. /**
  76674. * Defines whether this extension is enabled
  76675. */
  76676. enabled: boolean;
  76677. /**
  76678. * Defines whether this extension is required
  76679. */
  76680. required: boolean;
  76681. }
  76682. }
  76683. declare module BABYLON.GLTF2.Exporter {
  76684. /** @hidden */
  76685. export var __IGLTFExporterExtensionV2: number;
  76686. /**
  76687. * Interface for a glTF exporter extension
  76688. * @hidden
  76689. */
  76690. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  76691. /**
  76692. * Define this method to modify the default behavior before exporting a texture
  76693. * @param context The context when loading the asset
  76694. * @param babylonTexture The Babylon.js texture
  76695. * @param mimeType The mime-type of the generated image
  76696. * @returns A promise that resolves with the exported texture
  76697. */
  76698. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  76699. /**
  76700. * Define this method to get notified when a texture info is created
  76701. * @param context The context when loading the asset
  76702. * @param textureInfo The glTF texture info
  76703. * @param babylonTexture The Babylon.js texture
  76704. */
  76705. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76706. /**
  76707. * Define this method to modify the default behavior when exporting texture info
  76708. * @param context The context when loading the asset
  76709. * @param meshPrimitive glTF mesh primitive
  76710. * @param babylonSubMesh Babylon submesh
  76711. * @param binaryWriter glTF serializer binary writer instance
  76712. * @returns nullable IMeshPrimitive promise
  76713. */
  76714. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  76715. /**
  76716. * Define this method to modify the default behavior when exporting a node
  76717. * @param context The context when exporting the node
  76718. * @param node glTF node
  76719. * @param babylonNode BabylonJS node
  76720. * @returns nullable INode promise
  76721. */
  76722. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  76723. [key: number]: number;
  76724. }): Promise<Nullable<INode>>;
  76725. /**
  76726. * Define this method to modify the default behavior when exporting a material
  76727. * @param material glTF material
  76728. * @param babylonMaterial BabylonJS material
  76729. * @returns nullable IMaterial promise
  76730. */
  76731. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  76732. /**
  76733. * Define this method to return additional textures to export from a material
  76734. * @param material glTF material
  76735. * @param babylonMaterial BabylonJS material
  76736. * @returns List of textures
  76737. */
  76738. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76739. /** Gets a boolean indicating that this extension was used */
  76740. wasUsed: boolean;
  76741. /** Gets a boolean indicating that this extension is required for the file to work */
  76742. required: boolean;
  76743. /**
  76744. * Called after the exporter state changes to EXPORTING
  76745. */
  76746. onExporting?(): void;
  76747. }
  76748. }
  76749. declare module BABYLON.GLTF2.Exporter {
  76750. /**
  76751. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  76752. * @hidden
  76753. */
  76754. export class _GLTFMaterialExporter {
  76755. /**
  76756. * Represents the dielectric specular values for R, G and B
  76757. */
  76758. private static readonly _DielectricSpecular;
  76759. /**
  76760. * Allows the maximum specular power to be defined for material calculations
  76761. */
  76762. private static readonly _MaxSpecularPower;
  76763. /**
  76764. * Mapping to store textures
  76765. */
  76766. private _textureMap;
  76767. /**
  76768. * Numeric tolerance value
  76769. */
  76770. private static readonly _Epsilon;
  76771. /**
  76772. * Reference to the glTF Exporter
  76773. */
  76774. private _exporter;
  76775. constructor(exporter: _Exporter);
  76776. /**
  76777. * Specifies if two colors are approximately equal in value
  76778. * @param color1 first color to compare to
  76779. * @param color2 second color to compare to
  76780. * @param epsilon threshold value
  76781. */
  76782. private static FuzzyEquals;
  76783. /**
  76784. * Gets the materials from a Babylon scene and converts them to glTF materials
  76785. * @param scene babylonjs scene
  76786. * @param mimeType texture mime type
  76787. * @param images array of images
  76788. * @param textures array of textures
  76789. * @param materials array of materials
  76790. * @param imageData mapping of texture names to base64 textures
  76791. * @param hasTextureCoords specifies if texture coordinates are present on the material
  76792. */
  76793. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  76794. /**
  76795. * Makes a copy of the glTF material without the texture parameters
  76796. * @param originalMaterial original glTF material
  76797. * @returns glTF material without texture parameters
  76798. */
  76799. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  76800. /**
  76801. * Specifies if the material has any texture parameters present
  76802. * @param material glTF Material
  76803. * @returns boolean specifying if texture parameters are present
  76804. */
  76805. _hasTexturesPresent(material: IMaterial): boolean;
  76806. /**
  76807. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  76808. * @param babylonStandardMaterial
  76809. * @returns glTF Metallic Roughness Material representation
  76810. */
  76811. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  76812. /**
  76813. * Computes the metallic factor
  76814. * @param diffuse diffused value
  76815. * @param specular specular value
  76816. * @param oneMinusSpecularStrength one minus the specular strength
  76817. * @returns metallic value
  76818. */
  76819. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  76820. /**
  76821. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  76822. * @param glTFMaterial glTF material
  76823. * @param babylonMaterial Babylon material
  76824. */
  76825. private static _SetAlphaMode;
  76826. /**
  76827. * Converts a Babylon Standard Material to a glTF Material
  76828. * @param babylonStandardMaterial BJS Standard Material
  76829. * @param mimeType mime type to use for the textures
  76830. * @param images array of glTF image interfaces
  76831. * @param textures array of glTF texture interfaces
  76832. * @param materials array of glTF material interfaces
  76833. * @param imageData map of image file name to data
  76834. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76835. */
  76836. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76837. private _finishMaterial;
  76838. /**
  76839. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76840. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  76841. * @param mimeType mime type to use for the textures
  76842. * @param images array of glTF image interfaces
  76843. * @param textures array of glTF texture interfaces
  76844. * @param materials array of glTF material interfaces
  76845. * @param imageData map of image file name to data
  76846. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76847. */
  76848. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76849. /**
  76850. * Converts an image typed array buffer to a base64 image
  76851. * @param buffer typed array buffer
  76852. * @param width width of the image
  76853. * @param height height of the image
  76854. * @param mimeType mimetype of the image
  76855. * @returns base64 image string
  76856. */
  76857. private _createBase64FromCanvasAsync;
  76858. /**
  76859. * Generates a white texture based on the specified width and height
  76860. * @param width width of the texture in pixels
  76861. * @param height height of the texture in pixels
  76862. * @param scene babylonjs scene
  76863. * @returns white texture
  76864. */
  76865. private _createWhiteTexture;
  76866. /**
  76867. * 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
  76868. * @param texture1 first texture to resize
  76869. * @param texture2 second texture to resize
  76870. * @param scene babylonjs scene
  76871. * @returns resized textures or null
  76872. */
  76873. private _resizeTexturesToSameDimensions;
  76874. /**
  76875. * Converts an array of pixels to a Float32Array
  76876. * Throws an error if the pixel format is not supported
  76877. * @param pixels - array buffer containing pixel values
  76878. * @returns Float32 of pixels
  76879. */
  76880. private _convertPixelArrayToFloat32;
  76881. /**
  76882. * Convert Specular Glossiness Textures to Metallic Roughness
  76883. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  76884. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  76885. * @param diffuseTexture texture used to store diffuse information
  76886. * @param specularGlossinessTexture texture used to store specular and glossiness information
  76887. * @param factors specular glossiness material factors
  76888. * @param mimeType the mime type to use for the texture
  76889. * @returns pbr metallic roughness interface or null
  76890. */
  76891. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  76892. /**
  76893. * Converts specular glossiness material properties to metallic roughness
  76894. * @param specularGlossiness interface with specular glossiness material properties
  76895. * @returns interface with metallic roughness material properties
  76896. */
  76897. private _convertSpecularGlossinessToMetallicRoughness;
  76898. /**
  76899. * Calculates the surface reflectance, independent of lighting conditions
  76900. * @param color Color source to calculate brightness from
  76901. * @returns number representing the perceived brightness, or zero if color is undefined
  76902. */
  76903. private _getPerceivedBrightness;
  76904. /**
  76905. * Returns the maximum color component value
  76906. * @param color
  76907. * @returns maximum color component value, or zero if color is null or undefined
  76908. */
  76909. private _getMaxComponent;
  76910. /**
  76911. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  76912. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76913. * @param mimeType mime type to use for the textures
  76914. * @param images array of glTF image interfaces
  76915. * @param textures array of glTF texture interfaces
  76916. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76917. * @param imageData map of image file name to data
  76918. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76919. * @returns glTF PBR Metallic Roughness factors
  76920. */
  76921. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  76922. private _getGLTFTextureSampler;
  76923. private _getGLTFTextureWrapMode;
  76924. private _getGLTFTextureWrapModesSampler;
  76925. /**
  76926. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  76927. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76928. * @param mimeType mime type to use for the textures
  76929. * @param images array of glTF image interfaces
  76930. * @param textures array of glTF texture interfaces
  76931. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76932. * @param imageData map of image file name to data
  76933. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76934. * @returns glTF PBR Metallic Roughness factors
  76935. */
  76936. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76937. /**
  76938. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76939. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76940. * @param mimeType mime type to use for the textures
  76941. * @param images array of glTF image interfaces
  76942. * @param textures array of glTF texture interfaces
  76943. * @param materials array of glTF material interfaces
  76944. * @param imageData map of image file name to data
  76945. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76946. */
  76947. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76948. private setMetallicRoughnessPbrMaterial;
  76949. private getPixelsFromTexture;
  76950. /**
  76951. * Extracts a texture from a Babylon texture into file data and glTF data
  76952. * @param babylonTexture Babylon texture to extract
  76953. * @param mimeType Mime Type of the babylonTexture
  76954. * @return glTF texture info, or null if the texture format is not supported
  76955. */
  76956. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76957. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76958. /**
  76959. * Builds a texture from base64 string
  76960. * @param base64Texture base64 texture string
  76961. * @param baseTextureName Name to use for the texture
  76962. * @param mimeType image mime type for the texture
  76963. * @param images array of images
  76964. * @param textures array of textures
  76965. * @param imageData map of image data
  76966. * @returns glTF texture info, or null if the texture format is not supported
  76967. */
  76968. private _getTextureInfoFromBase64;
  76969. }
  76970. }
  76971. declare module BABYLON {
  76972. /**
  76973. * Class for holding and downloading glTF file data
  76974. */
  76975. export class GLTFData {
  76976. /**
  76977. * Object which contains the file name as the key and its data as the value
  76978. */
  76979. glTFFiles: {
  76980. [fileName: string]: string | Blob;
  76981. };
  76982. /**
  76983. * Initializes the glTF file object
  76984. */
  76985. constructor();
  76986. /**
  76987. * Downloads the glTF data as files based on their names and data
  76988. */
  76989. downloadFiles(): void;
  76990. }
  76991. }
  76992. declare module BABYLON {
  76993. /**
  76994. * Holds a collection of exporter options and parameters
  76995. */
  76996. export interface IExportOptions {
  76997. /**
  76998. * Function which indicates whether a babylon node should be exported or not
  76999. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77000. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77001. */
  77002. shouldExportNode?(node: Node): boolean;
  77003. /**
  77004. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77005. * @param metadata source metadata to read from
  77006. * @returns the data to store to glTF node extras
  77007. */
  77008. metadataSelector?(metadata: any): any;
  77009. /**
  77010. * The sample rate to bake animation curves
  77011. */
  77012. animationSampleRate?: number;
  77013. /**
  77014. * Begin serialization without waiting for the scene to be ready
  77015. */
  77016. exportWithoutWaitingForScene?: boolean;
  77017. /**
  77018. * Indicates if coordinate system swapping root nodes should be included in export
  77019. */
  77020. includeCoordinateSystemConversionNodes?: boolean;
  77021. }
  77022. /**
  77023. * Class for generating glTF data from a Babylon scene.
  77024. */
  77025. export class GLTF2Export {
  77026. /**
  77027. * Exports the geometry of the scene to .gltf file format asynchronously
  77028. * @param scene Babylon scene with scene hierarchy information
  77029. * @param filePrefix File prefix to use when generating the glTF file
  77030. * @param options Exporter options
  77031. * @returns Returns an object with a .gltf file and associates texture names
  77032. * as keys and their data and paths as values
  77033. */
  77034. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77035. private static _PreExportAsync;
  77036. private static _PostExportAsync;
  77037. /**
  77038. * Exports the geometry of the scene to .glb file format asychronously
  77039. * @param scene Babylon scene with scene hierarchy information
  77040. * @param filePrefix File prefix to use when generating glb file
  77041. * @param options Exporter options
  77042. * @returns Returns an object with a .glb filename as key and data as value
  77043. */
  77044. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77045. }
  77046. }
  77047. declare module BABYLON.GLTF2.Exporter {
  77048. /**
  77049. * @hidden
  77050. */
  77051. export class _GLTFUtilities {
  77052. /**
  77053. * Creates a buffer view based on the supplied arguments
  77054. * @param bufferIndex index value of the specified buffer
  77055. * @param byteOffset byte offset value
  77056. * @param byteLength byte length of the bufferView
  77057. * @param byteStride byte distance between conequential elements
  77058. * @param name name of the buffer view
  77059. * @returns bufferView for glTF
  77060. */
  77061. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  77062. /**
  77063. * Creates an accessor based on the supplied arguments
  77064. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  77065. * @param name The name of the accessor
  77066. * @param type The type of the accessor
  77067. * @param componentType The datatype of components in the attribute
  77068. * @param count The number of attributes referenced by this accessor
  77069. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77070. * @param min Minimum value of each component in this attribute
  77071. * @param max Maximum value of each component in this attribute
  77072. * @returns accessor for glTF
  77073. */
  77074. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77075. /**
  77076. * Calculates the minimum and maximum values of an array of position floats
  77077. * @param positions Positions array of a mesh
  77078. * @param vertexStart Starting vertex offset to calculate min and max values
  77079. * @param vertexCount Number of vertices to check for min and max values
  77080. * @returns min number array and max number array
  77081. */
  77082. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77083. min: number[];
  77084. max: number[];
  77085. };
  77086. /**
  77087. * Converts a new right-handed Vector3
  77088. * @param vector vector3 array
  77089. * @returns right-handed Vector3
  77090. */
  77091. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77092. /**
  77093. * Converts a Vector3 to right-handed
  77094. * @param vector Vector3 to convert to right-handed
  77095. */
  77096. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77097. /**
  77098. * Converts a three element number array to right-handed
  77099. * @param vector number array to convert to right-handed
  77100. */
  77101. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77102. /**
  77103. * Converts a new right-handed Vector3
  77104. * @param vector vector3 array
  77105. * @returns right-handed Vector3
  77106. */
  77107. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77108. /**
  77109. * Converts a Vector3 to right-handed
  77110. * @param vector Vector3 to convert to right-handed
  77111. */
  77112. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77113. /**
  77114. * Converts a three element number array to right-handed
  77115. * @param vector number array to convert to right-handed
  77116. */
  77117. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77118. /**
  77119. * Converts a Vector4 to right-handed
  77120. * @param vector Vector4 to convert to right-handed
  77121. */
  77122. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77123. /**
  77124. * Converts a Vector4 to right-handed
  77125. * @param vector Vector4 to convert to right-handed
  77126. */
  77127. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77128. /**
  77129. * Converts a Quaternion to right-handed
  77130. * @param quaternion Source quaternion to convert to right-handed
  77131. */
  77132. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77133. /**
  77134. * Converts a Quaternion to right-handed
  77135. * @param quaternion Source quaternion to convert to right-handed
  77136. */
  77137. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77138. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77139. }
  77140. }
  77141. declare module BABYLON.GLTF2.Exporter {
  77142. /**
  77143. * Converts Babylon Scene into glTF 2.0.
  77144. * @hidden
  77145. */
  77146. export class _Exporter {
  77147. /**
  77148. * Stores the glTF to export
  77149. */
  77150. _glTF: IGLTF;
  77151. /**
  77152. * Stores all generated buffer views, which represents views into the main glTF buffer data
  77153. */
  77154. _bufferViews: IBufferView[];
  77155. /**
  77156. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  77157. */
  77158. _accessors: IAccessor[];
  77159. /**
  77160. * Stores all the generated nodes, which contains transform and/or mesh information per node
  77161. */
  77162. _nodes: INode[];
  77163. /**
  77164. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  77165. */
  77166. private _scenes;
  77167. /**
  77168. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  77169. */
  77170. private _meshes;
  77171. /**
  77172. * Stores all the generated material information, which represents the appearance of each primitive
  77173. */
  77174. _materials: IMaterial[];
  77175. _materialMap: {
  77176. [materialID: number]: number;
  77177. };
  77178. /**
  77179. * Stores all the generated texture information, which is referenced by glTF materials
  77180. */
  77181. _textures: ITexture[];
  77182. /**
  77183. * Stores all the generated image information, which is referenced by glTF textures
  77184. */
  77185. _images: IImage[];
  77186. /**
  77187. * Stores all the texture samplers
  77188. */
  77189. _samplers: ISampler[];
  77190. /**
  77191. * Stores all the generated animation samplers, which is referenced by glTF animations
  77192. */
  77193. /**
  77194. * Stores the animations for glTF models
  77195. */
  77196. private _animations;
  77197. /**
  77198. * Stores the total amount of bytes stored in the glTF buffer
  77199. */
  77200. private _totalByteLength;
  77201. /**
  77202. * Stores a reference to the Babylon scene containing the source geometry and material information
  77203. */
  77204. _babylonScene: Scene;
  77205. /**
  77206. * Stores a map of the image data, where the key is the file name and the value
  77207. * is the image data
  77208. */
  77209. _imageData: {
  77210. [fileName: string]: {
  77211. data: Uint8Array;
  77212. mimeType: ImageMimeType;
  77213. };
  77214. };
  77215. /**
  77216. * Stores a map of the unique id of a node to its index in the node array
  77217. */
  77218. _nodeMap: {
  77219. [key: number]: number;
  77220. };
  77221. /**
  77222. * Specifies if the source Babylon scene was left handed, and needed conversion.
  77223. */
  77224. _convertToRightHandedSystem: boolean;
  77225. /**
  77226. * Specifies if a Babylon node should be converted to right-handed on export
  77227. */
  77228. _convertToRightHandedSystemMap: {
  77229. [nodeId: number]: boolean;
  77230. };
  77231. _includeCoordinateSystemConversionNodes: boolean;
  77232. /**
  77233. * Baked animation sample rate
  77234. */
  77235. private _animationSampleRate;
  77236. private _options;
  77237. private _localEngine;
  77238. _glTFMaterialExporter: _GLTFMaterialExporter;
  77239. private _extensions;
  77240. private static _ExtensionNames;
  77241. private static _ExtensionFactories;
  77242. private _applyExtension;
  77243. private _applyExtensions;
  77244. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  77245. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  77246. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77247. [key: number]: number;
  77248. }): Promise<Nullable<INode>>;
  77249. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  77250. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  77251. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77252. private _forEachExtensions;
  77253. private _extensionsOnExporting;
  77254. /**
  77255. * Load glTF serializer extensions
  77256. */
  77257. private _loadExtensions;
  77258. /**
  77259. * Creates a glTF Exporter instance, which can accept optional exporter options
  77260. * @param babylonScene Babylon scene object
  77261. * @param options Options to modify the behavior of the exporter
  77262. */
  77263. constructor(babylonScene: Scene, options?: IExportOptions);
  77264. dispose(): void;
  77265. /**
  77266. * Registers a glTF exporter extension
  77267. * @param name Name of the extension to export
  77268. * @param factory The factory function that creates the exporter extension
  77269. */
  77270. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77271. /**
  77272. * Un-registers an exporter extension
  77273. * @param name The name fo the exporter extension
  77274. * @returns A boolean indicating whether the extension has been un-registered
  77275. */
  77276. static UnregisterExtension(name: string): boolean;
  77277. /**
  77278. * Lazy load a local engine
  77279. */
  77280. _getLocalEngine(): Engine;
  77281. private reorderIndicesBasedOnPrimitiveMode;
  77282. /**
  77283. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77284. * clock-wise during export to glTF
  77285. * @param submesh BabylonJS submesh
  77286. * @param primitiveMode Primitive mode of the mesh
  77287. * @param sideOrientation the winding order of the submesh
  77288. * @param vertexBufferKind The type of vertex attribute
  77289. * @param meshAttributeArray The vertex attribute data
  77290. * @param byteOffset The offset to the binary data
  77291. * @param binaryWriter The binary data for the glTF file
  77292. * @param convertToRightHandedSystem Converts the values to right-handed
  77293. */
  77294. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77295. /**
  77296. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77297. * clock-wise during export to glTF
  77298. * @param submesh BabylonJS submesh
  77299. * @param primitiveMode Primitive mode of the mesh
  77300. * @param sideOrientation the winding order of the submesh
  77301. * @param vertexBufferKind The type of vertex attribute
  77302. * @param meshAttributeArray The vertex attribute data
  77303. * @param byteOffset The offset to the binary data
  77304. * @param binaryWriter The binary data for the glTF file
  77305. * @param convertToRightHandedSystem Converts the values to right-handed
  77306. */
  77307. private reorderTriangleFillMode;
  77308. /**
  77309. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77310. * clock-wise during export to glTF
  77311. * @param submesh BabylonJS submesh
  77312. * @param primitiveMode Primitive mode of the mesh
  77313. * @param sideOrientation the winding order of the submesh
  77314. * @param vertexBufferKind The type of vertex attribute
  77315. * @param meshAttributeArray The vertex attribute data
  77316. * @param byteOffset The offset to the binary data
  77317. * @param binaryWriter The binary data for the glTF file
  77318. * @param convertToRightHandedSystem Converts the values to right-handed
  77319. */
  77320. private reorderTriangleStripDrawMode;
  77321. /**
  77322. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77323. * clock-wise during export to glTF
  77324. * @param submesh BabylonJS submesh
  77325. * @param primitiveMode Primitive mode of the mesh
  77326. * @param sideOrientation the winding order of the submesh
  77327. * @param vertexBufferKind The type of vertex attribute
  77328. * @param meshAttributeArray The vertex attribute data
  77329. * @param byteOffset The offset to the binary data
  77330. * @param binaryWriter The binary data for the glTF file
  77331. * @param convertToRightHandedSystem Converts the values to right-handed
  77332. */
  77333. private reorderTriangleFanMode;
  77334. /**
  77335. * Writes the vertex attribute data to binary
  77336. * @param vertices The vertices to write to the binary writer
  77337. * @param byteOffset The offset into the binary writer to overwrite binary data
  77338. * @param vertexAttributeKind The vertex attribute type
  77339. * @param meshAttributeArray The vertex attribute data
  77340. * @param binaryWriter The writer containing the binary data
  77341. * @param convertToRightHandedSystem Converts the values to right-handed
  77342. */
  77343. private writeVertexAttributeData;
  77344. /**
  77345. * Writes mesh attribute data to a data buffer
  77346. * Returns the bytelength of the data
  77347. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77348. * @param meshAttributeArray Array containing the attribute data
  77349. * @param binaryWriter The buffer to write the binary data to
  77350. * @param indices Used to specify the order of the vertex data
  77351. * @param convertToRightHandedSystem Converts the values to right-handed
  77352. */
  77353. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  77354. /**
  77355. * Generates glTF json data
  77356. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77357. * @param glTFPrefix Text to use when prefixing a glTF file
  77358. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77359. * @returns json data as string
  77360. */
  77361. private generateJSON;
  77362. /**
  77363. * Generates data for .gltf and .bin files based on the glTF prefix string
  77364. * @param glTFPrefix Text to use when prefixing a glTF file
  77365. * @param dispose Dispose the exporter
  77366. * @returns GLTFData with glTF file data
  77367. */
  77368. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77369. /**
  77370. * Creates a binary buffer for glTF
  77371. * @returns array buffer for binary data
  77372. */
  77373. private _generateBinaryAsync;
  77374. /**
  77375. * Pads the number to a multiple of 4
  77376. * @param num number to pad
  77377. * @returns padded number
  77378. */
  77379. private _getPadding;
  77380. /**
  77381. * @hidden
  77382. */
  77383. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77384. /**
  77385. * Sets the TRS for each node
  77386. * @param node glTF Node for storing the transformation data
  77387. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77388. * @param convertToRightHandedSystem Converts the values to right-handed
  77389. */
  77390. private setNodeTransformation;
  77391. private getVertexBufferFromMesh;
  77392. /**
  77393. * Creates a bufferview based on the vertices type for the Babylon mesh
  77394. * @param kind Indicates the type of vertices data
  77395. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77396. * @param binaryWriter The buffer to write the bufferview data to
  77397. * @param convertToRightHandedSystem Converts the values to right-handed
  77398. */
  77399. private createBufferViewKind;
  77400. /**
  77401. * The primitive mode of the Babylon mesh
  77402. * @param babylonMesh The BabylonJS mesh
  77403. */
  77404. private getMeshPrimitiveMode;
  77405. /**
  77406. * Sets the primitive mode of the glTF mesh primitive
  77407. * @param meshPrimitive glTF mesh primitive
  77408. * @param primitiveMode The primitive mode
  77409. */
  77410. private setPrimitiveMode;
  77411. /**
  77412. * Sets the vertex attribute accessor based of the glTF mesh primitive
  77413. * @param meshPrimitive glTF mesh primitive
  77414. * @param attributeKind vertex attribute
  77415. * @returns boolean specifying if uv coordinates are present
  77416. */
  77417. private setAttributeKind;
  77418. /**
  77419. * Sets data for the primitive attributes of each submesh
  77420. * @param mesh glTF Mesh object to store the primitive attribute information
  77421. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  77422. * @param binaryWriter Buffer to write the attribute data to
  77423. * @param convertToRightHandedSystem Converts the values to right-handed
  77424. */
  77425. private setPrimitiveAttributesAsync;
  77426. /**
  77427. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  77428. * @param node The node to check
  77429. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  77430. */
  77431. private isBabylonCoordinateSystemConvertingNode;
  77432. /**
  77433. * Creates a glTF scene based on the array of meshes
  77434. * Returns the the total byte offset
  77435. * @param babylonScene Babylon scene to get the mesh data from
  77436. * @param binaryWriter Buffer to write binary data to
  77437. */
  77438. private createSceneAsync;
  77439. /**
  77440. * Creates a mapping of Node unique id to node index and handles animations
  77441. * @param babylonScene Babylon Scene
  77442. * @param nodes Babylon transform nodes
  77443. * @param binaryWriter Buffer to write binary data to
  77444. * @returns Node mapping of unique id to index
  77445. */
  77446. private createNodeMapAndAnimationsAsync;
  77447. /**
  77448. * Creates a glTF node from a Babylon mesh
  77449. * @param babylonMesh Source Babylon mesh
  77450. * @param binaryWriter Buffer for storing geometry data
  77451. * @param convertToRightHandedSystem Converts the values to right-handed
  77452. * @param nodeMap Node mapping of unique id to glTF node index
  77453. * @returns glTF node
  77454. */
  77455. private createNodeAsync;
  77456. }
  77457. /**
  77458. * @hidden
  77459. *
  77460. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  77461. */
  77462. export class _BinaryWriter {
  77463. /**
  77464. * Array buffer which stores all binary data
  77465. */
  77466. private _arrayBuffer;
  77467. /**
  77468. * View of the array buffer
  77469. */
  77470. private _dataView;
  77471. /**
  77472. * byte offset of data in array buffer
  77473. */
  77474. private _byteOffset;
  77475. /**
  77476. * Initialize binary writer with an initial byte length
  77477. * @param byteLength Initial byte length of the array buffer
  77478. */
  77479. constructor(byteLength: number);
  77480. /**
  77481. * Resize the array buffer to the specified byte length
  77482. * @param byteLength
  77483. */
  77484. private resizeBuffer;
  77485. /**
  77486. * Get an array buffer with the length of the byte offset
  77487. * @returns ArrayBuffer resized to the byte offset
  77488. */
  77489. getArrayBuffer(): ArrayBuffer;
  77490. /**
  77491. * Get the byte offset of the array buffer
  77492. * @returns byte offset
  77493. */
  77494. getByteOffset(): number;
  77495. /**
  77496. * Stores an UInt8 in the array buffer
  77497. * @param entry
  77498. * @param byteOffset If defined, specifies where to set the value as an offset.
  77499. */
  77500. setUInt8(entry: number, byteOffset?: number): void;
  77501. /**
  77502. * Gets an UInt32 in the array buffer
  77503. * @param entry
  77504. * @param byteOffset If defined, specifies where to set the value as an offset.
  77505. */
  77506. getUInt32(byteOffset: number): number;
  77507. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77508. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77509. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77510. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77511. /**
  77512. * Stores a Float32 in the array buffer
  77513. * @param entry
  77514. */
  77515. setFloat32(entry: number, byteOffset?: number): void;
  77516. /**
  77517. * Stores an UInt32 in the array buffer
  77518. * @param entry
  77519. * @param byteOffset If defined, specifies where to set the value as an offset.
  77520. */
  77521. setUInt32(entry: number, byteOffset?: number): void;
  77522. }
  77523. }
  77524. declare module BABYLON.GLTF2.Exporter {
  77525. /**
  77526. * @hidden
  77527. * Interface to store animation data.
  77528. */
  77529. export interface _IAnimationData {
  77530. /**
  77531. * Keyframe data.
  77532. */
  77533. inputs: number[];
  77534. /**
  77535. * Value data.
  77536. */
  77537. outputs: number[][];
  77538. /**
  77539. * Animation interpolation data.
  77540. */
  77541. samplerInterpolation: AnimationSamplerInterpolation;
  77542. /**
  77543. * Minimum keyframe value.
  77544. */
  77545. inputsMin: number;
  77546. /**
  77547. * Maximum keyframe value.
  77548. */
  77549. inputsMax: number;
  77550. }
  77551. /**
  77552. * @hidden
  77553. */
  77554. export interface _IAnimationInfo {
  77555. /**
  77556. * The target channel for the animation
  77557. */
  77558. animationChannelTargetPath: AnimationChannelTargetPath;
  77559. /**
  77560. * The glTF accessor type for the data.
  77561. */
  77562. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  77563. /**
  77564. * Specifies if quaternions should be used.
  77565. */
  77566. useQuaternion: boolean;
  77567. }
  77568. /**
  77569. * @hidden
  77570. * Utility class for generating glTF animation data from BabylonJS.
  77571. */
  77572. export class _GLTFAnimation {
  77573. /**
  77574. * @ignore
  77575. *
  77576. * Creates glTF channel animation from BabylonJS animation.
  77577. * @param babylonTransformNode - BabylonJS mesh.
  77578. * @param animation - animation.
  77579. * @param animationChannelTargetPath - The target animation channel.
  77580. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  77581. * @param useQuaternion - Specifies if quaternions are used.
  77582. * @returns nullable IAnimationData
  77583. */
  77584. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  77585. private static _DeduceAnimationInfo;
  77586. /**
  77587. * @ignore
  77588. * Create node animations from the transform node animations
  77589. * @param babylonNode
  77590. * @param runtimeGLTFAnimation
  77591. * @param idleGLTFAnimations
  77592. * @param nodeMap
  77593. * @param nodes
  77594. * @param binaryWriter
  77595. * @param bufferViews
  77596. * @param accessors
  77597. * @param convertToRightHandedSystem
  77598. * @param animationSampleRate
  77599. */
  77600. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  77601. [key: number]: number;
  77602. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77603. /**
  77604. * @ignore
  77605. * Create node animations from the animation groups
  77606. * @param babylonScene
  77607. * @param glTFAnimations
  77608. * @param nodeMap
  77609. * @param nodes
  77610. * @param binaryWriter
  77611. * @param bufferViews
  77612. * @param accessors
  77613. * @param convertToRightHandedSystemMap
  77614. * @param animationSampleRate
  77615. */
  77616. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  77617. [key: number]: number;
  77618. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  77619. [nodeId: number]: boolean;
  77620. }, animationSampleRate: number): void;
  77621. private static AddAnimation;
  77622. /**
  77623. * Create a baked animation
  77624. * @param babylonTransformNode BabylonJS mesh
  77625. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  77626. * @param animationChannelTargetPath animation target channel
  77627. * @param minFrame minimum animation frame
  77628. * @param maxFrame maximum animation frame
  77629. * @param fps frames per second of the animation
  77630. * @param inputs input key frames of the animation
  77631. * @param outputs output key frame data of the animation
  77632. * @param convertToRightHandedSystem converts the values to right-handed
  77633. * @param useQuaternion specifies if quaternions should be used
  77634. */
  77635. private static _CreateBakedAnimation;
  77636. private static _ConvertFactorToVector3OrQuaternion;
  77637. private static _SetInterpolatedValue;
  77638. /**
  77639. * Creates linear animation from the animation key frames
  77640. * @param babylonTransformNode BabylonJS mesh
  77641. * @param animation BabylonJS animation
  77642. * @param animationChannelTargetPath The target animation channel
  77643. * @param frameDelta The difference between the last and first frame of the animation
  77644. * @param inputs Array to store the key frame times
  77645. * @param outputs Array to store the key frame data
  77646. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77647. * @param useQuaternion Specifies if quaternions are used in the animation
  77648. */
  77649. private static _CreateLinearOrStepAnimation;
  77650. /**
  77651. * Creates cubic spline animation from the animation key frames
  77652. * @param babylonTransformNode BabylonJS mesh
  77653. * @param animation BabylonJS animation
  77654. * @param animationChannelTargetPath The target animation channel
  77655. * @param frameDelta The difference between the last and first frame of the animation
  77656. * @param inputs Array to store the key frame times
  77657. * @param outputs Array to store the key frame data
  77658. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77659. * @param useQuaternion Specifies if quaternions are used in the animation
  77660. */
  77661. private static _CreateCubicSplineAnimation;
  77662. private static _GetBasePositionRotationOrScale;
  77663. /**
  77664. * Adds a key frame value
  77665. * @param keyFrame
  77666. * @param animation
  77667. * @param outputs
  77668. * @param animationChannelTargetPath
  77669. * @param basePositionRotationOrScale
  77670. * @param convertToRightHandedSystem
  77671. * @param useQuaternion
  77672. */
  77673. private static _AddKeyframeValue;
  77674. /**
  77675. * Determine the interpolation based on the key frames
  77676. * @param keyFrames
  77677. * @param animationChannelTargetPath
  77678. * @param useQuaternion
  77679. */
  77680. private static _DeduceInterpolation;
  77681. /**
  77682. * Adds an input tangent or output tangent to the output data
  77683. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  77684. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  77685. * @param outputs The animation data by keyframe
  77686. * @param animationChannelTargetPath The target animation channel
  77687. * @param interpolation The interpolation type
  77688. * @param keyFrame The key frame with the animation data
  77689. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  77690. * @param useQuaternion Specifies if quaternions are used
  77691. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  77692. */
  77693. private static AddSplineTangent;
  77694. /**
  77695. * Get the minimum and maximum key frames' frame values
  77696. * @param keyFrames animation key frames
  77697. * @returns the minimum and maximum key frame value
  77698. */
  77699. private static calculateMinMaxKeyFrames;
  77700. }
  77701. }
  77702. declare module BABYLON.GLTF2.Exporter {
  77703. /** @hidden */
  77704. export var textureTransformPixelShader: {
  77705. name: string;
  77706. shader: string;
  77707. };
  77708. }
  77709. declare module BABYLON.GLTF2.Exporter.Extensions {
  77710. /**
  77711. * @hidden
  77712. */
  77713. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  77714. private _recordedTextures;
  77715. /** Name of this extension */
  77716. readonly name: string;
  77717. /** Defines whether this extension is enabled */
  77718. enabled: boolean;
  77719. /** Defines whether this extension is required */
  77720. required: boolean;
  77721. /** Reference to the glTF exporter */
  77722. private _wasUsed;
  77723. constructor(exporter: _Exporter);
  77724. dispose(): void;
  77725. /** @hidden */
  77726. get wasUsed(): boolean;
  77727. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77728. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  77729. /**
  77730. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  77731. * @param babylonTexture
  77732. * @param offset
  77733. * @param rotation
  77734. * @param scale
  77735. * @param scene
  77736. */
  77737. private _textureTransformTextureAsync;
  77738. }
  77739. }
  77740. declare module BABYLON.GLTF2.Exporter.Extensions {
  77741. /**
  77742. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  77743. */
  77744. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  77745. /** The name of this extension. */
  77746. readonly name: string;
  77747. /** Defines whether this extension is enabled. */
  77748. enabled: boolean;
  77749. /** Defines whether this extension is required */
  77750. required: boolean;
  77751. /** Reference to the glTF exporter */
  77752. private _exporter;
  77753. private _lights;
  77754. /** @hidden */
  77755. constructor(exporter: _Exporter);
  77756. /** @hidden */
  77757. dispose(): void;
  77758. /** @hidden */
  77759. get wasUsed(): boolean;
  77760. /** @hidden */
  77761. onExporting(): void;
  77762. /**
  77763. * Define this method to modify the default behavior when exporting a node
  77764. * @param context The context when exporting the node
  77765. * @param node glTF node
  77766. * @param babylonNode BabylonJS node
  77767. * @param nodeMap Node mapping of unique id to glTF node index
  77768. * @returns nullable INode promise
  77769. */
  77770. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77771. [key: number]: number;
  77772. }): Promise<Nullable<INode>>;
  77773. }
  77774. }
  77775. declare module BABYLON.GLTF2.Exporter.Extensions {
  77776. /**
  77777. * @hidden
  77778. */
  77779. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  77780. /** Name of this extension */
  77781. readonly name: string;
  77782. /** Defines whether this extension is enabled */
  77783. enabled: boolean;
  77784. /** Defines whether this extension is required */
  77785. required: boolean;
  77786. /** Reference to the glTF exporter */
  77787. private _textureInfos;
  77788. private _exportedTextures;
  77789. private _wasUsed;
  77790. constructor(exporter: _Exporter);
  77791. dispose(): void;
  77792. /** @hidden */
  77793. get wasUsed(): boolean;
  77794. private _getTextureIndex;
  77795. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77796. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77797. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  77798. }
  77799. }
  77800. declare module BABYLON {
  77801. /**
  77802. * Class for generating STL data from a Babylon scene.
  77803. */
  77804. export class STLExport {
  77805. /**
  77806. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  77807. * @param meshes list defines the mesh to serialize
  77808. * @param download triggers the automatic download of the file.
  77809. * @param fileName changes the downloads fileName.
  77810. * @param binary changes the STL to a binary type.
  77811. * @param isLittleEndian toggle for binary type exporter.
  77812. * @returns the STL as UTF8 string
  77813. */
  77814. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  77815. }
  77816. }
  77817. declare module "babylonjs-gltf2interface" {
  77818. export = BABYLON.GLTF2;
  77819. }
  77820. /**
  77821. * Module for glTF 2.0 Interface
  77822. */
  77823. declare module BABYLON.GLTF2 {
  77824. /**
  77825. * The datatype of the components in the attribute
  77826. */
  77827. const enum AccessorComponentType {
  77828. /**
  77829. * Byte
  77830. */
  77831. BYTE = 5120,
  77832. /**
  77833. * Unsigned Byte
  77834. */
  77835. UNSIGNED_BYTE = 5121,
  77836. /**
  77837. * Short
  77838. */
  77839. SHORT = 5122,
  77840. /**
  77841. * Unsigned Short
  77842. */
  77843. UNSIGNED_SHORT = 5123,
  77844. /**
  77845. * Unsigned Int
  77846. */
  77847. UNSIGNED_INT = 5125,
  77848. /**
  77849. * Float
  77850. */
  77851. FLOAT = 5126,
  77852. }
  77853. /**
  77854. * Specifies if the attirbute is a scalar, vector, or matrix
  77855. */
  77856. const enum AccessorType {
  77857. /**
  77858. * Scalar
  77859. */
  77860. SCALAR = "SCALAR",
  77861. /**
  77862. * Vector2
  77863. */
  77864. VEC2 = "VEC2",
  77865. /**
  77866. * Vector3
  77867. */
  77868. VEC3 = "VEC3",
  77869. /**
  77870. * Vector4
  77871. */
  77872. VEC4 = "VEC4",
  77873. /**
  77874. * Matrix2x2
  77875. */
  77876. MAT2 = "MAT2",
  77877. /**
  77878. * Matrix3x3
  77879. */
  77880. MAT3 = "MAT3",
  77881. /**
  77882. * Matrix4x4
  77883. */
  77884. MAT4 = "MAT4",
  77885. }
  77886. /**
  77887. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77888. */
  77889. const enum AnimationChannelTargetPath {
  77890. /**
  77891. * Translation
  77892. */
  77893. TRANSLATION = "translation",
  77894. /**
  77895. * Rotation
  77896. */
  77897. ROTATION = "rotation",
  77898. /**
  77899. * Scale
  77900. */
  77901. SCALE = "scale",
  77902. /**
  77903. * Weights
  77904. */
  77905. WEIGHTS = "weights",
  77906. }
  77907. /**
  77908. * Interpolation algorithm
  77909. */
  77910. const enum AnimationSamplerInterpolation {
  77911. /**
  77912. * The animated values are linearly interpolated between keyframes
  77913. */
  77914. LINEAR = "LINEAR",
  77915. /**
  77916. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  77917. */
  77918. STEP = "STEP",
  77919. /**
  77920. * The animation's interpolation is computed using a cubic spline with specified tangents
  77921. */
  77922. CUBICSPLINE = "CUBICSPLINE",
  77923. }
  77924. /**
  77925. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77926. */
  77927. const enum CameraType {
  77928. /**
  77929. * A perspective camera containing properties to create a perspective projection matrix
  77930. */
  77931. PERSPECTIVE = "perspective",
  77932. /**
  77933. * An orthographic camera containing properties to create an orthographic projection matrix
  77934. */
  77935. ORTHOGRAPHIC = "orthographic",
  77936. }
  77937. /**
  77938. * The mime-type of the image
  77939. */
  77940. const enum ImageMimeType {
  77941. /**
  77942. * JPEG Mime-type
  77943. */
  77944. JPEG = "image/jpeg",
  77945. /**
  77946. * PNG Mime-type
  77947. */
  77948. PNG = "image/png",
  77949. }
  77950. /**
  77951. * The alpha rendering mode of the material
  77952. */
  77953. const enum MaterialAlphaMode {
  77954. /**
  77955. * The alpha value is ignored and the rendered output is fully opaque
  77956. */
  77957. OPAQUE = "OPAQUE",
  77958. /**
  77959. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  77960. */
  77961. MASK = "MASK",
  77962. /**
  77963. * 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)
  77964. */
  77965. BLEND = "BLEND",
  77966. }
  77967. /**
  77968. * The type of the primitives to render
  77969. */
  77970. const enum MeshPrimitiveMode {
  77971. /**
  77972. * Points
  77973. */
  77974. POINTS = 0,
  77975. /**
  77976. * Lines
  77977. */
  77978. LINES = 1,
  77979. /**
  77980. * Line Loop
  77981. */
  77982. LINE_LOOP = 2,
  77983. /**
  77984. * Line Strip
  77985. */
  77986. LINE_STRIP = 3,
  77987. /**
  77988. * Triangles
  77989. */
  77990. TRIANGLES = 4,
  77991. /**
  77992. * Triangle Strip
  77993. */
  77994. TRIANGLE_STRIP = 5,
  77995. /**
  77996. * Triangle Fan
  77997. */
  77998. TRIANGLE_FAN = 6,
  77999. }
  78000. /**
  78001. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78002. */
  78003. const enum TextureMagFilter {
  78004. /**
  78005. * Nearest
  78006. */
  78007. NEAREST = 9728,
  78008. /**
  78009. * Linear
  78010. */
  78011. LINEAR = 9729,
  78012. }
  78013. /**
  78014. * Minification filter. All valid values correspond to WebGL enums
  78015. */
  78016. const enum TextureMinFilter {
  78017. /**
  78018. * Nearest
  78019. */
  78020. NEAREST = 9728,
  78021. /**
  78022. * Linear
  78023. */
  78024. LINEAR = 9729,
  78025. /**
  78026. * Nearest Mip-Map Nearest
  78027. */
  78028. NEAREST_MIPMAP_NEAREST = 9984,
  78029. /**
  78030. * Linear Mipmap Nearest
  78031. */
  78032. LINEAR_MIPMAP_NEAREST = 9985,
  78033. /**
  78034. * Nearest Mipmap Linear
  78035. */
  78036. NEAREST_MIPMAP_LINEAR = 9986,
  78037. /**
  78038. * Linear Mipmap Linear
  78039. */
  78040. LINEAR_MIPMAP_LINEAR = 9987,
  78041. }
  78042. /**
  78043. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78044. */
  78045. const enum TextureWrapMode {
  78046. /**
  78047. * Clamp to Edge
  78048. */
  78049. CLAMP_TO_EDGE = 33071,
  78050. /**
  78051. * Mirrored Repeat
  78052. */
  78053. MIRRORED_REPEAT = 33648,
  78054. /**
  78055. * Repeat
  78056. */
  78057. REPEAT = 10497,
  78058. }
  78059. /**
  78060. * glTF Property
  78061. */
  78062. interface IProperty {
  78063. /**
  78064. * Dictionary object with extension-specific objects
  78065. */
  78066. extensions?: {
  78067. [key: string]: any;
  78068. };
  78069. /**
  78070. * Application-Specific data
  78071. */
  78072. extras?: any;
  78073. }
  78074. /**
  78075. * glTF Child of Root Property
  78076. */
  78077. interface IChildRootProperty extends IProperty {
  78078. /**
  78079. * The user-defined name of this object
  78080. */
  78081. name?: string;
  78082. }
  78083. /**
  78084. * Indices of those attributes that deviate from their initialization value
  78085. */
  78086. interface IAccessorSparseIndices extends IProperty {
  78087. /**
  78088. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78089. */
  78090. bufferView: number;
  78091. /**
  78092. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78093. */
  78094. byteOffset?: number;
  78095. /**
  78096. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78097. */
  78098. componentType: AccessorComponentType;
  78099. }
  78100. /**
  78101. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78102. */
  78103. interface IAccessorSparseValues extends IProperty {
  78104. /**
  78105. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78106. */
  78107. bufferView: number;
  78108. /**
  78109. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78110. */
  78111. byteOffset?: number;
  78112. }
  78113. /**
  78114. * Sparse storage of attributes that deviate from their initialization value
  78115. */
  78116. interface IAccessorSparse extends IProperty {
  78117. /**
  78118. * The number of attributes encoded in this sparse accessor
  78119. */
  78120. count: number;
  78121. /**
  78122. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78123. */
  78124. indices: IAccessorSparseIndices;
  78125. /**
  78126. * 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
  78127. */
  78128. values: IAccessorSparseValues;
  78129. }
  78130. /**
  78131. * 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
  78132. */
  78133. interface IAccessor extends IChildRootProperty {
  78134. /**
  78135. * The index of the bufferview
  78136. */
  78137. bufferView?: number;
  78138. /**
  78139. * The offset relative to the start of the bufferView in bytes
  78140. */
  78141. byteOffset?: number;
  78142. /**
  78143. * The datatype of components in the attribute
  78144. */
  78145. componentType: AccessorComponentType;
  78146. /**
  78147. * Specifies whether integer data values should be normalized
  78148. */
  78149. normalized?: boolean;
  78150. /**
  78151. * The number of attributes referenced by this accessor
  78152. */
  78153. count: number;
  78154. /**
  78155. * Specifies if the attribute is a scalar, vector, or matrix
  78156. */
  78157. type: AccessorType;
  78158. /**
  78159. * Maximum value of each component in this attribute
  78160. */
  78161. max?: number[];
  78162. /**
  78163. * Minimum value of each component in this attribute
  78164. */
  78165. min?: number[];
  78166. /**
  78167. * Sparse storage of attributes that deviate from their initialization value
  78168. */
  78169. sparse?: IAccessorSparse;
  78170. }
  78171. /**
  78172. * Targets an animation's sampler at a node's property
  78173. */
  78174. interface IAnimationChannel extends IProperty {
  78175. /**
  78176. * The index of a sampler in this animation used to compute the value for the target
  78177. */
  78178. sampler: number;
  78179. /**
  78180. * The index of the node and TRS property to target
  78181. */
  78182. target: IAnimationChannelTarget;
  78183. }
  78184. /**
  78185. * The index of the node and TRS property that an animation channel targets
  78186. */
  78187. interface IAnimationChannelTarget extends IProperty {
  78188. /**
  78189. * The index of the node to target
  78190. */
  78191. node: number;
  78192. /**
  78193. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78194. */
  78195. path: AnimationChannelTargetPath;
  78196. }
  78197. /**
  78198. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78199. */
  78200. interface IAnimationSampler extends IProperty {
  78201. /**
  78202. * The index of an accessor containing keyframe input values, e.g., time
  78203. */
  78204. input: number;
  78205. /**
  78206. * Interpolation algorithm
  78207. */
  78208. interpolation?: AnimationSamplerInterpolation;
  78209. /**
  78210. * The index of an accessor, containing keyframe output values
  78211. */
  78212. output: number;
  78213. }
  78214. /**
  78215. * A keyframe animation
  78216. */
  78217. interface IAnimation extends IChildRootProperty {
  78218. /**
  78219. * An array of channels, each of which targets an animation's sampler at a node's property
  78220. */
  78221. channels: IAnimationChannel[];
  78222. /**
  78223. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78224. */
  78225. samplers: IAnimationSampler[];
  78226. }
  78227. /**
  78228. * Metadata about the glTF asset
  78229. */
  78230. interface IAsset extends IChildRootProperty {
  78231. /**
  78232. * A copyright message suitable for display to credit the content creator
  78233. */
  78234. copyright?: string;
  78235. /**
  78236. * Tool that generated this glTF model. Useful for debugging
  78237. */
  78238. generator?: string;
  78239. /**
  78240. * The glTF version that this asset targets
  78241. */
  78242. version: string;
  78243. /**
  78244. * The minimum glTF version that this asset targets
  78245. */
  78246. minVersion?: string;
  78247. }
  78248. /**
  78249. * A buffer points to binary geometry, animation, or skins
  78250. */
  78251. interface IBuffer extends IChildRootProperty {
  78252. /**
  78253. * 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
  78254. */
  78255. uri?: string;
  78256. /**
  78257. * The length of the buffer in bytes
  78258. */
  78259. byteLength: number;
  78260. }
  78261. /**
  78262. * A view into a buffer generally representing a subset of the buffer
  78263. */
  78264. interface IBufferView extends IChildRootProperty {
  78265. /**
  78266. * The index of the buffer
  78267. */
  78268. buffer: number;
  78269. /**
  78270. * The offset into the buffer in bytes
  78271. */
  78272. byteOffset?: number;
  78273. /**
  78274. * The lenth of the bufferView in bytes
  78275. */
  78276. byteLength: number;
  78277. /**
  78278. * The stride, in bytes
  78279. */
  78280. byteStride?: number;
  78281. }
  78282. /**
  78283. * An orthographic camera containing properties to create an orthographic projection matrix
  78284. */
  78285. interface ICameraOrthographic extends IProperty {
  78286. /**
  78287. * The floating-point horizontal magnification of the view. Must not be zero
  78288. */
  78289. xmag: number;
  78290. /**
  78291. * The floating-point vertical magnification of the view. Must not be zero
  78292. */
  78293. ymag: number;
  78294. /**
  78295. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78296. */
  78297. zfar: number;
  78298. /**
  78299. * The floating-point distance to the near clipping plane
  78300. */
  78301. znear: number;
  78302. }
  78303. /**
  78304. * A perspective camera containing properties to create a perspective projection matrix
  78305. */
  78306. interface ICameraPerspective extends IProperty {
  78307. /**
  78308. * The floating-point aspect ratio of the field of view
  78309. */
  78310. aspectRatio?: number;
  78311. /**
  78312. * The floating-point vertical field of view in radians
  78313. */
  78314. yfov: number;
  78315. /**
  78316. * The floating-point distance to the far clipping plane
  78317. */
  78318. zfar?: number;
  78319. /**
  78320. * The floating-point distance to the near clipping plane
  78321. */
  78322. znear: number;
  78323. }
  78324. /**
  78325. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78326. */
  78327. interface ICamera extends IChildRootProperty {
  78328. /**
  78329. * An orthographic camera containing properties to create an orthographic projection matrix
  78330. */
  78331. orthographic?: ICameraOrthographic;
  78332. /**
  78333. * A perspective camera containing properties to create a perspective projection matrix
  78334. */
  78335. perspective?: ICameraPerspective;
  78336. /**
  78337. * Specifies if the camera uses a perspective or orthographic projection
  78338. */
  78339. type: CameraType;
  78340. }
  78341. /**
  78342. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78343. */
  78344. interface IImage extends IChildRootProperty {
  78345. /**
  78346. * 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
  78347. */
  78348. uri?: string;
  78349. /**
  78350. * The image's MIME type
  78351. */
  78352. mimeType?: ImageMimeType;
  78353. /**
  78354. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78355. */
  78356. bufferView?: number;
  78357. }
  78358. /**
  78359. * Material Normal Texture Info
  78360. */
  78361. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78362. /**
  78363. * The scalar multiplier applied to each normal vector of the normal texture
  78364. */
  78365. scale?: number;
  78366. }
  78367. /**
  78368. * Material Occlusion Texture Info
  78369. */
  78370. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78371. /**
  78372. * A scalar multiplier controlling the amount of occlusion applied
  78373. */
  78374. strength?: number;
  78375. }
  78376. /**
  78377. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78378. */
  78379. interface IMaterialPbrMetallicRoughness {
  78380. /**
  78381. * The material's base color factor
  78382. */
  78383. baseColorFactor?: number[];
  78384. /**
  78385. * The base color texture
  78386. */
  78387. baseColorTexture?: ITextureInfo;
  78388. /**
  78389. * The metalness of the material
  78390. */
  78391. metallicFactor?: number;
  78392. /**
  78393. * The roughness of the material
  78394. */
  78395. roughnessFactor?: number;
  78396. /**
  78397. * The metallic-roughness texture
  78398. */
  78399. metallicRoughnessTexture?: ITextureInfo;
  78400. }
  78401. /**
  78402. * The material appearance of a primitive
  78403. */
  78404. interface IMaterial extends IChildRootProperty {
  78405. /**
  78406. * 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
  78407. */
  78408. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78409. /**
  78410. * The normal map texture
  78411. */
  78412. normalTexture?: IMaterialNormalTextureInfo;
  78413. /**
  78414. * The occlusion map texture
  78415. */
  78416. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78417. /**
  78418. * The emissive map texture
  78419. */
  78420. emissiveTexture?: ITextureInfo;
  78421. /**
  78422. * 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
  78423. */
  78424. emissiveFactor?: number[];
  78425. /**
  78426. * The alpha rendering mode of the material
  78427. */
  78428. alphaMode?: MaterialAlphaMode;
  78429. /**
  78430. * The alpha cutoff value of the material
  78431. */
  78432. alphaCutoff?: number;
  78433. /**
  78434. * Specifies whether the material is double sided
  78435. */
  78436. doubleSided?: boolean;
  78437. }
  78438. /**
  78439. * Geometry to be rendered with the given material
  78440. */
  78441. interface IMeshPrimitive extends IProperty {
  78442. /**
  78443. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  78444. */
  78445. attributes: {
  78446. [name: string]: number;
  78447. };
  78448. /**
  78449. * The index of the accessor that contains the indices
  78450. */
  78451. indices?: number;
  78452. /**
  78453. * The index of the material to apply to this primitive when rendering
  78454. */
  78455. material?: number;
  78456. /**
  78457. * The type of primitives to render. All valid values correspond to WebGL enums
  78458. */
  78459. mode?: MeshPrimitiveMode;
  78460. /**
  78461. * 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
  78462. */
  78463. targets?: {
  78464. [name: string]: number;
  78465. }[];
  78466. }
  78467. /**
  78468. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  78469. */
  78470. interface IMesh extends IChildRootProperty {
  78471. /**
  78472. * An array of primitives, each defining geometry to be rendered with a material
  78473. */
  78474. primitives: IMeshPrimitive[];
  78475. /**
  78476. * Array of weights to be applied to the Morph Targets
  78477. */
  78478. weights?: number[];
  78479. }
  78480. /**
  78481. * A node in the node hierarchy
  78482. */
  78483. interface INode extends IChildRootProperty {
  78484. /**
  78485. * The index of the camera referenced by this node
  78486. */
  78487. camera?: number;
  78488. /**
  78489. * The indices of this node's children
  78490. */
  78491. children?: number[];
  78492. /**
  78493. * The index of the skin referenced by this node
  78494. */
  78495. skin?: number;
  78496. /**
  78497. * A floating-point 4x4 transformation matrix stored in column-major order
  78498. */
  78499. matrix?: number[];
  78500. /**
  78501. * The index of the mesh in this node
  78502. */
  78503. mesh?: number;
  78504. /**
  78505. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  78506. */
  78507. rotation?: number[];
  78508. /**
  78509. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  78510. */
  78511. scale?: number[];
  78512. /**
  78513. * The node's translation along the x, y, and z axes
  78514. */
  78515. translation?: number[];
  78516. /**
  78517. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  78518. */
  78519. weights?: number[];
  78520. }
  78521. /**
  78522. * Texture sampler properties for filtering and wrapping modes
  78523. */
  78524. interface ISampler extends IChildRootProperty {
  78525. /**
  78526. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78527. */
  78528. magFilter?: TextureMagFilter;
  78529. /**
  78530. * Minification filter. All valid values correspond to WebGL enums
  78531. */
  78532. minFilter?: TextureMinFilter;
  78533. /**
  78534. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78535. */
  78536. wrapS?: TextureWrapMode;
  78537. /**
  78538. * T (V) wrapping mode. All valid values correspond to WebGL enums
  78539. */
  78540. wrapT?: TextureWrapMode;
  78541. }
  78542. /**
  78543. * The root nodes of a scene
  78544. */
  78545. interface IScene extends IChildRootProperty {
  78546. /**
  78547. * The indices of each root node
  78548. */
  78549. nodes: number[];
  78550. }
  78551. /**
  78552. * Joints and matrices defining a skin
  78553. */
  78554. interface ISkin extends IChildRootProperty {
  78555. /**
  78556. * 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
  78557. */
  78558. inverseBindMatrices?: number;
  78559. /**
  78560. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  78561. */
  78562. skeleton?: number;
  78563. /**
  78564. * 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)
  78565. */
  78566. joints: number[];
  78567. }
  78568. /**
  78569. * A texture and its sampler
  78570. */
  78571. interface ITexture extends IChildRootProperty {
  78572. /**
  78573. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  78574. */
  78575. sampler?: number;
  78576. /**
  78577. * The index of the image used by this texture
  78578. */
  78579. source: number;
  78580. }
  78581. /**
  78582. * Reference to a texture
  78583. */
  78584. interface ITextureInfo extends IProperty {
  78585. /**
  78586. * The index of the texture
  78587. */
  78588. index: number;
  78589. /**
  78590. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  78591. */
  78592. texCoord?: number;
  78593. }
  78594. /**
  78595. * The root object for a glTF asset
  78596. */
  78597. interface IGLTF extends IProperty {
  78598. /**
  78599. * An array of accessors. An accessor is a typed view into a bufferView
  78600. */
  78601. accessors?: IAccessor[];
  78602. /**
  78603. * An array of keyframe animations
  78604. */
  78605. animations?: IAnimation[];
  78606. /**
  78607. * Metadata about the glTF asset
  78608. */
  78609. asset: IAsset;
  78610. /**
  78611. * An array of buffers. A buffer points to binary geometry, animation, or skins
  78612. */
  78613. buffers?: IBuffer[];
  78614. /**
  78615. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  78616. */
  78617. bufferViews?: IBufferView[];
  78618. /**
  78619. * An array of cameras
  78620. */
  78621. cameras?: ICamera[];
  78622. /**
  78623. * Names of glTF extensions used somewhere in this asset
  78624. */
  78625. extensionsUsed?: string[];
  78626. /**
  78627. * Names of glTF extensions required to properly load this asset
  78628. */
  78629. extensionsRequired?: string[];
  78630. /**
  78631. * An array of images. An image defines data used to create a texture
  78632. */
  78633. images?: IImage[];
  78634. /**
  78635. * An array of materials. A material defines the appearance of a primitive
  78636. */
  78637. materials?: IMaterial[];
  78638. /**
  78639. * An array of meshes. A mesh is a set of primitives to be rendered
  78640. */
  78641. meshes?: IMesh[];
  78642. /**
  78643. * An array of nodes
  78644. */
  78645. nodes?: INode[];
  78646. /**
  78647. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  78648. */
  78649. samplers?: ISampler[];
  78650. /**
  78651. * The index of the default scene
  78652. */
  78653. scene?: number;
  78654. /**
  78655. * An array of scenes
  78656. */
  78657. scenes?: IScene[];
  78658. /**
  78659. * An array of skins. A skin is defined by joints and matrices
  78660. */
  78661. skins?: ISkin[];
  78662. /**
  78663. * An array of textures
  78664. */
  78665. textures?: ITexture[];
  78666. }
  78667. /**
  78668. * The glTF validation results
  78669. * @ignore
  78670. */
  78671. interface IGLTFValidationResults {
  78672. info: {
  78673. generator: string;
  78674. hasAnimations: boolean;
  78675. hasDefaultScene: boolean;
  78676. hasMaterials: boolean;
  78677. hasMorphTargets: boolean;
  78678. hasSkins: boolean;
  78679. hasTextures: boolean;
  78680. maxAttributesUsed: number;
  78681. primitivesCount: number
  78682. };
  78683. issues: {
  78684. messages: Array<string>;
  78685. numErrors: number;
  78686. numHints: number;
  78687. numInfos: number;
  78688. numWarnings: number;
  78689. truncated: boolean
  78690. };
  78691. mimeType: string;
  78692. uri: string;
  78693. validatedAt: string;
  78694. validatorVersion: string;
  78695. }
  78696. /**
  78697. * The glTF validation options
  78698. */
  78699. interface IGLTFValidationOptions {
  78700. /** Uri to use */
  78701. uri?: string;
  78702. /** Function used to load external resources */
  78703. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  78704. /** Boolean indicating that we need to validate accessor data */
  78705. validateAccessorData?: boolean;
  78706. /** max number of issues allowed */
  78707. maxIssues?: number;
  78708. /** Ignored issues */
  78709. ignoredIssues?: Array<string>;
  78710. /** Value to override severy settings */
  78711. severityOverrides?: Object;
  78712. }
  78713. /**
  78714. * The glTF validator object
  78715. * @ignore
  78716. */
  78717. interface IGLTFValidator {
  78718. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78719. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78720. }
  78721. }
  78722. declare module BABYLON {
  78723. /** @hidden */
  78724. export var cellPixelShader: {
  78725. name: string;
  78726. shader: string;
  78727. };
  78728. }
  78729. declare module BABYLON {
  78730. /** @hidden */
  78731. export var cellVertexShader: {
  78732. name: string;
  78733. shader: string;
  78734. };
  78735. }
  78736. declare module BABYLON {
  78737. export class CellMaterial extends BABYLON.PushMaterial {
  78738. private _diffuseTexture;
  78739. diffuseTexture: BABYLON.BaseTexture;
  78740. diffuseColor: BABYLON.Color3;
  78741. _computeHighLevel: boolean;
  78742. computeHighLevel: boolean;
  78743. private _disableLighting;
  78744. disableLighting: boolean;
  78745. private _maxSimultaneousLights;
  78746. maxSimultaneousLights: number;
  78747. private _renderId;
  78748. constructor(name: string, scene: BABYLON.Scene);
  78749. needAlphaBlending(): boolean;
  78750. needAlphaTesting(): boolean;
  78751. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78752. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78753. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78754. getAnimatables(): BABYLON.IAnimatable[];
  78755. getActiveTextures(): BABYLON.BaseTexture[];
  78756. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78757. dispose(forceDisposeEffect?: boolean): void;
  78758. getClassName(): string;
  78759. clone(name: string): CellMaterial;
  78760. serialize(): any;
  78761. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  78762. }
  78763. }
  78764. declare module BABYLON {
  78765. export class CustomShaderStructure {
  78766. FragmentStore: string;
  78767. VertexStore: string;
  78768. constructor();
  78769. }
  78770. export class ShaderSpecialParts {
  78771. constructor();
  78772. Fragment_Begin: string;
  78773. Fragment_Definitions: string;
  78774. Fragment_MainBegin: string;
  78775. Fragment_Custom_Diffuse: string;
  78776. Fragment_Before_Lights: string;
  78777. Fragment_Before_Fog: string;
  78778. Fragment_Custom_Alpha: string;
  78779. Fragment_Before_FragColor: string;
  78780. Vertex_Begin: string;
  78781. Vertex_Definitions: string;
  78782. Vertex_MainBegin: string;
  78783. Vertex_Before_PositionUpdated: string;
  78784. Vertex_Before_NormalUpdated: string;
  78785. Vertex_MainEnd: string;
  78786. }
  78787. export class CustomMaterial extends BABYLON.StandardMaterial {
  78788. static ShaderIndexer: number;
  78789. CustomParts: ShaderSpecialParts;
  78790. _isCreatedShader: boolean;
  78791. _createdShaderName: string;
  78792. _customUniform: string[];
  78793. _newUniforms: string[];
  78794. _newUniformInstances: any[];
  78795. _newSamplerInstances: BABYLON.Texture[];
  78796. FragmentShader: string;
  78797. VertexShader: string;
  78798. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78799. ReviewUniform(name: string, arr: string[]): string[];
  78800. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  78801. constructor(name: string, scene: BABYLON.Scene);
  78802. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  78803. Fragment_Begin(shaderPart: string): CustomMaterial;
  78804. Fragment_Definitions(shaderPart: string): CustomMaterial;
  78805. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  78806. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  78807. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  78808. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  78809. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  78810. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  78811. Vertex_Begin(shaderPart: string): CustomMaterial;
  78812. Vertex_Definitions(shaderPart: string): CustomMaterial;
  78813. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  78814. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  78815. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  78816. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  78817. }
  78818. }
  78819. declare module BABYLON {
  78820. export class ShaderAlebdoParts {
  78821. constructor();
  78822. Fragment_Begin: string;
  78823. Fragment_Definitions: string;
  78824. Fragment_MainBegin: string;
  78825. Fragment_Custom_Albedo: string;
  78826. Fragment_Before_Lights: string;
  78827. Fragment_Custom_MetallicRoughness: string;
  78828. Fragment_Custom_MicroSurface: string;
  78829. Fragment_Before_Fog: string;
  78830. Fragment_Custom_Alpha: string;
  78831. Fragment_Before_FragColor: string;
  78832. Vertex_Begin: string;
  78833. Vertex_Definitions: string;
  78834. Vertex_MainBegin: string;
  78835. Vertex_Before_PositionUpdated: string;
  78836. Vertex_Before_NormalUpdated: string;
  78837. Vertex_MainEnd: string;
  78838. }
  78839. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  78840. static ShaderIndexer: number;
  78841. CustomParts: ShaderAlebdoParts;
  78842. _isCreatedShader: boolean;
  78843. _createdShaderName: string;
  78844. _customUniform: string[];
  78845. _newUniforms: string[];
  78846. _newUniformInstances: any[];
  78847. _newSamplerInstances: BABYLON.Texture[];
  78848. FragmentShader: string;
  78849. VertexShader: string;
  78850. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78851. ReviewUniform(name: string, arr: string[]): string[];
  78852. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  78853. constructor(name: string, scene: BABYLON.Scene);
  78854. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  78855. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  78856. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  78857. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  78858. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  78859. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  78860. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  78861. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  78862. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  78863. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  78864. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  78865. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  78866. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  78867. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  78868. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  78869. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  78870. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  78871. }
  78872. }
  78873. declare module BABYLON {
  78874. /** @hidden */
  78875. export var firePixelShader: {
  78876. name: string;
  78877. shader: string;
  78878. };
  78879. }
  78880. declare module BABYLON {
  78881. /** @hidden */
  78882. export var fireVertexShader: {
  78883. name: string;
  78884. shader: string;
  78885. };
  78886. }
  78887. declare module BABYLON {
  78888. export class FireMaterial extends BABYLON.PushMaterial {
  78889. private _diffuseTexture;
  78890. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78891. private _distortionTexture;
  78892. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78893. private _opacityTexture;
  78894. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78895. diffuseColor: BABYLON.Color3;
  78896. speed: number;
  78897. private _scaledDiffuse;
  78898. private _renderId;
  78899. private _lastTime;
  78900. constructor(name: string, scene: BABYLON.Scene);
  78901. needAlphaBlending(): boolean;
  78902. needAlphaTesting(): boolean;
  78903. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78904. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78905. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78906. getAnimatables(): BABYLON.IAnimatable[];
  78907. getActiveTextures(): BABYLON.BaseTexture[];
  78908. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78909. getClassName(): string;
  78910. dispose(forceDisposeEffect?: boolean): void;
  78911. clone(name: string): FireMaterial;
  78912. serialize(): any;
  78913. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  78914. }
  78915. }
  78916. declare module BABYLON {
  78917. /** @hidden */
  78918. export var furPixelShader: {
  78919. name: string;
  78920. shader: string;
  78921. };
  78922. }
  78923. declare module BABYLON {
  78924. /** @hidden */
  78925. export var furVertexShader: {
  78926. name: string;
  78927. shader: string;
  78928. };
  78929. }
  78930. declare module BABYLON {
  78931. export class FurMaterial extends BABYLON.PushMaterial {
  78932. private _diffuseTexture;
  78933. diffuseTexture: BABYLON.BaseTexture;
  78934. private _heightTexture;
  78935. heightTexture: BABYLON.BaseTexture;
  78936. diffuseColor: BABYLON.Color3;
  78937. furLength: number;
  78938. furAngle: number;
  78939. furColor: BABYLON.Color3;
  78940. furOffset: number;
  78941. furSpacing: number;
  78942. furGravity: BABYLON.Vector3;
  78943. furSpeed: number;
  78944. furDensity: number;
  78945. furOcclusion: number;
  78946. furTexture: BABYLON.DynamicTexture;
  78947. private _disableLighting;
  78948. disableLighting: boolean;
  78949. private _maxSimultaneousLights;
  78950. maxSimultaneousLights: number;
  78951. highLevelFur: boolean;
  78952. _meshes: BABYLON.AbstractMesh[];
  78953. private _renderId;
  78954. private _furTime;
  78955. constructor(name: string, scene: BABYLON.Scene);
  78956. get furTime(): number;
  78957. set furTime(furTime: number);
  78958. needAlphaBlending(): boolean;
  78959. needAlphaTesting(): boolean;
  78960. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78961. updateFur(): void;
  78962. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78963. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78964. getAnimatables(): BABYLON.IAnimatable[];
  78965. getActiveTextures(): BABYLON.BaseTexture[];
  78966. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78967. dispose(forceDisposeEffect?: boolean): void;
  78968. clone(name: string): FurMaterial;
  78969. serialize(): any;
  78970. getClassName(): string;
  78971. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78972. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78973. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78974. }
  78975. }
  78976. declare module BABYLON {
  78977. /** @hidden */
  78978. export var gradientPixelShader: {
  78979. name: string;
  78980. shader: string;
  78981. };
  78982. }
  78983. declare module BABYLON {
  78984. /** @hidden */
  78985. export var gradientVertexShader: {
  78986. name: string;
  78987. shader: string;
  78988. };
  78989. }
  78990. declare module BABYLON {
  78991. export class GradientMaterial extends BABYLON.PushMaterial {
  78992. private _maxSimultaneousLights;
  78993. maxSimultaneousLights: number;
  78994. topColor: BABYLON.Color3;
  78995. topColorAlpha: number;
  78996. bottomColor: BABYLON.Color3;
  78997. bottomColorAlpha: number;
  78998. offset: number;
  78999. scale: number;
  79000. smoothness: number;
  79001. private _disableLighting;
  79002. disableLighting: boolean;
  79003. private _renderId;
  79004. constructor(name: string, scene: BABYLON.Scene);
  79005. needAlphaBlending(): boolean;
  79006. needAlphaTesting(): boolean;
  79007. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79008. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79009. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79010. getAnimatables(): BABYLON.IAnimatable[];
  79011. dispose(forceDisposeEffect?: boolean): void;
  79012. clone(name: string): GradientMaterial;
  79013. serialize(): any;
  79014. getClassName(): string;
  79015. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79016. }
  79017. }
  79018. declare module BABYLON {
  79019. /** @hidden */
  79020. export var gridPixelShader: {
  79021. name: string;
  79022. shader: string;
  79023. };
  79024. }
  79025. declare module BABYLON {
  79026. /** @hidden */
  79027. export var gridVertexShader: {
  79028. name: string;
  79029. shader: string;
  79030. };
  79031. }
  79032. declare module BABYLON {
  79033. /**
  79034. * The grid materials allows you to wrap any shape with a grid.
  79035. * Colors are customizable.
  79036. */
  79037. export class GridMaterial extends BABYLON.PushMaterial {
  79038. /**
  79039. * Main color of the grid (e.g. between lines)
  79040. */
  79041. mainColor: BABYLON.Color3;
  79042. /**
  79043. * Color of the grid lines.
  79044. */
  79045. lineColor: BABYLON.Color3;
  79046. /**
  79047. * The scale of the grid compared to unit.
  79048. */
  79049. gridRatio: number;
  79050. /**
  79051. * Allows setting an offset for the grid lines.
  79052. */
  79053. gridOffset: BABYLON.Vector3;
  79054. /**
  79055. * The frequency of thicker lines.
  79056. */
  79057. majorUnitFrequency: number;
  79058. /**
  79059. * The visibility of minor units in the grid.
  79060. */
  79061. minorUnitVisibility: number;
  79062. /**
  79063. * The grid opacity outside of the lines.
  79064. */
  79065. opacity: number;
  79066. /**
  79067. * Determine RBG output is premultiplied by alpha value.
  79068. */
  79069. preMultiplyAlpha: boolean;
  79070. private _opacityTexture;
  79071. opacityTexture: BABYLON.BaseTexture;
  79072. private _gridControl;
  79073. private _renderId;
  79074. /**
  79075. * constructor
  79076. * @param name The name given to the material in order to identify it afterwards.
  79077. * @param scene The scene the material is used in.
  79078. */
  79079. constructor(name: string, scene: BABYLON.Scene);
  79080. /**
  79081. * Returns wehter or not the grid requires alpha blending.
  79082. */
  79083. needAlphaBlending(): boolean;
  79084. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79085. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79086. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79087. /**
  79088. * Dispose the material and its associated resources.
  79089. * @param forceDisposeEffect will also dispose the used effect when true
  79090. */
  79091. dispose(forceDisposeEffect?: boolean): void;
  79092. clone(name: string): GridMaterial;
  79093. serialize(): any;
  79094. getClassName(): string;
  79095. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79096. }
  79097. }
  79098. declare module BABYLON {
  79099. /** @hidden */
  79100. export var lavaPixelShader: {
  79101. name: string;
  79102. shader: string;
  79103. };
  79104. }
  79105. declare module BABYLON {
  79106. /** @hidden */
  79107. export var lavaVertexShader: {
  79108. name: string;
  79109. shader: string;
  79110. };
  79111. }
  79112. declare module BABYLON {
  79113. export class LavaMaterial extends BABYLON.PushMaterial {
  79114. private _diffuseTexture;
  79115. diffuseTexture: BABYLON.BaseTexture;
  79116. noiseTexture: BABYLON.BaseTexture;
  79117. fogColor: BABYLON.Color3;
  79118. speed: number;
  79119. movingSpeed: number;
  79120. lowFrequencySpeed: number;
  79121. fogDensity: number;
  79122. private _lastTime;
  79123. diffuseColor: BABYLON.Color3;
  79124. private _disableLighting;
  79125. disableLighting: boolean;
  79126. private _unlit;
  79127. unlit: boolean;
  79128. private _maxSimultaneousLights;
  79129. maxSimultaneousLights: number;
  79130. private _scaledDiffuse;
  79131. private _renderId;
  79132. constructor(name: string, scene: BABYLON.Scene);
  79133. needAlphaBlending(): boolean;
  79134. needAlphaTesting(): boolean;
  79135. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79136. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79137. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79138. getAnimatables(): BABYLON.IAnimatable[];
  79139. getActiveTextures(): BABYLON.BaseTexture[];
  79140. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79141. dispose(forceDisposeEffect?: boolean): void;
  79142. clone(name: string): LavaMaterial;
  79143. serialize(): any;
  79144. getClassName(): string;
  79145. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79146. }
  79147. }
  79148. declare module BABYLON {
  79149. /** @hidden */
  79150. export var mixPixelShader: {
  79151. name: string;
  79152. shader: string;
  79153. };
  79154. }
  79155. declare module BABYLON {
  79156. /** @hidden */
  79157. export var mixVertexShader: {
  79158. name: string;
  79159. shader: string;
  79160. };
  79161. }
  79162. declare module BABYLON {
  79163. export class MixMaterial extends BABYLON.PushMaterial {
  79164. /**
  79165. * Mix textures
  79166. */
  79167. private _mixTexture1;
  79168. mixTexture1: BABYLON.BaseTexture;
  79169. private _mixTexture2;
  79170. mixTexture2: BABYLON.BaseTexture;
  79171. /**
  79172. * Diffuse textures
  79173. */
  79174. private _diffuseTexture1;
  79175. diffuseTexture1: BABYLON.Texture;
  79176. private _diffuseTexture2;
  79177. diffuseTexture2: BABYLON.Texture;
  79178. private _diffuseTexture3;
  79179. diffuseTexture3: BABYLON.Texture;
  79180. private _diffuseTexture4;
  79181. diffuseTexture4: BABYLON.Texture;
  79182. private _diffuseTexture5;
  79183. diffuseTexture5: BABYLON.Texture;
  79184. private _diffuseTexture6;
  79185. diffuseTexture6: BABYLON.Texture;
  79186. private _diffuseTexture7;
  79187. diffuseTexture7: BABYLON.Texture;
  79188. private _diffuseTexture8;
  79189. diffuseTexture8: BABYLON.Texture;
  79190. /**
  79191. * Uniforms
  79192. */
  79193. diffuseColor: BABYLON.Color3;
  79194. specularColor: BABYLON.Color3;
  79195. specularPower: number;
  79196. private _disableLighting;
  79197. disableLighting: boolean;
  79198. private _maxSimultaneousLights;
  79199. maxSimultaneousLights: number;
  79200. private _renderId;
  79201. constructor(name: string, scene: BABYLON.Scene);
  79202. needAlphaBlending(): boolean;
  79203. needAlphaTesting(): boolean;
  79204. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79205. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79206. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79207. getAnimatables(): BABYLON.IAnimatable[];
  79208. getActiveTextures(): BABYLON.BaseTexture[];
  79209. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79210. dispose(forceDisposeEffect?: boolean): void;
  79211. clone(name: string): MixMaterial;
  79212. serialize(): any;
  79213. getClassName(): string;
  79214. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  79215. }
  79216. }
  79217. declare module BABYLON {
  79218. /** @hidden */
  79219. export var normalPixelShader: {
  79220. name: string;
  79221. shader: string;
  79222. };
  79223. }
  79224. declare module BABYLON {
  79225. /** @hidden */
  79226. export var normalVertexShader: {
  79227. name: string;
  79228. shader: string;
  79229. };
  79230. }
  79231. declare module BABYLON {
  79232. export class NormalMaterial extends BABYLON.PushMaterial {
  79233. private _diffuseTexture;
  79234. diffuseTexture: BABYLON.BaseTexture;
  79235. diffuseColor: BABYLON.Color3;
  79236. private _disableLighting;
  79237. disableLighting: boolean;
  79238. private _maxSimultaneousLights;
  79239. maxSimultaneousLights: number;
  79240. private _renderId;
  79241. constructor(name: string, scene: BABYLON.Scene);
  79242. needAlphaBlending(): boolean;
  79243. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79244. needAlphaTesting(): boolean;
  79245. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79246. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79247. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79248. getAnimatables(): BABYLON.IAnimatable[];
  79249. getActiveTextures(): BABYLON.BaseTexture[];
  79250. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79251. dispose(forceDisposeEffect?: boolean): void;
  79252. clone(name: string): NormalMaterial;
  79253. serialize(): any;
  79254. getClassName(): string;
  79255. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  79256. }
  79257. }
  79258. declare module BABYLON {
  79259. /** @hidden */
  79260. export var shadowOnlyPixelShader: {
  79261. name: string;
  79262. shader: string;
  79263. };
  79264. }
  79265. declare module BABYLON {
  79266. /** @hidden */
  79267. export var shadowOnlyVertexShader: {
  79268. name: string;
  79269. shader: string;
  79270. };
  79271. }
  79272. declare module BABYLON {
  79273. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  79274. private _renderId;
  79275. private _activeLight;
  79276. constructor(name: string, scene: BABYLON.Scene);
  79277. shadowColor: BABYLON.Color3;
  79278. needAlphaBlending(): boolean;
  79279. needAlphaTesting(): boolean;
  79280. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79281. get activeLight(): BABYLON.IShadowLight;
  79282. set activeLight(light: BABYLON.IShadowLight);
  79283. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79284. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79285. clone(name: string): ShadowOnlyMaterial;
  79286. serialize(): any;
  79287. getClassName(): string;
  79288. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  79289. }
  79290. }
  79291. declare module BABYLON {
  79292. /** @hidden */
  79293. export var simplePixelShader: {
  79294. name: string;
  79295. shader: string;
  79296. };
  79297. }
  79298. declare module BABYLON {
  79299. /** @hidden */
  79300. export var simpleVertexShader: {
  79301. name: string;
  79302. shader: string;
  79303. };
  79304. }
  79305. declare module BABYLON {
  79306. export class SimpleMaterial extends BABYLON.PushMaterial {
  79307. private _diffuseTexture;
  79308. diffuseTexture: BABYLON.BaseTexture;
  79309. diffuseColor: BABYLON.Color3;
  79310. private _disableLighting;
  79311. disableLighting: boolean;
  79312. private _maxSimultaneousLights;
  79313. maxSimultaneousLights: number;
  79314. private _renderId;
  79315. constructor(name: string, scene: BABYLON.Scene);
  79316. needAlphaBlending(): boolean;
  79317. needAlphaTesting(): boolean;
  79318. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79319. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79320. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79321. getAnimatables(): BABYLON.IAnimatable[];
  79322. getActiveTextures(): BABYLON.BaseTexture[];
  79323. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79324. dispose(forceDisposeEffect?: boolean): void;
  79325. clone(name: string): SimpleMaterial;
  79326. serialize(): any;
  79327. getClassName(): string;
  79328. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79329. }
  79330. }
  79331. declare module BABYLON {
  79332. /** @hidden */
  79333. export var skyPixelShader: {
  79334. name: string;
  79335. shader: string;
  79336. };
  79337. }
  79338. declare module BABYLON {
  79339. /** @hidden */
  79340. export var skyVertexShader: {
  79341. name: string;
  79342. shader: string;
  79343. };
  79344. }
  79345. declare module BABYLON {
  79346. /**
  79347. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79348. * @see https://doc.babylonjs.com/extensions/sky
  79349. */
  79350. export class SkyMaterial extends BABYLON.PushMaterial {
  79351. /**
  79352. * Defines the overall luminance of sky in interval ]0, 1[.
  79353. */
  79354. luminance: number;
  79355. /**
  79356. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79357. */
  79358. turbidity: number;
  79359. /**
  79360. * Defines the sky appearance (light intensity).
  79361. */
  79362. rayleigh: number;
  79363. /**
  79364. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79365. */
  79366. mieCoefficient: number;
  79367. /**
  79368. * Defines the amount of haze particles following the Mie scattering theory.
  79369. */
  79370. mieDirectionalG: number;
  79371. /**
  79372. * Defines the distance of the sun according to the active scene camera.
  79373. */
  79374. distance: number;
  79375. /**
  79376. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79377. * "inclined".
  79378. */
  79379. inclination: number;
  79380. /**
  79381. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79382. * an object direction and a reference direction.
  79383. */
  79384. azimuth: number;
  79385. /**
  79386. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79387. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79388. */
  79389. sunPosition: BABYLON.Vector3;
  79390. /**
  79391. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79392. * .sunPosition property.
  79393. */
  79394. useSunPosition: boolean;
  79395. /**
  79396. * Defines an offset vector used to get a horizon offset.
  79397. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79398. */
  79399. cameraOffset: BABYLON.Vector3;
  79400. private _cameraPosition;
  79401. private _renderId;
  79402. /**
  79403. * Instantiates a new sky material.
  79404. * This material allows to create dynamic and texture free
  79405. * effects for skyboxes by taking care of the atmosphere state.
  79406. * @see https://doc.babylonjs.com/extensions/sky
  79407. * @param name Define the name of the material in the scene
  79408. * @param scene Define the scene the material belong to
  79409. */
  79410. constructor(name: string, scene: BABYLON.Scene);
  79411. /**
  79412. * Specifies if the material will require alpha blending
  79413. * @returns a boolean specifying if alpha blending is needed
  79414. */
  79415. needAlphaBlending(): boolean;
  79416. /**
  79417. * Specifies if this material should be rendered in alpha test mode
  79418. * @returns false as the sky material doesn't need alpha testing.
  79419. */
  79420. needAlphaTesting(): boolean;
  79421. /**
  79422. * Get the texture used for alpha test purpose.
  79423. * @returns null as the sky material has no texture.
  79424. */
  79425. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79426. /**
  79427. * Get if the submesh is ready to be used and all its information available.
  79428. * Child classes can use it to update shaders
  79429. * @param mesh defines the mesh to check
  79430. * @param subMesh defines which submesh to check
  79431. * @param useInstances specifies that instances should be used
  79432. * @returns a boolean indicating that the submesh is ready or not
  79433. */
  79434. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79435. /**
  79436. * Binds the submesh to this material by preparing the effect and shader to draw
  79437. * @param world defines the world transformation matrix
  79438. * @param mesh defines the mesh containing the submesh
  79439. * @param subMesh defines the submesh to bind the material to
  79440. */
  79441. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79442. /**
  79443. * Get the list of animatables in the material.
  79444. * @returns the list of animatables object used in the material
  79445. */
  79446. getAnimatables(): BABYLON.IAnimatable[];
  79447. /**
  79448. * Disposes the material
  79449. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79450. */
  79451. dispose(forceDisposeEffect?: boolean): void;
  79452. /**
  79453. * Makes a duplicate of the material, and gives it a new name
  79454. * @param name defines the new name for the duplicated material
  79455. * @returns the cloned material
  79456. */
  79457. clone(name: string): SkyMaterial;
  79458. /**
  79459. * Serializes this material in a JSON representation
  79460. * @returns the serialized material object
  79461. */
  79462. serialize(): any;
  79463. /**
  79464. * Gets the current class name of the material e.g. "SkyMaterial"
  79465. * Mainly use in serialization.
  79466. * @returns the class name
  79467. */
  79468. getClassName(): string;
  79469. /**
  79470. * Creates a sky material from parsed material data
  79471. * @param source defines the JSON representation of the material
  79472. * @param scene defines the hosting scene
  79473. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79474. * @returns a new sky material
  79475. */
  79476. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  79477. }
  79478. }
  79479. declare module BABYLON {
  79480. /** @hidden */
  79481. export var terrainPixelShader: {
  79482. name: string;
  79483. shader: string;
  79484. };
  79485. }
  79486. declare module BABYLON {
  79487. /** @hidden */
  79488. export var terrainVertexShader: {
  79489. name: string;
  79490. shader: string;
  79491. };
  79492. }
  79493. declare module BABYLON {
  79494. export class TerrainMaterial extends BABYLON.PushMaterial {
  79495. private _mixTexture;
  79496. mixTexture: BABYLON.BaseTexture;
  79497. private _diffuseTexture1;
  79498. diffuseTexture1: BABYLON.Texture;
  79499. private _diffuseTexture2;
  79500. diffuseTexture2: BABYLON.Texture;
  79501. private _diffuseTexture3;
  79502. diffuseTexture3: BABYLON.Texture;
  79503. private _bumpTexture1;
  79504. bumpTexture1: BABYLON.Texture;
  79505. private _bumpTexture2;
  79506. bumpTexture2: BABYLON.Texture;
  79507. private _bumpTexture3;
  79508. bumpTexture3: BABYLON.Texture;
  79509. diffuseColor: BABYLON.Color3;
  79510. specularColor: BABYLON.Color3;
  79511. specularPower: number;
  79512. private _disableLighting;
  79513. disableLighting: boolean;
  79514. private _maxSimultaneousLights;
  79515. maxSimultaneousLights: number;
  79516. private _renderId;
  79517. constructor(name: string, scene: BABYLON.Scene);
  79518. needAlphaBlending(): boolean;
  79519. needAlphaTesting(): boolean;
  79520. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79521. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79522. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79523. getAnimatables(): BABYLON.IAnimatable[];
  79524. getActiveTextures(): BABYLON.BaseTexture[];
  79525. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79526. dispose(forceDisposeEffect?: boolean): void;
  79527. clone(name: string): TerrainMaterial;
  79528. serialize(): any;
  79529. getClassName(): string;
  79530. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  79531. }
  79532. }
  79533. declare module BABYLON {
  79534. /** @hidden */
  79535. export var triplanarPixelShader: {
  79536. name: string;
  79537. shader: string;
  79538. };
  79539. }
  79540. declare module BABYLON {
  79541. /** @hidden */
  79542. export var triplanarVertexShader: {
  79543. name: string;
  79544. shader: string;
  79545. };
  79546. }
  79547. declare module BABYLON {
  79548. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  79549. mixTexture: BABYLON.BaseTexture;
  79550. private _diffuseTextureX;
  79551. diffuseTextureX: BABYLON.BaseTexture;
  79552. private _diffuseTextureY;
  79553. diffuseTextureY: BABYLON.BaseTexture;
  79554. private _diffuseTextureZ;
  79555. diffuseTextureZ: BABYLON.BaseTexture;
  79556. private _normalTextureX;
  79557. normalTextureX: BABYLON.BaseTexture;
  79558. private _normalTextureY;
  79559. normalTextureY: BABYLON.BaseTexture;
  79560. private _normalTextureZ;
  79561. normalTextureZ: BABYLON.BaseTexture;
  79562. tileSize: number;
  79563. diffuseColor: BABYLON.Color3;
  79564. specularColor: BABYLON.Color3;
  79565. specularPower: number;
  79566. private _disableLighting;
  79567. disableLighting: boolean;
  79568. private _maxSimultaneousLights;
  79569. maxSimultaneousLights: number;
  79570. private _renderId;
  79571. constructor(name: string, scene: BABYLON.Scene);
  79572. needAlphaBlending(): boolean;
  79573. needAlphaTesting(): boolean;
  79574. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79575. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79576. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79577. getAnimatables(): BABYLON.IAnimatable[];
  79578. getActiveTextures(): BABYLON.BaseTexture[];
  79579. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79580. dispose(forceDisposeEffect?: boolean): void;
  79581. clone(name: string): TriPlanarMaterial;
  79582. serialize(): any;
  79583. getClassName(): string;
  79584. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  79585. }
  79586. }
  79587. declare module BABYLON {
  79588. /** @hidden */
  79589. export var waterPixelShader: {
  79590. name: string;
  79591. shader: string;
  79592. };
  79593. }
  79594. declare module BABYLON {
  79595. /** @hidden */
  79596. export var waterVertexShader: {
  79597. name: string;
  79598. shader: string;
  79599. };
  79600. }
  79601. declare module BABYLON {
  79602. export class WaterMaterial extends BABYLON.PushMaterial {
  79603. renderTargetSize: BABYLON.Vector2;
  79604. private _bumpTexture;
  79605. bumpTexture: BABYLON.BaseTexture;
  79606. diffuseColor: BABYLON.Color3;
  79607. specularColor: BABYLON.Color3;
  79608. specularPower: number;
  79609. private _disableLighting;
  79610. disableLighting: boolean;
  79611. private _maxSimultaneousLights;
  79612. maxSimultaneousLights: number;
  79613. /**
  79614. * @param {number}: Represents the wind force
  79615. */
  79616. windForce: number;
  79617. /**
  79618. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  79619. */
  79620. windDirection: BABYLON.Vector2;
  79621. /**
  79622. * @param {number}: Wave height, represents the height of the waves
  79623. */
  79624. waveHeight: number;
  79625. /**
  79626. * @param {number}: Bump height, represents the bump height related to the bump map
  79627. */
  79628. bumpHeight: number;
  79629. /**
  79630. * @param {boolean}: Add a smaller moving bump to less steady waves.
  79631. */
  79632. private _bumpSuperimpose;
  79633. bumpSuperimpose: boolean;
  79634. /**
  79635. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  79636. */
  79637. private _fresnelSeparate;
  79638. fresnelSeparate: boolean;
  79639. /**
  79640. * @param {boolean}: bump Waves modify the reflection.
  79641. */
  79642. private _bumpAffectsReflection;
  79643. bumpAffectsReflection: boolean;
  79644. /**
  79645. * @param {number}: The water color blended with the refraction (near)
  79646. */
  79647. waterColor: BABYLON.Color3;
  79648. /**
  79649. * @param {number}: The blend factor related to the water color
  79650. */
  79651. colorBlendFactor: number;
  79652. /**
  79653. * @param {number}: The water color blended with the reflection (far)
  79654. */
  79655. waterColor2: BABYLON.Color3;
  79656. /**
  79657. * @param {number}: The blend factor related to the water color (reflection, far)
  79658. */
  79659. colorBlendFactor2: number;
  79660. /**
  79661. * @param {number}: Represents the maximum length of a wave
  79662. */
  79663. waveLength: number;
  79664. /**
  79665. * @param {number}: Defines the waves speed
  79666. */
  79667. waveSpeed: number;
  79668. /**
  79669. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  79670. * will avoid calculating useless pixels in the pixel shader of the water material.
  79671. */
  79672. disableClipPlane: boolean;
  79673. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  79674. private _mesh;
  79675. private _refractionRTT;
  79676. private _reflectionRTT;
  79677. private _reflectionTransform;
  79678. private _lastTime;
  79679. private _lastDeltaTime;
  79680. private _renderId;
  79681. private _useLogarithmicDepth;
  79682. private _waitingRenderList;
  79683. private _imageProcessingConfiguration;
  79684. private _imageProcessingObserver;
  79685. /**
  79686. * Gets a boolean indicating that current material needs to register RTT
  79687. */
  79688. get hasRenderTargetTextures(): boolean;
  79689. /**
  79690. * Constructor
  79691. */
  79692. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  79693. get useLogarithmicDepth(): boolean;
  79694. set useLogarithmicDepth(value: boolean);
  79695. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79696. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79697. addToRenderList(node: any): void;
  79698. enableRenderTargets(enable: boolean): void;
  79699. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  79700. get renderTargetsEnabled(): boolean;
  79701. needAlphaBlending(): boolean;
  79702. needAlphaTesting(): boolean;
  79703. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79704. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79705. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79706. private _createRenderTargets;
  79707. getAnimatables(): BABYLON.IAnimatable[];
  79708. getActiveTextures(): BABYLON.BaseTexture[];
  79709. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79710. dispose(forceDisposeEffect?: boolean): void;
  79711. clone(name: string): WaterMaterial;
  79712. serialize(): any;
  79713. getClassName(): string;
  79714. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  79715. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  79716. }
  79717. }
  79718. declare module BABYLON {
  79719. /** @hidden */
  79720. export var asciiartPixelShader: {
  79721. name: string;
  79722. shader: string;
  79723. };
  79724. }
  79725. declare module BABYLON {
  79726. /**
  79727. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  79728. *
  79729. * It basically takes care rendering the font front the given font size to a texture.
  79730. * This is used later on in the postprocess.
  79731. */
  79732. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  79733. private _font;
  79734. private _text;
  79735. private _charSize;
  79736. /**
  79737. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79738. */
  79739. get charSize(): number;
  79740. /**
  79741. * Create a new instance of the Ascii Art FontTexture class
  79742. * @param name the name of the texture
  79743. * @param font the font to use, use the W3C CSS notation
  79744. * @param text the caracter set to use in the rendering.
  79745. * @param scene the scene that owns the texture
  79746. */
  79747. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79748. /**
  79749. * Gets the max char width of a font.
  79750. * @param font the font to use, use the W3C CSS notation
  79751. * @return the max char width
  79752. */
  79753. private getFontWidth;
  79754. /**
  79755. * Gets the max char height of a font.
  79756. * @param font the font to use, use the W3C CSS notation
  79757. * @return the max char height
  79758. */
  79759. private getFontHeight;
  79760. /**
  79761. * Clones the current AsciiArtTexture.
  79762. * @return the clone of the texture.
  79763. */
  79764. clone(): AsciiArtFontTexture;
  79765. /**
  79766. * Parses a json object representing the texture and returns an instance of it.
  79767. * @param source the source JSON representation
  79768. * @param scene the scene to create the texture for
  79769. * @return the parsed texture
  79770. */
  79771. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  79772. }
  79773. /**
  79774. * Option available in the Ascii Art Post Process.
  79775. */
  79776. export interface IAsciiArtPostProcessOptions {
  79777. /**
  79778. * The font to use following the w3c font definition.
  79779. */
  79780. font?: string;
  79781. /**
  79782. * The character set to use in the postprocess.
  79783. */
  79784. characterSet?: string;
  79785. /**
  79786. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79787. * This number is defined between 0 and 1;
  79788. */
  79789. mixToTile?: number;
  79790. /**
  79791. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79792. * This number is defined between 0 and 1;
  79793. */
  79794. mixToNormal?: number;
  79795. }
  79796. /**
  79797. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  79798. *
  79799. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79800. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  79801. */
  79802. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  79803. /**
  79804. * The font texture used to render the char in the post process.
  79805. */
  79806. private _asciiArtFontTexture;
  79807. /**
  79808. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79809. * This number is defined between 0 and 1;
  79810. */
  79811. mixToTile: number;
  79812. /**
  79813. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79814. * This number is defined between 0 and 1;
  79815. */
  79816. mixToNormal: number;
  79817. /**
  79818. * Instantiates a new Ascii Art Post Process.
  79819. * @param name the name to give to the postprocess
  79820. * @camera the camera to apply the post process to.
  79821. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  79822. */
  79823. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  79824. }
  79825. }
  79826. declare module BABYLON {
  79827. /** @hidden */
  79828. export var digitalrainPixelShader: {
  79829. name: string;
  79830. shader: string;
  79831. };
  79832. }
  79833. declare module BABYLON {
  79834. /**
  79835. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  79836. *
  79837. * It basically takes care rendering the font front the given font size to a texture.
  79838. * This is used later on in the postprocess.
  79839. */
  79840. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  79841. private _font;
  79842. private _text;
  79843. private _charSize;
  79844. /**
  79845. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79846. */
  79847. get charSize(): number;
  79848. /**
  79849. * Create a new instance of the Digital Rain FontTexture class
  79850. * @param name the name of the texture
  79851. * @param font the font to use, use the W3C CSS notation
  79852. * @param text the caracter set to use in the rendering.
  79853. * @param scene the scene that owns the texture
  79854. */
  79855. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79856. /**
  79857. * Gets the max char width of a font.
  79858. * @param font the font to use, use the W3C CSS notation
  79859. * @return the max char width
  79860. */
  79861. private getFontWidth;
  79862. /**
  79863. * Gets the max char height of a font.
  79864. * @param font the font to use, use the W3C CSS notation
  79865. * @return the max char height
  79866. */
  79867. private getFontHeight;
  79868. /**
  79869. * Clones the current DigitalRainFontTexture.
  79870. * @return the clone of the texture.
  79871. */
  79872. clone(): DigitalRainFontTexture;
  79873. /**
  79874. * Parses a json object representing the texture and returns an instance of it.
  79875. * @param source the source JSON representation
  79876. * @param scene the scene to create the texture for
  79877. * @return the parsed texture
  79878. */
  79879. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  79880. }
  79881. /**
  79882. * Option available in the Digital Rain Post Process.
  79883. */
  79884. export interface IDigitalRainPostProcessOptions {
  79885. /**
  79886. * The font to use following the w3c font definition.
  79887. */
  79888. font?: string;
  79889. /**
  79890. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79891. * This number is defined between 0 and 1;
  79892. */
  79893. mixToTile?: number;
  79894. /**
  79895. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79896. * This number is defined between 0 and 1;
  79897. */
  79898. mixToNormal?: number;
  79899. }
  79900. /**
  79901. * DigitalRainPostProcess helps rendering everithing in digital rain.
  79902. *
  79903. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79904. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  79905. */
  79906. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  79907. /**
  79908. * The font texture used to render the char in the post process.
  79909. */
  79910. private _digitalRainFontTexture;
  79911. /**
  79912. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79913. * This number is defined between 0 and 1;
  79914. */
  79915. mixToTile: number;
  79916. /**
  79917. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79918. * This number is defined between 0 and 1;
  79919. */
  79920. mixToNormal: number;
  79921. /**
  79922. * Instantiates a new Digital Rain Post Process.
  79923. * @param name the name to give to the postprocess
  79924. * @camera the camera to apply the post process to.
  79925. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  79926. */
  79927. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  79928. }
  79929. }
  79930. declare module BABYLON {
  79931. /** @hidden */
  79932. export var brickProceduralTexturePixelShader: {
  79933. name: string;
  79934. shader: string;
  79935. };
  79936. }
  79937. declare module BABYLON {
  79938. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  79939. private _numberOfBricksHeight;
  79940. private _numberOfBricksWidth;
  79941. private _jointColor;
  79942. private _brickColor;
  79943. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79944. updateShaderUniforms(): void;
  79945. get numberOfBricksHeight(): number;
  79946. set numberOfBricksHeight(value: number);
  79947. get numberOfBricksWidth(): number;
  79948. set numberOfBricksWidth(value: number);
  79949. get jointColor(): BABYLON.Color3;
  79950. set jointColor(value: BABYLON.Color3);
  79951. get brickColor(): BABYLON.Color3;
  79952. set brickColor(value: BABYLON.Color3);
  79953. /**
  79954. * Serializes this brick procedural texture
  79955. * @returns a serialized brick procedural texture object
  79956. */
  79957. serialize(): any;
  79958. /**
  79959. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  79960. * @param parsedTexture defines parsed texture data
  79961. * @param scene defines the current scene
  79962. * @param rootUrl defines the root URL containing brick procedural texture information
  79963. * @returns a parsed Brick Procedural BABYLON.Texture
  79964. */
  79965. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  79966. }
  79967. }
  79968. declare module BABYLON {
  79969. /** @hidden */
  79970. export var cloudProceduralTexturePixelShader: {
  79971. name: string;
  79972. shader: string;
  79973. };
  79974. }
  79975. declare module BABYLON {
  79976. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79977. private _skyColor;
  79978. private _cloudColor;
  79979. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79980. updateShaderUniforms(): void;
  79981. get skyColor(): BABYLON.Color4;
  79982. set skyColor(value: BABYLON.Color4);
  79983. get cloudColor(): BABYLON.Color4;
  79984. set cloudColor(value: BABYLON.Color4);
  79985. /**
  79986. * Serializes this cloud procedural texture
  79987. * @returns a serialized cloud procedural texture object
  79988. */
  79989. serialize(): any;
  79990. /**
  79991. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79992. * @param parsedTexture defines parsed texture data
  79993. * @param scene defines the current scene
  79994. * @param rootUrl defines the root URL containing cloud procedural texture information
  79995. * @returns a parsed Cloud Procedural BABYLON.Texture
  79996. */
  79997. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79998. }
  79999. }
  80000. declare module BABYLON {
  80001. /** @hidden */
  80002. export var fireProceduralTexturePixelShader: {
  80003. name: string;
  80004. shader: string;
  80005. };
  80006. }
  80007. declare module BABYLON {
  80008. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80009. private _time;
  80010. private _speed;
  80011. private _autoGenerateTime;
  80012. private _fireColors;
  80013. private _alphaThreshold;
  80014. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80015. updateShaderUniforms(): void;
  80016. render(useCameraPostProcess?: boolean): void;
  80017. static get PurpleFireColors(): BABYLON.Color3[];
  80018. static get GreenFireColors(): BABYLON.Color3[];
  80019. static get RedFireColors(): BABYLON.Color3[];
  80020. static get BlueFireColors(): BABYLON.Color3[];
  80021. get autoGenerateTime(): boolean;
  80022. set autoGenerateTime(value: boolean);
  80023. get fireColors(): BABYLON.Color3[];
  80024. set fireColors(value: BABYLON.Color3[]);
  80025. get time(): number;
  80026. set time(value: number);
  80027. get speed(): BABYLON.Vector2;
  80028. set speed(value: BABYLON.Vector2);
  80029. get alphaThreshold(): number;
  80030. set alphaThreshold(value: number);
  80031. /**
  80032. * Serializes this fire procedural texture
  80033. * @returns a serialized fire procedural texture object
  80034. */
  80035. serialize(): any;
  80036. /**
  80037. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  80038. * @param parsedTexture defines parsed texture data
  80039. * @param scene defines the current scene
  80040. * @param rootUrl defines the root URL containing fire procedural texture information
  80041. * @returns a parsed Fire Procedural BABYLON.Texture
  80042. */
  80043. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  80044. }
  80045. }
  80046. declare module BABYLON {
  80047. /** @hidden */
  80048. export var grassProceduralTexturePixelShader: {
  80049. name: string;
  80050. shader: string;
  80051. };
  80052. }
  80053. declare module BABYLON {
  80054. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  80055. private _grassColors;
  80056. private _groundColor;
  80057. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80058. updateShaderUniforms(): void;
  80059. get grassColors(): BABYLON.Color3[];
  80060. set grassColors(value: BABYLON.Color3[]);
  80061. get groundColor(): BABYLON.Color3;
  80062. set groundColor(value: BABYLON.Color3);
  80063. /**
  80064. * Serializes this grass procedural texture
  80065. * @returns a serialized grass procedural texture object
  80066. */
  80067. serialize(): any;
  80068. /**
  80069. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  80070. * @param parsedTexture defines parsed texture data
  80071. * @param scene defines the current scene
  80072. * @param rootUrl defines the root URL containing grass procedural texture information
  80073. * @returns a parsed Grass Procedural BABYLON.Texture
  80074. */
  80075. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80076. }
  80077. }
  80078. declare module BABYLON {
  80079. /** @hidden */
  80080. export var marbleProceduralTexturePixelShader: {
  80081. name: string;
  80082. shader: string;
  80083. };
  80084. }
  80085. declare module BABYLON {
  80086. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80087. private _numberOfTilesHeight;
  80088. private _numberOfTilesWidth;
  80089. private _amplitude;
  80090. private _jointColor;
  80091. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80092. updateShaderUniforms(): void;
  80093. get numberOfTilesHeight(): number;
  80094. set numberOfTilesHeight(value: number);
  80095. get amplitude(): number;
  80096. set amplitude(value: number);
  80097. get numberOfTilesWidth(): number;
  80098. set numberOfTilesWidth(value: number);
  80099. get jointColor(): BABYLON.Color3;
  80100. set jointColor(value: BABYLON.Color3);
  80101. /**
  80102. * Serializes this marble procedural texture
  80103. * @returns a serialized marble procedural texture object
  80104. */
  80105. serialize(): any;
  80106. /**
  80107. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80108. * @param parsedTexture defines parsed texture data
  80109. * @param scene defines the current scene
  80110. * @param rootUrl defines the root URL containing marble procedural texture information
  80111. * @returns a parsed Marble Procedural BABYLON.Texture
  80112. */
  80113. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80114. }
  80115. }
  80116. declare module BABYLON {
  80117. /** @hidden */
  80118. export var normalMapProceduralTexturePixelShader: {
  80119. name: string;
  80120. shader: string;
  80121. };
  80122. }
  80123. declare module BABYLON {
  80124. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80125. private _baseTexture;
  80126. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80127. updateShaderUniforms(): void;
  80128. render(useCameraPostProcess?: boolean): void;
  80129. resize(size: any, generateMipMaps: any): void;
  80130. get baseTexture(): BABYLON.Texture;
  80131. set baseTexture(texture: BABYLON.Texture);
  80132. /**
  80133. * Serializes this normal map procedural texture
  80134. * @returns a serialized normal map procedural texture object
  80135. */
  80136. serialize(): any;
  80137. /**
  80138. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80139. * @param parsedTexture defines parsed texture data
  80140. * @param scene defines the current scene
  80141. * @param rootUrl defines the root URL containing normal map procedural texture information
  80142. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80143. */
  80144. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80145. }
  80146. }
  80147. declare module BABYLON {
  80148. /** @hidden */
  80149. export var perlinNoiseProceduralTexturePixelShader: {
  80150. name: string;
  80151. shader: string;
  80152. };
  80153. }
  80154. declare module BABYLON {
  80155. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  80156. time: number;
  80157. timeScale: number;
  80158. translationSpeed: number;
  80159. private _currentTranslation;
  80160. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80161. updateShaderUniforms(): void;
  80162. render(useCameraPostProcess?: boolean): void;
  80163. resize(size: any, generateMipMaps: any): void;
  80164. /**
  80165. * Serializes this perlin noise procedural texture
  80166. * @returns a serialized perlin noise procedural texture object
  80167. */
  80168. serialize(): any;
  80169. /**
  80170. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  80171. * @param parsedTexture defines parsed texture data
  80172. * @param scene defines the current scene
  80173. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  80174. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  80175. */
  80176. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  80177. }
  80178. }
  80179. declare module BABYLON {
  80180. /** @hidden */
  80181. export var roadProceduralTexturePixelShader: {
  80182. name: string;
  80183. shader: string;
  80184. };
  80185. }
  80186. declare module BABYLON {
  80187. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  80188. private _roadColor;
  80189. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80190. updateShaderUniforms(): void;
  80191. get roadColor(): BABYLON.Color3;
  80192. set roadColor(value: BABYLON.Color3);
  80193. /**
  80194. * Serializes this road procedural texture
  80195. * @returns a serialized road procedural texture object
  80196. */
  80197. serialize(): any;
  80198. /**
  80199. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  80200. * @param parsedTexture defines parsed texture data
  80201. * @param scene defines the current scene
  80202. * @param rootUrl defines the root URL containing road procedural texture information
  80203. * @returns a parsed Road Procedural BABYLON.Texture
  80204. */
  80205. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  80206. }
  80207. }
  80208. declare module BABYLON {
  80209. /** @hidden */
  80210. export var starfieldProceduralTexturePixelShader: {
  80211. name: string;
  80212. shader: string;
  80213. };
  80214. }
  80215. declare module BABYLON {
  80216. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  80217. private _time;
  80218. private _alpha;
  80219. private _beta;
  80220. private _zoom;
  80221. private _formuparam;
  80222. private _stepsize;
  80223. private _tile;
  80224. private _brightness;
  80225. private _darkmatter;
  80226. private _distfading;
  80227. private _saturation;
  80228. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80229. updateShaderUniforms(): void;
  80230. get time(): number;
  80231. set time(value: number);
  80232. get alpha(): number;
  80233. set alpha(value: number);
  80234. get beta(): number;
  80235. set beta(value: number);
  80236. get formuparam(): number;
  80237. set formuparam(value: number);
  80238. get stepsize(): number;
  80239. set stepsize(value: number);
  80240. get zoom(): number;
  80241. set zoom(value: number);
  80242. get tile(): number;
  80243. set tile(value: number);
  80244. get brightness(): number;
  80245. set brightness(value: number);
  80246. get darkmatter(): number;
  80247. set darkmatter(value: number);
  80248. get distfading(): number;
  80249. set distfading(value: number);
  80250. get saturation(): number;
  80251. set saturation(value: number);
  80252. /**
  80253. * Serializes this starfield procedural texture
  80254. * @returns a serialized starfield procedural texture object
  80255. */
  80256. serialize(): any;
  80257. /**
  80258. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  80259. * @param parsedTexture defines parsed texture data
  80260. * @param scene defines the current scene
  80261. * @param rootUrl defines the root URL containing startfield procedural texture information
  80262. * @returns a parsed Starfield Procedural BABYLON.Texture
  80263. */
  80264. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  80265. }
  80266. }
  80267. declare module BABYLON {
  80268. /** @hidden */
  80269. export var woodProceduralTexturePixelShader: {
  80270. name: string;
  80271. shader: string;
  80272. };
  80273. }
  80274. declare module BABYLON {
  80275. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  80276. private _ampScale;
  80277. private _woodColor;
  80278. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80279. updateShaderUniforms(): void;
  80280. get ampScale(): number;
  80281. set ampScale(value: number);
  80282. get woodColor(): BABYLON.Color3;
  80283. set woodColor(value: BABYLON.Color3);
  80284. /**
  80285. * Serializes this wood procedural texture
  80286. * @returns a serialized wood procedural texture object
  80287. */
  80288. serialize(): any;
  80289. /**
  80290. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  80291. * @param parsedTexture defines parsed texture data
  80292. * @param scene defines the current scene
  80293. * @param rootUrl defines the root URL containing wood procedural texture information
  80294. * @returns a parsed Wood Procedural BABYLON.Texture
  80295. */
  80296. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80297. }
  80298. }